Skip to content

Commit f795e7e

Browse files
authored
Implemented side panels toggling (contributed by williamchange)
Implemented side panels toggling
2 parents 652b98b + f7ac3fe commit f795e7e

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

material_maker/doc/user_interface_main_menu.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ View menu
9797

9898
* *Reset zoom* Resets the zoom level of the current material graph view
9999

100-
* *Show/Hide side panels* (or the *Control+SpaceBar* keyboard shortcut) can
101-
be used to hide the side panels so the space available for the main panel
100+
* *Show/Hide side panels* (or the *Control/Cmd+Alt+SpaceBar* keyboard shortcut) can
101+
be used to hide the other panels so the space available for the graph panel
102102
is maximized (which can be useful on smaller displays).
103103

104104
* the *Panels* submenu can be used to show or hide all side panels

material_maker/doc/user_interface_shortcuts.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ General
3434
+-------------------------------------------------------+----------------------------------------------------+
3535
| :kbd:`Ctrl/Cmd-E` | Export material again |
3636
+-------------------------------------------------------+----------------------------------------------------+
37+
| :kbd:`Ctrl/Cmd-Alt-Space` | Toggle side panels to maximize graph area |
38+
+-------------------------------------------------------+----------------------------------------------------+
39+
3740

3841
Graph Editor
3942
++++++++++++

material_maker/main_window.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const MENU : Array[Dictionary] = [
101101
{ menu="View/Center view", command="view_center", shortcut="C" },
102102
{ menu="View/Reset zoom", command="view_reset_zoom", shortcut="Control+0" },
103103
{ menu="View/-" },
104-
# { menu="View/Show or Hide side panels", command="toggle_side_panels", shortcut="Control+Space" },
104+
{ menu="View/Show or Hide side panels", command="toggle_side_panels", shortcut="Alt+Control+Space" },
105105
{ menu="View/Panels", submenu="show_panels" },
106106
{ menu="View/Presets", submenu="panels_preset" },
107107
{ menu="View/Reset Panels", command="view_reset_panels" },

material_maker/main_window_layout.gd

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,22 @@ var current_mode : String = "material"
4141
var layout : Dictionary = {}
4242

4343
var presets : Array[Dictionary]
44+
var previous_layout : Dictionary
45+
4446

4547
func _ready() -> void:
4648
previous_width = size.x
4749

4850
func 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

5161
func load_panels() -> void:
5262
# Create panels
@@ -81,6 +91,8 @@ func load_panels() -> void:
8191

8292
func 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

109121
func 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

Comments
 (0)