| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/alternate_app_list_button.h" | 5 #include "ash/shelf/alternate_app_list_button.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/launcher/launcher_button_host.h" | |
| 9 #include "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
| 9 #include "ash/shelf/shelf_button_host.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
| 14 #include "grit/ash_strings.h" | 14 #include "grit/ash_strings.h" |
| 15 #include "ui/base/accessibility/accessible_view_state.h" | 15 #include "ui/base/accessibility/accessible_view_state.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/compositor/layer_animation_element.h" | 19 #include "ui/compositor/layer_animation_element.h" |
| 20 #include "ui/compositor/layer_animation_sequence.h" | 20 #include "ui/compositor/layer_animation_sequence.h" |
| 21 #include "ui/compositor/scoped_layer_animation_settings.h" | 21 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/image/image_skia_operations.h" | 23 #include "ui/gfx/image/image_skia_operations.h" |
| 24 #include "ui/views/controls/button/image_button.h" | 24 #include "ui/views/controls/button/image_button.h" |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 namespace internal { | 27 namespace internal { |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 const int AlternateAppListButton::kImageBoundsSize = 7; | 30 const int AlternateAppListButton::kImageBoundsSize = 7; |
| 31 | 31 |
| 32 | 32 |
| 33 AlternateAppListButton::AlternateAppListButton(views::ButtonListener* listener, | 33 AlternateAppListButton::AlternateAppListButton(views::ButtonListener* listener, |
| 34 LauncherButtonHost* host, | 34 ShelfButtonHost* host, |
| 35 ShelfWidget* shelf_widget) | 35 ShelfWidget* shelf_widget) |
| 36 : views::ImageButton(listener), | 36 : views::ImageButton(listener), |
| 37 host_(host), | 37 host_(host), |
| 38 shelf_widget_(shelf_widget) { | 38 shelf_widget_(shelf_widget) { |
| 39 SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE)); | 39 SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE)); |
| 40 SetSize(gfx::Size(ShelfLayoutManager::kShelfSize, | 40 SetSize(gfx::Size(ShelfLayoutManager::kShelfSize, |
| 41 ShelfLayoutManager::kShelfSize)); | 41 ShelfLayoutManager::kShelfSize)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 AlternateAppListButton::~AlternateAppListButton() { | 44 AlternateAppListButton::~AlternateAppListButton() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool AlternateAppListButton::OnMousePressed(const ui::MouseEvent& event) { | 47 bool AlternateAppListButton::OnMousePressed(const ui::MouseEvent& event) { |
| 48 ImageButton::OnMousePressed(event); | 48 ImageButton::OnMousePressed(event); |
| 49 host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event); | 49 host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event); |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void AlternateAppListButton::OnMouseReleased(const ui::MouseEvent& event) { | 53 void AlternateAppListButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 54 ImageButton::OnMouseReleased(event); | 54 ImageButton::OnMouseReleased(event); |
| 55 host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false); | 55 host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void AlternateAppListButton::OnMouseCaptureLost() { | 58 void AlternateAppListButton::OnMouseCaptureLost() { |
| 59 host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true); | 59 host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true); |
| 60 ImageButton::OnMouseCaptureLost(); | 60 ImageButton::OnMouseCaptureLost(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool AlternateAppListButton::OnMouseDragged(const ui::MouseEvent& event) { | 63 bool AlternateAppListButton::OnMouseDragged(const ui::MouseEvent& event) { |
| 64 ImageButton::OnMouseDragged(event); | 64 ImageButton::OnMouseDragged(event); |
| 65 host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event); | 65 host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event); |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void AlternateAppListButton::OnMouseMoved(const ui::MouseEvent& event) { | 69 void AlternateAppListButton::OnMouseMoved(const ui::MouseEvent& event) { |
| 70 ImageButton::OnMouseMoved(event); | 70 ImageButton::OnMouseMoved(event); |
| 71 host_->MouseMovedOverButton(this); | 71 host_->MouseMovedOverButton(this); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void AlternateAppListButton::OnMouseEntered(const ui::MouseEvent& event) { | 74 void AlternateAppListButton::OnMouseEntered(const ui::MouseEvent& event) { |
| 75 ImageButton::OnMouseEntered(event); | 75 ImageButton::OnMouseEntered(event); |
| 76 host_->MouseEnteredButton(this); | 76 host_->MouseEnteredButton(this); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void AlternateAppListButton::OnMouseExited(const ui::MouseEvent& event) { | 79 void AlternateAppListButton::OnMouseExited(const ui::MouseEvent& event) { |
| 80 ImageButton::OnMouseExited(event); | 80 ImageButton::OnMouseExited(event); |
| 81 host_->MouseExitedButton(this); | 81 host_->MouseExitedButton(this); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void AlternateAppListButton::OnGestureEvent(ui::GestureEvent* event) { | 84 void AlternateAppListButton::OnGestureEvent(ui::GestureEvent* event) { |
| 85 switch (event->type()) { | 85 switch (event->type()) { |
| 86 case ui::ET_GESTURE_SCROLL_BEGIN: | 86 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 87 host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event); | 87 host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event); |
| 88 event->SetHandled(); | 88 event->SetHandled(); |
| 89 return; | 89 return; |
| 90 case ui::ET_GESTURE_SCROLL_UPDATE: | 90 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 91 host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event); | 91 host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event); |
| 92 event->SetHandled(); | 92 event->SetHandled(); |
| 93 return; | 93 return; |
| 94 case ui::ET_GESTURE_SCROLL_END: | 94 case ui::ET_GESTURE_SCROLL_END: |
| 95 case ui::ET_SCROLL_FLING_START: | 95 case ui::ET_SCROLL_FLING_START: |
| 96 host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false); | 96 host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false); |
| 97 event->SetHandled(); | 97 event->SetHandled(); |
| 98 return; | 98 return; |
| 99 default: | 99 default: |
| 100 ImageButton::OnGestureEvent(event); | 100 ImageButton::OnGestureEvent(event); |
| 101 return; | 101 return; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 void AlternateAppListButton::OnPaint(gfx::Canvas* canvas) { | 105 void AlternateAppListButton::OnPaint(gfx::Canvas* canvas) { |
| 106 // Call the base class first to paint any background/borders. | 106 // Call the base class first to paint any background/borders. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 void AlternateAppListButton::GetAccessibleState( | 162 void AlternateAppListButton::GetAccessibleState( |
| 163 ui::AccessibleViewState* state) { | 163 ui::AccessibleViewState* state) { |
| 164 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 164 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 165 state->name = host_->GetAccessibleName(this); | 165 state->name = host_->GetAccessibleName(this); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace internal | 168 } // namespace internal |
| 169 } // namespace ash | 169 } // namespace ash |
| OLD | NEW |