Chromium Code Reviews| Index: ash/shelf/app_list_button.cc |
| diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc |
| index 9ba833254e3e93274058c2a435da2d5ae3e24790..e1e741a06e00e020b7a06418d5150cb21183f863 100644 |
| --- a/ash/shelf/app_list_button.cc |
| +++ b/ash/shelf/app_list_button.cc |
| @@ -12,6 +12,7 @@ |
| #include "ash/shelf/shelf_layout_manager.h" |
| #include "ash/shelf/shelf_widget.h" |
| #include "ash/shell.h" |
| +#include "base/command_line.h" |
| #include "grit/ash_resources.h" |
| #include "grit/ash_strings.h" |
| #include "ui/accessibility/ax_view_state.h" |
| @@ -35,12 +36,19 @@ AppListButton::AppListButton(views::ButtonListener* listener, |
| ShelfButtonHost* host, |
| ShelfWidget* shelf_widget) |
| : views::ImageButton(listener), |
| + draw_background_as_active_(false), |
| + touch_feedback_enabled_(false), |
| host_(host), |
| shelf_widget_(shelf_widget) { |
| SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); |
| SetSize(gfx::Size(kShelfSize, kShelfSize)); |
| SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| + |
| + if (CommandLine::ForCurrentProcess()-> |
| + HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
| + touch_feedback_enabled_ = true; |
|
flackr
2014/09/11 21:01:02
initializer list.
jonross
2014/09/12 17:16:08
Done.
|
| + } |
| } |
| AppListButton::~AppListButton() { |
| @@ -86,6 +94,8 @@ void AppListButton::OnMouseExited(const ui::MouseEvent& event) { |
| void AppListButton::OnGestureEvent(ui::GestureEvent* event) { |
| switch (event->type()) { |
| case ui::ET_GESTURE_SCROLL_BEGIN: |
| + if (touch_feedback_enabled_) |
| + SetDrawBackgroundAsActive(false); |
| host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event); |
| event->SetHandled(); |
| return; |
| @@ -98,6 +108,17 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) { |
| host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false); |
| event->SetHandled(); |
| return; |
| + case ui::ET_GESTURE_TAP_DOWN: |
| + if (touch_feedback_enabled_) |
| + SetDrawBackgroundAsActive(true); |
| + ImageButton::OnGestureEvent(event); |
| + break; |
| + case ui::ET_GESTURE_TAP_CANCEL: |
| + case ui::ET_GESTURE_TAP: |
| + if (touch_feedback_enabled_) |
| + SetDrawBackgroundAsActive(false); |
| + ImageButton::OnGestureEvent(event); |
| + break; |
| default: |
| ImageButton::OnGestureEvent(event); |
| return; |
| @@ -109,7 +130,8 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) { |
| View::OnPaint(canvas); |
| int background_image_id = 0; |
| - if (Shell::GetInstance()->GetAppListTargetVisibility()) { |
| + if (Shell::GetInstance()->GetAppListTargetVisibility() || |
| + draw_background_as_active_) { |
| background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; |
| } else { |
| if (shelf_widget_->GetDimsShelf()) |
| @@ -166,4 +188,12 @@ void AppListButton::GetAccessibleState(ui::AXViewState* state) { |
| state->name = host_->GetAccessibleName(this); |
| } |
| +void AppListButton::SetDrawBackgroundAsActive( |
| + bool draw_background_as_active) { |
| + if (draw_background_as_active_ == draw_background_as_active) |
| + return; |
| + draw_background_as_active_ = draw_background_as_active; |
| + SchedulePaint(); |
| +} |
| + |
| } // namespace ash |