diff --git a/src/UI/Dialogs/ManageLayouts.gd b/src/UI/Dialogs/ManageLayouts.gd index 0f33b960c..52cdaed44 100644 --- a/src/UI/Dialogs/ManageLayouts.gd +++ b/src/UI/Dialogs/ManageLayouts.gd @@ -3,17 +3,21 @@ extends AcceptDialog var layout_selected := -1 var is_editing := false -onready var layout_list: ItemList = $VBoxContainer/SavedLayouts +onready var layout_list: ItemList = find_node("SavedLayouts") onready var edit_layout: Button = find_node("EditLayout") onready var delete_layout: Button = find_node("DeleteLayout") onready var layout_settings: ConfirmationDialog = $LayoutSettings onready var layout_name: LineEdit = $LayoutSettings/LayoutName onready var delete_confirmation: ConfirmationDialog = $DeleteConfirmation +onready var mimic_ui = find_node("LayoutPreview") func _on_ManageLayouts_about_to_show() -> void: for layout in Global.top_menu_container.layouts: layout_list.add_item(layout[0]) + refresh_preview() + if layout_selected != -1: + layout_list.select(layout_selected) func _on_ManageLayouts_popup_hide() -> void: @@ -29,6 +33,7 @@ func _on_SavedLayouts_item_selected(index: int) -> void: layout_selected = index edit_layout.disabled = index < Global.top_menu_container.default_layout_size delete_layout.disabled = index < Global.top_menu_container.default_layout_size + refresh_preview() func _on_SavedLayouts_nothing_selected() -> void: @@ -93,3 +98,21 @@ func _on_DeleteConfirmation_confirmed() -> void: layout_selected = -1 edit_layout.disabled = true delete_layout.disabled = true + refresh_preview() + + +func refresh_preview(): + for tab in mimic_ui.get_tabs(): + mimic_ui.remove_child(tab) + for item in Global.top_menu_container.ui.get_tabs(): + var box := TextEdit.new() + box.name = item.name + box.text = item.name + box.wrap_enabled = true + box.readonly = true + mimic_ui.add_child(box) + if layout_selected == -1: + mimic_ui.visible = false + return + mimic_ui.visible = true + mimic_ui.set_layout(Global.top_menu_container.layouts[layout_selected][1].clone()) diff --git a/src/UI/Dialogs/ManageLayouts.tscn b/src/UI/Dialogs/ManageLayouts.tscn index 86c283b64..08d568159 100644 --- a/src/UI/Dialogs/ManageLayouts.tscn +++ b/src/UI/Dialogs/ManageLayouts.tscn @@ -1,10 +1,26 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://src/UI/Dialogs/ManageLayouts.gd" type="Script" id=1] +[ext_resource path="res://addons/dockable_container/layout_panel.gd" type="Script" id=2] +[ext_resource path="res://addons/dockable_container/layout.gd" type="Script" id=3] +[ext_resource path="res://addons/dockable_container/dockable_container.gd" type="Script" id=4] + +[sub_resource type="Resource" id=1] +resource_name = "Tabs" +script = ExtResource( 2 ) +names = PoolStringArray( ) +current_tab = -1 + +[sub_resource type="Resource" id=2] +resource_name = "Layout" +script = ExtResource( 3 ) +root = SubResource( 1 ) +hidden_tabs = { +} [node name="ManageLayouts" type="AcceptDialog"] -margin_right = 191.0 -margin_bottom = 217.0 +margin_right = 543.0 +margin_bottom = 562.0 window_title = "Manage Layouts" resizable = true script = ExtResource( 1 ) @@ -16,29 +32,84 @@ margin_left = 8.0 margin_top = 8.0 margin_right = -8.0 margin_bottom = -36.0 -__meta__ = { -"_edit_use_anchors_": false -} -[node name="Label" type="Label" parent="VBoxContainer"] -margin_right = 200.0 +[node name="PreviewHeader" type="HBoxContainer" parent="VBoxContainer"] +margin_right = 527.0 margin_bottom = 14.0 -text = "Layouts" -__meta__ = { -"_edit_use_anchors_": false -} +custom_constants/separation = 0 -[node name="SavedLayouts" type="ItemList" parent="VBoxContainer"] +[node name="Label" type="Label" parent="VBoxContainer/PreviewHeader"] +margin_right = 50.0 +margin_bottom = 14.0 +theme_type_variation = "Header" +text = "Preview" + +[node name="HSeparator" type="HSeparator" parent="VBoxContainer/PreviewHeader"] +margin_left = 50.0 +margin_right = 527.0 +margin_bottom = 14.0 +size_flags_horizontal = 3 + +[node name="PreviewInstruction" type="Label" parent="VBoxContainer"] +self_modulate = Color( 0.658824, 1, 0.286275, 1 ) margin_top = 18.0 -margin_right = 200.0 -margin_bottom = 149.0 -rect_min_size = Vector2( 0, 20 ) +margin_right = 527.0 +margin_bottom = 32.0 +text = "This is a preview (changing this won't change the Layout)" +align = 1 +autowrap = true + +[node name="PreviewContainer" type="ScrollContainer" parent="VBoxContainer"] +margin_top = 36.0 +margin_right = 527.0 +margin_bottom = 354.0 size_flags_vertical = 3 +[node name="LayoutPreview" type="Container" parent="VBoxContainer/PreviewContainer"] +margin_right = 527.0 +margin_bottom = 318.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource( 4 ) +tabs_visible = false +layout = SubResource( 2 ) + +[node name="LayoutsHeader" type="HBoxContainer" parent="VBoxContainer"] +margin_top = 358.0 +margin_right = 527.0 +margin_bottom = 372.0 +custom_constants/separation = 0 + +[node name="Label" type="Label" parent="VBoxContainer/LayoutsHeader"] +margin_right = 49.0 +margin_bottom = 14.0 +theme_type_variation = "Header" +text = "Layouts" + +[node name="HSeparator" type="HSeparator" parent="VBoxContainer/LayoutsHeader"] +margin_left = 49.0 +margin_right = 527.0 +margin_bottom = 14.0 +size_flags_horizontal = 3 + +[node name="LayoutInstruction" type="Label" parent="VBoxContainer"] +self_modulate = Color( 0.658824, 1, 0.286275, 1 ) +margin_top = 376.0 +margin_right = 527.0 +margin_bottom = 390.0 +text = "Double click to set as new startup layout" +autowrap = true + +[node name="SavedLayouts" type="ItemList" parent="VBoxContainer"] +margin_top = 394.0 +margin_right = 527.0 +margin_bottom = 494.0 +rect_min_size = Vector2( 0, 100 ) + [node name="ButtonsContainer" type="HBoxContainer" parent="VBoxContainer"] -margin_top = 153.0 -margin_right = 200.0 -margin_bottom = 173.0 +margin_top = 498.0 +margin_right = 527.0 +margin_bottom = 518.0 [node name="AddLayout" type="Button" parent="VBoxContainer/ButtonsContainer"] margin_right = 37.0 @@ -68,8 +139,9 @@ text = "Delete" [node name="LayoutSettings" type="ConfirmationDialog" parent="."] margin_left = 8.0 margin_top = 8.0 -margin_right = 208.0 -margin_bottom = 181.0 +margin_right = 535.0 +margin_bottom = 526.0 +rect_min_size = Vector2( 172, 60.2 ) resizable = true [node name="LayoutName" type="LineEdit" parent="LayoutSettings"] @@ -77,15 +149,18 @@ anchor_top = 0.5 anchor_right = 1.0 anchor_bottom = 0.5 margin_left = 8.0 -margin_top = -78.5 +margin_top = -251.0 margin_right = -8.0 -margin_bottom = 50.5 +margin_bottom = 223.0 size_flags_horizontal = 3 placeholder_text = "Insert name" [node name="DeleteConfirmation" type="ConfirmationDialog" parent="."] -margin_right = 200.0 -margin_bottom = 70.0 +margin_left = 8.0 +margin_top = 8.0 +margin_right = 535.0 +margin_bottom = 526.0 +rect_min_size = Vector2( 172, 60.2 ) dialog_text = "Are you sure you want to delete this layout?" [connection signal="about_to_show" from="." to="." method="_on_ManageLayouts_about_to_show"]