Chromium Code Reviews| Index: ash/system/tray/hover_highlight_view.cc |
| diff --git a/ash/system/tray/hover_highlight_view.cc b/ash/system/tray/hover_highlight_view.cc |
| index be2efc258dfb7222bb7f1ffe9abcdc4ea96bc56e..c91ceecebbf405f029f877b8d718eaf8fe403a7b 100644 |
| --- a/ash/system/tray/hover_highlight_view.cc |
| +++ b/ash/system/tray/hover_highlight_view.cc |
| @@ -7,8 +7,10 @@ |
| #include "ash/system/tray/fixed_sized_image_view.h" |
| #include "ash/system/tray/tray_constants.h" |
| #include "ash/system/tray/view_click_listener.h" |
| +#include "base/command_line.h" |
|
flackr
2014/10/01 18:29:21
Remove this include?
jonross
2014/10/01 18:51:16
Done.
|
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/base/ui_base_switches_util.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/resources/grit/ui_resources.h" |
| @@ -130,6 +132,19 @@ void HoverHighlightView::SetExpandable(bool expandable) { |
| } |
| } |
| +void HoverHighlightView::SetHoverHighlight(bool hover) { |
| + if (hover_ == hover) |
| + return; |
| + hover_ = hover; |
| + if (!text_label_) |
| + return; |
| + if (hover_ && text_highlight_color_) |
| + text_label_->SetEnabledColor(text_highlight_color_); |
| + if (!hover_ && text_default_color_) |
| + text_label_->SetEnabledColor(text_default_color_); |
| + SchedulePaint(); |
| +} |
| + |
| bool HoverHighlightView::PerformAction(const ui::Event& event) { |
| if (!listener_) |
| return false; |
| @@ -159,17 +174,23 @@ int HoverHighlightView::GetHeightForWidth(int width) const { |
| } |
| void HoverHighlightView::OnMouseEntered(const ui::MouseEvent& event) { |
| - hover_ = true; |
| - if (text_highlight_color_ && text_label_) |
| - text_label_->SetEnabledColor(text_highlight_color_); |
| - SchedulePaint(); |
| + SetHoverHighlight(true); |
| } |
| void HoverHighlightView::OnMouseExited(const ui::MouseEvent& event) { |
| - hover_ = false; |
| - if (text_default_color_ && text_label_) |
| - text_label_->SetEnabledColor(text_default_color_); |
| - SchedulePaint(); |
| + SetHoverHighlight(false); |
| +} |
| + |
| +void HoverHighlightView::OnGestureEvent(ui::GestureEvent* event) { |
| + if (switches::IsTouchFeedbackEnabled()) { |
| + if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| + SetHoverHighlight(true); |
| + } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || |
| + event->type() == ui::ET_GESTURE_TAP) { |
| + SetHoverHighlight(false); |
| + } |
| + } |
| + ActionableView::OnGestureEvent(event); |
| } |
| void HoverHighlightView::OnEnabledChanged() { |