Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 2720183002: [Views] Update ink drop for omnibox icons (Closed)
Patch Set: Removed CanProcessEventsWithinSubtree Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "chrome/browser/ui/layout_constants.h" 7 #include "chrome/browser/ui/layout_constants.h"
8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
11 #include "ui/compositor/layer_animator.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h"
11 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/color_utils.h" 14 #include "ui/gfx/color_utils.h"
13 #include "ui/gfx/scoped_canvas.h" 15 #include "ui/gfx/scoped_canvas.h"
14 #include "ui/native_theme/native_theme.h" 16 #include "ui/native_theme/native_theme.h"
17 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
15 #include "ui/views/animation/ink_drop_highlight.h" 18 #include "ui/views/animation/ink_drop_highlight.h"
19 #include "ui/views/animation/ink_drop_impl.h"
20 #include "ui/views/animation/ink_drop_ripple.h"
16 #include "ui/views/border.h" 21 #include "ui/views/border.h"
17 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
18 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
19 24
20 namespace { 25 namespace {
21 26
22 // Amount of space on either side of the separator that appears after the label. 27 // Amount of space on either side of the separator that appears after the label.
23 constexpr int kSpaceBesideSeparator = 8; 28 constexpr int kSpaceBesideSeparator = 8;
24 29
30 // The length of the separator's fade animation. These values are empirical.
31 constexpr int kFadeInDurationMs = 250;
32 constexpr int kFadeOutDurationMs = 175;
33
25 } // namespace 34 } // namespace
26 35
36 //////////////////////////////////////////////////////////////////
37 // SeparatorView class
38
39 IconLabelBubbleView::SeparatorView::SeparatorView(IconLabelBubbleView* owner) {
40 DCHECK(owner);
41 owner_ = owner;
42 }
43
44 void IconLabelBubbleView::SeparatorView::OnPaint(gfx::Canvas* canvas) {
45 const SkColor plain_text_color = owner_->GetNativeTheme()->GetSystemColor(
46 ui::NativeTheme::kColorId_TextfieldDefaultColor);
47 const SkColor separator_color = SkColorSetA(
48 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC);
49 float x = GetLocalBounds().right() - owner_->GetPostSeparatorPadding();
50 canvas->Draw1pxLine(gfx::PointF(x, GetLocalBounds().y()),
51 gfx::PointF(x, GetLocalBounds().bottom()),
52 separator_color);
53 }
54
55 void IconLabelBubbleView::SeparatorView::OnImplicitAnimationsCompleted() {
56 if (layer() && layer()->opacity() == 1.0f)
57 DestroyLayer();
58 }
59
60 void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
61 if (!visible())
62 return;
63
64 views::InkDrop* ink_drop = owner_->GetInkDrop();
65 DCHECK(ink_drop);
66
67 // If an inkdrop highlight or ripple is animating in or visible, the
68 // separator should fade out.
69 views::InkDropState state = ink_drop->GetTargetInkDropState();
70 float opacity = 0.0f;
71 float duration = kFadeOutDurationMs;
72 if (!ink_drop->IsHighlightFadingInOrVisible() &&
73 (state == views::InkDropState::HIDDEN ||
74 state == views::InkDropState::ACTION_TRIGGERED ||
75 state == views::InkDropState::DEACTIVATED)) {
76 opacity = 1.0f;
77 duration = kFadeInDurationMs;
78 }
79
80 if (!layer())
81 SetPaintToLayer();
82 layer()->SetFillsBoundsOpaquely(false);
83
84 ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator());
85 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(duration));
86 animation.SetTweenType(gfx::Tween::Type::EASE_IN);
87 animation.AddObserver(this);
88 layer()->SetOpacity(opacity);
89 }
90
91 //////////////////////////////////////////////////////////////////
92 // IconLabelBubbleView class
93
27 IconLabelBubbleView::IconLabelBubbleView(const gfx::FontList& font_list, 94 IconLabelBubbleView::IconLabelBubbleView(const gfx::FontList& font_list,
28 bool elide_in_middle) 95 bool elide_in_middle)
29 : image_(new views::ImageView()), 96 : CustomButton(nullptr),
30 label_(new views::Label(base::string16(), {font_list})) { 97 image_(new views::ImageView()),
98 label_(new views::Label(base::string16(), {font_list})),
99 ink_drop_container_(new views::InkDropContainerView()),
100 separator_view_(new SeparatorView(this)),
101 suppress_button_release_(false) {
31 // Disable separate hit testing for |image_|. This prevents views treating 102 // Disable separate hit testing for |image_|. This prevents views treating
32 // |image_| as a separate mouse hover region from |this|. 103 // |image_| as a separate mouse hover region from |this|.
33 image_->set_can_process_events_within_subtree(false); 104 image_->set_can_process_events_within_subtree(false);
34 image_->SetBorder(views::CreateEmptyBorder( 105 image_->SetBorder(views::CreateEmptyBorder(
35 gfx::Insets(LocationBarView::kIconInteriorPadding))); 106 gfx::Insets(LocationBarView::kIconInteriorPadding)));
36 AddChildView(image_); 107 AddChildView(image_);
37 108
38 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 109 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
39 110
40 if (elide_in_middle) 111 if (elide_in_middle)
41 label_->SetElideBehavior(gfx::ELIDE_MIDDLE); 112 label_->SetElideBehavior(gfx::ELIDE_MIDDLE);
42 AddChildView(label_); 113 AddChildView(label_);
43 114
115 separator_view_->SetVisible(ShouldShowLabel());
116 AddChildView(separator_view_);
117
118 AddChildView(ink_drop_container_);
119 ink_drop_container_->SetVisible(false);
120
44 // Bubbles are given the full internal height of the location bar so that all 121 // Bubbles are given the full internal height of the location bar so that all
45 // child views in the location bar have the same height. The visible height of 122 // child views in the location bar have the same height. The visible height of
46 // the bubble should be smaller, so use an empty border to shrink down the 123 // the bubble should be smaller, so use an empty border to shrink down the
47 // content bounds so the background gets painted correctly. 124 // content bounds so the background gets painted correctly.
48 SetBorder(views::CreateEmptyBorder( 125 SetBorder(views::CreateEmptyBorder(
49 gfx::Insets(LocationBarView::kBubbleVerticalPadding, 0))); 126 gfx::Insets(LocationBarView::kBubbleVerticalPadding, 0)));
50 127
128 set_notify_enter_exit_on_child(true);
129
51 // Flip the canvas in RTL so the separator is drawn on the correct side. 130 // Flip the canvas in RTL so the separator is drawn on the correct side.
52 EnableCanvasFlippingForRTLUI(true); 131 separator_view_->EnableCanvasFlippingForRTLUI(true);
53 } 132 }
54 133
55 IconLabelBubbleView::~IconLabelBubbleView() { 134 IconLabelBubbleView::~IconLabelBubbleView() {
56 } 135 }
57 136
137 void IconLabelBubbleView::InkDropAnimationStarted() {
138 separator_view_->UpdateOpacity();
139 }
140
58 void IconLabelBubbleView::SetLabel(const base::string16& label) { 141 void IconLabelBubbleView::SetLabel(const base::string16& label) {
59 label_->SetText(label); 142 label_->SetText(label);
143 separator_view_->SetVisible(ShouldShowLabel());
60 } 144 }
61 145
62 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) { 146 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) {
63 image_->SetImage(image_skia); 147 image_->SetImage(image_skia);
64 } 148 }
65 149
66 bool IconLabelBubbleView::ShouldShowLabel() const { 150 bool IconLabelBubbleView::ShouldShowLabel() const {
67 return label_->visible() && !label_->text().empty(); 151 return label_->visible() && !label_->text().empty();
68 } 152 }
69 153
70 double IconLabelBubbleView::WidthMultiplier() const { 154 double IconLabelBubbleView::WidthMultiplier() const {
71 return 1.0; 155 return 1.0;
72 } 156 }
73 157
74 bool IconLabelBubbleView::IsShrinking() const { 158 bool IconLabelBubbleView::IsShrinking() const {
75 return false; 159 return false;
76 } 160 }
77 161
78 bool IconLabelBubbleView::OnActivate(const ui::Event& event) { 162 bool IconLabelBubbleView::ShowBubble(const ui::Event& event) {
163 return false;
164 }
165
166 bool IconLabelBubbleView::IsBubbleShowing() const {
79 return false; 167 return false;
80 } 168 }
81 169
82 gfx::Size IconLabelBubbleView::GetPreferredSize() const { 170 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
83 // Height will be ignored by the LocationBarView. 171 // Height will be ignored by the LocationBarView.
84 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 172 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
85 } 173 }
86 174
87 bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) {
88 if (event.key_code() == ui::VKEY_RETURN)
89 return OnActivate(event);
90 return false;
91 }
92
93 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) {
94 if (event.key_code() == ui::VKEY_SPACE)
95 return OnActivate(event);
96 return false;
97 }
98
99 void IconLabelBubbleView::Layout() { 175 void IconLabelBubbleView::Layout() {
100 // We may not have horizontal room for both the image and the trailing 176 // We may not have horizontal room for both the image and the trailing
101 // padding. When the view is expanding (or showing-label steady state), the 177 // padding. When the view is expanding (or showing-label steady state), the
102 // image. When the view is contracting (or hidden-label steady state), whittle 178 // image. When the view is contracting (or hidden-label steady state), whittle
103 // away at the trailing padding instead. 179 // away at the trailing padding instead.
104 int bubble_trailing_padding = GetPostSeparatorPadding(); 180 int bubble_trailing_padding = GetPostSeparatorPadding();
105 int image_width = image_->GetPreferredSize().width(); 181 int image_width = image_->GetPreferredSize().width();
106 const int space_shortage = image_width + bubble_trailing_padding - width(); 182 const int space_shortage = image_width + bubble_trailing_padding - width();
107 if (space_shortage > 0) { 183 if (space_shortage > 0) {
108 if (ShouldShowLabel()) 184 if (ShouldShowLabel())
109 image_width -= space_shortage; 185 image_width -= space_shortage;
110 else 186 else
111 bubble_trailing_padding -= space_shortage; 187 bubble_trailing_padding -= space_shortage;
112 } 188 }
113 image_->SetBounds(0, 0, image_width, height()); 189 image_->SetBounds(0, 0, image_width, height());
114 190
115 // Compute the label bounds. The label gets whatever size is left over after 191 // Compute the label bounds. The label gets whatever size is left over after
116 // accounting for the preferred image width and padding amounts. Note that if 192 // accounting for the preferred image width and padding amounts. Note that if
117 // the label has zero size it doesn't actually matter what we compute its X 193 // the label has zero size it doesn't actually matter what we compute its X
118 // value to be, since it won't be visible. 194 // value to be, since it won't be visible.
119 const int label_x = image_->bounds().right() + GetInternalSpacing(); 195 const int label_x = image_->bounds().right() + GetInternalSpacing();
120 const int label_width = 196 const int label_width =
121 std::max(0, width() - label_x - bubble_trailing_padding - 197 std::max(0, width() - label_x - bubble_trailing_padding -
122 kSpaceBesideSeparator - GetSeparatorLayoutWidth()); 198 kSpaceBesideSeparator - GetSeparatorLayoutWidth());
123 label_->SetBounds(label_x, 0, label_width, height()); 199 label_->SetBounds(label_x, 0, label_width, height());
200
201 const int kSeparatorHeight = 16;
202 gfx::Rect separator_bounds(label_->bounds());
203 separator_bounds.Inset(0, (separator_bounds.height() - kSeparatorHeight) / 2);
204
205 float separator_width = kSpaceBesideSeparator + GetPostSeparatorPadding();
206 separator_view_->SetBounds(GetLocalBounds().right() - separator_width,
207 separator_bounds.y(), separator_width,
208 kSeparatorHeight);
209
210 gfx::Rect ink_drop_bounds = GetLocalBounds();
211 if (ShouldShowLabel()) {
212 ink_drop_bounds.set_width(ink_drop_bounds.width() -
213 GetPostSeparatorPadding());
214 }
215
216 ink_drop_container_->SetBoundsRect(ink_drop_bounds);
217 }
218
219 bool IconLabelBubbleView::OnMousePressed(const ui::MouseEvent& event) {
220 suppress_button_release_ = IsBubbleShowing();
221 return CustomButton::OnMousePressed(event);
124 } 222 }
125 223
126 void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 224 void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
127 label_->GetAccessibleNodeData(node_data); 225 label_->GetAccessibleNodeData(node_data);
128 } 226 }
129 227
228 void IconLabelBubbleView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
229 if (!IsMouseHovered()) {
230 GetInkDrop()->AnimateToState(views::InkDropState::HIDDEN);
231 GetInkDrop()->SetHovered(false);
232 }
233 CustomButton::OnBoundsChanged(previous_bounds);
234 }
235
130 void IconLabelBubbleView::OnNativeThemeChanged( 236 void IconLabelBubbleView::OnNativeThemeChanged(
131 const ui::NativeTheme* native_theme) { 237 const ui::NativeTheme* native_theme) {
132 label_->SetEnabledColor(GetTextColor()); 238 label_->SetEnabledColor(GetTextColor());
133 label_->SetBackgroundColor(GetParentBackgroundColor()); 239 label_->SetBackgroundColor(GetParentBackgroundColor());
134 SchedulePaint(); 240 SchedulePaint();
135 } 241 }
136 242
137 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) { 243 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
138 image()->SetPaintToLayer(); 244 ink_drop_container_->AddInkDropLayer(ink_drop_layer);
139 image()->layer()->SetFillsBoundsOpaquely(false);
140 InkDropHostView::AddInkDropLayer(ink_drop_layer);
141 } 245 }
142 246
143 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 247 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
144 InkDropHostView::RemoveInkDropLayer(ink_drop_layer); 248 ink_drop_container_->RemoveInkDropLayer(ink_drop_layer);
145 image()->DestroyLayer(); 249 }
250
251 std::unique_ptr<views::InkDrop> IconLabelBubbleView::CreateInkDrop() {
252 std::unique_ptr<views::InkDropImpl> ink_drop =
253 CreateDefaultFloodFillInkDropImpl();
254 ink_drop->SetShowHighlightOnFocus(true);
255 ink_drop->AddObserver(this);
256 return std::move(ink_drop);
146 } 257 }
147 258
148 std::unique_ptr<views::InkDropHighlight> 259 std::unique_ptr<views::InkDropHighlight>
149 IconLabelBubbleView::CreateInkDropHighlight() const { 260 IconLabelBubbleView::CreateInkDropHighlight() const {
150 // Only show a highlight effect when the label is empty/invisible. 261 return InkDropHostView::CreateDefaultInkDropHighlight(
151 return label()->visible() ? nullptr 262 gfx::RectF(ink_drop_container_->bounds()).CenterPoint(),
152 : InkDropHostView::CreateInkDropHighlight(); 263 ink_drop_container_->size());
264 }
265
266 std::unique_ptr<views::InkDropRipple> IconLabelBubbleView::CreateInkDropRipple()
267 const {
268 gfx::Point center_point = GetInkDropCenterBasedOnLastEvent();
269 View::ConvertPointToTarget(this, ink_drop_container_, &center_point);
270 center_point.SetToMax(ink_drop_container_->origin());
271 center_point.SetToMin(ink_drop_container_->bounds().bottom_right());
272
273 return base::MakeUnique<views::FloodFillInkDropRipple>(
274 ink_drop_container_->size(), center_point, GetInkDropBaseColor(),
275 ink_drop_visible_opacity());
153 } 276 }
154 277
155 SkColor IconLabelBubbleView::GetInkDropBaseColor() const { 278 SkColor IconLabelBubbleView::GetInkDropBaseColor() const {
156 return color_utils::DeriveDefaultIconColor(GetTextColor()); 279 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor(
280 ui::NativeTheme::kColorId_TextfieldDefaultColor));
281 }
282
283 bool IconLabelBubbleView::IsTriggerableEvent(const ui::Event& event) {
284 if (event.IsMouseEvent())
285 return !IsBubbleShowing() && !suppress_button_release_;
286
287 return true;
288 }
289
290 bool IconLabelBubbleView::ShouldUpdateInkDropOnClickCanceled() const {
291 // The click might be cancelled because the bubble is still opened. In this
292 // case, the ink drop state should not be hidden by CustomButton.
293 return false;
294 }
295
296 void IconLabelBubbleView::NotifyClick(const ui::Event& event) {
297 CustomButton::NotifyClick(event);
298 OnActivate(event);
299 }
300
301 void IconLabelBubbleView::OnWidgetDestroying(views::Widget* widget) {
302 widget->RemoveObserver(this);
303 }
304
305 void IconLabelBubbleView::OnWidgetVisibilityChanged(views::Widget* widget,
306 bool visible) {
307 // |widget| is a bubble that has just got shown / hidden.
308 if (!visible)
309 AnimateInkDrop(views::InkDropState::HIDDEN, nullptr /* event */);
157 } 310 }
158 311
159 SkColor IconLabelBubbleView::GetParentBackgroundColor() const { 312 SkColor IconLabelBubbleView::GetParentBackgroundColor() const {
160 return GetNativeTheme()->GetSystemColor( 313 return GetNativeTheme()->GetSystemColor(
161 ui::NativeTheme::kColorId_TextfieldDefaultBackground); 314 ui::NativeTheme::kColorId_TextfieldDefaultBackground);
162 } 315 }
163 316
164 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int label_width) const { 317 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int label_width) const {
165 gfx::Size size(image_->GetPreferredSize()); 318 gfx::Size size(image_->GetPreferredSize());
166 const bool shrinking = IsShrinking(); 319 const bool shrinking = IsShrinking();
(...skipping 14 matching lines...) Expand all
181 // pop back to an icon after the animation finishes. 334 // pop back to an icon after the animation finishes.
182 const int max_width = 335 const int max_width =
183 size.width() + GetInternalSpacing() + label_width + post_label_width; 336 size.width() + GetInternalSpacing() + label_width + post_label_width;
184 const int current_width = WidthMultiplier() * max_width; 337 const int current_width = WidthMultiplier() * max_width;
185 size.set_width(shrinking ? std::max(current_width, size.width()) 338 size.set_width(shrinking ? std::max(current_width, size.width())
186 : current_width); 339 : current_width);
187 } 340 }
188 return size; 341 return size;
189 } 342 }
190 343
344 gfx::Size IconLabelBubbleView::GetMaxSizeForLabelWidth(int label_width) const {
345 gfx::Size size(image_->GetPreferredSize());
346 if (ShouldShowLabel() || IsShrinking()) {
347 // On scale factors < 2, we reserve 1 DIP for the 1 px separator. For
348 // higher scale factors, we simply take the separator px out of the
349 // kSpaceBesideSeparator region before the separator, as that results in a
350 // width closer to the desired gap than if we added a whole DIP for the
351 // separator px. (For scale 2, the two methods have equal error: 1 px.)
352 const int separator_width = (GetScaleFactor() >= 2) ? 0 : 1;
353 const int post_label_width =
354 (kSpaceBesideSeparator + separator_width + GetPostSeparatorPadding());
355 size.Enlarge(GetInternalSpacing() + label_width + post_label_width, 0);
356 }
357 return size;
358 }
359
191 int IconLabelBubbleView::GetInternalSpacing() const { 360 int IconLabelBubbleView::GetInternalSpacing() const {
192 return image_->GetPreferredSize().IsEmpty() 361 return image_->GetPreferredSize().IsEmpty()
193 ? 0 362 ? 0
194 : GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING); 363 : GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING);
195 } 364 }
196 365
197 int IconLabelBubbleView::GetSeparatorLayoutWidth() const { 366 int IconLabelBubbleView::GetSeparatorLayoutWidth() const {
198 // On scale factors < 2, we reserve 1 DIP for the 1 px separator. For 367 // On scale factors < 2, we reserve 1 DIP for the 1 px separator. For
199 // higher scale factors, we simply take the separator px out of the 368 // higher scale factors, we simply take the separator px out of the
200 // kSpaceBesideSeparator region before the separator, as that results in a 369 // kSpaceBesideSeparator region before the separator, as that results in a
(...skipping 10 matching lines...) Expand all
211 } 380 }
212 381
213 float IconLabelBubbleView::GetScaleFactor() const { 382 float IconLabelBubbleView::GetScaleFactor() const {
214 const views::Widget* widget = GetWidget(); 383 const views::Widget* widget = GetWidget();
215 // There may be no widget in tests, and in ash there may be no compositor if 384 // There may be no widget in tests, and in ash there may be no compositor if
216 // the native view of the Widget doesn't have a parent. 385 // the native view of the Widget doesn't have a parent.
217 const ui::Compositor* compositor = widget ? widget->GetCompositor() : nullptr; 386 const ui::Compositor* compositor = widget ? widget->GetCompositor() : nullptr;
218 return compositor ? compositor->device_scale_factor() : 1.0f; 387 return compositor ? compositor->device_scale_factor() : 1.0f;
219 } 388 }
220 389
390 bool IconLabelBubbleView::OnActivate(const ui::Event& event) {
391 if (ShowBubble(event)) {
392 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
393 return true;
394 }
395
396 AnimateInkDrop(views::InkDropState::HIDDEN, nullptr);
397 return false;
398 }
399
221 const char* IconLabelBubbleView::GetClassName() const { 400 const char* IconLabelBubbleView::GetClassName() const {
222 return "IconLabelBubbleView"; 401 return "IconLabelBubbleView";
223 } 402 }
224
225 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
226 if (!ShouldShowLabel())
227 return;
228
229 const SkColor plain_text_color = GetNativeTheme()->GetSystemColor(
230 ui::NativeTheme::kColorId_TextfieldDefaultColor);
231 const SkColor separator_color = SkColorSetA(
232 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC);
233
234 gfx::Rect bounds(label_->bounds());
235 const int kSeparatorHeight = 16;
236 bounds.Inset(0, (bounds.height() - kSeparatorHeight) / 2);
237 bounds.set_width(bounds.width() + kSpaceBesideSeparator);
238 canvas->Draw1pxLine(gfx::PointF(bounds.top_right()),
239 gfx::PointF(bounds.bottom_right()), separator_color);
240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698