OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CONTENTS_SWITCHER_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ui/app_list/pagination_model_observer.h" | |
10 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
11 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
12 | 11 |
13 namespace app_list { | 12 namespace app_list { |
14 | 13 |
15 class ContentsView; | 14 class ContentsView; |
16 | 15 |
17 // A view that contains buttons to switch the displayed view in the given | 16 // A view that contains buttons to switch the displayed view in the given |
18 // ContentsView. | 17 // ContentsView. |
19 class ContentsSwitcherView : public views::View, | 18 class ContentsSwitcherView : public views::View, public views::ButtonListener { |
20 public views::ButtonListener, | |
21 public PaginationModelObserver { | |
22 public: | 19 public: |
23 explicit ContentsSwitcherView(ContentsView* contents_view); | 20 explicit ContentsSwitcherView(ContentsView* contents_view); |
24 virtual ~ContentsSwitcherView(); | 21 virtual ~ContentsSwitcherView(); |
25 | 22 |
26 ContentsView* contents_view() const { return contents_view_; } | 23 ContentsView* contents_view() const { return contents_view_; } |
27 | 24 |
28 // Adds a switcher button using |resource_id| as the button's image, which | 25 // Adds a switcher button using |resource_id| as the button's image, which |
29 // opens the page with index |page_index| in the ContentsView. |resource_id| | 26 // opens the page with index |page_index| in the ContentsView. |resource_id| |
30 // is ignored if it is 0. | 27 // is ignored if it is 0. |
31 void AddSwitcherButton(int resource_id, int page_index); | 28 void AddSwitcherButton(int resource_id, int page_index); |
32 | 29 |
33 private: | 30 private: |
34 // Overridden from views::View: | 31 // Overridden from views::View: |
35 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 32 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
36 virtual void Layout() OVERRIDE; | 33 virtual void Layout() OVERRIDE; |
37 | 34 |
38 // Overridden from views::ButtonListener: | 35 // Overridden from views::ButtonListener: |
39 virtual void ButtonPressed(views::Button* sender, | 36 virtual void ButtonPressed(views::Button* sender, |
40 const ui::Event& event) OVERRIDE; | 37 const ui::Event& event) OVERRIDE; |
41 | 38 |
42 // Overridden from PaginationModelObserver: | |
43 virtual void TotalPagesChanged() OVERRIDE; | |
44 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; | |
45 virtual void TransitionStarted() OVERRIDE; | |
46 virtual void TransitionChanged() OVERRIDE; | |
47 | |
48 ContentsView* contents_view_; // Owned by views hierarchy. | 39 ContentsView* contents_view_; // Owned by views hierarchy. |
49 views::View* buttons_; // Owned by views hierarchy. | 40 views::View* buttons_; // Owned by views hierarchy. |
50 // Stores Views owned by views hierarchy. | |
51 std::vector<views::View*> page_active_indicators_; | |
52 | 41 |
53 DISALLOW_COPY_AND_ASSIGN(ContentsSwitcherView); | 42 DISALLOW_COPY_AND_ASSIGN(ContentsSwitcherView); |
54 }; | 43 }; |
55 | 44 |
56 } // namespace app_list | 45 } // namespace app_list |
57 | 46 |
58 #endif // UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ | 47 #endif // UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ |
OLD | NEW |