Chromium Code Reviews| 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 UI_APP_LIST_APP_LIST_SHOWER_IMPL_H_ |
| 6 #define ASH_WM_APP_LIST_CONTROLLER_H_ | 6 #define UI_APP_LIST_APP_LIST_SHOWER_IMPL_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 "ui/app_list/app_list_shower.h" | |
| 11 #include "ui/app_list/app_list_shower_delegate.h" | |
| 12 #include "ui/app_list/pagination_model_observer.h" | 12 #include "ui/app_list/pagination_model_observer.h" |
| 13 #include "ui/aura/client/focus_change_observer.h" | 13 #include "ui/aura/client/focus_change_observer.h" |
| 14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 15 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
| 16 #include "ui/events/event_handler.h" | |
| 17 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/keyboard/keyboard_controller_observer.h" | 17 #include "ui/keyboard/keyboard_controller_observer.h" |
| 19 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
| 20 | 19 |
| 21 namespace app_list { | 20 namespace app_list { |
| 22 class ApplicationDragAndDropHost; | |
| 23 class AppListView; | 21 class AppListView; |
| 22 class AppListViewDelegate; | |
| 23 class AppListShowerDelegateFactory; | |
| 24 | |
| 25 namespace test { | |
| 26 class AppListShowerImplTestApi; | |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace ui { | 29 class AppListShowerImplTest; |
| 27 class LocatedEvent; | 30 class AppListViewDelegate; |
| 28 } | |
| 29 | 31 |
| 30 namespace ash { | 32 // Manages app list UI. Creates AppListView and schedules showing/hiding |
| 31 namespace test { | 33 // animation. While the UI is visible, it monitors things such as app list |
| 32 class AppListControllerTestApi; | 34 // activation state to auto dismiss the UI. Delegates the responsibility |
| 33 } | 35 // for laying out the app list UI to ash::AppListLayoutDelegate. |
| 34 | 36 class APP_LIST_EXPORT AppListShowerImpl |
| 35 // AppListController is a controller that manages app list UI for shell. | 37 : public AppListShower, |
| 36 // It creates AppListView and schedules showing/hiding animation. | 38 public aura::client::FocusChangeObserver, |
| 37 // While the UI is visible, it monitors things such as app list widget's | 39 public aura::WindowObserver, |
| 38 // activation state and desktop mouse click to auto dismiss the UI. | 40 public ui::ImplicitAnimationObserver, |
| 39 class AppListController : public ui::EventHandler, | 41 public views::WidgetObserver, |
| 40 public aura::client::FocusChangeObserver, | 42 public keyboard::KeyboardControllerObserver, |
| 41 public aura::WindowObserver, | 43 public PaginationModelObserver { |
| 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: | 44 public: |
| 49 AppListController(); | 45 explicit AppListShowerImpl(AppListShowerDelegateFactory* factory); |
| 50 ~AppListController() override; | 46 ~AppListShowerImpl() 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 | 47 |
| 65 // Returns app list window or NULL if it is not visible. | 48 // Returns app list window or NULL if it is not visible. |
| 66 aura::Window* GetWindow(); | 49 aura::Window* GetWindow(); |
| 67 | 50 |
| 68 // Returns app list view if one exists, or NULL otherwise. | 51 // Returns app list view if one exists, or NULL otherwise. |
| 69 app_list::AppListView* GetView() { return view_; } | 52 AppListView* GetView() { return view_; } |
| 53 | |
| 54 void set_view_delegate(AppListViewDelegate* view_delegate) { | |
|
xiyuan
2016/03/24 20:31:12
Can we pass this in as an arg to ctor? Using a set
mfomitchev
2016/03/29 17:33:31
Consider the AppListServiceAsh in the complete imp
| |
| 55 view_delegate_ = view_delegate; | |
| 56 } | |
| 57 | |
| 58 // AppListShower: | |
| 59 void Show(aura::Window* window) override; | |
| 60 void Dismiss() override; | |
| 61 bool IsVisible() const override; | |
| 62 bool GetTargetVisibility() const override; | |
| 70 | 63 |
| 71 private: | 64 private: |
| 72 friend class test::AppListControllerTestApi; | 65 friend class test::AppListShowerImplTestApi; |
| 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 | 66 |
| 79 // Sets the app list view and attempts to show it. | 67 // Sets the app list view and attempts to show it. |
| 80 void SetView(app_list::AppListView* view); | 68 void SetView(AppListView* view); |
| 81 | 69 |
| 82 // Forgets the view. | 70 // Forgets the view. |
| 83 void ResetView(); | 71 void ResetView(); |
| 84 | 72 |
| 85 // Starts show/hide animation. | 73 // Starts show/hide animation. |
| 86 void ScheduleAnimation(); | 74 void ScheduleAnimation(); |
| 87 | 75 |
| 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: | 76 // aura::client::FocusChangeObserver overrides: |
| 98 void OnWindowFocused(aura::Window* gained_focus, | 77 void OnWindowFocused(aura::Window* gained_focus, |
| 99 aura::Window* lost_focus) override; | 78 aura::Window* lost_focus) override; |
| 100 | 79 |
| 101 // aura::WindowObserver overrides: | 80 // aura::WindowObserver overrides: |
| 102 void OnWindowBoundsChanged(aura::Window* root, | 81 void OnWindowBoundsChanged(aura::Window* root, |
| 103 const gfx::Rect& old_bounds, | 82 const gfx::Rect& old_bounds, |
| 104 const gfx::Rect& new_bounds) override; | 83 const gfx::Rect& new_bounds) override; |
| 105 | 84 |
| 106 // ui::ImplicitAnimationObserver overrides: | 85 // ui::ImplicitAnimationObserver overrides: |
| 107 void OnImplicitAnimationsCompleted() override; | 86 void OnImplicitAnimationsCompleted() override; |
| 108 | 87 |
| 109 // views::WidgetObserver overrides: | 88 // views::WidgetObserver overrides: |
| 110 void OnWidgetDestroying(views::Widget* widget) override; | 89 void OnWidgetDestroying(views::Widget* widget) override; |
| 111 | 90 |
| 112 // KeyboardControllerObserver overrides: | 91 // KeyboardControllerObserver overrides: |
| 113 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | 92 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; |
| 114 | 93 |
| 115 // ShellObserver overrides: | 94 // PaginationModelObserver 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; | 95 void TotalPagesChanged() override; |
| 125 void SelectedPageChanged(int old_selected, int new_selected) override; | 96 void SelectedPageChanged(int old_selected, int new_selected) override; |
| 126 void TransitionStarted() override; | 97 void TransitionStarted() override; |
| 127 void TransitionChanged() override; | 98 void TransitionChanged() override; |
| 128 | 99 |
| 100 AppListShowerDelegateFactory* factory_; | |
|
xiyuan
2016/03/24 20:31:12
nit: document ownership and "AppListShowerDelegate
mfomitchev
2016/03/29 17:33:32
Done.
| |
| 101 | |
| 102 // Responsible for laying out the app list UI. | |
| 103 scoped_ptr<AppListShowerDelegate> shower_delegate_; | |
| 104 | |
| 105 // Not owned. | |
| 106 AppListViewDelegate* view_delegate_; | |
|
xiyuan
2016/03/24 20:31:12
nit: prefer to use member initializer instead of i
mfomitchev
2016/03/29 17:33:31
Cool, done. Thanks for the link! I updated the oth
| |
| 107 | |
| 129 // Whether we should show or hide app list widget. | 108 // Whether we should show or hide app list widget. |
| 130 bool is_visible_; | 109 bool is_visible_; |
| 131 | 110 |
| 132 // Whether the app list should remain centered. | |
| 133 bool is_centered_; | |
| 134 | |
| 135 // The AppListView this class manages, owned by its widget. | 111 // The AppListView this class manages, owned by its widget. |
| 136 app_list::AppListView* view_; | 112 AppListView* view_; |
| 137 | 113 |
| 138 // The current page of the AppsGridView of |view_|. This is stored outside of | 114 // 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. | 115 // the view's PaginationModel, so that it persists when the view is destroyed. |
| 140 int current_apps_page_; | 116 int current_apps_page_; |
| 141 | 117 |
| 142 // Cached bounds of |view_| for snapping back animation after over-scroll. | 118 // Cached bounds of |view_| for snapping back animation after over-scroll. |
| 143 gfx::Rect view_bounds_; | 119 gfx::Rect view_bounds_; |
| 144 | 120 |
| 145 // Whether should schedule snap back animation. | 121 // Whether should schedule snap back animation. |
| 146 bool should_snap_back_; | 122 bool should_snap_back_; |
| 147 | |
| 148 DISALLOW_COPY_AND_ASSIGN(AppListController); | |
|
xiyuan
2016/03/24 20:31:12
Why removing this?
mfomitchev
2016/03/29 17:33:32
Fixed
| |
| 149 }; | 123 }; |
| 150 | 124 |
| 151 } // namespace ash | 125 } // namespace app_list |
| 152 | 126 |
| 153 #endif // ASH_WM_APP_LIST_CONTROLLER_H_ | 127 #endif // UI_APP_LIST_APP_LIST_SHOWER_IMPL_H_ |
| OLD | NEW |