mirror of
https://github.com/Relintai/material-maker.git
synced 2025-01-09 05:39:38 +01:00
Added menu to show/hide panes
This commit is contained in:
parent
48fbd55546
commit
3f679cc348
@ -6,6 +6,7 @@
|
||||
[node name="Library" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 2 )
|
||||
|
@ -13,6 +13,7 @@ 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 preview_2d
|
||||
var preview_3d
|
||||
|
||||
@ -49,6 +50,8 @@ const MENU = [
|
||||
|
||||
{ menu="View", command="view_center", shortcut="C", description="Center view" },
|
||||
{ menu="View", command="view_reset_zoom", shortcut="Control+0", description="Reset zoom" },
|
||||
{ menu="View" },
|
||||
{ menu="View", submenu="show_panes", description="Panes" },
|
||||
|
||||
{ menu="Tools", submenu="create", description="Create" },
|
||||
{ menu="Tools", command="create_subgraph", shortcut="Control+G", description="Create group" },
|
||||
@ -68,20 +71,6 @@ const MENU = [
|
||||
{ menu="Help", command="about", description="About" }
|
||||
]
|
||||
|
||||
const PANEL_POSITIONS = {
|
||||
TopLeft="VBoxContainer/Layout/Left/Top",
|
||||
BottomLeft="VBoxContainer/Layout/Left/Bottom",
|
||||
TopRight="VBoxContainer/Layout/SplitRight/Right/Top",
|
||||
BottomRight="VBoxContainer/Layout/SplitRight/Right/Bottom"
|
||||
}
|
||||
const PANELS = [
|
||||
{ name="Library", scene=preload("res://material_maker/library.tscn"), position="TopLeft" },
|
||||
{ name="Preview2D", scene=preload("res://material_maker/preview/preview_2d_panel.tscn"), position="BottomLeft" },
|
||||
{ name="Preview3D", scene=preload("res://material_maker/preview/preview_3d_panel.tscn"), position="BottomLeft" }
|
||||
]
|
||||
|
||||
var panels = {}
|
||||
|
||||
signal quit
|
||||
|
||||
var is_mac = false
|
||||
@ -137,17 +126,9 @@ func _ready() -> void:
|
||||
# Set window title
|
||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||
|
||||
# Create panels
|
||||
for panel_pos in PANEL_POSITIONS.keys():
|
||||
get_node(PANEL_POSITIONS[panel_pos]).set_tabs_rearrange_group(1)
|
||||
for panel in PANELS:
|
||||
var node = panel.scene.instance()
|
||||
node.name = panel.name
|
||||
var tab = get_node(PANEL_POSITIONS[panel.position])
|
||||
tab.add_child(node)
|
||||
panels[panel.name] = node
|
||||
preview_2d = panels["Preview2D"]
|
||||
preview_3d = panels["Preview3D"]
|
||||
layout.load_panes()
|
||||
preview_2d = layout.get_pane("Preview2D")
|
||||
preview_3d = layout.get_pane("Preview3D")
|
||||
|
||||
# Load recent projects
|
||||
load_recents()
|
||||
@ -263,6 +244,21 @@ func _on_SetTheme_id_pressed(id) -> void:
|
||||
set_theme(theme_name)
|
||||
config_cache.set_value("window", "theme", theme_name)
|
||||
|
||||
|
||||
func create_menu_show_panes(menu : PopupMenu) -> void:
|
||||
menu.clear()
|
||||
var panes = layout.get_pane_list()
|
||||
for i in range(panes.size()):
|
||||
menu.add_check_item(panes[i], i)
|
||||
menu.set_item_checked(i, layout.is_pane_visible(panes[i]))
|
||||
if !menu.is_connected("id_pressed", self, "_on_ShowPanes_id_pressed"):
|
||||
menu.connect("id_pressed", self, "_on_ShowPanes_id_pressed")
|
||||
|
||||
func _on_ShowPanes_id_pressed(id) -> void:
|
||||
var pane : String = layout.get_pane_list()[id]
|
||||
layout.set_pane_visible(pane, !layout.is_pane_visible(pane))
|
||||
print(pane)
|
||||
|
||||
func create_menu_create(menu) -> void:
|
||||
var gens = mm_loader.get_generator_list()
|
||||
menu.clear()
|
||||
|
@ -104,6 +104,7 @@ margin_right = 203.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/Left"]
|
||||
margin_top = 354.0
|
||||
|
@ -1,9 +1,52 @@
|
||||
extends HSplitContainer
|
||||
|
||||
const PANE_POSITIONS = {
|
||||
TopLeft="Left/Top",
|
||||
BottomLeft="Left/Bottom",
|
||||
TopRight="SplitRight/Right/Top",
|
||||
BottomRight="SplitRight/Right/Bottom"
|
||||
}
|
||||
const PANES = [
|
||||
{ name="Library", scene=preload("res://material_maker/library.tscn"), position="TopLeft" },
|
||||
{ name="Preview2D", scene=preload("res://material_maker/preview/preview_2d_panel.tscn"), position="BottomLeft" },
|
||||
{ name="Preview3D", scene=preload("res://material_maker/preview/preview_3d_panel.tscn"), position="BottomLeft" }
|
||||
]
|
||||
|
||||
var panes = {}
|
||||
|
||||
func load_panes() -> void:
|
||||
# Create panels
|
||||
for pane_pos in PANE_POSITIONS.keys():
|
||||
get_node(PANE_POSITIONS[pane_pos]).set_tabs_rearrange_group(1)
|
||||
for pane in PANES:
|
||||
var node = pane.scene.instance()
|
||||
node.name = pane.name
|
||||
var tab = get_node(PANE_POSITIONS[pane.position])
|
||||
tab.add_child(node)
|
||||
panes[pane.name] = node
|
||||
|
||||
func get_pane(n) -> Control:
|
||||
return panes[n]
|
||||
|
||||
func get_pane_list() -> Array:
|
||||
var panes_list = panes.keys()
|
||||
panes_list.sort()
|
||||
return panes_list
|
||||
|
||||
func is_pane_visible(pane_name : String) -> bool:
|
||||
return panes[pane_name].get_parent() != null
|
||||
|
||||
func set_pane_visible(pane_name : String, v : bool) -> void:
|
||||
var pane = panes[pane_name]
|
||||
if v:
|
||||
pane.get_meta("parent_tab_container").add_child(pane)
|
||||
else:
|
||||
pane.set_meta("parent_tab_container", pane.get_parent())
|
||||
pane.get_parent().remove_child(pane)
|
||||
|
||||
|
||||
func _on_Left_dragged(offset):
|
||||
func _on_Left_dragged(offset : int) -> void:
|
||||
print(offset)
|
||||
|
||||
func _on_Right_dragged(offset):
|
||||
func _on_Right_dragged(offset : int) -> void:
|
||||
print(offset)
|
||||
|
@ -1,20 +1,44 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://material_maker/preview/control_point.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://material_maker/preview/preview_2d.tscn" type="PackedScene" id=3]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 size;
|
||||
|
||||
void fragment() {
|
||||
float ms = max(size.x, size.y);
|
||||
vec2 uv = fract(0.5+1.2*(UV-vec2(0.5))*ms/size.yx);
|
||||
float is = min(size.x, size.y)/1.2;
|
||||
vec2 m2 = min(fract(uv), 1.0-fract(uv));
|
||||
vec4 image = texture(tex, uv);
|
||||
vec3 image_with_background = mix(vec3(mod(floor(uv.x*32.0)+floor(uv.y*32.0), 2.0)), image.xyz, image.a);
|
||||
float lines_color = 0.5*(cos(5.0*TIME+100.0*(uv.x+uv.y))+1.0);
|
||||
COLOR = vec4(mix(image_with_background, vec3(lines_color), step(is*min(m2.x, m2.y), 1.0)), 1.0);
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
resource_local_to_scene = true
|
||||
shader = SubResource( 1 )
|
||||
shader_param/size = Vector2( 585, 492 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 48, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 64, 16, 16 )
|
||||
|
||||
[node name="Preview2D" instance=ExtResource( 3 )]
|
||||
material = SubResource( 2 )
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
|
||||
[node name="P1" parent="." index="0" instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
@ -23,7 +47,7 @@ margin_left = 5.0
|
||||
margin_top = 29.0
|
||||
margin_right = 37.0
|
||||
margin_bottom = 61.0
|
||||
texture = SubResource( 1 )
|
||||
texture = SubResource( 3 )
|
||||
|
||||
[node name="P2" parent="." index="1" instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
@ -32,7 +56,7 @@ margin_left = 5.0
|
||||
margin_top = 29.0
|
||||
margin_right = 37.0
|
||||
margin_bottom = 61.0
|
||||
texture = SubResource( 1 )
|
||||
texture = SubResource( 3 )
|
||||
|
||||
[node name="Rect1" parent="." index="2" instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
@ -41,7 +65,7 @@ margin_left = 5.0
|
||||
margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 1
|
||||
|
||||
@ -53,7 +77,7 @@ margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
|
||||
@ -65,7 +89,7 @@ margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "Radius1"
|
||||
control_type = 2
|
||||
|
||||
@ -77,7 +101,7 @@ margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 3
|
||||
|
||||
@ -89,7 +113,7 @@ margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
|
||||
@ -101,6 +125,6 @@ margin_top = 29.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 45.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 2 )
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
|
@ -4,6 +4,16 @@
|
||||
[ext_resource path="res://material_maker/preview/preview_3d_ui.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="Preview3D" instance=ExtResource( 1 )]
|
||||
visible = true
|
||||
margin_left = 0.0
|
||||
margin_top = 0.0
|
||||
margin_right = 0.0
|
||||
margin_bottom = 0.0
|
||||
rect_min_size = Vector2( 250, 200 )
|
||||
|
||||
[node name="MaterialPreview" parent="." index="0"]
|
||||
size = Vector2( 1280, 720 )
|
||||
render_target_update_mode = 3
|
||||
|
||||
[node name="Preview3DUI" parent="." index="1" instance=ExtResource( 2 )]
|
||||
[connection signal="environment_selected" from="Preview3DUI" to="." method="_on_Environment_item_selected"]
|
||||
|
Loading…
Reference in New Issue
Block a user