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_APPS_GRID_VIEW_H_ | 5 #ifndef UI_APP_LIST_APPS_GRID_VIEW_H_ |
6 #define UI_APP_LIST_APPS_GRID_VIEW_H_ | 6 #define UI_APP_LIST_APPS_GRID_VIEW_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
14 #include "ui/app_list/app_list_model.h" | 14 #include "ui/app_list/app_list_model.h" |
| 15 #include "ui/app_list/app_list_model_observer.h" |
15 #include "ui/app_list/pagination_model_observer.h" | 16 #include "ui/app_list/pagination_model_observer.h" |
16 #include "ui/base/models/list_model_observer.h" | 17 #include "ui/base/models/list_model_observer.h" |
17 #include "ui/views/animation/bounds_animator.h" | 18 #include "ui/views/animation/bounds_animator.h" |
18 #include "ui/views/controls/button/button.h" | 19 #include "ui/views/controls/button/button.h" |
19 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
20 #include "ui/views/view_model.h" | 21 #include "ui/views/view_model.h" |
21 | 22 |
22 namespace views { | 23 namespace views { |
23 class ButtonListener; | 24 class ButtonListener; |
24 } | 25 } |
25 | 26 |
26 namespace app_list { | 27 namespace app_list { |
27 | 28 |
28 namespace test { | 29 namespace test { |
29 class AppsGridViewTestApi; | 30 class AppsGridViewTestApi; |
30 } | 31 } |
31 | 32 |
32 class AppListItemView; | 33 class AppListItemView; |
33 class AppsGridViewDelegate; | 34 class AppsGridViewDelegate; |
34 class PageSwitcher; | 35 class PageSwitcher; |
35 class PaginationModel; | 36 class PaginationModel; |
36 | 37 |
37 // AppsGridView displays a grid for AppListModel::Apps sub model. | 38 // AppsGridView displays a grid for AppListModel::Apps sub model. |
38 class APP_LIST_EXPORT AppsGridView : public views::View, | 39 class APP_LIST_EXPORT AppsGridView : public views::View, |
39 public views::ButtonListener, | 40 public views::ButtonListener, |
40 public ui::ListModelObserver, | 41 public ui::ListModelObserver, |
41 public PaginationModelObserver { | 42 public PaginationModelObserver, |
| 43 public AppListModelObserver { |
42 public: | 44 public: |
43 enum Pointer { | 45 enum Pointer { |
44 NONE, | 46 NONE, |
45 MOUSE, | 47 MOUSE, |
46 TOUCH, | 48 TOUCH, |
47 }; | 49 }; |
48 | 50 |
49 AppsGridView(AppsGridViewDelegate* delegate, | 51 AppsGridView(AppsGridViewDelegate* delegate, |
50 PaginationModel* pagination_model); | 52 PaginationModel* pagination_model); |
51 virtual ~AppsGridView(); | 53 virtual ~AppsGridView(); |
52 | 54 |
53 // Sets fixed layout parameters. After setting this, CalculateLayout below | 55 // Sets fixed layout parameters. After setting this, CalculateLayout below |
54 // is no longer called to dynamically choosing those layout params. | 56 // is no longer called to dynamically choosing those layout params. |
55 void SetLayout(int icon_size, int cols, int rows_per_page); | 57 void SetLayout(int icon_size, int cols, int rows_per_page); |
56 | 58 |
57 // Sets |model| to use. Note this does not take ownership of |model|. | 59 // Sets |model| to use. Note this does not take ownership of |model|. |
58 void SetModel(AppListModel::Apps* model); | 60 void SetModel(AppListModel* model); |
59 | 61 |
60 void SetSelectedView(views::View* view); | 62 void SetSelectedView(views::View* view); |
61 void ClearSelectedView(views::View* view); | 63 void ClearSelectedView(views::View* view); |
62 bool IsSelectedView(const views::View* view) const; | 64 bool IsSelectedView(const views::View* view) const; |
63 | 65 |
64 // Ensures the view is visible. Note that if there is a running page | 66 // Ensures the view is visible. Note that if there is a running page |
65 // transition, this does nothing. | 67 // transition, this does nothing. |
66 void EnsureViewVisible(const views::View* view); | 68 void EnsureViewVisible(const views::View* view); |
67 | 69 |
68 void InitiateDrag(views::View* view, | 70 void InitiateDrag(views::View* view, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 }; | 108 }; |
107 | 109 |
108 int tiles_per_page() const { return cols_ * rows_per_page_; } | 110 int tiles_per_page() const { return cols_ * rows_per_page_; } |
109 | 111 |
110 // Updates from model. | 112 // Updates from model. |
111 void Update(); | 113 void Update(); |
112 | 114 |
113 // Updates page splits for item views. | 115 // Updates page splits for item views. |
114 void UpdatePaging(); | 116 void UpdatePaging(); |
115 | 117 |
| 118 // Updates the number of pulsing block views based on AppListModel status and |
| 119 // number of apps. |
| 120 void UpdatePulsingBlockViews(); |
| 121 |
116 views::View* CreateViewForItemAtIndex(size_t index); | 122 views::View* CreateViewForItemAtIndex(size_t index); |
117 | 123 |
118 void SetSelectedItemByIndex(const Index& index); | 124 void SetSelectedItemByIndex(const Index& index); |
119 bool IsValidIndex(const Index& index) const; | 125 bool IsValidIndex(const Index& index) const; |
120 | 126 |
121 Index GetIndexOfView(const views::View* view) const; | 127 Index GetIndexOfView(const views::View* view) const; |
122 views::View* GetViewAtIndex(const Index& index) const; | 128 views::View* GetViewAtIndex(const Index& index) const; |
123 | 129 |
124 void MoveSelected(int page_delta, int slot_delta); | 130 void MoveSelected(int page_delta, int slot_delta); |
125 | 131 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; | 167 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; |
162 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; | 168 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; |
163 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; | 169 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; |
164 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; | 170 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; |
165 | 171 |
166 // Overridden from PaginationModelObserver: | 172 // Overridden from PaginationModelObserver: |
167 virtual void TotalPagesChanged() OVERRIDE; | 173 virtual void TotalPagesChanged() OVERRIDE; |
168 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; | 174 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; |
169 virtual void TransitionChanged() OVERRIDE; | 175 virtual void TransitionChanged() OVERRIDE; |
170 | 176 |
171 AppListModel::Apps* model_; // Owned by AppListModel. | 177 // Overridden from AppListModelObserver: |
| 178 virtual void OnAppListModelStatusChanged() OVERRIDE; |
| 179 |
| 180 AppListModel* model_; // Owned by AppListView. |
172 AppsGridViewDelegate* delegate_; | 181 AppsGridViewDelegate* delegate_; |
173 PaginationModel* pagination_model_; // Owned by AppListController. | 182 PaginationModel* pagination_model_; // Owned by AppListController. |
174 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. | 183 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. |
175 | 184 |
176 gfx::Size icon_size_; | 185 gfx::Size icon_size_; |
177 int cols_; | 186 int cols_; |
178 int rows_per_page_; | 187 int rows_per_page_; |
179 | 188 |
180 // Tracks app item views. There is a view per item in |model_|. | 189 // Tracks app item views. There is a view per item in |model_|. |
181 views::ViewModel view_model_; | 190 views::ViewModel view_model_; |
182 | 191 |
| 192 // Tracks pulsing block views. |
| 193 views::ViewModel pulsing_blocks_model_; |
| 194 |
183 views::View* selected_view_; | 195 views::View* selected_view_; |
184 | 196 |
185 views::View* drag_view_; | 197 views::View* drag_view_; |
186 gfx::Point drag_start_; | 198 gfx::Point drag_start_; |
187 Pointer drag_pointer_; | 199 Pointer drag_pointer_; |
188 Index drop_target_; | 200 Index drop_target_; |
189 | 201 |
190 gfx::Point last_drag_point_; | 202 gfx::Point last_drag_point_; |
191 | 203 |
192 // Timer to auto flip page when dragging an item near the left/right edges. | 204 // Timer to auto flip page when dragging an item near the left/right edges. |
193 base::OneShotTimer<AppsGridView> page_flip_timer_; | 205 base::OneShotTimer<AppsGridView> page_flip_timer_; |
194 | 206 |
195 // Target page to switch to when |page_flip_timer_| fires. | 207 // Target page to switch to when |page_flip_timer_| fires. |
196 int page_flip_target_; | 208 int page_flip_target_; |
197 | 209 |
198 // Delay in milliseconds of when |page_flip_timer_| should fire after user | 210 // Delay in milliseconds of when |page_flip_timer_| should fire after user |
199 // drags an item near the edges. | 211 // drags an item near the edges. |
200 int page_flip_delay_in_ms_; | 212 int page_flip_delay_in_ms_; |
201 | 213 |
202 views::BoundsAnimator bounds_animator_; | 214 views::BoundsAnimator bounds_animator_; |
203 | 215 |
204 DISALLOW_COPY_AND_ASSIGN(AppsGridView); | 216 DISALLOW_COPY_AND_ASSIGN(AppsGridView); |
205 }; | 217 }; |
206 | 218 |
207 } // namespace app_list | 219 } // namespace app_list |
208 | 220 |
209 #endif // UI_APP_LIST_APPS_GRID_VIEW_H_ | 221 #endif // UI_APP_LIST_APPS_GRID_VIEW_H_ |
OLD | NEW |