OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 ASH_APP_LIST_APP_LIST_GROUPS_VIEW_H_ | |
6 #define ASH_APP_LIST_APP_LIST_GROUPS_VIEW_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "ash/ash_export.h" | |
13 #include "ui/base/models/list_model_observer.h" | |
14 #include "ui/views/controls/button/button.h" | |
15 #include "ui/views/view.h" | |
16 | |
17 namespace views { | |
18 class BoundsAnimator; | |
19 } | |
20 | |
21 namespace ash { | |
22 | |
23 class AppListItemGroupView; | |
24 class AppListItemViewListener; | |
25 class AppListModel; | |
26 | |
27 // AppListGroupsView displays the UI for an AppListModel. If there are more than | |
28 // one group in the model , a button strip is displayed to allow user to switch | |
29 // between pages. | |
30 class ASH_EXPORT AppListGroupsView : public views::View, | |
31 public views::ButtonListener, | |
32 public ui::ListModelObserver { | |
33 public: | |
34 AppListGroupsView(AppListModel* model, | |
35 AppListItemViewListener* listener); | |
36 virtual ~AppListGroupsView(); | |
37 | |
38 // Gets current focused tile. | |
39 views::View* GetFocusedTile() const; | |
40 | |
41 private: | |
42 // Updates from model. | |
43 void Update(); | |
44 | |
45 // Adds a result group page. | |
46 void AddPage(const std::string& title, AppListItemGroupView* page); | |
47 | |
48 // Gets preferred number of tiles per row. | |
49 int GetPreferredTilesPerRow() const; | |
50 | |
51 // Gets current result page. | |
52 AppListItemGroupView* GetCurrentPageView() const; | |
53 | |
54 // Sets current result page. | |
55 void SetCurrentPage(int page); | |
56 | |
57 // Overridden from views::View: | |
58 virtual void Layout() OVERRIDE; | |
59 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; | |
60 | |
61 // Overridden from views::ButtonListener: | |
62 virtual void ButtonPressed(views::Button* sender, | |
63 const views::Event& event) OVERRIDE; | |
64 | |
65 // Overridden from ListModelObserver: | |
66 virtual void ListItemsAdded(int start, int count) OVERRIDE; | |
67 virtual void ListItemsRemoved(int start, int count) OVERRIDE; | |
68 virtual void ListItemsChanged(int start, int count) OVERRIDE; | |
69 | |
70 AppListModel* model_; // Owned by parent AppListView. | |
71 AppListItemViewListener* listener_; | |
72 | |
73 std::vector<AppListItemGroupView*> pages_; | |
74 views::View* page_buttons_; | |
75 int current_page_; | |
76 | |
77 scoped_ptr<views::BoundsAnimator> animator_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(AppListGroupsView); | |
80 }; | |
81 | |
82 } // namespace ash | |
83 | |
84 #endif // ASH_APP_LIST_APP_LIST_GROUPS_VIEW_H_ | |
OLD | NEW |