Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ui/app_list/views/contents_switcher_view.h

Issue 336313010: App List: Refactor ContentsSwitcherView so it doesn't hard-code pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/views/controls/button/button.h" 9 #include "ui/views/controls/button/button.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 11
12 namespace app_list { 12 namespace app_list {
13 13
14 class ContentsView; 14 class ContentsView;
15 15
16 // 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
17 // ContentsView. 17 // ContentsView.
18 class ContentsSwitcherView : public views::View, public views::ButtonListener { 18 class ContentsSwitcherView : public views::View, public views::ButtonListener {
19 public: 19 public:
20 explicit ContentsSwitcherView(ContentsView* contents_view); 20 explicit ContentsSwitcherView();
21 virtual ~ContentsSwitcherView(); 21 virtual ~ContentsSwitcherView();
22 22
23 ContentsView* contents_view() const { return contents_view_; } 23 ContentsView* contents_view() const { return contents_view_; }
24 24
25 // Initialize the ContentsSwitcherView with a ContentsView sibling. Must be
26 // called before AddSwitcherButton.
27 void Init(ContentsView* contents_view);
28
29 // Adds a switcher button using |resource_id| as the button's image, which
30 // opens the page with index |page_index| in the ContentsView.
31 void AddSwitcherButton(int resource_id, int page_index);
calamity 2014/06/18 05:22:29 Add a note about resource_id of 0 being ignored.
Matt Giuca 2014/06/18 06:47:02 Done.
32
25 private: 33 private:
26 // Adds a switcher button using |resource_id| as the button's image and |tag|
27 // as the button's id.
28 void AddSwitcherButton(int resource_id, int tag);
29
30 // Overridden from views::View: 34 // Overridden from views::View:
31 virtual gfx::Size GetPreferredSize() const OVERRIDE; 35 virtual gfx::Size GetPreferredSize() const OVERRIDE;
32 virtual void Layout() OVERRIDE; 36 virtual void Layout() OVERRIDE;
33 37
34 // Overridden from views::ButtonListener: 38 // Overridden from views::ButtonListener:
35 virtual void ButtonPressed(views::Button* sender, 39 virtual void ButtonPressed(views::Button* sender,
36 const ui::Event& event) OVERRIDE; 40 const ui::Event& event) OVERRIDE;
37 41
38 ContentsView* contents_view_; // Owned by views hierarchy. 42 ContentsView* contents_view_; // Owned by views hierarchy.
39 views::View* buttons_; // Owned by views hierarchy. 43 views::View* buttons_; // Owned by views hierarchy.
40 44
41 DISALLOW_COPY_AND_ASSIGN(ContentsSwitcherView); 45 DISALLOW_COPY_AND_ASSIGN(ContentsSwitcherView);
42 }; 46 };
43 47
44 } // namespace app_list 48 } // namespace app_list
45 49
46 #endif // UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_ 50 #endif // UI_APP_LIST_VIEWS_CONTENTS_SWITCHER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698