Index: chrome/browser/ui/cocoa/browser_window_layout.mm |
diff --git a/chrome/browser/ui/cocoa/browser_window_layout.mm b/chrome/browser/ui/cocoa/browser_window_layout.mm |
index 0b303b5bf73b60163c33adbd1f19c3b912e3bc18..120477085fbb690750e352a5c3e847fd6f720a9f 100644 |
--- a/chrome/browser/ui/cocoa/browser_window_layout.mm |
+++ b/chrome/browser/ui/cocoa/browser_window_layout.mm |
@@ -5,6 +5,7 @@ |
#import "chrome/browser/ui/cocoa/browser_window_layout.h" |
#include "base/logging.h" |
+#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
namespace chrome { |
@@ -21,6 +22,8 @@ const CGFloat kLocBarLeftRightInset = 1; |
const CGFloat kLocBarTopInset = 0; |
const CGFloat kLocBarBottomInset = 1; |
+// Space between the incognito badge and the right edge of the window. |
+const CGFloat kAvatarRightOffset = 4; |
} // namespace |
@interface BrowserWindowLayout () |
@@ -81,6 +84,26 @@ const CGFloat kLocBarBottomInset = 1; |
parameters_.hasTabStrip = hasTabStrip; |
} |
+- (void)setFullscreenButtonFrame:(NSRect)frame { |
+ parameters_.fullscreenButtonFrame = frame; |
+} |
+ |
+- (void)setShouldShowAvatar:(BOOL)shouldShowAvatar { |
+ parameters_.shouldShowAvatar = shouldShowAvatar; |
+} |
+ |
+- (void)setShouldUseNewAvatar:(BOOL)shouldUseNewAvatar { |
+ parameters_.shouldUseNewAvatar = shouldUseNewAvatar; |
+} |
+ |
+- (void)setAvatarSize:(NSSize)avatarSize { |
+ parameters_.avatarSize = avatarSize; |
+} |
+ |
+- (void)setAvatarLineWidth:(BOOL)avatarLineWidth { |
+ parameters_.avatarLineWidth = avatarLineWidth; |
+} |
+ |
- (void)setHasToolbar:(BOOL)hasToolbar { |
parameters_.hasToolbar = hasToolbar; |
} |
@@ -140,15 +163,80 @@ const CGFloat kLocBarBottomInset = 1; |
} |
- (void)computeTabStripLayout { |
- if (parameters_.hasTabStrip) { |
- maxY_ = parameters_.windowSize.height + fullscreenYOffset_; |
- CGFloat width = parameters_.contentViewSize.width; |
- output_.tabStripFrame = NSMakeRect( |
- 0, maxY_ - chrome::kTabStripHeight, width, chrome::kTabStripHeight); |
- maxY_ = NSMinY(output_.tabStripFrame); |
- } else { |
+ if (!parameters_.hasTabStrip) { |
maxY_ = parameters_.contentViewSize.height + fullscreenYOffset_; |
+ return; |
} |
+ |
+ // Temporary variable to hold the output. |
+ chrome::TabStripLayout layout; |
+ memset(&layout, 0, sizeof(layout)); |
Robert Sesek
2014/09/26 16:55:55
Can you not do = {0} or = {} instead? Otherwise, I
erikchen
2014/09/26 17:39:05
= {} will correctly zero initialize the struct. I
|
+ |
+ // Lay out the tab strip. |
+ maxY_ = parameters_.windowSize.height + fullscreenYOffset_; |
+ CGFloat width = parameters_.contentViewSize.width; |
+ layout.frame = NSMakeRect( |
+ 0, maxY_ - chrome::kTabStripHeight, width, chrome::kTabStripHeight); |
+ maxY_ = NSMinY(layout.frame); |
+ |
+ // In Yosemite fullscreen, manually add the fullscreen controls to the tab |
+ // strip. |
+ layout.addWindowControls = |
+ parameters_.inAnyFullscreen && base::mac::IsOSYosemiteOrLater(); |
Robert Sesek
2014/09/26 16:55:55
What about when not in screen?
erikchen
2014/09/26 17:39:06
I don't understand your question. My best interpre
Robert Sesek
2014/09/26 19:06:23
Sorry, yes meant fullscreen. The naming of the mem
erikchen
2014/09/26 20:55:59
I renamed all of the fields, properties, and metho
|
+ |
+ // Set left indentation based on fullscreen mode status. |
+ if (!parameters_.inAnyFullscreen || layout.addWindowControls) |
+ layout.leftIndent = [TabStripController defaultLeftIndentForControls]; |
+ |
+ // Lay out the icognito/avatar badge because calculating the indentation on |
+ // the right depends on it. |
+ if (parameters_.shouldShowAvatar) { |
+ CGFloat badgeXOffset = -kAvatarRightOffset; |
+ CGFloat badgeYOffset = 0; |
+ CGFloat buttonHeight = parameters_.avatarSize.height; |
+ |
+ if (parameters_.shouldUseNewAvatar) { |
+ // The fullscreen icon is displayed to the right of the avatar button. |
+ if (!parameters_.inAnyFullscreen && |
+ !NSIsEmptyRect(parameters_.fullscreenButtonFrame)) { |
+ badgeXOffset -= width - NSMinX(parameters_.fullscreenButtonFrame); |
+ } |
+ // Center the button vertically on the tabstrip. |
+ badgeYOffset = (chrome::kTabStripHeight - buttonHeight) / 2; |
+ } else { |
+ // Actually place the badge *above* |maxY|, by +2 to miss the divider. |
+ badgeYOffset = 2 * parameters_.avatarLineWidth; |
+ } |
+ |
+ NSSize size = NSMakeSize(parameters_.avatarSize.width, |
+ std::min(buttonHeight, chrome::kTabStripHeight)); |
+ NSPoint origin = |
+ NSMakePoint(width - parameters_.avatarSize.width + badgeXOffset, |
+ maxY_ + badgeYOffset); |
+ layout.avatarFrame = |
+ NSMakeRect(origin.x, origin.y, size.width, size.height); |
+ } |
+ |
+ // Calculate the right indentation. The default indentation built into the |
Robert Sesek
2014/09/26 16:55:55
nit: preference is for one space between sentences
erikchen
2014/09/26 17:39:05
Done. (This was a copy paste).
|
+ // tabstrip leaves enough room for the fullscreen button on Lion (10.7) to |
+ // Mavericks (10.9). On 10.6 and >=10.10, the right indent needs to be |
+ // adjusted to make room for the new tab button when an avatar is present. |
+ CGFloat rightIndent = 0; |
+ if (!parameters_.inAnyFullscreen && |
+ !NSIsEmptyRect(parameters_.fullscreenButtonFrame)) { |
+ rightIndent = width - NSMinX(parameters_.fullscreenButtonFrame); |
+ |
+ if (parameters_.shouldUseNewAvatar) { |
+ // The new avatar button is to the left of the fullscreen button. |
+ // (The old avatar button is to the right). |
+ rightIndent += parameters_.avatarSize.width + kAvatarRightOffset; |
+ } |
+ } else if (parameters_.shouldShowAvatar) { |
+ rightIndent += parameters_.avatarSize.width + kAvatarRightOffset; |
+ } |
+ layout.rightIndent = rightIndent; |
+ |
+ output_.tabStripLayout = layout; |
} |
- (void)computeContentViewLayout { |