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

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

Issue 2368283002: views: add focus to TabbedPane (Closed)
Patch Set: sed tr sed 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 16 matching lines...) Expand all
27 ~TabbedPane() override; 27 ~TabbedPane() override;
28 28
29 TabbedPaneListener* listener() const { return listener_; } 29 TabbedPaneListener* listener() const { return listener_; }
30 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } 30 void set_listener(TabbedPaneListener* listener) { listener_ = listener; }
31 31
32 int selected_tab_index() const { return selected_tab_index_; } 32 int selected_tab_index() const { return selected_tab_index_; }
33 33
34 // Returns the number of tabs. 34 // Returns the number of tabs.
35 int GetTabCount(); 35 int GetTabCount();
36 36
37 // Returns the contents of the selected tab or NULL if there is none.
38 View* GetSelectedTab();
39
40 // Adds a new tab at the end of this TabbedPane with the specified |title|. 37 // Adds a new tab at the end of this TabbedPane with the specified |title|.
41 // |contents| is the view displayed when the tab is selected and is owned by 38 // |contents| is the view displayed when the tab is selected and is owned by
42 // the TabbedPane. 39 // the TabbedPane.
43 void AddTab(const base::string16& title, View* contents); 40 void AddTab(const base::string16& title, View* contents);
44 41
45 // Adds a new tab at |index| with |title|. |contents| is the view displayed 42 // Adds a new tab at |index| with |title|. |contents| is the view displayed
46 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane 43 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane
47 // is currently empty, the new tab is selected. 44 // is currently empty, the new tab is selected.
48 void AddTabAtIndex(int index, const base::string16& title, View* contents); 45 void AddTabAtIndex(int index, const base::string16& title, View* contents);
49 46
50 // Selects the tab at |index|, which must be valid. 47 // Selects the tab at |index|, which must be valid.
51 void SelectTabAt(int index); 48 void SelectTabAt(int index);
52 49
53 // Selects |tab| (the tabstrip view, not its content) if it is valid. 50 // Selects |tab| (the tabstrip view, not its content) if it is valid.
54 void SelectTab(Tab* tab); 51 void SelectTab(Tab* tab);
55 52
56 // Overridden from View: 53 // Overridden from View:
57 gfx::Size GetPreferredSize() const override; 54 gfx::Size GetPreferredSize() const override;
58 const char* GetClassName() const override; 55 const char* GetClassName() const override;
59 56
60 private: 57 private:
58 friend class FocusTraversalTest;
59 friend class Tab;
61 friend class TabStrip; 60 friend class TabStrip;
61 FRIEND_TEST_ALL_PREFIXES(TabbedPaneTest, AddAndSelect);
62 FRIEND_TEST_ALL_PREFIXES(TabbedPaneTest, ArrowKeyBindings);
62 63
63 // Get the Tab (the tabstrip view, not its content) at the valid |index|. 64 // Get the Tab (the tabstrip view, not its content) at the valid |index|.
64 Tab* GetTabAt(int index); 65 Tab* GetTabAt(int index);
65 66
67 // Get the Tab (the tabstrip view, not its content) at the selected index.
68 Tab* GetSelectedTab();
69
70 // Returns the content View of the currently selected Tab.
71 View* GetSelectedTabContentView();
sky 2016/10/06 21:14:40 Ick! Why not move the declaration of tab to this h
Elly Fong-Jones 2016/10/07 17:18:24 Done.
72
73 // Gets the currently selected Tab (returned as a View, because the Tab class
74 // is private).
75 View* GetSelectedTabAsView();
76
77 // Moves the selection by |delta| tabs, where negative delta means leftwards
78 // and positive delta means rightwards. Returns whether the selection could be
79 // moved by that amount; the only way this can fail is if there is only one
80 // tab.
81 bool MoveSelectionBy(int delta);
82
66 // Overridden from View: 83 // Overridden from View:
67 void Layout() override; 84 void Layout() override;
68 void ViewHierarchyChanged( 85 void ViewHierarchyChanged(
69 const ViewHierarchyChangedDetails& details) override; 86 const ViewHierarchyChangedDetails& details) override;
70 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 87 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
71 void OnFocus() override;
72 void GetAccessibleState(ui::AXViewState* state) override; 88 void GetAccessibleState(ui::AXViewState* state) override;
73 89
74 // A listener notified when tab selection changes. Weak, not owned. 90 // A listener notified when tab selection changes. Weak, not owned.
75 TabbedPaneListener* listener_; 91 TabbedPaneListener* listener_;
76 92
77 // The tab strip and contents container. The child indices of these members 93 // The tab strip and contents container. The child indices of these members
78 // correspond to match each Tab with its respective content View. 94 // correspond to match each Tab with its respective content View.
79 TabStrip* tab_strip_; 95 TabStrip* tab_strip_;
80 View* contents_; 96 View* contents_;
81 97
82 // The selected tab index or -1 if invalid. 98 // The selected tab index or -1 if invalid.
83 int selected_tab_index_; 99 int selected_tab_index_;
84 100
85 DISALLOW_COPY_AND_ASSIGN(TabbedPane); 101 DISALLOW_COPY_AND_ASSIGN(TabbedPane);
86 }; 102 };
87 103
88 } // namespace views 104 } // namespace views
89 105
90 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ 106 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698