| OLD | NEW |
| 1 // Copyright 2016 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 UI_APP_LIST_SHOWER_APP_LIST_SHOWER_IMPL_H_ | 5 #ifndef UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ |
| 6 #define UI_APP_LIST_SHOWER_APP_LIST_SHOWER_IMPL_H_ | 6 #define UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/app_list/pagination_model_observer.h" | 12 #include "ui/app_list/pagination_model_observer.h" |
| 13 #include "ui/app_list/shower/app_list_shower.h" | 13 #include "ui/app_list/presenter/app_list_presenter.h" |
| 14 #include "ui/app_list/shower/app_list_shower_delegate.h" | 14 #include "ui/app_list/presenter/app_list_presenter_delegate.h" |
| 15 #include "ui/aura/client/focus_change_observer.h" | 15 #include "ui/aura/client/focus_change_observer.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/compositor/layer_animation_observer.h" | 17 #include "ui/compositor/layer_animation_observer.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/views/widget/widget_observer.h" | 19 #include "ui/views/widget/widget_observer.h" |
| 20 | 20 |
| 21 namespace app_list { | 21 namespace app_list { |
| 22 class AppListView; | 22 class AppListView; |
| 23 class AppListViewDelegate; | 23 class AppListViewDelegate; |
| 24 class AppListShowerDelegateFactory; | 24 class AppListPresenterDelegateFactory; |
| 25 | 25 |
| 26 namespace test { | 26 namespace test { |
| 27 class AppListShowerImplTestApi; | 27 class AppListPresenterImplTestApi; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class AppListShowerImplTest; | 30 class AppListPresenterImplTest; |
| 31 class AppListViewDelegate; | 31 class AppListViewDelegate; |
| 32 | 32 |
| 33 // Manages app list UI. Creates AppListView and schedules showing/hiding | 33 // Manages app list UI. Creates AppListView and schedules showing/hiding |
| 34 // animation. While the UI is visible, it monitors things such as app list | 34 // animation. While the UI is visible, it monitors things such as app list |
| 35 // activation state to auto dismiss the UI. Delegates the responsibility | 35 // activation state to auto dismiss the UI. Delegates the responsibility |
| 36 // for laying out the app list UI to ash::AppListLayoutDelegate. | 36 // for laying out the app list UI to ash::AppListLayoutDelegate. |
| 37 class APP_LIST_SHOWER_EXPORT AppListShowerImpl | 37 class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl |
| 38 : public AppListShower, | 38 : public AppListPresenter, |
| 39 public aura::client::FocusChangeObserver, | 39 public aura::client::FocusChangeObserver, |
| 40 public aura::WindowObserver, | 40 public aura::WindowObserver, |
| 41 public ui::ImplicitAnimationObserver, | 41 public ui::ImplicitAnimationObserver, |
| 42 public views::WidgetObserver, | 42 public views::WidgetObserver, |
| 43 public PaginationModelObserver { | 43 public PaginationModelObserver { |
| 44 public: | 44 public: |
| 45 explicit AppListShowerImpl(AppListShowerDelegateFactory* factory); | 45 explicit AppListPresenterImpl(AppListPresenterDelegateFactory* factory); |
| 46 ~AppListShowerImpl() override; | 46 ~AppListPresenterImpl() override; |
| 47 | 47 |
| 48 // Returns app list window or NULL if it is not visible. | 48 // Returns app list window or NULL if it is not visible. |
| 49 aura::Window* GetWindow(); | 49 aura::Window* GetWindow(); |
| 50 | 50 |
| 51 // Returns app list view if one exists, or NULL otherwise. | 51 // Returns app list view if one exists, or NULL otherwise. |
| 52 AppListView* GetView() { return view_; } | 52 AppListView* GetView() { return view_; } |
| 53 | 53 |
| 54 // AppListShower: | 54 // AppListPresenter: |
| 55 void Show(aura::Window* window) override; | 55 void Show(aura::Window* window) override; |
| 56 void Dismiss() override; | 56 void Dismiss() override; |
| 57 bool IsVisible() const override; | 57 bool IsVisible() const override; |
| 58 bool GetTargetVisibility() const override; | 58 bool GetTargetVisibility() const override; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 friend class test::AppListShowerImplTestApi; | 61 friend class test::AppListPresenterImplTestApi; |
| 62 | 62 |
| 63 // Sets the app list view and attempts to show it. | 63 // Sets the app list view and attempts to show it. |
| 64 void SetView(AppListView* view); | 64 void SetView(AppListView* view); |
| 65 | 65 |
| 66 // Forgets the view. | 66 // Forgets the view. |
| 67 void ResetView(); | 67 void ResetView(); |
| 68 | 68 |
| 69 // Starts show/hide animation. | 69 // Starts show/hide animation. |
| 70 void ScheduleAnimation(); | 70 void ScheduleAnimation(); |
| 71 | 71 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 // views::WidgetObserver overrides: | 84 // views::WidgetObserver overrides: |
| 85 void OnWidgetDestroying(views::Widget* widget) override; | 85 void OnWidgetDestroying(views::Widget* widget) override; |
| 86 | 86 |
| 87 // PaginationModelObserver overrides: | 87 // PaginationModelObserver overrides: |
| 88 void TotalPagesChanged() override; | 88 void TotalPagesChanged() override; |
| 89 void SelectedPageChanged(int old_selected, int new_selected) override; | 89 void SelectedPageChanged(int old_selected, int new_selected) override; |
| 90 void TransitionStarted() override; | 90 void TransitionStarted() override; |
| 91 void TransitionChanged() override; | 91 void TransitionChanged() override; |
| 92 | 92 |
| 93 // Not owned | 93 // Not owned |
| 94 AppListShowerDelegateFactory* const factory_; | 94 AppListPresenterDelegateFactory* const factory_; |
| 95 | 95 |
| 96 // Responsible for laying out the app list UI. | 96 // Responsible for laying out the app list UI. |
| 97 std::unique_ptr<AppListShowerDelegate> shower_delegate_; | 97 std::unique_ptr<AppListPresenterDelegate> presenter_delegate_; |
| 98 | 98 |
| 99 // Whether we should show or hide app list widget. | 99 // Whether we should show or hide app list widget. |
| 100 bool is_visible_ = false; | 100 bool is_visible_ = false; |
| 101 | 101 |
| 102 // The AppListView this class manages, owned by its widget. | 102 // The AppListView this class manages, owned by its widget. |
| 103 AppListView* view_ = nullptr; | 103 AppListView* view_ = nullptr; |
| 104 | 104 |
| 105 // The current page of the AppsGridView of |view_|. This is stored outside of | 105 // The current page of the AppsGridView of |view_|. This is stored outside of |
| 106 // the view's PaginationModel, so that it persists when the view is destroyed. | 106 // the view's PaginationModel, so that it persists when the view is destroyed. |
| 107 int current_apps_page_ = -1; | 107 int current_apps_page_ = -1; |
| 108 | 108 |
| 109 // Cached bounds of |view_| for snapping back animation after over-scroll. | 109 // Cached bounds of |view_| for snapping back animation after over-scroll. |
| 110 gfx::Rect view_bounds_; | 110 gfx::Rect view_bounds_; |
| 111 | 111 |
| 112 // Whether should schedule snap back animation. | 112 // Whether should schedule snap back animation. |
| 113 bool should_snap_back_ = false; | 113 bool should_snap_back_ = false; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(AppListShowerImpl); | 115 DISALLOW_COPY_AND_ASSIGN(AppListPresenterImpl); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace app_list | 118 } // namespace app_list |
| 119 | 119 |
| 120 #endif // UI_APP_LIST_SHOWER_APP_LIST_SHOWER_IMPL_H_ | 120 #endif // UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ |
| OLD | NEW |