Skip to content

Commit 984703d

Browse files
Allen BauerCommit Bot
authored andcommitted
Material Refresh - Horizontally offset the tab interior path.
Make the separator height 24dip for touchable mode. Bug: 845161 Change-Id: I61b3653d5f7f6726c1e85d42b90c1d5ed7e360e7 Reviewed-on: https://chromium-review.googlesource.com/1060349 Commit-Queue: Allen Bauer <[email protected]> Reviewed-by: Bret Sepulveda <[email protected]> Cr-Commit-Position: refs/heads/master@{#560567}
1 parent b6a921e commit 984703d

File tree

1 file changed

+30
-19
lines changed
  • chrome/browser/ui/views/tabs

1 file changed

+30
-19
lines changed

chrome/browser/ui/views/tabs/tab.cc

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,28 @@ using MD = ui::MaterialDesignController;
7575

7676
namespace {
7777

78-
const int kExtraLeftPaddingToBalanceCloseButtonPadding = 2;
78+
constexpr int kExtraLeftPaddingToBalanceCloseButtonPadding = 2;
7979

8080
// When a non-pinned tab becomes a pinned tab the width of the tab animates. If
8181
// the width of a pinned tab is at least kPinnedTabExtraWidthToRenderAsNormal
8282
// larger than the desired pinned tab width then the tab is rendered as a normal
8383
// tab. This is done to avoid having the title immediately disappear when
8484
// transitioning a tab from normal to pinned tab.
85-
const int kPinnedTabExtraWidthToRenderAsNormal = 30;
85+
constexpr int kPinnedTabExtraWidthToRenderAsNormal = 30;
8686

8787
// How opaque to make the hover state (out of 1).
88-
const double kHoverOpacity = 0.33;
88+
constexpr double kHoverOpacity = 0.33;
8989

9090
// Opacity of the active tab background painted over inactive selected tabs.
91-
const double kSelectedTabOpacity = 0.3;
91+
constexpr double kSelectedTabOpacity = 0.3;
9292

9393
// Inactive selected tabs have their throb value scaled by this.
94-
const double kSelectedTabThrobScale = 0.95 - kSelectedTabOpacity;
94+
constexpr double kSelectedTabThrobScale = 0.95 - kSelectedTabOpacity;
95+
96+
// Height of the separator painted on the left edge of the tab for the material
97+
// refresh mode.
98+
constexpr int kTabSeparatorHeight = 20;
99+
constexpr int kTabSeparatorTouchHeight = 24;
95100

96101
////////////////////////////////////////////////////////////////////////////////
97102
// Drawing and utility functions
@@ -148,43 +153,47 @@ gfx::Path GetInteriorPath(float scale,
148153
gfx::Path left_path;
149154
if (MD::IsRefreshUi()) {
150155
const float radius = (endcap_width / 2) * scale;
151-
152156
const float stroke_thickness = TabStrip::ShouldDrawStrokes() ? 1 : 0;
153157

154158
// Bottom right.
155-
right_path.moveTo(right, bottom);
159+
right_path.moveTo(right - scaled_horizontal_inset, bottom);
160+
right_path.rLineTo(0, stroke_thickness);
156161

157162
right_path.arcTo(radius, radius, 0, SkPath::kSmall_ArcSize,
158-
SkPath::kCW_Direction, right - radius, bottom - radius);
163+
SkPath::kCW_Direction,
164+
right - radius - scaled_horizontal_inset, bottom - radius);
159165

160166
// Right vertical.
161-
right_path.lineTo(right - radius, radius + stroke_thickness);
167+
right_path.lineTo(right - radius - scaled_horizontal_inset,
168+
radius - stroke_thickness);
162169

163170
// Top right.
164-
right_path.arcTo(radius, radius, 0, SkPath::kSmall_ArcSize,
165-
SkPath::kCCW_Direction, right - radius * 2,
166-
stroke_thickness);
171+
right_path.arcTo(
172+
radius, radius, 0, SkPath::kSmall_ArcSize, SkPath::kCCW_Direction,
173+
right - radius * 2 - scaled_horizontal_inset, stroke_thickness);
167174

168175
// Top edge.
169176
right_path.lineTo(0, stroke_thickness);
170177
right_path.lineTo(0, bottom);
171178
right_path.close();
172179

173180
// Top left.
174-
left_path.moveTo(radius * 2, stroke_thickness);
181+
left_path.moveTo(radius * 2 + scaled_horizontal_inset, stroke_thickness);
175182

176183
left_path.arcTo(radius, radius, 0, SkPath::kSmall_ArcSize,
177-
SkPath::kCCW_Direction, radius, radius + stroke_thickness);
184+
SkPath::kCCW_Direction, radius + scaled_horizontal_inset,
185+
radius);
178186

179187
// Left vertical.
180-
left_path.lineTo(radius, bottom - radius);
188+
left_path.lineTo(radius + scaled_horizontal_inset, bottom - radius);
181189

182190
// Bottom left.
183191
left_path.arcTo(radius, radius, 0, SkPath::kSmall_ArcSize,
184-
SkPath::kCW_Direction, 0, bottom);
192+
SkPath::kCW_Direction, scaled_horizontal_inset,
193+
bottom + stroke_thickness);
185194

186195
// Bottom edge.
187-
left_path.lineTo(right, bottom);
196+
left_path.lineTo(right, bottom + stroke_thickness);
188197
left_path.lineTo(right, stroke_thickness);
189198
left_path.close();
190199
} else {
@@ -237,7 +246,7 @@ gfx::Path GetBorderPath(float scale,
237246
gfx::Path path;
238247

239248
path.moveTo(0, bottom);
240-
path.rLineTo(0, -1);
249+
path.rLineTo(0, -stroke_thickness);
241250

242251
if (MD::IsRefreshUi()) {
243252
const float radius = (endcap_width / 2) * scale;
@@ -1205,7 +1214,9 @@ void Tab::PaintSeparator(gfx::Canvas* canvas, SkColor inactive_color) {
12051214

12061215
const int tab_height = GetContentsBounds().height();
12071216
gfx::RectF separator_bounds;
1208-
separator_bounds.set_size(gfx::SizeF(1, 20));
1217+
separator_bounds.set_size(gfx::SizeF(1, MD::IsTouchOptimizedUiEnabled()
1218+
? kTabSeparatorTouchHeight
1219+
: kTabSeparatorHeight));
12091220
separator_bounds.set_origin(gfx::PointF(
12101221
GetTabEndcapWidth() / 2, (tab_height - separator_bounds.height()) / 2));
12111222
// The following will paint the separator using an opacity that should

0 commit comments

Comments
 (0)