diff --git a/addons/README.md b/addons/README.md index 9f0a504c8..cb578e18a 100644 --- a/addons/README.md +++ b/addons/README.md @@ -24,7 +24,7 @@ Files extracted from source: ## godot-dockable-container - Upstream: https://github.com/gilzoide/godot-dockable-container -- Version: 63943c37835c504b1178a83b4b0050815ecf69c0 +- Version: [274ea7264440003071bcd024f31e130c984df3c6](https://github.com/gilzoide/godot-dockable-container/pull/27/commits/274ea7264440003071bcd024f31e130c984df3c6) (PR #27) - License: [CC0-1.0](https://github.com/gilzoide/godot-dockable-container/blob/main/LICENSE) ## SmartSlicer diff --git a/addons/dockable_container/dockable_container.gd b/addons/dockable_container/dockable_container.gd index bdbfd67f2..66e88cbca 100644 --- a/addons/dockable_container/dockable_container.gd +++ b/addons/dockable_container/dockable_container.gd @@ -26,10 +26,15 @@ const DragNDropPanel := preload("drag_n_drop_panel.gd") get: return _tabs_visible set(value): - _tabs_visible = value - for i in range(1, _panel_container.get_child_count()): - var panel := _panel_container.get_child(i) as DockablePanel - panel.tabs_visible = value + set_tabs_visible(value) +## Always ensure that tabs are visible if a panel has more than one tab. +## Only takes effect is [member tabs_visible] is [code]false[/code]. +@export var tabs_visible_if_more_than_one := false: + get: + return _tabs_visible_if_more_than_one + set(value): + _tabs_visible_if_more_than_one = value + set_tabs_visible(_tabs_visible) @export var rearrange_group := 0 @export var layout := DockableLayout.new(): get: @@ -49,6 +54,7 @@ var _drag_panel: DockablePanel var _tab_align := TabBar.ALIGNMENT_CENTER var _tabs_visible := true var _use_hidden_tabs_for_min_size := false +var _tabs_visible_if_more_than_one := false var _current_panel_index := 0 var _current_split_index := 0 var _children_names := {} @@ -187,15 +193,18 @@ func set_layout(value: DockableLayout) -> void: queue_sort() -func set_tab_alignment(value: TabBar.AlignmentMode) -> void: - _tab_align = value +func set_tabs_visible(value: bool) -> void: + _tabs_visible = value for i in range(1, _panel_container.get_child_count()): - var panel = _panel_container.get_child(i) - panel.tab_alignment = value + var panel := _panel_container.get_child(i) as DockablePanel + if _tabs_visible_if_more_than_one and panel.get_tab_count() > 1: + panel.tabs_visible = true + else: + panel.tabs_visible = value -func get_tab_align() -> int: - return _tab_align +func get_tabs_visible() -> bool: + return _tabs_visible func set_use_hidden_tabs_for_min_size(value: bool) -> void: @@ -321,6 +330,8 @@ func _resort() -> void: _untrack_children_after(_panel_container, _current_panel_index) _untrack_children_after(_split_container, _current_split_index) + if not tabs_visible and tabs_visible_if_more_than_one: + set_tabs_visible(_tabs_visible) ## Calculate DockablePanel and SplitHandle minimum sizes, skipping empty diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index cc29f95bb..73478447f 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -251,6 +251,7 @@ size_flags_horizontal = 3 size_flags_vertical = 3 script = ExtResource("35") tabs_visible = false +tabs_visible_if_more_than_one = true layout = SubResource("Resource_b6o2t") [node name="Tools" parent="DockableContainer" instance=ExtResource("1")]