init: 从 gilzoide/godot-dockable-container 提取的插件文件

This commit is contained in:
2026-05-27 14:45:42 +08:00
commit 4012a56327
31 changed files with 1823 additions and 0 deletions

63
samples/TestScene.gd Normal file
View File

@@ -0,0 +1,63 @@
extends VBoxContainer
const SAVED_LAYOUT_PATH := "user://layout.tres"
@onready var _container := $DockableContainers/DockableContainer as DockableContainer
@onready var _clone_control := $HBoxContainer/ControlPrefab as ColorRect
@onready var _checkbox_container := $HBoxContainer as HBoxContainer
func _ready() -> void:
if not OS.is_userfs_persistent():
$HBoxContainer/SaveLayoutButton.visible = false
$HBoxContainer/LoadLayoutButton.visible = false
var tabs := _container.get_tabs()
for i in tabs.size():
var checkbox := CheckBox.new()
checkbox.text = str(i)
checkbox.button_pressed = not _container.is_control_hidden(tabs[i])
checkbox.toggled.connect(_on_CheckButton_toggled.bind(tabs[i]))
_checkbox_container.add_child(checkbox)
func _on_add_pressed() -> void:
var control := _clone_control.duplicate()
control.get_node("Buttons/Rename").pressed.connect(
_on_control_rename_button_pressed.bind(control)
)
control.get_node("Buttons/Remove").pressed.connect(
_on_control_remove_button_pressed.bind(control)
)
control.color = Color(randf(), randf(), randf())
control.name = "Control0"
_container.add_child(control, true)
await _container.sort_children
_container.set_control_as_current_tab(control)
func _on_save_pressed() -> void:
if ResourceSaver.save(_container.layout, SAVED_LAYOUT_PATH) != OK:
print("ERROR")
func _on_load_pressed() -> void:
var res = load(SAVED_LAYOUT_PATH)
if res:
_container.set_layout(res.clone())
else:
print("Error")
func _on_control_rename_button_pressed(control: Control) -> void:
control.name = StringName(str(control.name) + " =D")
func _on_control_remove_button_pressed(control: Control) -> void:
control.get_parent().remove_child(control)
control.queue_free()
func _on_CheckButton_toggled(button_pressed: bool, tab: Control) -> void:
_container.set_control_hidden(tab, not button_pressed)

1
samples/TestScene.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bhop40eih06by

174
samples/TestScene.tscn Normal file
View File

