OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ASH_WM_APP_LIST_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_APP_LIST_APP_LIST_SHOWER_ASH_H_ |
6 #define ASH_WM_APP_LIST_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_APP_LIST_APP_LIST_SHOWER_ASH_H_ |
7 | 7 |
8 #include "ash/shelf/shelf_icon_observer.h" | |
9 #include "ash/shell_observer.h" | |
10 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| 12 #include "ui/app_list/app_list_controller.h" |
| 13 #include "ui/app_list/app_list_layout_delegate.h" |
12 #include "ui/app_list/pagination_model_observer.h" | 14 #include "ui/app_list/pagination_model_observer.h" |
13 #include "ui/aura/client/focus_change_observer.h" | 15 #include "ui/aura/client/focus_change_observer.h" |
14 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
15 #include "ui/compositor/layer_animation_observer.h" | 17 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/events/event_handler.h" | |
17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/keyboard/keyboard_controller_observer.h" | 19 #include "ui/keyboard/keyboard_controller_observer.h" |
19 #include "ui/views/widget/widget_observer.h" | 20 #include "ui/views/widget/widget_observer.h" |
20 | 21 |
21 namespace app_list { | 22 namespace app_list { |
22 class ApplicationDragAndDropHost; | |
23 class AppListView; | 23 class AppListView; |
24 } | 24 } |
25 | 25 |
26 namespace ui { | 26 class AppListViewDelegate; |
27 class LocatedEvent; | |
28 } | |
29 | 27 |
30 namespace ash { | 28 // Manages app list UI. Creates AppListView and schedules showing/hiding |
31 namespace test { | 29 // animation. While the UI is visible, it monitors things such as app list |
32 class AppListControllerTestApi; | 30 // activation state to auto dismiss the UI. Delegates the responsibility |
33 } | 31 // for laying out the app list UI to ash::AppListLayoutDelegate. |
34 | 32 class AppListShowerAsh : public app_list::AppListController, |
35 // AppListController is a controller that manages app list UI for shell. | 33 public aura::client::FocusChangeObserver, |
36 // It creates AppListView and schedules showing/hiding animation. | 34 public aura::WindowObserver, |
37 // While the UI is visible, it monitors things such as app list widget's | 35 public ui::ImplicitAnimationObserver, |
38 // activation state and desktop mouse click to auto dismiss the UI. | 36 public views::WidgetObserver, |
39 class AppListController : public ui::EventHandler, | 37 public keyboard::KeyboardControllerObserver, |
40 public aura::client::FocusChangeObserver, | 38 public app_list::PaginationModelObserver { |
41 public aura::WindowObserver, | |
42 public ui::ImplicitAnimationObserver, | |
43 public views::WidgetObserver, | |
44 public keyboard::KeyboardControllerObserver, | |
45 public ShellObserver, | |
46 public ShelfIconObserver, | |
47 public app_list::PaginationModelObserver { | |
48 public: | 39 public: |
49 AppListController(); | 40 AppListShowerAsh(); |
50 ~AppListController() override; | 41 ~AppListShowerAsh() override; |
51 | |
52 // Show/hide app list window. The |window| is used to deterime in | |
53 // which display (in which the |window| exists) the app list should | |
54 // be shown. | |
55 void Show(aura::Window* window); | |
56 void Dismiss(); | |
57 | |
58 // Whether app list window is visible (shown or being shown). | |
59 bool IsVisible() const; | |
60 | |
61 // Returns target visibility. This differs from IsVisible() if an animation | |
62 // is ongoing. | |
63 bool GetTargetVisibility() const { return is_visible_; } | |
64 | 42 |
65 // Returns app list window or NULL if it is not visible. | 43 // Returns app list window or NULL if it is not visible. |
66 aura::Window* GetWindow(); | 44 aura::Window* GetWindow(); |
67 | 45 |
68 // Returns app list view if one exists, or NULL otherwise. | 46 // Returns app list view if one exists, or NULL otherwise. |
69 app_list::AppListView* GetView() { return view_; } | 47 app_list::AppListView* GetView() { return view_; } |
70 | 48 |
| 49 void set_view_delegate(AppListViewDelegate* view_delegate) { |
| 50 view_delegate_ = view_delegate; |
| 51 } |
| 52 |
| 53 // app_list::AppListController: |
| 54 void Show(aura::Window* window) override; |
| 55 void Dismiss() override; |
| 56 bool IsVisible() const override; |
| 57 bool GetTargetVisibility() const override; |
| 58 |
71 private: | 59 private: |
72 friend class test::AppListControllerTestApi; | 60 // friend class test::AppListControllerTestApi; |
73 | |
74 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop | |
75 // operations outside the application list. | |
76 void SetDragAndDropHostOfCurrentAppList( | |
77 app_list::ApplicationDragAndDropHost* drag_and_drop_host); | |
78 | 61 |
79 // Sets the app list view and attempts to show it. | 62 // Sets the app list view and attempts to show it. |
80 void SetView(app_list::AppListView* view); | 63 void SetView(app_list::AppListView* view); |
81 | 64 |
82 // Forgets the view. | 65 // Forgets the view. |
83 void ResetView(); | 66 void ResetView(); |
84 | 67 |
85 // Starts show/hide animation. | 68 // Starts show/hide animation. |
86 void ScheduleAnimation(); | 69 void ScheduleAnimation(); |
87 | 70 |
88 void ProcessLocatedEvent(ui::LocatedEvent* event); | |
89 | |
90 // Makes app list bubble update its bounds. | |
91 void UpdateBounds(); | |
92 | |
93 // ui::EventHandler overrides: | |
94 void OnMouseEvent(ui::MouseEvent* event) override; | |
95 void OnGestureEvent(ui::GestureEvent* event) override; | |
96 | |
97 // aura::client::FocusChangeObserver overrides: | 71 // aura::client::FocusChangeObserver overrides: |
98 void OnWindowFocused(aura::Window* gained_focus, | 72 void OnWindowFocused(aura::Window* gained_focus, |
99 aura::Window* lost_focus) override; | 73 aura::Window* lost_focus) override; |
100 | 74 |
101 // aura::WindowObserver overrides: | 75 // aura::WindowObserver overrides: |
102 void OnWindowBoundsChanged(aura::Window* root, | 76 void OnWindowBoundsChanged(aura::Window* root, |
103 const gfx::Rect& old_bounds, | 77 const gfx::Rect& old_bounds, |
104 const gfx::Rect& new_bounds) override; | 78 const gfx::Rect& new_bounds) override; |
105 | 79 |
106 // ui::ImplicitAnimationObserver overrides: | 80 // ui::ImplicitAnimationObserver overrides: |
107 void OnImplicitAnimationsCompleted() override; | 81 void OnImplicitAnimationsCompleted() override; |
108 | 82 |
109 // views::WidgetObserver overrides: | 83 // views::WidgetObserver overrides: |
110 void OnWidgetDestroying(views::Widget* widget) override; | 84 void OnWidgetDestroying(views::Widget* widget) override; |
111 | 85 |
112 // KeyboardControllerObserver overrides: | 86 // KeyboardControllerObserver overrides: |
113 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | 87 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; |
114 | 88 |
115 // ShellObserver overrides: | |
116 void OnShelfAlignmentChanged(aura::Window* root_window) override; | |
117 void OnMaximizeModeStarted() override; | |
118 void OnMaximizeModeEnded() override; | |
119 | |
120 // ShelfIconObserver overrides: | |
121 void OnShelfIconPositionsChanged() override; | |
122 | |
123 // app_list::PaginationModelObserver overrides: | 89 // app_list::PaginationModelObserver overrides: |
124 void TotalPagesChanged() override; | 90 void TotalPagesChanged() override; |
125 void SelectedPageChanged(int old_selected, int new_selected) override; | 91 void SelectedPageChanged(int old_selected, int new_selected) override; |
126 void TransitionStarted() override; | 92 void TransitionStarted() override; |
127 void TransitionChanged() override; | 93 void TransitionChanged() override; |
128 | 94 |
| 95 // Responsible for laying out the app list UI. |
| 96 scoped_ptr<app_list::AppListLayoutDelegate> layout_delegate_; |
| 97 |
| 98 // Not owned. |
| 99 AppListViewDelegate* view_delegate_; |
| 100 |
129 // Whether we should show or hide app list widget. | 101 // Whether we should show or hide app list widget. |
130 bool is_visible_; | 102 bool is_visible_; |
131 | 103 |
132 // Whether the app list should remain centered. | |
133 bool is_centered_; | |
134 | |
135 // The AppListView this class manages, owned by its widget. | 104 // The AppListView this class manages, owned by its widget. |
136 app_list::AppListView* view_; | 105 app_list::AppListView* view_; |
137 | 106 |
138 // The current page of the AppsGridView of |view_|. This is stored outside of | 107 // The current page of the AppsGridView of |view_|. This is stored outside of |
139 // the view's PaginationModel, so that it persists when the view is destroyed. | 108 // the view's PaginationModel, so that it persists when the view is destroyed. |
140 int current_apps_page_; | 109 int current_apps_page_; |
141 | 110 |
142 // Cached bounds of |view_| for snapping back animation after over-scroll. | 111 // Cached bounds of |view_| for snapping back animation after over-scroll. |
143 gfx::Rect view_bounds_; | 112 gfx::Rect view_bounds_; |
144 | 113 |
145 // Whether should schedule snap back animation. | 114 // Whether should schedule snap back animation. |
146 bool should_snap_back_; | 115 bool should_snap_back_; |
147 | |
148 DISALLOW_COPY_AND_ASSIGN(AppListController); | |
149 }; | 116 }; |
150 | 117 |
151 } // namespace ash | 118 #endif // CHROME_BROWSER_UI_ASH_APP_LIST_APP_LIST_SHOWER_ASH_H_ |
152 | |
153 #endif // ASH_WM_APP_LIST_CONTROLLER_H_ | |
OLD | NEW |