| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/app_list_button.h" | 5 #include "ash/shelf/app_list_button.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/ash_switches.h" | |
| 9 #include "ash/shelf/shelf_button.h" | 8 #include "ash/shelf/shelf_button.h" |
| 10 #include "ash/shelf/shelf_button_host.h" | 9 #include "ash/shelf/shelf_button_host.h" |
| 11 #include "ash/shelf/shelf_item_types.h" | 10 #include "ash/shelf/shelf_item_types.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 16 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 17 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 18 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/base/ui_base_switches_util.h" |
| 21 #include "ui/compositor/layer.h" | 21 #include "ui/compositor/layer.h" |
| 22 #include "ui/compositor/layer_animation_element.h" | 22 #include "ui/compositor/layer_animation_element.h" |
| 23 #include "ui/compositor/layer_animation_sequence.h" | 23 #include "ui/compositor/layer_animation_sequence.h" |
| 24 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 25 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 26 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
| 27 #include "ui/views/controls/button/image_button.h" | 27 #include "ui/views/controls/button/image_button.h" |
| 28 #include "ui/views/painter.h" | 28 #include "ui/views/painter.h" |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 // static | 31 // static |
| 32 const int AppListButton::kImageBoundsSize = 7; | 32 const int AppListButton::kImageBoundsSize = 7; |
| 33 | 33 |
| 34 | 34 |
| 35 AppListButton::AppListButton(views::ButtonListener* listener, | 35 AppListButton::AppListButton(views::ButtonListener* listener, |
| 36 ShelfButtonHost* host, | 36 ShelfButtonHost* host, |
| 37 ShelfWidget* shelf_widget) | 37 ShelfWidget* shelf_widget) |
| 38 : views::ImageButton(listener), | 38 : views::ImageButton(listener), |
| 39 draw_background_as_active_(false), | 39 draw_background_as_active_(false), |
| 40 touch_feedback_enabled_(CommandLine::ForCurrentProcess()-> | |
| 41 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)), | |
| 42 host_(host), | 40 host_(host), |
| 43 shelf_widget_(shelf_widget) { | 41 shelf_widget_(shelf_widget) { |
| 44 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); | 42 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); |
| 45 SetSize(gfx::Size(kShelfSize, kShelfSize)); | 43 SetSize(gfx::Size(kShelfSize, kShelfSize)); |
| 46 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 44 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 47 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); | 45 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 48 } | 46 } |
| 49 | 47 |
| 50 AppListButton::~AppListButton() { | 48 AppListButton::~AppListButton() { |
| 51 } | 49 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 81 } |
| 84 | 82 |
| 85 void AppListButton::OnMouseExited(const ui::MouseEvent& event) { | 83 void AppListButton::OnMouseExited(const ui::MouseEvent& event) { |
| 86 ImageButton::OnMouseExited(event); | 84 ImageButton::OnMouseExited(event); |
| 87 host_->MouseExitedButton(this); | 85 host_->MouseExitedButton(this); |
| 88 } | 86 } |
| 89 | 87 |
| 90 void AppListButton::OnGestureEvent(ui::GestureEvent* event) { | 88 void AppListButton::OnGestureEvent(ui::GestureEvent* event) { |
| 91 switch (event->type()) { | 89 switch (event->type()) { |
| 92 case ui::ET_GESTURE_SCROLL_BEGIN: | 90 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 93 if (touch_feedback_enabled_) | 91 if (switches::IsTouchFeedbackEnabled()) |
| 94 SetDrawBackgroundAsActive(false); | 92 SetDrawBackgroundAsActive(false); |
| 95 host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event); | 93 host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event); |
| 96 event->SetHandled(); | 94 event->SetHandled(); |
| 97 return; | 95 return; |
| 98 case ui::ET_GESTURE_SCROLL_UPDATE: | 96 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 99 host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event); | 97 host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event); |
| 100 event->SetHandled(); | 98 event->SetHandled(); |
| 101 return; | 99 return; |
| 102 case ui::ET_GESTURE_SCROLL_END: | 100 case ui::ET_GESTURE_SCROLL_END: |
| 103 case ui::ET_SCROLL_FLING_START: | 101 case ui::ET_SCROLL_FLING_START: |
| 104 host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false); | 102 host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false); |
| 105 event->SetHandled(); | 103 event->SetHandled(); |
| 106 return; | 104 return; |
| 107 case ui::ET_GESTURE_TAP_DOWN: | 105 case ui::ET_GESTURE_TAP_DOWN: |
| 108 if (touch_feedback_enabled_) | 106 if (switches::IsTouchFeedbackEnabled()) |
| 109 SetDrawBackgroundAsActive(true); | 107 SetDrawBackgroundAsActive(true); |
| 110 ImageButton::OnGestureEvent(event); | 108 ImageButton::OnGestureEvent(event); |
| 111 break; | 109 break; |
| 112 case ui::ET_GESTURE_TAP_CANCEL: | 110 case ui::ET_GESTURE_TAP_CANCEL: |
| 113 case ui::ET_GESTURE_TAP: | 111 case ui::ET_GESTURE_TAP: |
| 114 if (touch_feedback_enabled_) | 112 if (switches::IsTouchFeedbackEnabled()) |
| 115 SetDrawBackgroundAsActive(false); | 113 SetDrawBackgroundAsActive(false); |
| 116 ImageButton::OnGestureEvent(event); | 114 ImageButton::OnGestureEvent(event); |
| 117 break; | 115 break; |
| 118 default: | 116 default: |
| 119 ImageButton::OnGestureEvent(event); | 117 ImageButton::OnGestureEvent(event); |
| 120 return; | 118 return; |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 | 121 |
| 124 void AppListButton::OnPaint(gfx::Canvas* canvas) { | 122 void AppListButton::OnPaint(gfx::Canvas* canvas) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 184 |
| 187 void AppListButton::SetDrawBackgroundAsActive( | 185 void AppListButton::SetDrawBackgroundAsActive( |
| 188 bool draw_background_as_active) { | 186 bool draw_background_as_active) { |
| 189 if (draw_background_as_active_ == draw_background_as_active) | 187 if (draw_background_as_active_ == draw_background_as_active) |
| 190 return; | 188 return; |
| 191 draw_background_as_active_ = draw_background_as_active; | 189 draw_background_as_active_ = draw_background_as_active; |
| 192 SchedulePaint(); | 190 SchedulePaint(); |
| 193 } | 191 } |
| 194 | 192 |
| 195 } // namespace ash | 193 } // namespace ash |
| OLD | NEW |