Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the TabBar of a TabContainer #80227

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/classes/TabContainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
Returns the previously active tab index.
</description>
</method>
<method name="get_tab_bar" qualifiers="const">
<return type="TabBar" />
<description>
Returns the [TabBar] contained in this container.
[b]Warning:[/b] This is a required internal node, removing and freeing it or editing its tabs may cause a crash. If you wish to edit the tabs, use the methods provided in [TabContainer].
</description>
</method>
<method name="get_tab_button_icon" qualifiers="const">
<return type="Texture2D" />
<param index="0" name="tab_idx" type="int" />
Expand Down
5 changes: 5 additions & 0 deletions scene/gui/tab_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ void TabContainer::remove_child_notify(Node *p_child) {
}
}

TabBar *TabContainer::get_tab_bar() const {
return tab_bar;
}

int TabContainer::get_tab_count() const {
return tab_bar->get_tab_count();
}
Expand Down Expand Up @@ -947,6 +951,7 @@ void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_tab"), &TabContainer::get_current_tab);
ClassDB::bind_method(D_METHOD("get_previous_tab"), &TabContainer::get_previous_tab);
ClassDB::bind_method(D_METHOD("get_current_tab_control"), &TabContainer::get_current_tab_control);
ClassDB::bind_method(D_METHOD("get_tab_bar"), &TabContainer::get_tab_bar);
ClassDB::bind_method(D_METHOD("get_tab_control", "tab_idx"), &TabContainer::get_tab_control);
ClassDB::bind_method(D_METHOD("set_tab_alignment", "alignment"), &TabContainer::set_tab_alignment);
ClassDB::bind_method(D_METHOD("get_tab_alignment"), &TabContainer::get_tab_alignment);
Expand Down
2 changes: 2 additions & 0 deletions scene/gui/tab_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class TabContainer : public Container {
static void _bind_methods();

public:
TabBar *get_tab_bar() const;

int get_tab_idx_at_point(const Point2 &p_point) const;
int get_tab_idx_from_control(Control *p_child) const;

Expand Down
Loading