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..fd1f6704586ed2f9e027540f69cd4123a64747d7 100644 |
| --- a/ash/system/tray/hover_highlight_view.cc |
| +++ b/ash/system/tray/hover_highlight_view.cc |
| @@ -4,9 +4,11 @@ |
| #include "ash/system/tray/hover_highlight_view.h" |
| +#include "ash/ash_switches.h" |
| #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" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| @@ -36,8 +38,13 @@ HoverHighlightView::HoverHighlightView(ViewClickListener* listener) |
| hover_(false), |
| expandable_(false), |
| checkable_(false), |
| - checked_(false) { |
| + checked_(false), |
| + touch_feedback_enabled_(false) { |
|
flackr
2014/09/11 20:49:37
Initialize it here with touch_feedback_enabled_(Co
jonross
2014/09/12 18:57:48
Done.
|
| set_notify_enter_exit_on_child(true); |
| + if (CommandLine::ForCurrentProcess()-> |
| + HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
| + touch_feedback_enabled_ = true; |
| + } |
| } |
| HoverHighlightView::~HoverHighlightView() { |
| @@ -130,6 +137,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 +179,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 (touch_feedback_enabled_) { |
| + 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() { |