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

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..d81f5a67aaf36cb6945c6e7aa4e4d180adb58a72 100644
--- a/ash/system/tray/hover_highlight_view.cc
+++ b/ash/system/tray/hover_highlight_view.cc
@@ -9,6 +9,7 @@
#include "ash/system/tray/view_click_listener.h"
#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 +131,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 +173,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() {

Powered by Google App Engine
This is Rietveld 408576698