mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Update the DockableContainer plugin
This commit is contained in:
parent
81dbc0177d
commit
66ea1fcfe9
|
@ -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: Based on [274ea7264440003071bcd024f31e130c984df3c6](https://github.com/gilzoide/godot-dockable-container/pull/27/commits/274ea7264440003071bcd024f31e130c984df3c6) (PR #27), but with changes in layout.gd that add a `save_on_change` variable and a `save()` method.
|
- Version: Based on [ddff84aa31e466101b4a75c7ff68d3a82701e387](https://github.com/gilzoide/godot-dockable-container/commit/ddff84aa31e466101b4a75c7ff68d3a82701e387), but with changes in layout.gd that add a `save_on_change` variable and a `save()` method.
|
||||||
- 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
|
||||||
|
|
|
@ -26,15 +26,21 @@ const DragNDropPanel := preload("drag_n_drop_panel.gd")
|
||||||
get:
|
get:
|
||||||
return _tabs_visible
|
return _tabs_visible
|
||||||
set(value):
|
set(value):
|
||||||
set_tabs_visible(value)
|
_tabs_visible = value
|
||||||
## Always ensure that tabs are visible if a panel has more than one tab.
|
for i in range(1, _panel_container.get_child_count()):
|
||||||
## Only takes effect is [member tabs_visible] is [code]false[/code].
|
var panel := _panel_container.get_child(i) as DockablePanel
|
||||||
@export var tabs_visible_if_more_than_one := false:
|
panel.show_tabs = _tabs_visible
|
||||||
|
## If [code]true[/code] and a panel only has one tab, it keeps that tab hidden even if
|
||||||
|
## [member tabs_visible] is [code]true[/code].
|
||||||
|
## Only takes effect is [member tabs_visible] is [code]true[/code].
|
||||||
|
@export var hide_single_tab := false:
|
||||||
get:
|
get:
|
||||||
return _tabs_visible_if_more_than_one
|
return _hide_single_tab
|
||||||
set(value):
|
set(value):
|
||||||
_tabs_visible_if_more_than_one = value
|
_hide_single_tab = value
|
||||||
set_tabs_visible(_tabs_visible)
|
for i in range(1, _panel_container.get_child_count()):
|
||||||
|
var panel := _panel_container.get_child(i) as DockablePanel
|
||||||
|
panel.hide_single_tab = _hide_single_tab
|
||||||
@export var rearrange_group := 0
|
@export var rearrange_group := 0
|
||||||
@export var layout := DockableLayout.new():
|
@export var layout := DockableLayout.new():
|
||||||
get:
|
get:
|
||||||
|
@ -54,7 +60,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 _hide_single_tab := 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 := {}
|
||||||
|
@ -193,20 +199,6 @@ func set_layout(value: DockableLayout) -> void:
|
||||||
queue_sort()
|
queue_sort()
|
||||||
|
|
||||||
|
|
||||||
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) 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_tabs_visible() -> bool:
|
|
||||||
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:
|
||||||
_use_hidden_tabs_for_min_size = value
|
_use_hidden_tabs_for_min_size = value
|
||||||
for i in range(1, _panel_container.get_child_count()):
|
for i in range(1, _panel_container.get_child_count()):
|
||||||
|
@ -330,8 +322,6 @@ 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
|
||||||
|
@ -407,7 +397,8 @@ func _get_panel(idx: int) -> DockablePanel:
|
||||||
return _panel_container.get_child(idx)
|
return _panel_container.get_child(idx)
|
||||||
var panel := DockablePanel.new()
|
var panel := DockablePanel.new()
|
||||||
panel.tab_alignment = _tab_align
|
panel.tab_alignment = _tab_align
|
||||||
panel.tabs_visible = _tabs_visible
|
panel.show_tabs = _tabs_visible
|
||||||
|
panel.hide_single_tab = _hide_single_tab
|
||||||
panel.use_hidden_tabs_for_min_size = _use_hidden_tabs_for_min_size
|
panel.use_hidden_tabs_for_min_size = _use_hidden_tabs_for_min_size
|
||||||
panel.set_tabs_rearrange_group(maxi(0, rearrange_group))
|
panel.set_tabs_rearrange_group(maxi(0, rearrange_group))
|
||||||
_panel_container.add_child(panel)
|
_panel_container.add_child(panel)
|
||||||
|
|
|
@ -8,8 +8,22 @@ var leaf: DockableLayoutPanel:
|
||||||
return get_leaf()
|
return get_leaf()
|
||||||
set(value):
|
set(value):
|
||||||
set_leaf(value)
|
set_leaf(value)
|
||||||
|
var show_tabs := true:
|
||||||
|
get:
|
||||||
|
return _show_tabs
|
||||||
|
set(value):
|
||||||
|
_show_tabs = value
|
||||||
|
_handle_tab_visibility()
|
||||||
|
var hide_single_tab := false:
|
||||||
|
get:
|
||||||
|
return _hide_single_tab
|
||||||
|
set(value):
|
||||||
|
_hide_single_tab = value
|
||||||
|
_handle_tab_visibility()
|
||||||
|
|
||||||
var _leaf: DockableLayoutPanel
|
var _leaf: DockableLayoutPanel
|
||||||
|
var _show_tabs := true
|
||||||
|
var _hide_single_tab := false
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -48,6 +62,7 @@ func track_nodes(nodes: Array[Control], new_leaf: DockableLayoutPanel) -> void:
|
||||||
ref_control.reference_to = nodes[i]
|
ref_control.reference_to = nodes[i]
|
||||||
set_tab_title(i, nodes[i].name)
|
set_tab_title(i, nodes[i].name)
|
||||||
set_leaf(new_leaf)
|
set_leaf(new_leaf)
|
||||||
|
_handle_tab_visibility()
|
||||||
|
|
||||||
|
|
||||||
func get_child_rect() -> Rect2:
|
func get_child_rect() -> Rect2:
|
||||||
|
@ -84,3 +99,10 @@ func _on_tab_changed(tab: int) -> void:
|
||||||
var name_index_in_leaf := _leaf.find_name(tab_name)
|
var name_index_in_leaf := _leaf.find_name(tab_name)
|
||||||
if name_index_in_leaf != tab: # NOTE: this handles added tabs (index == -1)
|
if name_index_in_leaf != tab: # NOTE: this handles added tabs (index == -1)
|
||||||
tab_layout_changed.emit(tab)
|
tab_layout_changed.emit(tab)
|
||||||
|
|
||||||
|
|
||||||
|
func _handle_tab_visibility() -> void:
|
||||||
|
if _hide_single_tab and get_tab_count() == 1:
|
||||||
|
tabs_visible = false
|
||||||
|
else:
|
||||||
|
tabs_visible = _show_tabs
|
||||||
|
|
|
@ -536,8 +536,8 @@ func window_menu_id_pressed(id: int) -> void:
|
||||||
Global.WindowMenu.WINDOW_OPACITY:
|
Global.WindowMenu.WINDOW_OPACITY:
|
||||||
window_opacity_dialog.popup()
|
window_opacity_dialog.popup()
|
||||||
Global.WindowMenu.MOVABLE_PANELS:
|
Global.WindowMenu.MOVABLE_PANELS:
|
||||||
main_ui.tabs_visible = !main_ui.tabs_visible
|
main_ui.hide_single_tab = not main_ui.hide_single_tab
|
||||||
window_menu.set_item_checked(id, main_ui.tabs_visible)
|
window_menu.set_item_checked(id, not main_ui.hide_single_tab)
|
||||||
Global.WindowMenu.ZEN_MODE:
|
Global.WindowMenu.ZEN_MODE:
|
||||||
_toggle_zen_mode()
|
_toggle_zen_mode()
|
||||||
Global.WindowMenu.FULLSCREEN_MODE:
|
Global.WindowMenu.FULLSCREEN_MODE:
|
||||||
|
|
|
@ -252,8 +252,7 @@ offset_right = -8.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
script = ExtResource("35")
|
script = ExtResource("35")
|
||||||
tabs_visible = false
|
hide_single_tab = true
|
||||||
tabs_visible_if_more_than_one = true
|
|
||||||
layout = SubResource("Resource_b6o2t")
|
layout = SubResource("Resource_b6o2t")
|
||||||
clone_layout_on_ready = false
|
clone_layout_on_ready = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue