Commit 79fb092c authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Correct padding around tabstrip for refresh.

This moves the padding outside the NTB into the NTB, allowing more consistent
positioning.

Bug: 851044
Test: Open two tabs.  The leftmost tab's left curve should taper out to the very corner of the toolbar, not 8 DIP later.
Change-Id: I01487e3c416a24b8387bf67c2b1a3e0817125cd9
Reviewed-on: https://chromium-review.googlesource.com/1135965
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575055}
parent 17667924
...@@ -69,6 +69,13 @@ int BrowserNonClientFrameView::GetAvatarIconPadding() { ...@@ -69,6 +69,13 @@ int BrowserNonClientFrameView::GetAvatarIconPadding() {
return MD::IsNewerMaterialUi() ? 8 : 4; return MD::IsNewerMaterialUi() ? 8 : 4;
} }
// static
int BrowserNonClientFrameView::GetTabstripPadding() {
// In Refresh, the apparent padding around the tabstrip is contained within
// the tabs and/or new tab button.
return MD::IsRefreshUi() ? 0 : 4;
}
void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() { void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {
MaybeObserveTabstrip(); MaybeObserveTabstrip();
OnSingleTabModeChanged(); OnSingleTabModeChanged();
...@@ -145,9 +152,10 @@ void BrowserNonClientFrameView::UpdateClientArea() {} ...@@ -145,9 +152,10 @@ void BrowserNonClientFrameView::UpdateClientArea() {}
void BrowserNonClientFrameView::UpdateMinimumSize() {} void BrowserNonClientFrameView::UpdateMinimumSize() {}
int BrowserNonClientFrameView::GetTabStripLeftInset() const { int BrowserNonClientFrameView::GetTabStripLeftInset() const {
int left_inset = GetTabstripPadding();
if (profile_indicator_icon()) if (profile_indicator_icon())
return 2 * GetAvatarIconPadding() + GetIncognitoAvatarIcon().width(); left_inset += GetAvatarIconPadding() + GetIncognitoAvatarIcon().width();
return MD::IsRefreshUi() ? 8 : 4; return left_inset;
} }
void BrowserNonClientFrameView::ChildPreferredSizeChanged(views::View* child) { void BrowserNonClientFrameView::ChildPreferredSizeChanged(views::View* child) {
......
...@@ -28,6 +28,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView, ...@@ -28,6 +28,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// Returns the padding on the left, right, and bottom of the avatar icon. // Returns the padding on the left, right, and bottom of the avatar icon.
static int GetAvatarIconPadding(); static int GetAvatarIconPadding();
// Returns the padding on the sides of the tabstrip.
static int GetTabstripPadding();
BrowserView* browser_view() const { return browser_view_; } BrowserView* browser_view() const { return browser_view_; }
BrowserFrame* frame() const { return frame_; } BrowserFrame* frame() const { return frame_; }
......
...@@ -54,7 +54,8 @@ gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStrip( ...@@ -54,7 +54,8 @@ gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStrip(
gfx::Rect bounds = gfx::Rect(0, kTabstripTopInset, width(), gfx::Rect bounds = gfx::Rect(0, kTabstripTopInset, width(),
tabstrip->GetPreferredSize().height()); tabstrip->GetPreferredSize().height());
bounds.Inset(GetTabStripLeftInset(), 0, GetAfterTabstripItemWidth() + 4, 0); bounds.Inset(GetTabStripLeftInset(), 0,
GetAfterTabstripItemWidth() + GetTabstripPadding(), 0);
return bounds; return bounds;
} }
......
...@@ -209,7 +209,7 @@ gfx::Size GlassBrowserFrameView::GetMinimumSize() const { ...@@ -209,7 +209,7 @@ gfx::Size GlassBrowserFrameView::GetMinimumSize() const {
} }
int GlassBrowserFrameView::GetTabStripLeftInset() const { int GlassBrowserFrameView::GetTabStripLeftInset() const {
return incognito_bounds_.right() + GetAvatarIconPadding(); return incognito_bounds_.right() + GetTabstripPadding();
} }
bool GlassBrowserFrameView::IsSingleTabModeAvailable() const { bool GlassBrowserFrameView::IsSingleTabModeAvailable() const {
...@@ -611,9 +611,8 @@ int GlassBrowserFrameView::MinimizeButtonX() const { ...@@ -611,9 +611,8 @@ int GlassBrowserFrameView::MinimizeButtonX() const {
} }
int GlassBrowserFrameView::TabStripCaptionSpacing() const { int GlassBrowserFrameView::TabStripCaptionSpacing() const {
// For Material Refresh, the end of the tabstrip contains empty space to // In Refresh, any necessary padding after the tabstrip is contained within
// ensure the window remains draggable, which is sufficient padding to the // the tabs and/or new tab button.
// other tabstrip contents.
if (MD::IsRefreshUi()) if (MD::IsRefreshUi())
return 0; return 0;
......
...@@ -126,7 +126,7 @@ gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( ...@@ -126,7 +126,7 @@ gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize(
} }
int OpaqueBrowserFrameViewLayout::GetTabStripLeftInset() const { int OpaqueBrowserFrameViewLayout::GetTabStripLeftInset() const {
return leading_button_start_ + OpaqueBrowserFrameView::GetAvatarIconPadding(); return leading_button_start_ + OpaqueBrowserFrameView::GetTabstripPadding();
} }
gfx::Rect OpaqueBrowserFrameViewLayout::GetWindowBoundsForClientBounds( gfx::Rect OpaqueBrowserFrameViewLayout::GetWindowBoundsForClientBounds(
...@@ -323,9 +323,8 @@ bool OpaqueBrowserFrameViewLayout::ShouldIncognitoIconBeOnRight() const { ...@@ -323,9 +323,8 @@ bool OpaqueBrowserFrameViewLayout::ShouldIncognitoIconBeOnRight() const {
} }
int OpaqueBrowserFrameViewLayout::TabStripCaptionSpacing() const { int OpaqueBrowserFrameViewLayout::TabStripCaptionSpacing() const {
// For Material Refresh, the end of the tabstrip contains empty space to // In Refresh, any necessary padding after the tabstrip is contained within
// ensure the window remains draggable, which is sufficient padding to the // the tabs and/or new tab button.
// other tabstrip contents.
if (MD::IsRefreshUi()) if (MD::IsRefreshUi())
return 0; return 0;
......
...@@ -249,7 +249,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase { ...@@ -249,7 +249,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
(maximized ? OpaqueBrowserFrameViewLayout::kCaptionSpacing (maximized ? OpaqueBrowserFrameViewLayout::kCaptionSpacing
: -delegate_->GetNewTabButtonPreferredSize().width()); : -delegate_->GetNewTabButtonPreferredSize().width());
} }
int tabstrip_x = OpaqueBrowserFrameView::GetAvatarIconPadding(); int tabstrip_x = OpaqueBrowserFrameView::GetTabstripPadding();
if (show_caption_buttons && caption_buttons_on_left) { if (show_caption_buttons && caption_buttons_on_left) {
int right_of_close = int right_of_close =
maximized ? kMaximizedExtraCloseWidth maximized ? kMaximizedExtraCloseWidth
......
...@@ -122,7 +122,9 @@ NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) ...@@ -122,7 +122,9 @@ NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
const int top = MD::IsNewerMaterialUi() const int top = MD::IsNewerMaterialUi()
? (extra_vertical_space / 2) ? (extra_vertical_space / 2)
: (extra_vertical_space - kNewTabButtonBottomOffset); : (extra_vertical_space - kNewTabButtonBottomOffset);
SetBorder(views::CreateEmptyBorder(gfx::Insets(top, 0, 0, 0))); const int horizontal = MD::IsRefreshUi() ? 8 : 0;
SetBorder(
views::CreateEmptyBorder(gfx::Insets(top, horizontal, 0, horizontal)));
} }
NewTabButton::~NewTabButton() { NewTabButton::~NewTabButton() {
......
...@@ -1358,8 +1358,7 @@ void TabStrip::OnPaint(gfx::Canvas* canvas) { ...@@ -1358,8 +1358,7 @@ void TabStrip::OnPaint(gfx::Canvas* canvas) {
const int width = Tab::kSeparatorThickness; const int width = Tab::kSeparatorThickness;
const float separator_height = Tab::GetTabSeparatorHeight(); const float separator_height = Tab::GetTabSeparatorHeight();
gfx::RectF separator_bounds( gfx::RectF separator_bounds(
GetMirroredXWithWidthInView( GetMirroredXWithWidthInView(new_tab_button_bounds_.x() - width, width),
new_tab_button_bounds_.x() - Tab::GetCornerRadius() - width, width),
(height() - separator_height) / 2, width, separator_height); (height() - separator_height) / 2, width, separator_height);
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setAntiAlias(true); flags.setAntiAlias(true);
...@@ -1588,11 +1587,20 @@ bool TabStrip::ShouldHighlightCloseButtonAfterRemove() { ...@@ -1588,11 +1587,20 @@ bool TabStrip::ShouldHighlightCloseButtonAfterRemove() {
} }
int TabStrip::TabToFollowingNewTabButtonSpacing() const { int TabStrip::TabToFollowingNewTabButtonSpacing() const {
// When there is no following new tab button, there is no relevant spacing.
if (controller_->GetNewTabButtonPosition() != AFTER_TABS) if (controller_->GetNewTabButtonPosition() != AFTER_TABS)
return 0; return 0;
constexpr int kNewTabButtonSpacing[] = {-5, -6, 6, 0, 0}; // In refresh, the new tab button contains built-in padding, and should be
return kNewTabButtonSpacing[MD::GetMode()]; // placed flush against the trailing separator.
if (MD::IsRefreshUi())
return -Tab::GetCornerRadius();
// Pre-refresh, there are a variety of hardcoded values.
const int mode = MD::GetMode();
DCHECK_LE(mode, 2);
constexpr int kNewTabButtonSpacing[] = {-5, -6, 6};
return kNewTabButtonSpacing[mode];
} }
bool TabStrip::MayHideNewTabButtonWhileDragging() const { bool TabStrip::MayHideNewTabButtonWhileDragging() const {
...@@ -1609,7 +1617,11 @@ int TabStrip::GetFrameGrabWidth() const { ...@@ -1609,7 +1617,11 @@ int TabStrip::GetFrameGrabWidth() const {
int width = kGrabWidth; int width = kGrabWidth;
const NewTabButtonPosition position = controller_->GetNewTabButtonPosition(); const NewTabButtonPosition position = controller_->GetNewTabButtonPosition();
if (position != AFTER_TABS) { if (position == AFTER_TABS) {
// The grab area is adjacent to the new tab button. Treat the padding in
// the new tab button as part of the grab area.
width -= new_tab_button_->GetInsets().right();
} else {
// The grab area is adjacent to the last tab. This tab has mostly empty // The grab area is adjacent to the last tab. This tab has mostly empty
// space where the outer (lower) corners are, which should be treated as // space where the outer (lower) corners are, which should be treated as
// part of the grab area, so decrease the size of the remaining grab area by // part of the grab area, so decrease the size of the remaining grab area by
...@@ -1752,9 +1764,13 @@ std::vector<gfx::Rect> TabStrip::CalculateBoundsForDraggedTabs( ...@@ -1752,9 +1764,13 @@ std::vector<gfx::Rect> TabStrip::CalculateBoundsForDraggedTabs(
} }
int TabStrip::TabStartX() const { int TabStrip::TabStartX() const {
return (controller_->GetNewTabButtonPosition() == LEADING) if (controller_->GetNewTabButtonPosition() != LEADING)
? new_tab_button_bounds_.width() return 0;
: 0;
// In refresh, the new tab button contains built-in padding, and should be
// placed flush against the leading separator.
const int overlap = MD::IsRefreshUi() ? Tab::GetCornerRadius() : 0;
return new_tab_button_bounds_.width() - overlap;
} }
int TabStrip::TabDragAreaEndX() const { int TabStrip::TabDragAreaEndX() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment