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 ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_ | 5 #ifndef UI_APP_LIST_APP_LIST_MODEL_VIEW_H_ |
6 #define ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_ | 6 #define UI_APP_LIST_APP_LIST_MODEL_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ui/app_list/app_list_export.h" |
10 #include "ash/app_list/pagination_model_observer.h" | 10 #include "ui/app_list/pagination_model_observer.h" |
11 #include "ui/base/models/list_model_observer.h" | 11 #include "ui/base/models/list_model_observer.h" |
12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 class ButtonListener; | 15 class ButtonListener; |
16 } | 16 } |
17 | 17 |
18 namespace ash { | 18 namespace app_list { |
19 | 19 |
20 class AppListItemView; | 20 class AppListItemView; |
21 class AppListModel; | 21 class AppListModel; |
22 class PaginationModel; | 22 class PaginationModel; |
23 | 23 |
24 // AppListModelView displays the UI for an AppListModel. | 24 // AppListModelView displays the UI for an AppListModel. |
25 class ASH_EXPORT AppListModelView : public views::View, | 25 class APP_LIST_EXPORT AppListModelView : public views::View, |
26 public ui::ListModelObserver, | 26 public ui::ListModelObserver, |
27 public PaginationModelObserver { | 27 public PaginationModelObserver { |
28 public: | 28 public: |
29 AppListModelView(views::ButtonListener* listener, | 29 AppListModelView(views::ButtonListener* listener, |
30 PaginationModel* pagination_model); | 30 PaginationModel* pagination_model); |
31 virtual ~AppListModelView(); | 31 virtual ~AppListModelView(); |
32 | 32 |
33 // Sets fixed layout parameters. After setting this, CalculateLayout below | 33 // Sets fixed layout parameters. After setting this, CalculateLayout below |
34 // is no longer called to dynamically choosing those layout params. | 34 // is no longer called to dynamically choosing those layout params. |
35 void SetLayout(int icon_size, int cols, int rows_per_page); | 35 void SetLayout(int icon_size, int cols, int rows_per_page); |
36 | 36 |
37 // Calculate preferred icon size, rows and cols for given |content_size| and | 37 // Calculate preferred icon size, rows and cols for given |content_size| and |
38 // |num_of_tiles|. | 38 // |num_of_tiles|. |
39 static void CalculateLayout(const gfx::Size& content_size, | 39 static void CalculateLayout(const gfx::Size& content_size, |
40 int num_of_tiles, | 40 int num_of_tiles, |
41 gfx::Size* icon_size, | 41 gfx::Size* icon_size, |
42 int* rows, | 42 int* rows, |
43 int* cols); | 43 int* cols); |
44 | 44 |
45 // Sets |model| to use. Note this does not take ownership of |model|. | 45 // Sets |model| to use. Note this does not take ownership of |model|. |
46 void SetModel(AppListModel* model); | 46 void SetModel(AppListModel* model); |
47 | 47 |
48 void SetSelectedItem(AppListItemView* item); | 48 void SetSelectedItem(AppListItemView* item); |
49 void ClearSelectedItem(AppListItemView* item); | 49 void ClearSelectedItem(AppListItemView* item); |
50 | 50 |
51 int tiles_per_page() const { | 51 int tiles_per_page() const { |
52 return cols_ * rows_per_page_; | 52 return cols_ * rows_per_page_; |
53 } | 53 } |
54 | 54 |
| 55 bool fixed_layout() const { |
| 56 return fixed_layout_; |
| 57 } |
| 58 |
55 private: | 59 private: |
56 // Updates from model. | 60 // Updates from model. |
57 void Update(); | 61 void Update(); |
58 | 62 |
59 AppListItemView* GetItemViewAtIndex(int index); | 63 AppListItemView* GetItemViewAtIndex(int index); |
60 void SetSelectedItemByIndex(int index); | 64 void SetSelectedItemByIndex(int index); |
61 | 65 |
62 // Overridden from views::View: | 66 // Overridden from views::View: |
63 virtual gfx::Size GetPreferredSize() OVERRIDE; | 67 virtual gfx::Size GetPreferredSize() OVERRIDE; |
64 virtual void Layout() OVERRIDE; | 68 virtual void Layout() OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
82 bool fixed_layout_; | 86 bool fixed_layout_; |
83 gfx::Size icon_size_; | 87 gfx::Size icon_size_; |
84 int cols_; | 88 int cols_; |
85 int rows_per_page_; | 89 int rows_per_page_; |
86 | 90 |
87 int selected_item_index_; | 91 int selected_item_index_; |
88 | 92 |
89 DISALLOW_COPY_AND_ASSIGN(AppListModelView); | 93 DISALLOW_COPY_AND_ASSIGN(AppListModelView); |
90 }; | 94 }; |
91 | 95 |
92 } // namespace ash | 96 } // namespace app_list |
93 | 97 |
94 #endif // ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_ | 98 #endif // UI_APP_LIST_APP_LIST_MODEL_VIEW_H_ |
OLD | NEW |