Index: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
index 95d90b6a30f199763d18195c5b1a16e0813a2291..0d88fa2c9b9030fb9246fde3ca6f4f4a43162efe 100644 |
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
@@ -4,8 +4,10 @@ |
#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
+#include "base/command_line.h" |
#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/ui/views/avatar_menu_button.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/profile_management_switches.h" |
#include "ui/gfx/font.h" |
#include "ui/views/controls/button/image_button.h" |
@@ -58,15 +60,16 @@ const int kAvatarLabelInnerSpacing = 10; |
// How far the new avatar button is from the closest caption button. |
const int kNewAvatarButtonOffset = 5; |
-// In restored mode, the New Tab button isn't at the same height as the caption |
-// buttons, but the space will look cluttered if it actually slides under them, |
-// so we stop it when the gap between the two is down to 5 px. |
-const int kNewTabCaptionRestoredSpacing = 5; |
+// When the title bar is in its normal two row mode, the New Tab button isn't at |
James Cook
2013/12/20 22:23:51
nit: You might want to put the word "restored" in
Matt Giuca
2014/01/06 04:28:21
Done.
|
+// the same height as the caption buttons, but the space will look cluttered if |
+// it actually slides under them, so we stop it when the gap between the two is |
+// down to 5 px. |
+const int kNewTabCaptionNormalSpacing = 5; |
-// In maximized mode, where the New Tab button and the caption buttons are at |
-// similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
-// looking too cluttered. |
-const int kNewTabCaptionMaximizedSpacing = 16; |
+// When the title bar is condensed to one row (as when maximized), the New Tab |
+// button and the caption buttons are at similar vertical coordinates, so we |
+// need to reserve a larger, 16 px gap to avoid looking too cluttered. |
+const int kNewTapCaptionCondensedSpacing = 16; |
// The top 3 px of the tabstrip is shadow; in maximized mode we push this off |
// the top of the screen so the tabs appear flush against the screen edge. |
@@ -143,8 +146,8 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( |
if (delegate_->GetAdditionalReservedSpaceInTabStrip()) |
available_width -= delegate_->GetAdditionalReservedSpaceInTabStrip(); |
- const int caption_spacing = delegate_->IsMaximized() ? |
- kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; |
+ const int caption_spacing = IsTitleBarCondensed() ? |
+ kNewTapCaptionCondensedSpacing : kNewTabCaptionNormalSpacing; |
const int tabstrip_width = available_width - caption_spacing; |
gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false), |
std::max(0, tabstrip_width), |
@@ -176,8 +179,8 @@ gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( |
if (delegate_->IsTabStripVisible()) { |
gfx::Size preferred_size = delegate_->GetTabstripPreferredSize(); |
const int min_tabstrip_width = preferred_size.width(); |
- const int caption_spacing = delegate_->IsMaximized() ? |
- kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; |
+ const int caption_spacing = IsTitleBarCondensed() ? |
+ kNewTapCaptionCondensedSpacing : kNewTabCaptionNormalSpacing; |
min_size.Enlarge(min_tabstrip_width + caption_spacing, 0); |
} |
@@ -195,7 +198,7 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetWindowBoundsForClientBounds( |
} |
int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { |
- return (!restored && (delegate_->IsMaximized() || |
+ return (!restored && (IsTitleBarCondensed() || |
delegate_->IsFullscreen())) ? |
0 : kFrameBorderThickness; |
} |
@@ -203,7 +206,7 @@ int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { |
int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { |
// When we fill the screen, we don't show a client edge. |
return FrameBorderThickness(false) + |
- ((delegate_->IsMaximized() || delegate_->IsFullscreen()) ? |
+ ((IsTitleBarCondensed() || delegate_->IsFullscreen()) ? |
0 : views::NonClientFrameView::kClientEdgeThickness); |
} |
@@ -215,22 +218,25 @@ int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( |
TitlebarBottomThickness(restored); |
} |
- return FrameBorderThickness(restored) - |
- ((delegate_->IsTabStripVisible() && |
- !restored && !delegate_->ShouldLeaveOffsetNearTopBorder()) |
- ? kTabstripTopShadowThickness : 0); |
+ int thickness = FrameBorderThickness(restored); |
+ if (!restored && delegate_->IsTabStripVisible() && |
James Cook
2013/12/20 22:23:51
better, thanks
|
+ (!delegate_->ShouldLeaveOffsetNearTopBorder() || IsTitleBarCondensed())) { |
+ thickness -= kTabstripTopShadowThickness; |
+ } |
+ return thickness; |
} |
int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { |
return NonClientTopBorderHeight(restored) + ((!restored && |
(!delegate_->ShouldLeaveOffsetNearTopBorder() || |
+ IsTitleBarCondensed() || |
delegate_->IsFullscreen())) ? |
0 : kNonClientRestoredExtraThickness); |
} |
int OpaqueBrowserFrameViewLayout::TitlebarBottomThickness(bool restored) const { |
return kTitlebarTopAndBottomEdgeThickness + |
- ((!restored && delegate_->IsMaximized()) ? 0 : |
+ ((!restored && IsTitleBarCondensed()) ? 0 : |
views::NonClientFrameView::kClientEdgeThickness); |
} |
@@ -238,7 +244,7 @@ int OpaqueBrowserFrameViewLayout::CaptionButtonY(bool restored) const { |
// Maximized buttons start at window top, since the window has no border. This |
// offset is for the image (the actual clickable bounds extend all the way to |
// the top to take Fitts' Law into account). |
- return ((!restored && delegate_->IsMaximized()) ? |
+ return ((!restored && IsTitleBarCondensed()) ? |
FrameBorderThickness(false) : |
views::NonClientFrameView::kFrameShadowThickness) + extra_caption_y_; |
} |
@@ -257,6 +263,15 @@ gfx::Rect OpaqueBrowserFrameViewLayout::CalculateClientAreaBounds( |
std::max(0, height - top_height - border_thickness)); |
} |
+bool OpaqueBrowserFrameViewLayout::IsTitleBarCondensed() const { |
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
+ return true; |
+#endif |
+ |
+ return delegate_->IsMaximized(); |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
// OpaqueBrowserFrameView, private: |
@@ -321,7 +336,7 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) { |
// slightly uncentered with restored windows, so when the window is |
// restored, instead of calculating the remaining space from below the |
// frame border, we calculate from below the 3D edge. |
- int unavailable_px_at_top = delegate_->IsMaximized() ? |
+ int unavailable_px_at_top = IsTitleBarCondensed() ? |
frame_thickness : kTitlebarTopAndBottomEdgeThickness; |
// When the icon is shorter than the minimum space we reserve for the |
// caption button, we vertically center it. We want to bias rounding to |
@@ -407,7 +422,7 @@ void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) { |
host->width() - trailing_button_start_ - kAvatarOuterSpacing - |
incognito_icon.width() : |
leading_button_start_ + kAvatarOuterSpacing; |
- int avatar_y = delegate_->IsMaximized() ? |
+ int avatar_y = IsTitleBarCondensed() ? |
(NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : |
avatar_restored_y; |
avatar_bounds_.SetRect( |
@@ -513,7 +528,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
// side of the caption buttons. In maximized mode we extend buttons to the |
// screen top and the rightmost button to the screen right (or leftmost button |
// to the screen left, for left-aligned buttons) to obey Fitts' Law. |
- bool is_maximized = delegate_->IsMaximized(); |
+ bool title_bar_condensed = IsTitleBarCondensed(); |
// When we are the first button on the leading side and are the close |
// button, we must flip ourselves, because the close button assets have |
@@ -522,7 +537,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
!has_leading_buttons_ && |
button == close_button_); |
// If the window is maximized, align the buttons to its upper edge. |
- int extra_height = is_maximized ? extra_caption_y_ : 0; |
+ int extra_height = title_bar_condensed ? extra_caption_y_ : 0; |
switch (alignment) { |
case ALIGN_LEADING: { |
@@ -531,7 +546,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
// If we're the first button on the left and maximized, add width to the |
// right hand side of the screen. |
- int extra_width = (is_maximized && !has_leading_buttons_) ? |
+ int extra_width = (title_bar_condensed && !has_leading_buttons_) ? |
(kFrameBorderThickness - |
views::NonClientFrameView::kFrameShadowThickness) : 0; |
@@ -552,7 +567,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
// If we're the first button on the right and maximized, add width to the |
// right hand side of the screen. |
- int extra_width = (is_maximized && !has_trailing_buttons_) ? |
+ int extra_width = (title_bar_condensed && !has_trailing_buttons_) ? |
(kFrameBorderThickness - |
views::NonClientFrameView::kFrameShadowThickness) : 0; |