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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/public/cpp/shelf_types.h" | 10 #include "ash/public/cpp/shelf_types.h" |
11 #include "ash/shelf/ink_drop_button_listener.h" | 11 #include "ash/shelf/ink_drop_button_listener.h" |
| 12 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
13 #include "ash/shelf/shelf_view.h" | 14 #include "ash/shelf/shelf_view.h" |
14 #include "ash/shelf/wm_shelf.h" | |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/strings/grit/ash_strings.h" | 16 #include "ash/strings/grit/ash_strings.h" |
17 #include "ash/system/tray/tray_popup_utils.h" | 17 #include "ash/system/tray/tray_popup_utils.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
20 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
21 #include "ui/accessibility/ax_node_data.h" | 21 #include "ui/accessibility/ax_node_data.h" |
22 #include "ui/app_list/presenter/app_list.h" | 22 #include "ui/app_list/presenter/app_list.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
25 #include "ui/gfx/scoped_canvas.h" | 25 #include "ui/gfx/scoped_canvas.h" |
26 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 26 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
27 #include "ui/views/animation/ink_drop_impl.h" | 27 #include "ui/views/animation/ink_drop_impl.h" |
28 #include "ui/views/animation/ink_drop_mask.h" | 28 #include "ui/views/animation/ink_drop_mask.h" |
29 #include "ui/views/painter.h" | 29 #include "ui/views/painter.h" |
30 | 30 |
31 namespace ash { | 31 namespace ash { |
32 | 32 |
33 AppListButton::AppListButton(InkDropButtonListener* listener, | 33 AppListButton::AppListButton(InkDropButtonListener* listener, |
34 ShelfView* shelf_view, | 34 ShelfView* shelf_view, |
35 WmShelf* wm_shelf) | 35 Shelf* shelf) |
36 : views::ImageButton(nullptr), | 36 : views::ImageButton(nullptr), |
37 is_showing_app_list_(false), | 37 is_showing_app_list_(false), |
38 background_color_(kShelfDefaultBaseColor), | 38 background_color_(kShelfDefaultBaseColor), |
39 listener_(listener), | 39 listener_(listener), |
40 shelf_view_(shelf_view), | 40 shelf_view_(shelf_view), |
41 wm_shelf_(wm_shelf) { | 41 shelf_(shelf) { |
42 DCHECK(listener_); | 42 DCHECK(listener_); |
43 DCHECK(shelf_view_); | 43 DCHECK(shelf_view_); |
44 DCHECK(wm_shelf_); | 44 DCHECK(shelf_); |
45 | 45 |
46 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 46 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
47 set_ink_drop_base_color(kShelfInkDropBaseColor); | 47 set_ink_drop_base_color(kShelfInkDropBaseColor); |
48 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 48 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
49 SetAccessibleName( | 49 SetAccessibleName( |
50 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); | 50 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); |
51 SetSize(gfx::Size(kShelfSize, kShelfSize)); | 51 SetSize(gfx::Size(kShelfSize, kShelfSize)); |
52 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); | 52 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); |
53 set_notify_action(CustomButton::NOTIFY_ON_PRESS); | 53 set_notify_action(CustomButton::NOTIFY_ON_PRESS); |
54 } | 54 } |
55 | 55 |
56 AppListButton::~AppListButton() {} | 56 AppListButton::~AppListButton() {} |
57 | 57 |
58 void AppListButton::OnAppListShown() { | 58 void AppListButton::OnAppListShown() { |
59 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); | 59 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); |
60 is_showing_app_list_ = true; | 60 is_showing_app_list_ = true; |
61 wm_shelf_->UpdateAutoHideState(); | 61 shelf_->UpdateAutoHideState(); |
62 } | 62 } |
63 | 63 |
64 void AppListButton::OnAppListDismissed() { | 64 void AppListButton::OnAppListDismissed() { |
65 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); | 65 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |
66 is_showing_app_list_ = false; | 66 is_showing_app_list_ = false; |
67 wm_shelf_->UpdateAutoHideState(); | 67 shelf_->UpdateAutoHideState(); |
68 } | 68 } |
69 | 69 |
70 void AppListButton::UpdateShelfItemBackground(SkColor color) { | 70 void AppListButton::UpdateShelfItemBackground(SkColor color) { |
71 background_color_ = color; | 71 background_color_ = color; |
72 SchedulePaint(); | 72 SchedulePaint(); |
73 } | 73 } |
74 | 74 |
75 void AppListButton::OnGestureEvent(ui::GestureEvent* event) { | 75 void AppListButton::OnGestureEvent(ui::GestureEvent* event) { |
76 switch (event->type()) { | 76 switch (event->type()) { |
77 case ui::ET_GESTURE_SCROLL_BEGIN: | 77 case ui::ET_GESTURE_SCROLL_BEGIN: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 gfx::Point AppListButton::GetCenterPoint() const { | 223 gfx::Point AppListButton::GetCenterPoint() const { |
224 // For a bottom-aligned shelf, the button bounds could have a larger height | 224 // For a bottom-aligned shelf, the button bounds could have a larger height |
225 // than width (in the case of touch-dragging the shelf updwards) or a larger | 225 // than width (in the case of touch-dragging the shelf updwards) or a larger |
226 // width than height (in the case of a shelf hide/show animation), so adjust | 226 // width than height (in the case of a shelf hide/show animation), so adjust |
227 // the y-position of the circle's center to ensure correct layout. Similarly | 227 // the y-position of the circle's center to ensure correct layout. Similarly |
228 // adjust the x-position for a left- or right-aligned shelf. | 228 // adjust the x-position for a left- or right-aligned shelf. |
229 const int x_mid = width() / 2.f; | 229 const int x_mid = width() / 2.f; |
230 const int y_mid = height() / 2.f; | 230 const int y_mid = height() / 2.f; |
231 ShelfAlignment alignment = wm_shelf_->GetAlignment(); | 231 ShelfAlignment alignment = shelf_->alignment(); |
232 if (alignment == SHELF_ALIGNMENT_BOTTOM || | 232 if (alignment == SHELF_ALIGNMENT_BOTTOM || |
233 alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 233 alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
234 return gfx::Point(x_mid, x_mid); | 234 return gfx::Point(x_mid, x_mid); |
235 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 235 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
236 return gfx::Point(y_mid, y_mid); | 236 return gfx::Point(y_mid, y_mid); |
237 } else { | 237 } else { |
238 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 238 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |
239 return gfx::Point(width() - y_mid, y_mid); | 239 return gfx::Point(width() - y_mid, y_mid); |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 } // namespace ash | 243 } // namespace ash |
OLD | NEW |