mirror of
https://github.com/Relintai/material-maker.git
synced 2025-01-09 05:39:38 +01:00
Added autolayout of empty panes
This commit is contained in:
parent
3eb7c1a50b
commit
743f5fa8d2
@ -11,9 +11,9 @@ var updating : bool = false
|
||||
var need_update : bool = false
|
||||
|
||||
onready var projects = $VBoxContainer/Layout/SplitRight/ProjectsPane/Projects
|
||||
onready var library = $VBoxContainer/Layout/Left/Top/Library
|
||||
|
||||
onready var layout = $VBoxContainer/Layout
|
||||
var library
|
||||
var preview_2d
|
||||
var preview_3d
|
||||
|
||||
@ -127,6 +127,7 @@ func _ready() -> void:
|
||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||
|
||||
layout.load_panes()
|
||||
library = layout.get_pane("Library")
|
||||
preview_2d = layout.get_pane("Preview2D")
|
||||
preview_3d = layout.get_pane("Preview3D")
|
||||
|
||||
|
@ -89,18 +89,18 @@ margin_top = 26.0
|
||||
margin_right = 1268.0
|
||||
margin_bottom = 708.0
|
||||
size_flags_vertical = 3
|
||||
split_offset = -1039
|
||||
split_offset = -1118
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Left" type="VSplitContainer" parent="VBoxContainer/Layout"]
|
||||
margin_right = 203.0
|
||||
margin_right = 124.0
|
||||
margin_bottom = 682.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
split_offset = 312
|
||||
|
||||
[node name="Top" type="TabContainer" parent="VBoxContainer/Layout/Left"]
|
||||
margin_right = 203.0
|
||||
margin_right = 124.0
|
||||
margin_bottom = 346.0
|
||||
tab_align = 0
|
||||
drag_to_rearrange_enabled = true
|
||||
@ -108,19 +108,20 @@ use_hidden_tabs_for_min_size = true
|
||||
|
||||
[node name="Bottom" type="TabContainer" parent="VBoxContainer/Layout/Left"]
|
||||
margin_top = 354.0
|
||||
margin_right = 203.0
|
||||
margin_right = 124.0
|
||||
margin_bottom = 682.0
|
||||
tab_align = 0
|
||||
drag_to_rearrange_enabled = true
|
||||
use_hidden_tabs_for_min_size = true
|
||||
|
||||
[node name="SplitRight" type="HSplitContainer" parent="VBoxContainer/Layout"]
|
||||
margin_left = 211.0
|
||||
margin_left = 132.0
|
||||
margin_right = 1268.0
|
||||
margin_bottom = 682.0
|
||||
split_offset = -226
|
||||
split_offset = 133
|
||||
|
||||
[node name="ProjectsPane" type="Control" parent="VBoxContainer/Layout/SplitRight"]
|
||||
margin_right = 562.0
|
||||
margin_right = 981.0
|
||||
margin_bottom = 682.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
@ -240,29 +241,33 @@ margin_right = 297.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="Right" type="VSplitContainer" parent="VBoxContainer/Layout/SplitRight"]
|
||||
margin_left = 570.0
|
||||
margin_right = 1057.0
|
||||
margin_left = 989.0
|
||||
margin_right = 1136.0
|
||||
margin_bottom = 682.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
split_offset = 312
|
||||
|
||||
[node name="Top" type="TabContainer" parent="VBoxContainer/Layout/SplitRight/Right"]
|
||||
margin_right = 487.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 346.0
|
||||
tab_align = 0
|
||||
drag_to_rearrange_enabled = true
|
||||
use_hidden_tabs_for_min_size = true
|
||||
|
||||
[node name="Bottom" type="TabContainer" parent="VBoxContainer/Layout/SplitRight/Right"]
|
||||
margin_top = 354.0
|
||||
margin_right = 487.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 682.0
|
||||
tab_align = 0
|
||||
drag_to_rearrange_enabled = true
|
||||
use_hidden_tabs_for_min_size = true
|
||||
|
||||
[node name="NodeFactory" type="Node" parent="."]
|
||||
script = ExtResource( 9 )
|
||||
[connection signal="dragged" from="VBoxContainer/Layout" to="VBoxContainer/Layout" method="_on_Left_dragged"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/Layout/Left/Top" to="VBoxContainer/Layout" method="_on_tab_changed"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/Layout/Left/Bottom" to="VBoxContainer/Layout" method="_on_tab_changed"]
|
||||
[connection signal="dragged" from="VBoxContainer/Layout/SplitRight" to="VBoxContainer/Layout" method="_on_Right_dragged"]
|
||||
[connection signal="resized" from="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview2D" to="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview2D" method="on_resized"]
|
||||
[connection signal="need_update" from="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview3D" to="." method="update_preview_3d"]
|
||||
@ -278,3 +283,5 @@ script = ExtResource( 9 )
|
||||
[connection signal="environment_selected" from="VBoxContainer/Layout/SplitRight/ProjectsPane/PreviewUI/Panel/HBoxContainer/Preview3DUI" to="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview3D" method="_on_Environment_item_selected"]
|
||||
[connection signal="model_selected" from="VBoxContainer/Layout/SplitRight/ProjectsPane/PreviewUI/Panel/HBoxContainer/Preview3DUI" to="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview3D" method="_on_Model_item_selected"]
|
||||
[connection signal="rotate_toggled" from="VBoxContainer/Layout/SplitRight/ProjectsPane/PreviewUI/Panel/HBoxContainer/Preview3DUI" to="VBoxContainer/Layout/SplitRight/ProjectsPane/Preview3D" method="_on_Rotate_toggled"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/Layout/SplitRight/Right/Top" to="VBoxContainer/Layout" method="_on_tab_changed"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/Layout/SplitRight/Right/Bottom" to="VBoxContainer/Layout" method="_on_tab_changed"]
|
||||
|
@ -24,6 +24,7 @@ func load_panes() -> void:
|
||||
var tab = get_node(PANE_POSITIONS[pane.position])
|
||||
tab.add_child(node)
|
||||
panes[pane.name] = node
|
||||
update_panes()
|
||||
|
||||
func get_pane(n) -> Control:
|
||||
return panes[n]
|
||||
@ -43,10 +44,44 @@ func set_pane_visible(pane_name : String, v : bool) -> void:
|
||||
else:
|
||||
pane.set_meta("parent_tab_container", pane.get_parent())
|
||||
pane.get_parent().remove_child(pane)
|
||||
update_panes()
|
||||
|
||||
func update_panes() -> void:
|
||||
var left_width = $Left.rect_size.x
|
||||
var left_requested = left_width
|
||||
var right_width = $SplitRight/Right.rect_size.x
|
||||
var right_requested = right_width
|
||||
if $Left/Top.get_tab_count() == 0:
|
||||
if $Left/Bottom.get_tab_count() == 0:
|
||||
left_requested = 10
|
||||
$Left.split_offset -= ($Left/Top.rect_size.y-$Left/Bottom.rect_size.y)/2
|
||||
$Left.clamp_split_offset()
|
||||
else:
|
||||
$Left.split_offset -= $Left/Top.rect_size.y-10
|
||||
$Left.clamp_split_offset()
|
||||
elif $Left/Bottom.get_tab_count() == 0:
|
||||
$Left.split_offset += $Left/Bottom.rect_size.y-10
|
||||
$Left.clamp_split_offset()
|
||||
if $SplitRight/Right/Top.get_tab_count() == 0:
|
||||
if $SplitRight/Right/Bottom.get_tab_count() == 0:
|
||||
right_requested = 10
|
||||
$SplitRight/Right.split_offset -= ($SplitRight/Right/Top.rect_size.y-$SplitRight/Right/Bottom.rect_size.y)/2
|
||||
$SplitRight/Right.clamp_split_offset()
|
||||
else:
|
||||
$SplitRight/Right.split_offset -= $SplitRight/Right/Top.rect_size.y-10
|
||||
$SplitRight/Right.clamp_split_offset()
|
||||
elif $SplitRight/Right/Bottom.get_tab_count() == 0:
|
||||
$SplitRight/Right.split_offset += $SplitRight/Right/Bottom.rect_size.y-10
|
||||
$SplitRight/Right.clamp_split_offset()
|
||||
split_offset += left_requested - left_width + right_requested - right_width
|
||||
clamp_split_offset()
|
||||
$SplitRight.split_offset += right_width - right_requested
|
||||
|
||||
func _on_Left_dragged(offset : int) -> void:
|
||||
print(offset)
|
||||
$Left.clamp_split_offset()
|
||||
|
||||
func _on_Right_dragged(offset : int) -> void:
|
||||
print(offset)
|
||||
$SplitRight/Right.clamp_split_offset()
|
||||
|
||||
func _on_tab_changed(_tab):
|
||||
update_panes()
|
||||
|
Loading…
Reference in New Issue
Block a user