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