@@ -0,0 +1,174 @@
[gd_scene format=3 uid="uid://drlvhuchtk6if"]
[ext_resource type="Script" uid="uid://ccdi3mi0a414a" path="res://addons/dockable_container/dockable_container.gd" id="1"]
[ext_resource type="Script" uid="uid://b1bj11c3wrsh3" path="res://addons/dockable_container/layout.gd" id="2"]
[ext_resource type="Script" uid="uid://bhop40eih06by" path="res://addons/dockable_container/samples/TestScene.gd" id="4"]
[ext_resource type="Script" uid="uid://btj8xjkmusjq5" path="res://addons/dockable_container/layout_split.gd" id="4_yhgfb"]
[ext_resource type="Script" uid="uid://d15h5pn8k8tjc" path="res://addons/dockable_container/layout_panel.gd" id="5"]
[sub_resource type="Resource" id="Resource_8aoc2"]
resource_name = "Tabs"
script = ExtResource("5")
names = PackedStringArray("Control0")
[sub_resource type="Resource" id="Resource_6kjom"]
resource_name = "Tabs"
script = ExtResource("5")
names = PackedStringArray("Control1", "Control2")
[sub_resource type="Resource" id="Resource_hl8y1"]
resource_name = "Split"
script = ExtResource("4_yhgfb")
direction = 1
first = SubResource("Resource_8aoc2")
second = SubResource("Resource_6kjom")
[sub_resource type="Resource" id="Resource_ybwqe"]
resource_name = "Layout"
script = ExtResource("2")
root = SubResource("Resource_hl8y1")
[sub_resource type="Resource" id="Resource_ntwfj"]
resource_name = "Tabs"
script = ExtResource("5")
names = PackedStringArray("Control3")
[sub_resource type="Resource" id="Resource_dmyvf"]
resource_name = "Tabs"
script = ExtResource("5")
names = PackedStringArray("Control4")
[sub_resource type="Resource" id="Resource_vag66"]
resource_name = "Split"
script = ExtResource("4_yhgfb")
direction = 1
percent = 0.281
first = SubResource("Resource_ntwfj")
second = SubResource("Resource_dmyvf")
[sub_resource type="Resource" id="Resource_4q660"]
resource_name = "Tabs"
script = ExtResource("5")
names = PackedStringArray("Control5")
[sub_resource type="Resource" id="Resource_jhibs"]
resource_name = "Split"
script = ExtResource("4_yhgfb")
first = SubResource("Resource_vag66")
second = SubResource("Resource_4q660")
[sub_resource type="Resource" id="Resource_xhxpg"]
resource_name = "Layout"
script = ExtResource("2")
root = SubResource("Resource_jhibs")
[node name="SampleScene" type="VBoxContainer" unique_id=63257421]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("4")
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=387084736]
layout_mode = 2
alignment = 1
[node name="AddControlButton" type="Button" parent="HBoxContainer" unique_id=2125688693]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
text = "(+) ADD CONTROL"
[node name="SaveLayoutButton" type="Button" parent="HBoxContainer" unique_id=1305135861]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
text = "Save Layout"
[node name="LoadLayoutButton" type="Button" parent="HBoxContainer" unique_id=1243058994]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
text = "Load Layout"
[node name="ControlPrefab" type="ColorRect" parent="HBoxContainer" unique_id=399318649]
visible = false
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(0.129412, 0.121569, 0.121569, 1)
[node name="Buttons" type="VBoxContainer" parent="HBoxContainer/ControlPrefab" unique_id=1055220509]
layout_mode = 0
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -65.5
offset_top = -22.0
offset_right = 65.5
offset_bottom = 22.0
[node name="Rename" type="Button" parent="HBoxContainer/ControlPrefab/Buttons" unique_id=1635652992]
layout_mode = 2
text = "Rename"
[node name="Remove" type="Button" parent="HBoxContainer/ControlPrefab/Buttons" unique_id=325010205]
layout_mode = 2
text = "REMOVE"
[node name="DockableContainers" type="HBoxContainer" parent="." unique_id=1263000341]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="DockableContainer" type="Container" parent="DockableContainers" unique_id=1541533577]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
layout = SubResource("Resource_ybwqe")
[node name="Control0" type="ColorRect" parent="DockableContainers/DockableContainer" unique_id=1755020147]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
[node name="Control1" type="ColorRect" parent="DockableContainers/DockableContainer" unique_id=1411986801]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(0.141176, 0.0745098, 0.603922, 1)
[node name="Control2" type="ColorRect" parent="DockableContainers/DockableContainer" unique_id=199396917]
visible = false
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(0.533333, 0.380392, 0.380392, 1)
[node name="Separator" type="ColorRect" parent="DockableContainers" unique_id=1232713094]
custom_minimum_size = Vector2(50, 0)
layout_mode = 2
color = Color(0, 0, 0, 1)
[node name="DockableContainer2" type="Container" parent="DockableContainers" unique_id=1148470831]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
layout = SubResource("Resource_xhxpg")
[node name="Control3" type="ColorRect" parent="DockableContainers/DockableContainer2" unique_id=209835842]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(0, 1, 0.905882, 1)
[node name="Control4" type="ColorRect" parent="DockableContainers/DockableContainer2" unique_id=1376035184]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(0, 0.698039, 0.0588235, 1)
[node name="Control5" type="ColorRect" parent="DockableContainers/DockableContainer2" unique_id=32573735]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
color = Color(1, 0.937255, 0, 1)
[connection signal="pressed" from="HBoxContainer/AddControlButton" to="." method="_on_add_pressed"]
[connection signal="pressed" from="HBoxContainer/SaveLayoutButton" to="." method="_on_save_pressed"]
[connection signal="pressed" from="HBoxContainer/LoadLayoutButton" to="." method="_on_load_pressed"]