diff --git a/doc/classes/TabBar.xml b/doc/classes/TabBar.xml index 41e1e255ae1..6ddcc2044d0 100644 --- a/doc/classes/TabBar.xml +++ b/doc/classes/TabBar.xml @@ -106,12 +106,6 @@ Returns the title of the tab at index [code]tab_idx[/code]. - - - - Returns the [TabBar]'s rearrange group ID. - - @@ -206,13 +200,6 @@ Sets a [code]title[/code] for the tab at index [code]tab_idx[/code]. - - - - - Defines the rearrange group ID. Choose for each [TabBar] the same value to dragging tabs between [TabBar]. Enable drag with [member drag_to_rearrange_enabled]. - - @@ -242,6 +229,10 @@ The number of tabs currently in the bar. + + [TabBar]s with the same rearrange group ID will allow dragging the tabs between them. Enable drag with [member drag_to_rearrange_enabled]. + Setting this to [code]-1[/code] will disable rearranging between [TabBar]s. + diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 3f4ec81c953..3ff4dffe651 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -71,12 +71,6 @@ Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title]. - - - - Returns the [TabContainer] rearrange group id. - - @@ -130,13 +124,6 @@ Sets a custom title for the tab at index [code]tab_idx[/code] (tab titles default to the name of the indexed child node). Set it to blank to make it the child's name again. - - - - - Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [member drag_to_rearrange_enabled]. - - @@ -154,6 +141,10 @@ Sets the position at which tabs will be placed. See [enum TabBar.AlignmentMode] for details. + + [TabContainer]s with the same rearrange group ID will allow dragging the tabs between them. Enable drag with [member drag_to_rearrange_enabled]. + Setting this to [code]-1[/code] will disable rearranging between [TabContainer]s. + If [code]true[/code], tabs are visible. If [code]false[/code], tabs' content and titles are hidden. diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 0e088a44e5e..a11248ec6b0 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -1541,6 +1541,7 @@ void TabBar::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_close_display_policy", PROPERTY_HINT_ENUM, "Show Never,Show Active Only,Show Always"), "set_tab_close_display_policy", "get_tab_close_display_policy"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scrolling_enabled"), "set_scrolling_enabled", "get_scrolling_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_to_rearrange_enabled"), "set_drag_to_rearrange_enabled", "get_drag_to_rearrange_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_rearrange_group"), "set_tabs_rearrange_group", "get_tabs_rearrange_group"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_to_selected"), "set_scroll_to_selected", "get_scroll_to_selected"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "select_with_rmb"), "set_select_with_rmb", "get_select_with_rmb"); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 0d5165dbd82..102fe185023 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -401,7 +401,10 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C } move_child(get_tab_control(tab_from_id), get_tab_control(hover_now)->get_index(false)); - set_current_tab(hover_now); + if (!is_tab_disabled(hover_now)) { + set_current_tab(hover_now); + } + } else if (get_tabs_rearrange_group() != -1) { // Drag and drop between TabContainers. Node *from_node = get_node(from_path); @@ -416,8 +419,9 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C } move_child(moving_tabc, get_tab_control(hover_now)->get_index(false)); - - set_current_tab(hover_now); + if (!is_tab_disabled(hover_now)) { + set_current_tab(hover_now); + } } } } @@ -864,6 +868,7 @@ void TabContainer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_visible"), "set_tabs_visible", "are_tabs_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "all_tabs_in_front"), "set_all_tabs_in_front", "is_all_tabs_in_front"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_to_rearrange_enabled"), "set_drag_to_rearrange_enabled", "get_drag_to_rearrange_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "tabs_rearrange_group"), "set_tabs_rearrange_group", "get_tabs_rearrange_group"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hidden_tabs_for_min_size"), "set_use_hidden_tabs_for_min_size", "get_use_hidden_tabs_for_min_size"); }