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

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: nico review 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 ce4254480a16635a5ff27b3c178f6000c663fdf8..5e4720c6b902ce23b125c72eb0d4d0d911f7bc69 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -18,6 +18,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window_state.h"
#import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
+#import "chrome/browser/ui/cocoa/browser/avatar_icon_controller.h"
#import "chrome/browser/ui/cocoa/dev_tools_controller.h"
#import "chrome/browser/ui/cocoa/fast_resize_view.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
@@ -56,6 +57,10 @@ const CGFloat kAvatarRightOffset = 4;
// incognito badge is present.
const CGFloat kAvatarTabStripShrink = 18;
+// Width of the full screen icon. Used to position the AvatarButton 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.
@@ -316,14 +321,26 @@ willPositionSheet:(NSWindow*)sheet
// 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.
CGFloat badgeXOffset = -kAvatarRightOffset;
- CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
+ CGFloat badgeYOffset = 0;
+ CGFloat buttonHeight;
+
+ if ([self shouldUseNewAvatarButton]) {
+ // The fullscreen icon is displayed to the right of the avatar button.
+ if (![self isFullscreen])
+ badgeXOffset -= kFullscreenIconWidth;
+
+ // Center the button vertically on the tabstrip.
+ buttonHeight = NSHeight([avatarButton frame]);
+ badgeYOffset = (tabStripHeight - buttonHeight) / 2;
+ } else {
+ buttonHeight = static_cast<CGFloat>(profiles::kAvatarIconHeight);
+ // Actually place the badge *above* |maxY|, by +2 to miss the divider.
+ badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
+
+ }
+ [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]),
+ std::min(buttonHeight, tabStripHeight))];
NSPoint origin =
NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset,
maxY + badgeYOffset);
@@ -343,9 +360,16 @@ willPositionSheet:(NSWindow*)sheet
rightIndent += -[window fullScreenButtonOriginAdjustment].x;
} else if ([self shouldShowAvatar]) {
rightIndent += kAvatarTabStripShrink;
- NSButton* labelButton = [avatarButtonController_ labelButtonView];
- if (labelButton)
- rightIndent += NSWidth([labelButton frame]) + kAvatarRightOffset;
+ if ([self shouldUseNewAvatarButton]) {
+ rightIndent += NSWidth([[avatarButtonController_ view] frame])
+ + kAvatarTabStripShrink;
+ } else {
+ NSButton* labelButton =
+ [static_cast<AvatarIconController*>(avatarButtonController_)
+ labelButtonView];
+ if (labelButton)
+ rightIndent += NSWidth([labelButton frame]) + kAvatarRightOffset;
+ }
}
[tabStripController_ setRightIndentForControls:rightIndent];
@@ -564,10 +588,11 @@ 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 = [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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm ('k') | chrome/browser/ui/cocoa/framed_browser_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698