Fixed control label edition in remote

This commit is contained in:
RodZill4 2019-10-10 22:43:34 +02:00
parent 825d98e0fe
commit 19b9d804b9
8 changed files with 131 additions and 281 deletions

View File

@ -92,6 +92,9 @@ func create_config_control(label):
widgets.push_back({ label=label, type="config_control", linked_widgets=[], configurations={} })
return index
func set_label(index, new_label):
widgets[index].label = new_label
func can_link_parameter(index, generator, param):
return true

View File

@ -112,7 +112,8 @@ func update_view(g):
clear_view()
generator = g
update_graph(generator.get_children(), generator.connections)
$ButtonUp.visible = generator != top_generator
$SubGraphUI.visible = generator != top_generator
$SubGraphUI/Label.text = generator.label
center_view()
func clear_material():
@ -285,6 +286,9 @@ func on_ButtonUp_pressed():
if generator != top_generator && generator.get_parent() is MMGenGraph:
call_deferred("update_view", generator.get_parent())
func _on_Label_text_changed(new_text):
generator.label = new_text
# Create subgraph
func create_subgraph():
@ -293,3 +297,5 @@ func create_subgraph():
generators.push_back(n.generator)
generator.create_subgraph(generators)
update_view(generator)

View File

@ -14,15 +14,25 @@ script = ExtResource( 1 )
wait_time = 0.2
one_shot = true
[node name="ButtonUp" type="Button" parent="."]
[node name="SubGraphUI" type="HBoxContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -44.0
margin_top = 4.0
margin_right = -14.0
margin_left = -197.0
margin_right = -13.0
margin_bottom = 24.0
[node name="Label" type="LineEdit" parent="SubGraphUI"]
margin_right = 150.0
margin_bottom = 24.0
rect_min_size = Vector2( 150, 0 )
[node name="ButtonUp" type="Button" parent="SubGraphUI"]
margin_left = 154.0
margin_right = 184.0
margin_bottom = 24.0
text = "Up"
[connection signal="connection_request" from="." to="." method="connect_node"]
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
[connection signal="pressed" from="ButtonUp" to="." method="on_ButtonUp_pressed"]
[connection signal="text_changed" from="SubGraphUI/Label" to="." method="_on_Label_text_changed"]
[connection signal="pressed" from="SubGraphUI/ButtonUp" to="." method="on_ButtonUp_pressed"]

View File

@ -10,6 +10,7 @@ func add_control(text, control):
var index = grid.get_child_count() / 4
var label = preload("res://addons/material_maker/widgets/linked_widgets/editable_label.tscn").instance()
label.set_text(text)
label.connect("label_changed", self, "on_label_changed", [ index ])
grid.add_child(label)
grid.add_child(control)
control.connect("mouse_entered", self, "on_enter_widget", [ control ])
@ -85,6 +86,9 @@ func _on_value_changed(new_value, variable):
func do_add_configuration(config_name, param_index):
generator.add_configuration(param_index, config_name)
func on_label_changed(new_name, index):
generator.set_label(index, new_name)
func _on_AddLink_pressed():
var widget = Control.new()
add_control("Unnamed", widget)

View File

@ -1,338 +1,132 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://addons/material_maker/widgets/about.gd" type="Script" id=1]
[ext_resource path="res://addons/material_maker/icons/icon.png" type="Texture" id=2]
[ext_resource path="res://addons/material_maker/widgets/icon.png" type="Texture" id=3]
[ext_resource path="res://addons/material_maker/widgets/facebook.png" type="Texture" id=4]
[ext_resource path="res://addons/material_maker/widgets/twitter.png" type="Texture" id=5]
[ext_resource path="res://addons/material_maker/widgets/youtube.png" type="Texture" id=6]
[ext_resource path="res://addons/material_maker/widgets/github.png" type="Texture" id=7]
[ext_resource path="res://rodz_labs_logo.png" type="Texture" id=4]
[ext_resource path="res://addons/material_maker/widgets/facebook.png" type="Texture" id=5]
[ext_resource path="res://addons/material_maker/widgets/twitter.png" type="Texture" id=6]
[ext_resource path="res://addons/material_maker/widgets/youtube.png" type="Texture" id=7]
[ext_resource path="res://addons/material_maker/widgets/github.png" type="Texture" id=8]
[node name="About" type="WindowDialog" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 152.0
margin_bottom = 191.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
popup_exclusive = false
[node name="About" type="WindowDialog"]
visible = true
margin_right = 138.0
margin_bottom = 241.0
window_title = "About..."
resizable = false
script = ExtResource( 1 )
_sections_unfolded = [ "Anchor", "custom_styles" ]
[node name="VBoxContainer" type="VBoxContainer" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
custom_constants/separation = 8
[node name="VBoxContainer1" type="VBoxContainer" parent="VBoxContainer" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 28.0
margin_right = 123.0
margin_bottom = 82.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
[node name="VBoxContainer1" type="VBoxContainer" parent="VBoxContainer"]
margin_left = 21.0
margin_right = 116.0
margin_bottom = 83.0
size_flags_horizontal = 4
size_flags_vertical = 2
alignment = 0
_sections_unfolded = [ "Size Flags" ]
custom_constants/separation = 5
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/VBoxContainer1" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="ApplicationName" type="Label" parent="VBoxContainer/VBoxContainer1"]
margin_right = 95.0
margin_bottom = 64.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 14.0
text = "Material Maker"
align = 1
[node name="MMLogo" type="TextureRect" parent="VBoxContainer/VBoxContainer1"]
margin_top = 19.0
margin_right = 95.0
margin_bottom = 83.0
texture = ExtResource( 2 )
stretch_mode = 4
[node name="ApplicationName" type="Label" parent="VBoxContainer/VBoxContainer1" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 68.0
margin_right = 95.0
margin_bottom = 82.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Material Maker"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Rect", "custom_fonts" ]
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 15.0
margin_top = 95.0
margin_right = 136.0
margin_bottom = 127.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_left = 8.0
margin_top = 100.0
margin_right = 129.0
margin_bottom = 132.0
size_flags_horizontal = 4
size_flags_vertical = 6
alignment = 0
_sections_unfolded = [ "Size Flags" ]
[node name="Godot" type="TextureButton" parent="VBoxContainer/HBoxContainer2" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Godot" type="TextureButton" parent="VBoxContainer/HBoxContainer2"]
margin_right = 32.0
margin_bottom = 32.0
rect_min_size = Vector2( 32, 32 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 3 )
expand = true
stretch_mode = 4
_sections_unfolded = [ "Rect", "Textures" ]
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2"]
margin_left = 36.0
margin_right = 121.0
margin_bottom = 31.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Based on
Godot Engine"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 22.0
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer"]
margin_left = 15.0
margin_top = 149.0
margin_right = 130.0
margin_bottom = 191.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
margin_right = 123.0
margin_bottom = 241.0
size_flags_horizontal = 4
size_flags_vertical = 10
alignment = 0
_sections_unfolded = [ "Anchor", "Size Flags" ]
size_flags_vertical = 8
custom_constants/separation = 4
[node name="RodzLabs" type="Label" parent="VBoxContainer/VBoxContainer3" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 108.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
[node name="RZLogo" type="TextureRect" parent="VBoxContainer/VBoxContainer3"]
margin_left = 22.0
margin_right = 86.0
margin_bottom = 64.0
rect_min_size = Vector2( 64, 64 )
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Rodz Labs"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
texture = ExtResource( 4 )
expand = true
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/VBoxContainer3" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 18.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/VBoxContainer3"]
margin_top = 68.0
margin_right = 108.0
margin_bottom = 42.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
margin_bottom = 92.0
size_flags_horizontal = 4
size_flags_vertical = 1
alignment = 0
_sections_unfolded = [ "Size Flags" ]
[node name="Facebook" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Facebook" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer"]
margin_right = 24.0
margin_bottom = 24.0
rect_min_size = Vector2( 24, 24 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 4 )
texture_normal = ExtResource( 5 )
expand = true
stretch_mode = 4
_sections_unfolded = [ "Size Flags", "Textures" ]
[node name="Twitter" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Twitter" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer"]
margin_left = 28.0
margin_right = 52.0
margin_bottom = 24.0
rect_min_size = Vector2( 24, 24 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 5 )
texture_normal = ExtResource( 6 )
expand = true
stretch_mode = 4
_sections_unfolded = [ "Textures" ]
[node name="Youtube" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Youtube" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer"]
margin_left = 56.0
margin_right = 80.0
margin_bottom = 24.0
rect_min_size = Vector2( 24, 24 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 6 )
texture_normal = ExtResource( 7 )
expand = true
stretch_mode = 4
_sections_unfolded = [ "Textures" ]
[node name="Github" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Github" type="TextureButton" parent="VBoxContainer/VBoxContainer3/HBoxContainer"]
margin_left = 84.0
margin_right = 108.0
margin_bottom = 24.0
rect_min_size = Vector2( 24, 24 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 7 )
texture_normal = ExtResource( 8 )
expand = true
stretch_mode = 4
_sections_unfolded = [ "Textures" ]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Godot" to="." method="open_url" binds= [ "https://godotengine.org/" ]]
[connection signal="pressed" from="VBoxContainer/VBoxContainer3/HBoxContainer/Facebook" to="." method="open_url" binds= [ "https://www.facebook.com/RodzLabs" ]]
[connection signal="pressed" from="VBoxContainer/VBoxContainer3/HBoxContainer/Twitter" to="." method="open_url" binds= [ "https://twitter.com/R0dZill4" ]]
[connection signal="pressed" from="VBoxContainer/VBoxContainer3/HBoxContainer/Youtube" to="." method="open_url" binds= [ "https://www.youtube.com/channel/UCTDByv9i3ul_qQ98zUYlNAQ" ]]
[connection signal="pressed" from="VBoxContainer/VBoxContainer3/HBoxContainer/Github" to="." method="open_url" binds= [ "https://github.com/RodZill4" ]]

View File

@ -1,13 +1,32 @@
tool
extends Label
extends HBoxContainer
var text setget set_text, get_text
signal label_changed(new_label)
func _ready():
pass
func get_text():
return $Label.text
func set_text(t):
$Label.text = t
func _on_gui_input(ev):
if ev is InputEventMouseButton and ev.doubleclick and ev.button_index == BUTTON_LEFT:
var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance()
add_child(dialog)
dialog.set_texts("Remote", "Enter a name this control")
dialog.connect("ok", self, "set_text", [])
dialog.popup_centered()
if ev is InputEventMouseButton and ev.pressed and ev.button_index == BUTTON_LEFT:
$Label.visible = false
$Editor.text = $Label.text
$Editor.visible = true
$Editor.select()
$Editor.grab_focus()
func _on_Editor_text_entered(__):
_on_Editor_focus_exited()
func _on_Editor_focus_exited():
$Label.text = $Editor.text
$Label.visible = true
$Editor.visible = false
emit_signal("label_changed", $Editor.text)

View File

@ -2,9 +2,21 @@
[ext_resource path="res://addons/material_maker/widgets/linked_widgets/editable_label.gd" type="Script" id=1]
[node name="Label" type="Label"]
[node name="EditableLabel" type="HBoxContainer"]
margin_right = 40.0
margin_bottom = 14.0
mouse_filter = 0
margin_bottom = 40.0
script = ExtResource( 1 )
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[node name="Label" type="Label" parent="."]
margin_top = 13.0
margin_bottom = 27.0
mouse_filter = 0
[node name="Editor" type="LineEdit" parent="."]
visible = false
margin_left = 4.0
margin_right = 62.0
margin_bottom = 40.0
[connection signal="gui_input" from="Label" to="." method="_on_gui_input"]
[connection signal="focus_exited" from="Editor" to="." method="_on_Editor_focus_exited"]
[connection signal="text_entered" from="Editor" to="." method="_on_Editor_text_entered"]

View File

@ -155,6 +155,7 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
mouse_default_cursor_shape = 0
custom_fonts/font = SubResource( 3 )
syntax_highlighting = true
show_line_numbers = true
@ -167,6 +168,7 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
mouse_default_cursor_shape = 0
custom_fonts/font = SubResource( 3 )
syntax_highlighting = true
show_line_numbers = true