@@ -41,12 +41,22 @@ var current_mode : String = "material"
4141var layout : Dictionary = {}
4242
4343var presets : Array [Dictionary ]
44+ var previous_layout : Dictionary
45+
4446
4547func _ready () -> void :
4648 previous_width = size .x
4749
4850func toggle_side_panels () -> void :
49- pass
51+ if not previous_layout .is_empty ():
52+ $ FlexibleLayout .init (previous_layout )
53+ previous_layout .clear ()
54+ else :
55+ var main_layout : Dictionary = {
56+ & "main" : { & "type" : "FlexTop" ,& "w" : 1073.0 , & "h" : 939.0 ,
57+ & "children" : [{ & "type" : "FlexMain" , & "w" : 1073.0 , & "h" : 939.0 , & "children" : [] }] }, & "windows" : [] }
58+ previous_layout = $ FlexibleLayout .serialize ()
59+ $ FlexibleLayout .init (main_layout )
5060
5161func load_panels () -> void :
5262 # Create panels
@@ -81,6 +91,8 @@ func load_panels() -> void:
8191
8292func save_config () -> void :
8393 layout [current_mode ] = $ FlexibleLayout .serialize ()
94+ if not previous_layout .is_empty ():
95+ layout [current_mode ] = previous_layout
8496 for mode in [ "material" , "paint" ]:
8597 if layout .has (mode ):
8698 mm_globals .config .set_value ("layout" , mode , JSON .stringify (layout [mode ]))
@@ -107,6 +119,7 @@ func is_panel_visible(panel_name : String) -> bool:
107119 return $ FlexibleLayout .flex_layout .is_panel_shown (panel_name )
108120
109121func set_panel_visible (panel_name : String , v : bool ) -> void :
122+ previous_layout .clear ()
110123 $ FlexibleLayout .show_panel (panel_name , v )
111124 $ FlexibleLayout .layout ()
112125
0 commit comments