Skip to content

Commit

Permalink
Merge pull request #736 from Jowan-Spooner/default-layout
Browse files Browse the repository at this point in the history
Add a basic default layout for the material mode
  • Loading branch information
RodZill4 authored Jan 14, 2025
2 parents c759fbc + b425640 commit 5f26942
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 23 additions & 1 deletion material_maker/main_window_layout.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ const PANELS = [
{ name="Layers", scene=preload("res://material_maker/panels/layers/layers.tscn"), position="BottomRight" },
{ name="Parameters", scene=preload("res://material_maker/panels/parameters/parameters.tscn"), position="TopRight" },
]

var default_material_layout := {
&"main": { &"type": "FlexTop", &"w": 1900.0, &"h": 939.0, &"children": [
{ &"type": "FlexSplit", &"w": 1900.0, &"h": 939.0, &"children": [
{ &"type": "FlexTab", &"w": 373.0, &"h": 939.0, &"children": [], &"tabs": [
&"Library", &"Hierarchy"], &"current": 0 },
{ &"type": "FlexMain", &"w": 1073.0, &"h": 939.0, &"children": [] },
{ &"type": "FlexSplit", &"w": 434.0, &"h": 939.0, &"children": [
{ &"type": "FlexTab", &"w": 434.0, &"h": 501.0, &"children": [], &"tabs": [
&"Preview2D", &"Histogram"], &"current": 0 },
{ &"type": "FlexTab", &"w": 434.0, &"h": 427.0, &"children": [], &"tabs": [
&"Preview3D", &"Preview2D (2)", &"Reference"], &"current": 0 }
], &"dir": "v" }], &"dir": "h" }]}, &"windows": [] }

var default_paint_layout : Dictionary = { main={ children=[ { children=[ { children=[], current=0, h=766.0, tabs=["Brushes"], type="FlexTab", w=279.0 }, { children=[], h=766.0, type="FlexMain", w=844.0 }, { children=[ { children=[], current=0, h=370.0, tabs=["Parameters"], type="FlexTab", w=240.0 }, { children=[], current=0, h=386.0, tabs=["Layers"], type="FlexTab", w=240.0 }], dir="v", h=766.0, type="FlexSplit", w=240.0 }], dir="h", h=766.0, type="FlexSplit", w=1383.0 }], h=766.0, type="FlexTop", w=1383.0 }, windows=[] }

const HIDE_PANELS = {
material=[ "Brushes", "Layers", "Parameters" ],
paint=[ "Preview3D", "Histogram", "Hierarchy" ]
Expand Down Expand Up @@ -41,18 +57,24 @@ func load_panels() -> void:
node.set(p, panel.parameters[p])
panels[panel.name] = node
$FlexibleLayout.add(panel.name, node)
var current_config = null

for mode in [ "material", "paint" ]:
if mm_globals.config.has_section_key("layout", mode):
layout[mode] = JSON.parse_string(mm_globals.config.get_value("layout", mode))
elif mode == "material":
layout[mode] = default_material_layout
elif mode == "paint":
layout[mode] = default_paint_layout
$FlexibleLayout.init(layout[current_mode] if layout.has(current_mode) else null)


func save_config() -> void:
layout[current_mode] = $FlexibleLayout.serialize()
for mode in [ "material", "paint" ]:
if layout.has(mode):
mm_globals.config.set_value("layout", mode, JSON.stringify(layout[mode]))


func get_panel(n) -> Control:
if panels.has(n):
return panels[n]
Expand Down
3 changes: 2 additions & 1 deletion material_maker/widgets/tabs/tabs.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Panel

var current_tab : int = -1 :
var current_tab : int = -1 :
get:
return current_tab
set(new_value):
Expand Down Expand Up @@ -31,6 +31,7 @@ func add_tab(control, legible_unique_name = false) -> void:
move_child(control, $TabBar.get_tab_count())
$TabBar.add_tab(control.name)
control.visible = false
_on_Projects_resized()

func set_current_tab(t : int):
current_tab = t
Expand Down

0 comments on commit 5f26942

Please sign in to comment.