Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5983)

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 117533002: [Mac] Redesign of the avatar menu button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tabstrip width Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 208342012934a71c1790347faee2b018814bb934..9f2be5ed969e98067b5176a402babf512c80990c 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -56,6 +56,10 @@ const CGFloat kAvatarRightOffset = 4;
// incognito badge is present.
const CGFloat kAvatarTabStripShrink = 18;
+// Width of the full screen icon. Used to position the NewAvatarButton to the
+// left of the icon.
+const CGFloat kFullscreenIconWidth = 30;
+
// Insets for the location bar, used when the full toolbar is hidden.
// TODO(viettrungluu): We can argue about the "correct" insetting; I like the
// following best, though arguably 0 inset is better/more correct.
@@ -315,15 +319,29 @@ willPositionSheet:(NSWindow*)sheet
// Lay out the icognito/avatar badge because calculating the indentation on
// the right depends on it.
if ([self shouldShowAvatar]) {
- NSView* avatarButton = [avatarButtonController_ view];
- CGFloat buttonHeight = std::min(
- static_cast<CGFloat>(profiles::kAvatarIconHeight), tabStripHeight);
- [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]),
- buttonHeight)];
-
- // Actually place the badge *above* |maxY|, by +2 to miss the divider.
+ NSView* avatarButton;
CGFloat badgeXOffset = -kAvatarRightOffset;
- CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
+ CGFloat badgeYOffset = 0;
+
+ if ([self shouldUseNewAvatarButton]) {
+ avatarButton = [newAvatarButtonController_ view];
+
+ // The fullscreen icon is displayed to the right of the avatar button.
+ if (![self isFullscreen])
+ badgeXOffset -= kFullscreenIconWidth;
+
+ // Center the button vertically on the tabstrip.
+ badgeYOffset = (tabStripHeight - [avatarButton frame].size.height) /2;
+ } else {
+ avatarButton = [avatarButtonController_ view];
+
+ CGFloat buttonHeight = std::min(
+ static_cast<CGFloat>(profiles::kAvatarIconHeight), tabStripHeight);
+ // Actually place the badge *above* |maxY|, by +2 to miss the divider.
+ badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
+ [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]),
+ buttonHeight)];
+ }
NSPoint origin =
NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset,
maxY + badgeYOffset);
@@ -343,10 +361,19 @@ willPositionSheet:(NSWindow*)sheet
rightIndent += -[window fullScreenButtonOriginAdjustment].x;
} else if ([self shouldShowAvatar]) {
rightIndent += kAvatarTabStripShrink;
- NSButton* labelButton = [avatarButtonController_ labelButtonView];
+ NSButton* labelButton = nil;
+ if (![self shouldUseNewAvatarButton])
+ labelButton = [avatarButtonController_ labelButtonView];
if (labelButton)
rightIndent += NSWidth([labelButton frame]) + kAvatarRightOffset;
}
+
+ // If the new avatar button is displayed, we need to account for its width.
+ if ([self shouldShowAvatar] && [self shouldUseNewAvatarButton]) {
+ rightIndent += NSWidth([[newAvatarButtonController_ view] frame])
+ + kAvatarTabStripShrink;
+ }
+
[tabStripController_ setRightIndentForControls:rightIndent];
// Go ahead and layout the tabs.
@@ -564,10 +591,15 @@ willPositionSheet:(NSWindow*)sheet
// Move the incognito badge if present.
if ([self shouldShowAvatar]) {
- [[avatarButtonController_ view] removeFromSuperview];
- [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout.
- [[[destWindow contentView] superview] addSubview:
- [avatarButtonController_ view]];
+ NSView* avatarButtonView;
+ if ([self shouldUseNewAvatarButton])
+ avatarButtonView = [newAvatarButtonController_ view];
+ else
+ avatarButtonView = [avatarButtonController_ view];
+
+ [avatarButtonView removeFromSuperview];
+ [avatarButtonView setHidden:YES]; // Will be shown in layout.
+ [[[destWindow contentView] superview] addSubview: avatarButtonView];
}
// Add the tab strip after setting the content view and moving the incognito

Powered by Google App Engine
This is Rietveld 408576698