Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a preview to layouts #787

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/UI/Dialogs/ManageLayouts.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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())
125 changes: 100 additions & 25 deletions src/UI/Dialogs/ManageLayouts.tscn
Original file line number Diff line number Diff line change
@@ -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 )
Expand All @@ -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
Expand Down Expand Up @@ -68,24 +139,28 @@ 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"]
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"]
Expand Down