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 UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 class AppListViewTestApi; | 35 class AppListViewTestApi; |
36 } | 36 } |
37 | 37 |
38 // AppListView is the top-level view and controller of app list UI. It creates | 38 // AppListView is the top-level view and controller of app list UI. It creates |
39 // and hosts a AppsGridView and passes AppListModel to it for display. | 39 // and hosts a AppsGridView and passes AppListModel to it for display. |
40 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 40 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, |
41 public SpeechUIModelObserver, | 41 public SpeechUIModelObserver, |
42 public display::DisplayObserver { | 42 public display::DisplayObserver { |
43 public: | 43 public: |
44 enum AppListState { | 44 enum AppListState { |
45 // Closes |app_list_main_view_| and dismisses the delegate. | 45 // If set, closes |app_list_main_view_| and dismisses the delegate. |
46 CLOSED = 0, | 46 CLOSED = 0, |
47 // The initial state for the app list when neither maximize or side shelf | 47 |
48 // modes are active. If set, the widget will peek over the shelf by | 48 // The initial state for the app list. If set, the widget will peek over |
49 // kPeekingAppListHeight DIPs. | 49 // the shelf by kPeekingAppListHeight DIPs. |
50 PEEKING, | 50 PEEKING, |
51 // Entered when text is entered into the search box from peeking mode. | 51 |
52 HALF, | 52 // If set, the widget will be repositioned to take up the whole screen. |
53 // Default app list state in maximize and side shelf modes. Entered from an | 53 FULLSCREEN, |
54 // upward swipe from |PEEKING| or from clicking the chevron. | |
55 FULLSCREEN_ALL_APPS, | |
56 // Entered from an upward swipe from |HALF| or by entering text in the | |
57 // search box from |FULLSCREEN_ALL_APPS|. | |
58 FULLSCREEN_SEARCH, | |
59 }; | 54 }; |
60 | 55 |
61 // Does not take ownership of |delegate|. | 56 // Does not take ownership of |delegate|. |
62 explicit AppListView(AppListViewDelegate* delegate); | 57 explicit AppListView(AppListViewDelegate* delegate); |
63 ~AppListView() override; | 58 ~AppListView() override; |
64 | 59 |
65 // Initializes the widget as a bubble or fullscreen view depending on if the | 60 // Initializes the widget as a bubble or fullscreen view depending on if the |
66 // fullscreen app list feature is set. |parent| and |initial_apps_page| are | 61 // fullscreen app list feature is set. |parent| and |initial_apps_page| are |
67 // used for both the bubble and fullscreen initialization. |is_maximize_mode| | 62 // used for both the bubble and fullscreen initialization. |
68 // is whether the display is in maximize mode and |is_side_shelf| is whether | 63 void Initialize(gfx::NativeView parent, int initial_apps_page); |
69 // the shelf is oriented on the side, and both are used for fullscreen | |
70 // app list initialization. | |
71 void Initialize(gfx::NativeView parent, | |
72 int initial_apps_page, | |
73 bool is_maximize_mode, | |
74 bool is_side_shelf); | |
75 | 64 |
76 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 65 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); |
77 | 66 |
78 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); | 67 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); |
79 | 68 |
80 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop | 69 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop |
81 // operations outside the application list. This has to be called after | 70 // operations outside the application list. This has to be called after |
82 // Initialize was called since the app list object needs to exist so that | 71 // Initialize was called since the app list object needs to exist so that |
83 // it can set the host. | 72 // it can set the host. |
84 void SetDragAndDropHostOfCurrentAppList( | 73 void SetDragAndDropHostOfCurrentAppList( |
(...skipping 28 matching lines...) Expand all Loading... |
113 PaginationModel* GetAppsPaginationModel(); | 102 PaginationModel* GetAppsPaginationModel(); |
114 | 103 |
115 // Overridden from views::View: | 104 // Overridden from views::View: |
116 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 105 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
117 void Layout() override; | 106 void Layout() override; |
118 void SchedulePaintInRect(const gfx::Rect& rect) override; | 107 void SchedulePaintInRect(const gfx::Rect& rect) override; |
119 | 108 |
120 // Changes the app list state. | 109 // Changes the app list state. |
121 void SetState(AppListState new_state); | 110 void SetState(AppListState new_state); |
122 | 111 |
123 // Changes the app list state depending on the current |app_list_state_| and | 112 bool is_fullscreen() const { return app_list_state_ == FULLSCREEN; } |
124 // whether the search box is empty. | |
125 void SetStateFromSearchBoxView(bool search_box_is_empty); | |
126 | |
127 bool is_fullscreen() const { | |
128 return app_list_state_ == FULLSCREEN_ALL_APPS || | |
129 app_list_state_ == FULLSCREEN_SEARCH; | |
130 } | |
131 | |
132 AppListState app_list_state() const { return app_list_state_; } | 113 AppListState app_list_state() const { return app_list_state_; } |
133 | 114 |
134 // Called when maximize mode starts and ends. | |
135 void OnMaximizeModeChanged(bool started); | |
136 | |
137 private: | 115 private: |
138 friend class test::AppListViewTestApi; | 116 friend class test::AppListViewTestApi; |
139 | 117 |
140 void InitContents(gfx::NativeView parent, int initial_apps_page); | 118 void InitContents(gfx::NativeView parent, int initial_apps_page); |
141 | 119 |
142 void InitChildWidgets(); | 120 void InitChildWidgets(); |
143 | 121 |
144 // Initializes the widget for fullscreen mode. | 122 // Initializes the widget for fullscreen mode. |
145 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | 123 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); |
146 | 124 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 AppListMainView* app_list_main_view_; | 167 AppListMainView* app_list_main_view_; |
190 SpeechView* speech_view_; | 168 SpeechView* speech_view_; |
191 views::Widget* fullscreen_widget_ = nullptr; // Owned by AppListView. | 169 views::Widget* fullscreen_widget_ = nullptr; // Owned by AppListView. |
192 | 170 |
193 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 171 views::View* search_box_focus_host_; // Owned by the views hierarchy. |
194 views::Widget* search_box_widget_; // Owned by the app list's widget. | 172 views::Widget* search_box_widget_; // Owned by the app list's widget. |
195 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 173 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. |
196 // Owned by the app list's widget. Null if the fullscreen app list is not | 174 // Owned by the app list's widget. Null if the fullscreen app list is not |
197 // enabled. | 175 // enabled. |
198 views::View* app_list_background_shield_ = nullptr; | 176 views::View* app_list_background_shield_ = nullptr; |
199 // Whether maximize mode is active. | |
200 bool is_maximize_mode_ = false; | |
201 // Whether the shelf is oriented on the side. | |
202 bool is_side_shelf_ = false; | |
203 | |
204 // The gap between the initial gesture event and the top of the window. | 177 // The gap between the initial gesture event and the top of the window. |
205 gfx::Point initial_drag_point_; | 178 gfx::Point initial_drag_point_; |
206 // The velocity of the gesture event. | 179 // The velocity of the gesture event. |
207 float last_fling_velocity_ = 0; | 180 float last_fling_velocity_ = 0; |
208 // Whether the fullscreen app list feature is enabled. | 181 // Whether the fullscreen app list feature is enabled. |
209 const bool is_fullscreen_app_list_enabled_; | 182 const bool is_fullscreen_app_list_enabled_; |
210 // The state of the app list, controlled via SetState(). | 183 // The state of the app list, controlled via SetState(). |
211 AppListState app_list_state_; | 184 AppListState app_list_state_; |
212 | 185 |
213 // An observer that notifies AppListView when the display has changed. | 186 // An observer that notifies AppListView when the display has changed. |
214 ScopedObserver<display::Screen, display::DisplayObserver> display_observer_; | 187 ScopedObserver<display::Screen, display::DisplayObserver> display_observer_; |
215 | 188 |
216 // A semi-transparent white overlay that covers the app list while dialogs are | 189 // A semi-transparent white overlay that covers the app list while dialogs are |
217 // open. | 190 // open. |
218 views::View* overlay_view_; | 191 views::View* overlay_view_; |
219 | 192 |
220 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 193 std::unique_ptr<HideViewAnimationObserver> animation_observer_; |
221 | 194 |
222 // For UMA and testing. If non-null, triggered when the app list is painted. | 195 // For UMA and testing. If non-null, triggered when the app list is painted. |
223 base::Closure next_paint_callback_; | 196 base::Closure next_paint_callback_; |
224 | 197 |
225 DISALLOW_COPY_AND_ASSIGN(AppListView); | 198 DISALLOW_COPY_AND_ASSIGN(AppListView); |
226 }; | 199 }; |
227 | 200 |
228 } // namespace app_list | 201 } // namespace app_list |
229 | 202 |
230 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 203 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
OLD | NEW |