Commit e557f931 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

For Refresh, let the tabstrip extend all the way to the caption buttons.

BUG=822037
TEST=none

Change-Id: I3c5f0199ea30b9ade417c7209a6be69f629c2ae2
Reviewed-on: https://chromium-review.googlesource.com/1029418
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555249}
parent 27b285d3
......@@ -56,6 +56,7 @@
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
#include "ui/base/layout.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/label.h"
......@@ -558,10 +559,17 @@ AvatarButtonStyle BrowserNonClientFrameViewAsh::GetAvatarButtonStyle() const {
// BrowserNonClientFrameViewAsh, private:
int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const {
// Space between right edge of tabstrip and maximize button.
int inset = caption_button_container_->GetPreferredSize().width();
// For Material Refresh, the end of the tabstrip contains empty space to
// ensure the window remains draggable, which is sufficient padding to the
// other tabstrip contents.
using MD = ui::MaterialDesignController;
constexpr int kTabstripRightSpacing = 10;
return kTabstripRightSpacing +
caption_button_container_->GetPreferredSize().width();
if (MD::GetMode() != MD::MATERIAL_REFRESH)
inset += kTabstripRightSpacing;
return inset;
}
bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const {
......
......@@ -381,11 +381,16 @@ void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) {
}
int BrowserNonClientFrameViewMus::GetTabStripRightInset() const {
// Space between right edge of tabstrip and maximize button.
int right_inset = frame_values().normal_insets.right() +
frame_values().max_title_bar_button_width;
// For Material Refresh, the end of the tabstrip contains empty space to
// ensure the window remains draggable, which is sufficient padding to the
// other tabstrip contents.
using MD = ui::MaterialDesignController;
constexpr int kTabstripRightSpacing = 10;
const int frame_right_insets = frame_values().normal_insets.right() +
frame_values().max_title_bar_button_width;
int right_inset = kTabstripRightSpacing + frame_right_insets;
if (MD::GetMode() != MD::MATERIAL_REFRESH)
right_inset += kTabstripRightSpacing;
#if defined(FRAME_AVATAR_BUTTON)
views::View* profile_switcher_view = GetProfileSwitcherButton();
......@@ -409,7 +414,7 @@ void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() {
#if defined(FRAME_AVATAR_BUTTON)
views::View* profile_switcher_view = GetProfileSwitcherButton();
gfx::Size button_size = profile_switcher_view->GetPreferredSize();
int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset;
int button_x = width() - GetTabStripRightInset();
profile_switcher_view->SetBounds(button_x, 0, button_size.width(),
button_size.height());
#endif
......
......@@ -24,6 +24,7 @@
#include "content/public/browser/web_contents.h"
#include "skia/ext/image_operations.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle_win.h"
#include "ui/base/theme_provider.h"
#include "ui/display/win/dpi.h"
......@@ -133,39 +134,8 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
views::View* tabstrip) const {
const int x = GetTabStripLeftInset();
int end_x = width() - ClientBorderThickness(false);
if (!CaptionButtonsOnLeadingEdge()) {
// 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.
constexpr int kNewTabCaptionRestoredSpacing = 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.
constexpr int kNewTabCaptionMaximizedSpacing = 16;
end_x = std::min(MinimizeButtonX(), end_x) -
(IsMaximized() ? kNewTabCaptionMaximizedSpacing
: kNewTabCaptionRestoredSpacing);
// The profile switcher button is optionally displayed to the left of the
// minimize button.
views::View* profile_switcher = GetProfileSwitcherButton();
if (profile_switcher) {
const int old_end_x = end_x;
end_x -= profile_switcher->width() + kProfileSwitcherButtonOffset;
// In non-maximized mode, allow the new tab button to slide completely
// under the profile switcher button.
if (!IsMaximized()) {
const int new_tab_button_width =
GetLayoutSize(NEW_TAB_BUTTON,
browser_view()->tabstrip()->IsIncognito())
.width();
end_x = std::min(
end_x + new_tab_button_width + kNewTabCaptionRestoredSpacing,
old_end_x);
}
}
}
if (!CaptionButtonsOnLeadingEdge())
end_x = std::min(MinimizeButtonX() - TabStripCaptionSpacing(), end_x);
return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x),
tabstrip->GetPreferredSize().height());
}
......@@ -592,6 +562,44 @@ int GlassBrowserFrameView::MinimizeButtonX() const {
: frame()->GetMinimizeButtonOffset();
}
int GlassBrowserFrameView::TabStripCaptionSpacing() const {
// For Material Refresh, the end of the tabstrip contains empty space to
// ensure the window remains draggable, which is sufficient padding to the
// other tabstrip contents.
using MD = ui::MaterialDesignController;
if (MD::GetMode() == MD::MATERIAL_REFRESH)
return 0;
// 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.
constexpr int kNewTabCaptionRestoredSpacing = 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.
constexpr int kNewTabCaptionMaximizedSpacing = 16;
const int caption_spacing = IsMaximized() ? kNewTabCaptionMaximizedSpacing
: kNewTabCaptionRestoredSpacing;
// The profile switcher button is optionally displayed to the left of the
// minimize button.
views::View* profile_switcher = GetProfileSwitcherButton();
if (!profile_switcher)
return caption_spacing;
int profile_spacing =
profile_switcher->width() + kProfileSwitcherButtonOffset;
// In non-maximized mode, allow the new tab button to slide completely under
// the profile switcher button.
if (!IsMaximized()) {
const bool incognito = browser_view()->tabstrip()->IsIncognito();
profile_spacing -= GetLayoutSize(NEW_TAB_BUTTON, incognito).width();
}
return std::max(caption_spacing, profile_spacing);
}
bool GlassBrowserFrameView::IsToolbarVisible() const {
return browser_view()->IsToolbarVisible() &&
!browser_view()->toolbar()->GetPreferredSize().IsEmpty();
......
......@@ -126,6 +126,10 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
// edge of the caption buttons.
int MinimizeButtonX() const;
// Returns the spacing between the trailing edge of the tabstrip and the start
// of the caption buttons.
int TabStripCaptionSpacing() const;
// Returns whether the toolbar is currently visible.
bool IsToolbarVisible() const;
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
#include "chrome/common/chrome_switches.h"
#include "components/signin/core/browser/profile_management_switches.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/font.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
......@@ -100,7 +101,7 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip(
const gfx::Size& tabstrip_preferred_size,
int available_width) const {
const int x = GetTabStripLeftInset();
available_width -= x + NewTabCaptionSpacing() + trailing_button_start_;
available_width -= x + TabStripCaptionSpacing() + trailing_button_start_;
return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width),
tabstrip_preferred_size.height());
}
......@@ -120,7 +121,7 @@ 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 = NewTabCaptionSpacing();
const int caption_spacing = TabStripCaptionSpacing();
min_size.Enlarge(min_tabstrip_width + caption_spacing, 0);
}
......@@ -314,7 +315,14 @@ bool OpaqueBrowserFrameViewLayout::ShouldIncognitoIconBeOnRight() const {
return trailing_buttons_.size() < leading_buttons_.size();
}
int OpaqueBrowserFrameViewLayout::NewTabCaptionSpacing() const {
int OpaqueBrowserFrameViewLayout::TabStripCaptionSpacing() const {
// For Material Refresh, the end of the tabstrip contains empty space to
// ensure the window remains draggable, which is sufficient padding to the
// other tabstrip contents.
using MD = ui::MaterialDesignController;
if (MD::GetMode() == MD::MATERIAL_REFRESH)
return 0;
return (has_trailing_buttons_ && IsTitleBarCondensed()) ?
kNewTabCaptionCondensedSpacing : kCaptionSpacing;
}
......
......@@ -169,9 +169,9 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
// the tab strip (instead of the usual left).
bool ShouldIncognitoIconBeOnRight() const;
// Determines the amount of spacing between the New Tab button and the element
// to its immediate right.
int NewTabCaptionSpacing() const;
// Determines the amount of spacing between the tabstrip and the caption
// buttons.
int TabStripCaptionSpacing() const;
// Layout various sub-components of this view.
void LayoutWindowControls(views::View* host);
......
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