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

Side by Side Diff: ui/views/controls/tabbed_pane/tabbed_pane.h

Issue 2415633002: TabbedPane: refactor away manual layout and selected_tab_index_ (Closed)
Patch Set: nits for msw Created 4 years, 2 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
OLDNEW
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_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ 5 #ifndef UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
6 #define UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ 6 #define UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 // Internal class name. 24 // Internal class name.
25 static const char kViewClassName[]; 25 static const char kViewClassName[];
26 26
27 TabbedPane(); 27 TabbedPane();
28 ~TabbedPane() override; 28 ~TabbedPane() override;
29 29
30 TabbedPaneListener* listener() const { return listener_; } 30 TabbedPaneListener* listener() const { return listener_; }
31 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } 31 void set_listener(TabbedPaneListener* listener) { listener_ = listener; }
32 32
33 int selected_tab_index() const { return selected_tab_index_; } 33 // Returns the index of the currently selected tab, or -1 if no tab is
34 // selected.
35 int GetSelectedTabIndex() const;
34 36
35 // Returns the number of tabs. 37 // Returns the number of tabs.
36 int GetTabCount(); 38 int GetTabCount();
37 39
38 // Adds a new tab at the end of this TabbedPane with the specified |title|. 40 // Adds a new tab at the end of this TabbedPane with the specified |title|.
39 // |contents| is the view displayed when the tab is selected and is owned by 41 // |contents| is the view displayed when the tab is selected and is owned by
40 // the TabbedPane. 42 // the TabbedPane.
41 void AddTab(const base::string16& title, View* contents); 43 void AddTab(const base::string16& title, View* contents);
42 44
43 // Adds a new tab at |index| with |title|. |contents| is the view displayed 45 // Adds a new tab at |index| with |title|. |contents| is the view displayed
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 113
112 bool selected() const { return contents_->visible(); } 114 bool selected() const { return contents_->visible(); }
113 void SetSelected(bool selected); 115 void SetSelected(bool selected);
114 116
115 // Overridden from View: 117 // Overridden from View:
116 bool OnMousePressed(const ui::MouseEvent& event) override; 118 bool OnMousePressed(const ui::MouseEvent& event) override;
117 void OnMouseEntered(const ui::MouseEvent& event) override; 119 void OnMouseEntered(const ui::MouseEvent& event) override;
118 void OnMouseExited(const ui::MouseEvent& event) override; 120 void OnMouseExited(const ui::MouseEvent& event) override;
119 void OnGestureEvent(ui::GestureEvent* event) override; 121 void OnGestureEvent(ui::GestureEvent* event) override;
120 gfx::Size GetPreferredSize() const override; 122 gfx::Size GetPreferredSize() const override;
121 void Layout() override;
122 const char* GetClassName() const override; 123 const char* GetClassName() const override;
123 void OnFocus() override; 124 void OnFocus() override;
124 void OnBlur() override; 125 void OnBlur() override;
125 bool OnKeyPressed(const ui::KeyEvent& event) override; 126 bool OnKeyPressed(const ui::KeyEvent& event) override;
126 127
127 protected: 128 protected:
128 Label* title() { return title_; } 129 Label* title() { return title_; }
129 130
130 // Called whenever |tab_state_| changes. 131 // Called whenever |tab_state_| changes.
131 virtual void OnStateChanged(); 132 virtual void OnStateChanged();
132 133
133 // Returns whether the containing TabStrip has focus.
134 bool ContainerHasFocus();
135
136 private: 134 private:
137 enum TabState { 135 enum TabState {
138 TAB_INACTIVE, 136 TAB_INACTIVE,
139 TAB_ACTIVE, 137 TAB_ACTIVE,
140 TAB_HOVERED, 138 TAB_HOVERED,
141 }; 139 };
142 140
143 void SetState(TabState tab_state); 141 void SetState(TabState tab_state);
144 142
145 TabbedPane* tabbed_pane_; 143 TabbedPane* tabbed_pane_;
146 Label* title_; 144 Label* title_;
147 gfx::Size preferred_title_size_; 145 gfx::Size preferred_title_size_;
148 TabState tab_state_; 146 TabState tab_state_;
149 // The content view associated with this tab. 147 // The content view associated with this tab.
150 View* contents_; 148 View* contents_;
151 149
152 DISALLOW_COPY_AND_ASSIGN(Tab); 150 DISALLOW_COPY_AND_ASSIGN(Tab);
153 }; 151 };
154 152
155 } // namespace views 153 } // namespace views
156 154
157 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ 155 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.cc ('k') | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698