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

Unified Diff: ash/system/tray/hover_highlight_view.cc

Issue 556383002: Status Panel Touch Feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
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..6acdec3e7d50ac49eb512c9da8063b74a983504b 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) {
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,24 @@ 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_SCROLL_BEGIN ||
flackr 2014/09/10 22:54:31 SCROLL_BEGIN shouldn't be necessary, should get a
jonross 2014/09/11 15:53:22 Done.
+ event->type() == ui::ET_GESTURE_TAP_CANCEL ||
+ event->type() == ui::ET_GESTURE_END) {
+ SetHoverHighlight(false);
+ }
+ }
+ ActionableView::OnGestureEvent(event);
}
void HoverHighlightView::OnEnabledChanged() {

Powered by Google App Engine
This is Rietveld 408576698