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

Side by Side Diff: ash/common/system/tray/hover_highlight_view.cc

Issue 2696033003: [Ash MD] Remove some non-MD code from HoverHighlightView (Closed)
Patch Set: Created 3 years, 10 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ash/common/system/tray/hover_highlight_view.h" 5 #include "ash/common/system/tray/hover_highlight_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/fixed_sized_image_view.h"
9 #include "ash/common/system/tray/tray_constants.h" 7 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_popup_utils.h" 8 #include "ash/common/system/tray/tray_popup_utils.h"
11 #include "ash/common/system/tray/tri_view.h" 9 #include "ash/common/system/tray/tri_view.h"
12 #include "ash/common/system/tray/view_click_listener.h" 10 #include "ash/common/system/tray/view_click_listener.h"
13 #include "ash/resources/vector_icons/vector_icons.h" 11 #include "ash/resources/vector_icons/vector_icons.h"
14 #include "ui/accessibility/ax_node_data.h" 12 #include "ui/accessibility/ax_node_data.h"
15 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/font_list.h" 15 #include "ui/gfx/font_list.h"
18 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/resources/grit/ui_resources.h" 17 #include "ui/resources/grit/ui_resources.h"
20 #include "ui/views/border.h" 18 #include "ui/views/border.h"
21 #include "ui/views/controls/image_view.h" 19 #include "ui/views/controls/image_view.h"
22 #include "ui/views/controls/label.h" 20 #include "ui/views/controls/label.h"
23 #include "ui/views/layout/box_layout.h" 21 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/layout/fill_layout.h" 22 #include "ui/views/layout/fill_layout.h"
25 #include "ui/views/resources/grit/views_resources.h" 23 #include "ui/views/resources/grit/views_resources.h"
26 24
27 namespace { 25 namespace {
28 26
29 const int kCheckLabelPadding = 4;
30
31 const gfx::FontList& GetFontList(bool highlight) { 27 const gfx::FontList& GetFontList(bool highlight) {
32 return ui::ResourceBundle::GetSharedInstance().GetFontList( 28 return ui::ResourceBundle::GetSharedInstance().GetFontList(
33 highlight ? ui::ResourceBundle::BoldFont : ui::ResourceBundle::BaseFont); 29 highlight ? ui::ResourceBundle::BoldFont : ui::ResourceBundle::BaseFont);
34 } 30 }
35 31
36 } // namespace 32 } // namespace
37 33
38 namespace ash { 34 namespace ash {
39 35
40 HoverHighlightView::HoverHighlightView(ViewClickListener* listener) 36 HoverHighlightView::HoverHighlightView(ViewClickListener* listener)
41 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), 37 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS),
42 listener_(listener), 38 listener_(listener) {
43 highlight_color_(kHoverBackgroundColor) {
44 set_notify_enter_exit_on_child(true); 39 set_notify_enter_exit_on_child(true);
45 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 40 SetInkDropMode(InkDropHostView::InkDropMode::ON);
46 SetInkDropMode(InkDropHostView::InkDropMode::ON);
47 } 41 }
48 42
49 HoverHighlightView::~HoverHighlightView() {} 43 HoverHighlightView::~HoverHighlightView() {}
50 44
51 bool HoverHighlightView::GetTooltipText(const gfx::Point& p, 45 bool HoverHighlightView::GetTooltipText(const gfx::Point& p,
52 base::string16* tooltip) const { 46 base::string16* tooltip) const {
53 if (tooltip_.empty()) 47 if (tooltip_.empty())
54 return false; 48 return false;
55 *tooltip = tooltip_; 49 *tooltip = tooltip_;
56 return true; 50 return true;
57 } 51 }
58 52
59 void HoverHighlightView::AddRightIcon(const gfx::ImageSkia& image, 53 void HoverHighlightView::AddRightIcon(const gfx::ImageSkia& image,
60 int icon_size) { 54 int icon_size) {
61 DCHECK(!right_view_); 55 DCHECK(!right_view_);
62 56 views::ImageView* right_icon = TrayPopupUtils::CreateMainImageView();
63 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
64 views::ImageView* right_icon = TrayPopupUtils::CreateMainImageView();
65 right_icon->SetImage(image);
66 AddRightView(right_icon);
67 return;
68 }
69
70 views::ImageView* right_icon = new FixedSizedImageView(icon_size, icon_size);
71 right_icon->SetImage(image); 57 right_icon->SetImage(image);
72 AddRightView(right_icon); 58 AddRightView(right_icon);
73 } 59 }
74 60
75 void HoverHighlightView::AddRightView(views::View* view) { 61 void HoverHighlightView::AddRightView(views::View* view) {
76 DCHECK(!right_view_); 62 DCHECK(!right_view_);
77
78 right_view_ = view; 63 right_view_ = view;
79 right_view_->SetEnabled(enabled()); 64 right_view_->SetEnabled(enabled());
80 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 65
81 DCHECK(tri_view_); 66 DCHECK(tri_view_);
82 tri_view_->AddView(TriView::Container::END, right_view_); 67 tri_view_->AddView(TriView::Container::END, right_view_);
83 tri_view_->SetContainerVisible(TriView::Container::END, true); 68 tri_view_->SetContainerVisible(TriView::Container::END, true);
84 return;
85 }
86 DCHECK(box_layout_);
87 AddChildView(right_view_);
88 } 69 }
89 70
90 // TODO(tdanderson): Ensure all checkable detailed view rows use this 71 // TODO(tdanderson): Ensure all checkable detailed view rows use this
91 // mechanism, and share the code that sets the accessible state for 72 // mechanism, and share the code that sets the accessible state for
92 // a checkbox. See crbug.com/652674. 73 // a checkbox. See crbug.com/652674.
93 void HoverHighlightView::SetRightViewVisible(bool visible) { 74 void HoverHighlightView::SetRightViewVisible(bool visible) {
94 if (!right_view_) 75 if (!right_view_)
95 return; 76 return;
96 77
97 right_view_->SetVisible(visible); 78 right_view_->SetVisible(visible);
98 Layout(); 79 Layout();
99 } 80 }
100 81
101 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, 82 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image,
102 const base::string16& text, 83 const base::string16& text) {
103 bool highlight) { 84 DoAddIconAndLabelsMd(image, text,
104 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 85 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
105 DoAddIconAndLabelMd(image, text, 86 base::string16());
106 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
107 return;
108 }
109
110 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 3,
111 kTrayPopupPaddingBetweenItems);
112 SetLayoutManager(box_layout_);
113 DoAddIconAndLabel(image, kTrayPopupDetailsIconWidth, text, highlight);
114 } 87 }
115 88
116 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image, 89 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image,
117 const base::string16& text, 90 const base::string16& text,
118 const base::string16& sub_text) { 91 const base::string16& sub_text) {
119 DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial());
120 DoAddIconAndLabelsMd(image, text, 92 DoAddIconAndLabelsMd(image, text,
121 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL, 93 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
122 sub_text); 94 sub_text);
123 } 95 }
124 96
125 void HoverHighlightView::AddIconAndLabelCustomSize(const gfx::ImageSkia& image,
126 const base::string16& text,
127 bool highlight,
128 int icon_size,
129 int indent,
130 int space_between_items) {
131 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
132 DoAddIconAndLabelMd(image, text,
133 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
134 return;
135 }
136
137 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, indent, 0,
138 space_between_items);
139 SetLayoutManager(box_layout_);
140 DoAddIconAndLabel(image, icon_size, text, highlight);
141 }
142
143 void HoverHighlightView::AddIconAndLabelForDefaultView( 97 void HoverHighlightView::AddIconAndLabelForDefaultView(
144 const gfx::ImageSkia& image, 98 const gfx::ImageSkia& image,
145 const base::string16& text, 99 const base::string16& text) {
146 bool highlight) { 100 DoAddIconAndLabelsMd(image, text,
147 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 101 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL,
148 DoAddIconAndLabelMd(image, text, 102 base::string16());
149 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
150 return;
151 }
152
153 // For non-MD, call AddIconAndLabel() so that |box_layout_| is instantiated
154 // and installed as the layout manager.
155 AddIconAndLabel(image, text, highlight);
156 }
157
158 void HoverHighlightView::DoAddIconAndLabel(const gfx::ImageSkia& image,
159 int icon_size,
160 const base::string16& text,
161 bool highlight) {
162 DCHECK(!MaterialDesignController::IsSystemTrayMenuMaterial());
163 DCHECK(box_layout_);
164
165 views::ImageView* image_view = new FixedSizedImageView(icon_size, 0);
166 image_view->SetImage(image);
167 image_view->SetEnabled(enabled());
168 AddChildView(image_view);
169
170 text_label_ = new views::Label(text);
171 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
172 text_label_->SetFontList(GetFontList(highlight));
173 if (text_default_color_)
174 text_label_->SetEnabledColor(text_default_color_);
175 text_label_->SetEnabled(enabled());
176 AddChildView(text_label_);
177 box_layout_->SetFlexForView(text_label_, 1);
178
179 SetAccessibleName(text);
180 }
181
182 void HoverHighlightView::DoAddIconAndLabelMd(
183 const gfx::ImageSkia& image,
184 const base::string16& text,
185 TrayPopupItemStyle::FontStyle font_style) {
186 DoAddIconAndLabelsMd(image, text, font_style, base::string16());
187 } 103 }
188 104
189 void HoverHighlightView::DoAddIconAndLabelsMd( 105 void HoverHighlightView::DoAddIconAndLabelsMd(
190 const gfx::ImageSkia& image, 106 const gfx::ImageSkia& image,
191 const base::string16& text, 107 const base::string16& text,
192 TrayPopupItemStyle::FontStyle font_style, 108 TrayPopupItemStyle::FontStyle font_style,
193 const base::string16& sub_text) { 109 const base::string16& sub_text) {
194 DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial());
195
196 SetLayoutManager(new views::FillLayout); 110 SetLayoutManager(new views::FillLayout);
197 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); 111 tri_view_ = TrayPopupUtils::CreateDefaultRowView();
198 AddChildView(tri_view_); 112 AddChildView(tri_view_);
199 113
200 left_icon_ = TrayPopupUtils::CreateMainImageView(); 114 left_icon_ = TrayPopupUtils::CreateMainImageView();
201 left_icon_->SetImage(image); 115 left_icon_->SetImage(image);
202 left_icon_->SetEnabled(enabled()); 116 left_icon_->SetEnabled(enabled());
203 tri_view_->AddView(TriView::Container::START, left_icon_); 117 tri_view_->AddView(TriView::Container::START, left_icon_);
204 118
205 text_label_ = TrayPopupUtils::CreateDefaultLabel(); 119 text_label_ = TrayPopupUtils::CreateDefaultLabel();
(...skipping 10 matching lines...) Expand all
216 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); 130 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
217 sub_style.SetupLabel(sub_text_label_); 131 sub_style.SetupLabel(sub_text_label_);
218 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_); 132 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_);
219 } 133 }
220 134
221 tri_view_->SetContainerVisible(TriView::Container::END, false); 135 tri_view_->SetContainerVisible(TriView::Container::END, false);
222 136
223 SetAccessibleName(text); 137 SetAccessibleName(text);
224 } 138 }
225 139
140 // TODO(tdanderson): Remove the SelectableHoverHighlightView class, and then
141 // audit for what additional cleanup is needed so that AddLabel() can be
142 // removed. See crbug.com/686345.
226 views::Label* HoverHighlightView::AddLabel(const base::string16& text, 143 views::Label* HoverHighlightView::AddLabel(const base::string16& text,
227 gfx::HorizontalAlignment alignment, 144 gfx::HorizontalAlignment alignment,
228 bool highlight) { 145 bool highlight) {
229 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 146 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
230 SetLayoutManager(box_layout_); 147 SetLayoutManager(box_layout_);
231 text_label_ = new views::Label(text); 148 text_label_ = new views::Label(text);
232 int left_margin = kTrayPopupPaddingHorizontal; 149 int left_margin = kTrayPopupPaddingHorizontal;
233 int right_margin = kTrayPopupPaddingHorizontal; 150 int right_margin = kTrayPopupPaddingHorizontal;
234 if (alignment != gfx::ALIGN_CENTER) { 151 if (alignment != gfx::ALIGN_CENTER) {
235 if (base::i18n::IsRTL()) 152 if (base::i18n::IsRTL())
236 right_margin += kTrayPopupDetailsLabelExtraLeftMargin; 153 right_margin += kTrayPopupDetailsLabelExtraLeftMargin;
237 else 154 else
238 left_margin += kTrayPopupDetailsLabelExtraLeftMargin; 155 left_margin += kTrayPopupDetailsLabelExtraLeftMargin;
239 } 156 }
240 text_label_->SetBorder( 157 text_label_->SetBorder(
241 views::CreateEmptyBorder(5, left_margin, 5, right_margin)); 158 views::CreateEmptyBorder(5, left_margin, 5, right_margin));
242 text_label_->SetHorizontalAlignment(alignment); 159 text_label_->SetHorizontalAlignment(alignment);
243 text_label_->SetFontList(GetFontList(highlight)); 160 text_label_->SetFontList(GetFontList(highlight));
244 // Do not set alpha value in disable color. It will have issue with elide 161 // Do not set alpha value in disable color. It will have issue with elide
245 // blending filter in disabled state for rendering label text color. 162 // blending filter in disabled state for rendering label text color.
246 text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127)); 163 text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127));
247 if (text_default_color_)
248 text_label_->SetEnabledColor(text_default_color_);
249 text_label_->SetEnabled(enabled()); 164 text_label_->SetEnabled(enabled());
250 AddChildView(text_label_); 165 AddChildView(text_label_);
251 box_layout_->SetFlexForView(text_label_, 1); 166 box_layout_->SetFlexForView(text_label_, 1);
252 167
253 SetAccessibleName(text); 168 SetAccessibleName(text);
254 return text_label_; 169 return text_label_;
255 } 170 }
256 171
257 views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text, 172 void HoverHighlightView::AddLabelRow(const base::string16& text) {
258 bool highlight,
259 bool checked) {
260 DCHECK(!MaterialDesignController::IsSystemTrayMenuMaterial());
261
262 if (checked) {
263 accessibility_state_ = AccessibilityState::CHECKED_CHECKBOX;
264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
265 const gfx::ImageSkia* check =
266 rb.GetImageNamed(IDR_MENU_CHECK).ToImageSkia();
267 int margin = kTrayPopupPaddingHorizontal +
268 kTrayPopupDetailsLabelExtraLeftMargin - kCheckLabelPadding;
269 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 3,
270 kCheckLabelPadding);
271 SetLayoutManager(box_layout_);
272 views::ImageView* image_view = new FixedSizedImageView(margin, 0);
273 image_view->SetImage(check);
274 image_view->SetHorizontalAlignment(views::ImageView::TRAILING);
275 image_view->SetEnabled(enabled());
276 AddChildView(image_view);
277
278 text_label_ = new views::Label(text);
279 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
280 text_label_->SetFontList(GetFontList(highlight));
281 text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0));
282 if (text_default_color_)
283 text_label_->SetEnabledColor(text_default_color_);
284 text_label_->SetEnabled(enabled());
285 AddChildView(text_label_);
286
287 SetAccessibleName(text);
288 return text_label_;
289 }
290
291 accessibility_state_ = AccessibilityState::UNCHECKED_CHECKBOX;
292 return AddLabel(text, gfx::ALIGN_LEFT, highlight);
293 }
294
295 void HoverHighlightView::AddLabelRowMd(const base::string16& text) {
296 DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial());
297
298 SetLayoutManager(new views::FillLayout); 173 SetLayoutManager(new views::FillLayout);
299 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); 174 tri_view_ = TrayPopupUtils::CreateDefaultRowView();
300 AddChildView(tri_view_); 175 AddChildView(tri_view_);
301 176
302 text_label_ = TrayPopupUtils::CreateDefaultLabel(); 177 text_label_ = TrayPopupUtils::CreateDefaultLabel();
303 text_label_->SetText(text); 178 text_label_->SetText(text);
304 179
305 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); 180 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
306 style.SetupLabel(text_label_); 181 style.SetupLabel(text_label_);
307 tri_view_->AddView(TriView::Container::CENTER, text_label_); 182 tri_view_->AddView(TriView::Container::CENTER, text_label_);
308 183
309 SetAccessibleName(text); 184 SetAccessibleName(text);
310 } 185 }
311 186
312 void HoverHighlightView::SetExpandable(bool expandable) { 187 void HoverHighlightView::SetExpandable(bool expandable) {
313 if (expandable != expandable_) { 188 if (expandable != expandable_) {
314 expandable_ = expandable; 189 expandable_ = expandable;
315 InvalidateLayout(); 190 InvalidateLayout();
316 } 191 }
317 } 192 }
318 193
319 void HoverHighlightView::SetHighlight(bool highlight) {
320 // Do not change the font styling for a highlighted row in material design.
321 if (MaterialDesignController::IsSystemTrayMenuMaterial())
322 return;
323
324 DCHECK(text_label_);
325 text_label_->SetFontList(GetFontList(highlight));
326 text_label_->InvalidateLayout();
327 }
328
329 void HoverHighlightView::SetAccessiblityState( 194 void HoverHighlightView::SetAccessiblityState(
330 AccessibilityState accessibility_state) { 195 AccessibilityState accessibility_state) {
331 accessibility_state_ = accessibility_state; 196 accessibility_state_ = accessibility_state;
332 if (accessibility_state_ != AccessibilityState::DEFAULT) 197 if (accessibility_state_ != AccessibilityState::DEFAULT)
333 NotifyAccessibilityEvent(ui::AX_EVENT_CHECKED_STATE_CHANGED, true); 198 NotifyAccessibilityEvent(ui::AX_EVENT_CHECKED_STATE_CHANGED, true);
334 } 199 }
335 200
336 void HoverHighlightView::SetHoverHighlight(bool hover) {
337 // We do not show any hover effects for material design.
338 if (MaterialDesignController::IsSystemTrayMenuMaterial())
339 return;
340
341 if (!enabled() && hover)
342 return;
343 if (hover_ == hover)
tdanderson 2017/02/14 22:48:20 Mohsen and +varkha@, on second thought I think we
344 return;
345 hover_ = hover;
346 if (!text_label_)
347 return;
348 if (hover_ && text_highlight_color_)
349 text_label_->SetEnabledColor(text_highlight_color_);
350 if (!hover_ && text_default_color_)
351 text_label_->SetEnabledColor(text_default_color_);
352 SchedulePaint();
353 }
354
355 bool HoverHighlightView::PerformAction(const ui::Event& event) { 201 bool HoverHighlightView::PerformAction(const ui::Event& event) {
356 if (!listener_) 202 if (!listener_)
357 return false; 203 return false;
358 listener_->OnViewClicked(this); 204 listener_->OnViewClicked(this);
359 return true; 205 return true;
360 } 206 }
361 207
362 void HoverHighlightView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 208 void HoverHighlightView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
363 ActionableView::GetAccessibleNodeData(node_data); 209 ActionableView::GetAccessibleNodeData(node_data);
364 210
(...skipping 15 matching lines...) Expand all
380 else if (!expandable_ || size.height() < default_height) 226 else if (!expandable_ || size.height() < default_height)
381 size.set_height(default_height); 227 size.set_height(default_height);
382 228
383 return size; 229 return size;
384 } 230 }
385 231
386 int HoverHighlightView::GetHeightForWidth(int width) const { 232 int HoverHighlightView::GetHeightForWidth(int width) const {
387 return GetPreferredSize().height(); 233 return GetPreferredSize().height();
388 } 234 }
389 235
390 void HoverHighlightView::OnMouseEntered(const ui::MouseEvent& event) {
391 SetHoverHighlight(true);
392 }
393
394 void HoverHighlightView::OnMouseExited(const ui::MouseEvent& event) {
395 SetHoverHighlight(false);
396 }
397
398 void HoverHighlightView::OnGestureEvent(ui::GestureEvent* event) {
399 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
400 SetHoverHighlight(true);
401 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
402 event->type() == ui::ET_GESTURE_TAP) {
403 SetHoverHighlight(false);
404 }
405 ActionableView::OnGestureEvent(event);
406 }
407
408 void HoverHighlightView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
409 SetHoverHighlight(IsMouseHovered());
410 }
411
412 void HoverHighlightView::OnEnabledChanged() { 236 void HoverHighlightView::OnEnabledChanged() {
413 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 237 if (left_icon_)
414 if (left_icon_) 238 left_icon_->SetEnabled(enabled());
415 left_icon_->SetEnabled(enabled()); 239 if (text_label_)
416 if (text_label_) 240 text_label_->SetEnabled(enabled());
417 text_label_->SetEnabled(enabled()); 241 if (right_view_)
418 if (right_view_) 242 right_view_->SetEnabled(enabled());
419 right_view_->SetEnabled(enabled());
420 } else {
421 if (!enabled())
422 SetHoverHighlight(false);
423 for (int i = 0; i < child_count(); ++i)
424 child_at(i)->SetEnabled(enabled());
425 }
426 }
427
428 void HoverHighlightView::OnPaintBackground(gfx::Canvas* canvas) {
429 canvas->DrawColor(hover_ ? highlight_color_ : default_color_);
430 } 243 }
431 244
432 void HoverHighlightView::OnFocus() { 245 void HoverHighlightView::OnFocus() {
433 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); 246 ScrollRectToVisible(gfx::Rect(gfx::Point(), size()));
434 ActionableView::OnFocus(); 247 ActionableView::OnFocus();
435 } 248 }
436 249
437 } // namespace ash 250 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/hover_highlight_view.h ('k') | ash/common/system/tray/label_tray_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698