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