Commit 92acaa68 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Factor some constants out of layout_constants.*; widen standard tabs in refresh.

This moves a couple of constants that are really local to individual files out
of layout_constants.* (which should only be used for cross-file concepts).

Along the way it makes two behavioral changes:
(1) The standard tab width in refresh and touchable refresh, not including
    endcaps, is increased from 193 to 268, per spec.
(2) The stacked tab width in touchable refresh is narrowed by about 8 DIP,
    because endcaps are actually narrower there than in touchable non-refresh,
    but the old code didn't take that into account.  I'm not aware of any
    particular spec on this.

I don't think there's a bug that covers making the standard tab width match the
sspec, interestingly enough.

BUG=none
TEST=none

Change-Id: Iddc6bbbff7730245b802f5a9faa6e40ee0baea02
Reviewed-on: https://chromium-review.googlesource.com/1112865Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570184}
parent c7a158af
......@@ -77,10 +77,6 @@ int GetLayoutConstant(LayoutConstant constant) {
return newer_material ? 8 : 6;
case TAB_STACK_DISTANCE:
return touch_optimized_material ? 4 : 6;
case TAB_STACK_TAB_WIDTH:
return touch_optimized_material ? 160 : 120;
case TAB_STANDARD_WIDTH:
return touch_optimized_material ? 245 : 193;
case TOOLBAR_ELEMENT_PADDING: {
constexpr int kPadding[] = {0, 8, 0, 4, 0};
return kPadding[mode];
......
......@@ -83,14 +83,6 @@ enum LayoutConstant {
// subsequent tab when tabs are stacked.
TAB_STACK_DISTANCE,
// The standard width of a tab when is stacked layout. This does not include
// the endcap width.
TAB_STACK_TAB_WIDTH,
// The standard tab width excluding the overlap (which is the endcap width on
// one side)
TAB_STANDARD_WIDTH,
// Additional horizontal padding between the elements in the toolbar.
TOOLBAR_ELEMENT_PADDING,
......
......@@ -1102,7 +1102,8 @@ int Tab::GetMinimumActiveWidth() {
// static
int Tab::GetStandardWidth() {
return GetLayoutConstant(TAB_STANDARD_WIDTH) + GetOverlap();
constexpr int kLayoutWidth[] = {193, 193, 245, 268, 268};
return GetOverlap() + kLayoutWidth[MD::GetMode()];
}
// static
......
......@@ -225,6 +225,10 @@ const TabSizeInfo& GetTabSizeInfo() {
return *g_tab_size_info;
}
int GetStackableTabWidth() {
return Tab::GetOverlap() + (MD::IsTouchOptimizedUiEnabled() ? 136 : 102);
}
} // namespace
///////////////////////////////////////////////////////////////////////////////
......@@ -1290,8 +1294,8 @@ gfx::Size TabStrip::CalculatePreferredSize() const {
if (touch_layout_ || adjust_layout_) {
// For stacked tabs the minimum size is calculated as the size needed to
// handle showing any number of tabs.
needed_tab_width = GetLayoutConstant(TAB_STACK_TAB_WIDTH) +
(2 * kStackedPadding * kMaxStackedCount);
needed_tab_width =
GetStackableTabWidth() + (2 * kStackedPadding * kMaxStackedCount);
} else {
// Otherwise the minimum width is based on the actual number of tabs.
const int pinned_tab_count = GetPinnedTabCount();
......@@ -2304,12 +2308,10 @@ void TabStrip::SwapLayoutIfNecessary() {
return;
if (needs_touch) {
gfx::Size tab_size(GetLayoutConstant(TAB_STACK_TAB_WIDTH),
GetLayoutConstant(TAB_HEIGHT));
const int overlap = Tab::GetOverlap();
touch_layout_.reset(new StackedTabStripLayout(
tab_size, overlap, kStackedPadding, kMaxStackedCount, &tabs_));
gfx::Size(GetStackableTabWidth(), GetLayoutConstant(TAB_HEIGHT)),
overlap, kStackedPadding, kMaxStackedCount, &tabs_));
touch_layout_->SetWidth(GetTabAreaWidth());
// This has to be after SetWidth() as SetWidth() is going to reset the
// bounds of the pinned tabs (since StackedTabStripLayout doesn't yet know
......@@ -2337,9 +2339,8 @@ bool TabStrip::NeedsTouchLayout() const {
if (normal_count <= 1 || normal_count == pinned_tab_count)
return false;
const int normal_width =
GetLayoutConstant(TAB_STACK_TAB_WIDTH) * normal_count -
Tab::GetOverlap() * (normal_count - 1);
const int normal_width = GetStackableTabWidth() * normal_count -
Tab::GetOverlap() * (normal_count - 1);
const int available_width = GetTabAreaWidth();
const int pinned_width =
pinned_tab_count ? (pinned_tab_count * Tab::GetPinnedWidth() -
......
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