Chromium Code Reviews| Index: ash/system/date/date_view.cc |
| diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc |
| index 9f450118d06e611bf58045c9f9ad0949f76d22ab..7a82d14b06a57ea6b7bf5b26f8afd0d5433ea441 100644 |
| --- a/ash/system/date/date_view.cc |
| +++ b/ash/system/date/date_view.cc |
| @@ -4,10 +4,12 @@ |
| #include "ash/system/date/date_view.h" |
| +#include "ash/ash_switches.h" |
| #include "ash/shell.h" |
| #include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/tray/tray_constants.h" |
| #include "ash/system/tray/tray_utils.h" |
| +#include "base/command_line.h" |
| #include "base/i18n/rtl.h" |
| #include "base/i18n/time_formatting.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -126,7 +128,9 @@ void BaseDateTimeView::OnLocaleChanged() { |
| } |
| DateView::DateView() |
| - : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> |
| + : active_(false), |
| + touch_feedback_enabled_(false), |
| + hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> |
| GetHourClockType()), |
| action_(TrayDate::NONE) { |
| SetLayoutManager( |
| @@ -137,6 +141,11 @@ DateView::DateView() |
| UpdateTextInternal(base::Time::Now()); |
| AddChildView(date_label_); |
| SetFocusable(false); |
| + |
| + if (CommandLine::ForCurrentProcess()-> |
| + HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
| + touch_feedback_enabled_ = true; |
|
flackr
2014/09/17 18:30:06
Sorry for only recognizing this now but you can cr
jonross
2014/09/30 18:31:33
Done.
|
| + } |
| } |
| DateView::~DateView() { |
| @@ -165,6 +174,17 @@ base::HourClockType DateView::GetHourTypeForTesting() const { |
| return hour_type_; |
| } |
| +void DateView::SetActive(bool active) { |
| + if (active_ == active) |
| + return; |
| + active_ = active; |
| + if (active_) |
| + date_label_->SetEnabledColor(kHeaderTextColorHover); |
| + else |
| + date_label_->SetEnabledColor(kHeaderTextColorNormal); |
| + SchedulePaint(); |
| +} |
| + |
| void DateView::UpdateTextInternal(const base::Time& now) { |
| SetAccessibleName( |
| base::TimeFormatFriendlyDate(now) + |
| @@ -189,15 +209,25 @@ bool DateView::PerformAction(const ui::Event& event) { |
| void DateView::OnMouseEntered(const ui::MouseEvent& event) { |
| if (action_ == TrayDate::NONE) |
| return; |
| - date_label_->SetEnabledColor(kHeaderTextColorHover); |
| - SchedulePaint(); |
| + SetActive(true); |
| } |
| void DateView::OnMouseExited(const ui::MouseEvent& event) { |
| if (action_ == TrayDate::NONE) |
| return; |
| - date_label_->SetEnabledColor(kHeaderTextColorNormal); |
| - SchedulePaint(); |
| + SetActive(false); |
| +} |
| + |
| +void DateView::OnGestureEvent(ui::GestureEvent* event) { |
| + if (touch_feedback_enabled_) { |
| + if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| + SetActive(true); |
| + } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || |
| + event->type() == ui::ET_GESTURE_END) { |
| + SetActive(false); |
| + } |
| + } |
| + BaseDateTimeView::OnGestureEvent(event); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -263,7 +293,7 @@ bool TimeView::OnMousePressed(const ui::MouseEvent& event) { |
| return false; |
| } |
| -void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout){ |
| +void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout) { |
| SetBorderFromLayout(clock_layout); |
| if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { |
| RemoveChildView(vertical_label_hours_.get()); |