| 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/app_list_button.h" | 5 #include "ash/shelf/app_list_button.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/launcher/launcher_button_host.h" | |
| 10 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 10 #include "ash/shelf/shelf_button_host.h" |
| 11 #include "grit/ash_resources.h" | 11 #include "grit/ash_resources.h" |
| 12 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
| 13 #include "ui/base/accessibility/accessible_view_state.h" | 13 #include "ui/base/accessibility/accessible_view_state.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
| 17 #include "ui/compositor/layer_animation_element.h" | 17 #include "ui/compositor/layer_animation_element.h" |
| 18 #include "ui/compositor/layer_animation_sequence.h" | 18 #include "ui/compositor/layer_animation_sequence.h" |
| 19 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace internal { | 22 namespace internal { |
| 23 | 23 |
| 24 const int kAnimationDurationInMs = 600; | 24 const int kAnimationDurationInMs = 600; |
| 25 const float kAnimationOpacity[] = { 1.0f, 0.4f, 1.0f }; | 25 const float kAnimationOpacity[] = { 1.0f, 0.4f, 1.0f }; |
| 26 | 26 |
| 27 AppListButton::AppListButton(views::ButtonListener* listener, | 27 AppListButton::AppListButton(views::ButtonListener* listener, |
| 28 LauncherButtonHost* host) | 28 ShelfButtonHost* host) |
| 29 : views::ImageButton(listener), | 29 : views::ImageButton(listener), |
| 30 host_(host) { | 30 host_(host) { |
| 31 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 31 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 32 SetImage( | 32 SetImage( |
| 33 views::CustomButton::STATE_NORMAL, | 33 views::CustomButton::STATE_NORMAL, |
| 34 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST).ToImageSkia()); | 34 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST).ToImageSkia()); |
| 35 SetImage( | 35 SetImage( |
| 36 views::CustomButton::STATE_HOVERED, | 36 views::CustomButton::STATE_HOVERED, |
| 37 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_HOT). | 37 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_HOT). |
| 38 ToImageSkia()); | 38 ToImageSkia()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); | 80 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); |
| 81 settings.SetTransitionDuration( | 81 settings.SetTransitionDuration( |
| 82 base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)); | 82 base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)); |
| 83 layer()->SetOpacity(1.0f); | 83 layer()->SetOpacity(1.0f); |
| 84 layer()->SetTransform(gfx::Transform()); | 84 layer()->SetTransform(gfx::Transform()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { | 87 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { |
| 88 ImageButton::OnMousePressed(event); | 88 ImageButton::OnMousePressed(event); |
| 89 host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event); | 89 host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event); |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { | 93 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 94 ImageButton::OnMouseReleased(event); | 94 ImageButton::OnMouseReleased(event); |
| 95 host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false); | 95 host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void AppListButton::OnMouseCaptureLost() { | 98 void AppListButton::OnMouseCaptureLost() { |
| 99 host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true); | 99 host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true); |
| 100 ImageButton::OnMouseCaptureLost(); | 100 ImageButton::OnMouseCaptureLost(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) { | 103 bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) { |
| 104 ImageButton::OnMouseDragged(event); | 104 ImageButton::OnMouseDragged(event); |
| 105 host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event); | 105 host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event); |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void AppListButton::OnMouseMoved(const ui::MouseEvent& event) { | 109 void AppListButton::OnMouseMoved(const ui::MouseEvent& event) { |
| 110 ImageButton::OnMouseMoved(event); | 110 ImageButton::OnMouseMoved(event); |
| 111 host_->MouseMovedOverButton(this); | 111 host_->MouseMovedOverButton(this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void AppListButton::OnMouseEntered(const ui::MouseEvent& event) { | 114 void AppListButton::OnMouseEntered(const ui::MouseEvent& event) { |
| 115 ImageButton::OnMouseEntered(event); | 115 ImageButton::OnMouseEntered(event); |
| 116 host_->MouseEnteredButton(this); | 116 host_->MouseEnteredButton(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void AppListButton::OnMouseExited(const ui::MouseEvent& event) { | 119 void AppListButton::OnMouseExited(const ui::MouseEvent& event) { |
| 120 ImageButton::OnMouseExited(event); | 120 ImageButton::OnMouseExited(event); |
| 121 host_->MouseExitedButton(this); | 121 host_->MouseExitedButton(this); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void AppListButton::GetAccessibleState(ui::AccessibleViewState* state) { | 124 void AppListButton::GetAccessibleState(ui::AccessibleViewState* state) { |
| 125 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 125 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 126 state->name = host_->GetAccessibleName(this); | 126 state->name = host_->GetAccessibleName(this); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace internal | 129 } // namespace internal |
| 130 } // namespace ash | 130 } // namespace ash |
| OLD | NEW |