| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_APP_LIST_CONTROLLER_H_ | |
| 6 #define ASH_WM_APP_LIST_CONTROLLER_H_ | |
| 7 | |
| 8 #include "ash/shelf/shelf_icon_observer.h" | |
| 9 #include "ash/shell_observer.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "ui/app_list/pagination_model_observer.h" | |
| 13 #include "ui/aura/client/focus_change_observer.h" | |
| 14 #include "ui/aura/window_observer.h" | |
| 15 #include "ui/compositor/layer_animation_observer.h" | |
| 16 #include "ui/events/event_handler.h" | |
| 17 #include "ui/gfx/geometry/rect.h" | |
| 18 #include "ui/keyboard/keyboard_controller_observer.h" | |
| 19 #include "ui/views/widget/widget_observer.h" | |
| 20 | |
| 21 namespace app_list { | |
| 22 class ApplicationDragAndDropHost; | |
| 23 class AppListView; | |
| 24 } | |
| 25 | |
| 26 namespace ui { | |
| 27 class LocatedEvent; | |
| 28 } | |
| 29 | |
| 30 namespace ash { | |
| 31 namespace test { | |
| 32 class AppListControllerTestApi; | |
| 33 } | |
| 34 | |
| 35 // AppListController is a controller that manages app list UI for shell. | |
| 36 // It creates AppListView and schedules showing/hiding animation. | |
| 37 // While the UI is visible, it monitors things such as app list widget's | |
| 38 // activation state and desktop mouse click to auto dismiss the UI. | |
| 39 class AppListController : public ui::EventHandler, | |
| 40 public aura::client::FocusChangeObserver, | |
| 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: | |
| 49 AppListController(); | |
| 50 ~AppListController() 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 | |
| 65 // Returns app list window or NULL if it is not visible. | |
| 66 aura::Window* GetWindow(); | |
| 67 | |
| 68 // Returns app list view if one exists, or NULL otherwise. | |
| 69 app_list::AppListView* GetView() { return view_; } | |
| 70 | |
| 71 private: | |
| 72 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 | |
| 79 // Sets the app list view and attempts to show it. | |
| 80 void SetView(app_list::AppListView* view); | |
| 81 | |
| 82 // Forgets the view. | |
| 83 void ResetView(); | |
| 84 | |
| 85 // Starts show/hide animation. | |
| 86 void ScheduleAnimation(); | |
| 87 | |
| 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: | |
| 98 void OnWindowFocused(aura::Window* gained_focus, | |
| 99 aura::Window* lost_focus) override; | |
| 100 | |
| 101 // aura::WindowObserver overrides: | |
| 102 void OnWindowBoundsChanged(aura::Window* root, | |
| 103 const gfx::Rect& old_bounds, | |
| 104 const gfx::Rect& new_bounds) override; | |
| 105 | |
| 106 // ui::ImplicitAnimationObserver overrides: | |
| 107 void OnImplicitAnimationsCompleted() override; | |
| 108 | |
| 109 // views::WidgetObserver overrides: | |
| 110 void OnWidgetDestroying(views::Widget* widget) override; | |
| 111 | |
| 112 // KeyboardControllerObserver overrides: | |
| 113 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | |
| 114 | |
| 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: | |
| 124 void TotalPagesChanged() override; | |
| 125 void SelectedPageChanged(int old_selected, int new_selected) override; | |
| 126 void TransitionStarted() override; | |
| 127 void TransitionChanged() override; | |
| 128 | |
| 129 // Whether we should show or hide app list widget. | |
| 130 bool is_visible_; | |
| 131 | |
| 132 // Whether the app list should remain centered. | |
| 133 bool is_centered_; | |
| 134 | |
| 135 // The AppListView this class manages, owned by its widget. | |
| 136 app_list::AppListView* view_; | |
| 137 | |
| 138 // 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. | |
| 140 int current_apps_page_; | |
| 141 | |
| 142 // Cached bounds of |view_| for snapping back animation after over-scroll. | |
| 143 gfx::Rect view_bounds_; | |
| 144 | |
| 145 // Whether should schedule snap back animation. | |
| 146 bool should_snap_back_; | |
| 147 | |
| 148 DISALLOW_COPY_AND_ASSIGN(AppListController); | |
| 149 }; | |
| 150 | |
| 151 } // namespace ash | |
| 152 | |
| 153 #endif // ASH_WM_APP_LIST_CONTROLLER_H_ | |
| OLD | NEW |