1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Always show panel tabs if there are more than one

Bringing this feature back from 0.x. Not very happy that we're once again not synced with upstream dockable_container, so hopefully https://github.com/gilzoide/godot-dockable-container/pull/27 is merged soon.
This commit is contained in:
Emmanouil Papadeas 2024-01-12 20:56:35 +02:00
parent 80bcfe200d
commit 9631527da6
3 changed files with 23 additions and 11 deletions

View file

@ -24,7 +24,7 @@ Files extracted from source:
## godot-dockable-container ## godot-dockable-container
- Upstream: https://github.com/gilzoide/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) - License: [CC0-1.0](https://github.com/gilzoide/godot-dockable-container/blob/main/LICENSE)
## SmartSlicer ## SmartSlicer

View file

@ -26,10 +26,15 @@ const DragNDropPanel := preload("drag_n_drop_panel.gd")
get: get:
return _tabs_visible return _tabs_visible
set(value): set(value):
_tabs_visible = value set_tabs_visible(value)
for i in range(1, _panel_container.get_child_count()): ## Always ensure that tabs are visible if a panel has more than one tab.
var panel := _panel_container.get_child(i) as DockablePanel ## Only takes effect is [member tabs_visible] is [code]false[/code].
panel.tabs_visible = value @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 rearrange_group := 0
@export var layout := DockableLayout.new(): @export var layout := DockableLayout.new():
get: get:
@ -49,6 +54,7 @@ var _drag_panel: DockablePanel
var _tab_align := TabBar.ALIGNMENT_CENTER var _tab_align := TabBar.ALIGNMENT_CENTER
var _tabs_visible := true var _tabs_visible := true
var _use_hidden_tabs_for_min_size := false var _use_hidden_tabs_for_min_size := false
var _tabs_visible_if_more_than_one := false
var _current_panel_index := 0 var _current_panel_index := 0
var _current_split_index := 0 var _current_split_index := 0
var _children_names := {} var _children_names := {}
@ -187,15 +193,18 @@ func set_layout(value: DockableLayout) -> void:
queue_sort() queue_sort()
func set_tab_alignment(value: TabBar.AlignmentMode) -> void: func set_tabs_visible(value: bool) -> void:
_tab_align = value _tabs_visible = value
for i in range(1, _panel_container.get_child_count()): for i in range(1, _panel_container.get_child_count()):
var panel = _panel_container.get_child(i) var panel := _panel_container.get_child(i) as DockablePanel
panel.tab_alignment = value 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: func get_tabs_visible() -> bool:
return _tab_align return _tabs_visible
func set_use_hidden_tabs_for_min_size(value: bool) -> void: 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(_panel_container, _current_panel_index)
_untrack_children_after(_split_container, _current_split_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 ## Calculate DockablePanel and SplitHandle minimum sizes, skipping empty

View file

@ -251,6 +251,7 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
script = ExtResource("35") script = ExtResource("35")
tabs_visible = false tabs_visible = false
tabs_visible_if_more_than_one = true
layout = SubResource("Resource_b6o2t") layout = SubResource("Resource_b6o2t")
[node name="Tools" parent="DockableContainer" instance=ExtResource("1")] [node name="Tools" parent="DockableContainer" instance=ExtResource("1")]