| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 ASH_WM_APP_LIST_CONTROLLER_H_ |
| 6 #define ASH_WM_APP_LIST_CONTROLLER_H_ | 6 #define ASH_WM_APP_LIST_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/launcher/launcher_icon_observer.h" | 8 #include "ash/launcher/launcher_icon_observer.h" |
| 9 #include "ash/shell_observer.h" | 9 #include "ash/shell_observer.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/observer_list.h" |
| 12 #include "base/timer.h" | 13 #include "base/timer.h" |
| 13 #include "ui/app_list/pagination_model_observer.h" | 14 #include "ui/app_list/pagination_model_observer.h" |
| 14 #include "ui/aura/client/focus_change_observer.h" | 15 #include "ui/aura/client/focus_change_observer.h" |
| 15 #include "ui/aura/root_window_observer.h" | 16 #include "ui/aura/root_window_observer.h" |
| 16 #include "ui/base/events/event_handler.h" | 17 #include "ui/base/events/event_handler.h" |
| 17 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
| 18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.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 AppListView; | 23 class AppListView; |
| 23 class PaginationModel; | 24 class PaginationModel; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace ui { | 27 namespace ui { |
| 27 class LocatedEvent; | 28 class LocatedEvent; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace ash { | 31 namespace ash { |
| 32 |
| 33 class Shell; |
| 34 |
| 31 namespace internal { | 35 namespace internal { |
| 32 | 36 |
| 37 class AppListControllerObserver; |
| 38 |
| 33 // AppListController is a controller that manages app list UI for shell. | 39 // AppListController is a controller that manages app list UI for shell. |
| 34 // It creates AppListView and schedules showing/hiding animation. | 40 // It creates AppListView and schedules showing/hiding animation. |
| 35 // While the UI is visible, it monitors things such as app list widget's | 41 // While the UI is visible, it monitors things such as app list widget's |
| 36 // activation state and desktop mouse click to auto dismiss the UI. | 42 // activation state and desktop mouse click to auto dismiss the UI. |
| 37 class AppListController : public ui::EventHandler, | 43 class AppListController : public ui::EventHandler, |
| 38 public aura::client::FocusChangeObserver, | 44 public aura::client::FocusChangeObserver, |
| 39 public aura::RootWindowObserver, | 45 public aura::RootWindowObserver, |
| 40 public ui::ImplicitAnimationObserver, | 46 public ui::ImplicitAnimationObserver, |
| 41 public views::WidgetObserver, | 47 public views::WidgetObserver, |
| 42 public ShellObserver, | 48 public ShellObserver, |
| 43 public LauncherIconObserver, | 49 public LauncherIconObserver, |
| 44 public app_list::PaginationModelObserver { | 50 public app_list::PaginationModelObserver { |
| 45 public: | 51 public: |
| 46 AppListController(); | 52 explicit AppListController(Shell* shell); |
| 47 virtual ~AppListController(); | 53 virtual ~AppListController(); |
| 48 | 54 |
| 55 // Closes opened app list and cleans up its dependency on shell. |
| 56 void Shutdown(); |
| 57 |
| 49 // Show/hide app list window. The |window| is used to deterime in | 58 // Show/hide app list window. The |window| is used to deterime in |
| 50 // which display (in which the |window| exists) the app list should | 59 // which display (in which the |window| exists) the app list should |
| 51 // be shown. | 60 // be shown. |
| 52 void SetVisible(bool visible, aura::Window* window); | 61 void SetVisible(bool visible, aura::Window* window); |
| 53 | 62 |
| 54 // Whether app list window is visible (shown or being shown). | 63 // Whether app list window is visible (shown or being shown). |
| 55 bool IsVisible() const; | 64 bool IsVisible() const; |
| 56 | 65 |
| 66 // Convenience wrapper to toggle visibility using the SetVisible() and |
| 67 // IsVisible(). |
| 68 void Toggle(aura::Window* window); |
| 69 |
| 57 // Returns target visibility. This differs from IsVisible() if an animation | 70 // Returns target visibility. This differs from IsVisible() if an animation |
| 58 // is ongoing. | 71 // is ongoing. |
| 59 bool GetTargetVisibility() const { return is_visible_; } | 72 bool GetTargetVisibility() const { return is_visible_; } |
| 60 | 73 |
| 61 // Returns app list window or NULL if it is not visible. | 74 // Returns app list window or NULL if it is not visible. |
| 62 aura::Window* GetWindow(); | 75 aura::Window* GetWindow(); |
| 63 | 76 |
| 77 void AddObserver(AppListControllerObserver* observer); |
| 78 void RemoveObserver(AppListControllerObserver* observer); |
| 79 |
| 64 private: | 80 private: |
| 65 // Sets the app list view and attempts to show it. | 81 // Sets the app list view and attempts to show it. |
| 66 void SetView(app_list::AppListView* view); | 82 void SetView(app_list::AppListView* view); |
| 67 | 83 |
| 68 // Forgets the view. | 84 // Forgets the view. |
| 69 void ResetView(); | 85 void ResetView(); |
| 70 | 86 |
| 71 // Starts show/hide animation. | 87 // Starts show/hide animation. |
| 72 void ScheduleAnimation(); | 88 void ScheduleAnimation(); |
| 73 | 89 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE; | 114 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE; |
| 99 | 115 |
| 100 // LauncherIconObserver overrides: | 116 // LauncherIconObserver overrides: |
| 101 virtual void OnLauncherIconPositionsChanged() OVERRIDE; | 117 virtual void OnLauncherIconPositionsChanged() OVERRIDE; |
| 102 | 118 |
| 103 // app_list::PaginationModelObserver overrides: | 119 // app_list::PaginationModelObserver overrides: |
| 104 virtual void TotalPagesChanged() OVERRIDE; | 120 virtual void TotalPagesChanged() OVERRIDE; |
| 105 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; | 121 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; |
| 106 virtual void TransitionChanged() OVERRIDE; | 122 virtual void TransitionChanged() OVERRIDE; |
| 107 | 123 |
| 124 Shell* shell_; |
| 125 |
| 108 scoped_ptr<app_list::PaginationModel> pagination_model_; | 126 scoped_ptr<app_list::PaginationModel> pagination_model_; |
| 109 | 127 |
| 110 // Whether we should show or hide app list widget. | 128 // Whether we should show or hide app list widget. |
| 111 bool is_visible_; | 129 bool is_visible_; |
| 112 | 130 |
| 113 // The AppListView this class manages, owned by its widget. | 131 // The AppListView this class manages, owned by its widget. |
| 114 app_list::AppListView* view_; | 132 app_list::AppListView* view_; |
| 115 | 133 |
| 116 // Cached bounds of |view_| for snapping back animation after over-scroll. | 134 // Cached bounds of |view_| for snapping back animation after over-scroll. |
| 117 gfx::Rect view_bounds_; | 135 gfx::Rect view_bounds_; |
| 118 | 136 |
| 119 // Whether should schedule snap back animation. | 137 // Whether should schedule snap back animation. |
| 120 bool should_snap_back_; | 138 bool should_snap_back_; |
| 121 | 139 |
| 140 ObserverList<AppListControllerObserver, true> observers_; |
| 141 |
| 122 DISALLOW_COPY_AND_ASSIGN(AppListController); | 142 DISALLOW_COPY_AND_ASSIGN(AppListController); |
| 123 }; | 143 }; |
| 124 | 144 |
| 125 } // namespace internal | 145 } // namespace internal |
| 126 } // namespace ash | 146 } // namespace ash |
| 127 | 147 |
| 128 #endif // ASH_WM_APP_LIST_CONTROLLER_H_ | 148 #endif // ASH_WM_APP_LIST_CONTROLLER_H_ |
| OLD | NEW |