From a08067aed1a0e2684b6c85dc4158d540cb53e010 Mon Sep 17 00:00:00 2001 From: Flairieve Date: Tue, 6 Aug 2019 00:36:52 -0500 Subject: [PATCH] Added grid settings --- addons/graphics_editor/Editor.tscn | 6 +- addons/graphics_editor/Settings.gd | 49 ++++++----- addons/graphics_editor/Settings.tscn | 118 +++++++++++++++++++++++++-- 3 files changed, 144 insertions(+), 29 deletions(-) diff --git a/addons/graphics_editor/Editor.tscn b/addons/graphics_editor/Editor.tscn index 29bf6bc..d589069 100644 --- a/addons/graphics_editor/Editor.tscn +++ b/addons/graphics_editor/Editor.tscn @@ -51,7 +51,7 @@ color = Color( 0.639216, 0.639216, 0.639216, 1 ) [node name="VisualGrid2" parent="PaintCanvasContainer/PaintCanvas/Grids" instance=ExtResource( 4 )] mouse_filter = 2 color = Color( 1, 1, 1, 1 ) -size = 160 +size = 160.0 [node name="CanvasOutline" type="Control" parent="PaintCanvasContainer/PaintCanvas"] anchor_right = 1.0 @@ -166,9 +166,9 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 margin_left = -155.0 -margin_top = -80.0 +margin_top = -150.0 margin_right = 155.0 -margin_bottom = 80.0 +margin_bottom = 150.0 [connection signal="mouse_entered" from="PaintCanvasContainer" to="PaintCanvasContainer" method="_on_PaintCanvasContainer_mouse_entered"] [connection signal="mouse_exited" from="PaintCanvasContainer" to="PaintCanvasContainer" method="_on_PaintCanvasContainer_mouse_exited"] [connection signal="pressed" from="ToolMenu/Buttons/PaintTool" to="." method="_on_PaintTool_pressed"] diff --git a/addons/graphics_editor/Settings.gd b/addons/graphics_editor/Settings.gd index 7218aff..f68e8c9 100644 --- a/addons/graphics_editor/Settings.gd +++ b/addons/graphics_editor/Settings.gd @@ -3,32 +3,41 @@ extends Control onready var editor = get_parent() onready var canvas_outline = get_parent().get_node("PaintCanvasContainer/PaintCanvas/CanvasOutline") -var start_time -var end_time +onready var visual_grid_1 = get_parent().get_node("PaintCanvasContainer/PaintCanvas/Grids/VisualGrid") +onready var visual_grid_2 = get_parent().get_node("PaintCanvasContainer/PaintCanvas/Grids/VisualGrid2") func _ready(): - #start_time = OS.get_ticks_msec() + #CanvasOutline settings get_node("CanvasOutline/Enabled/CheckButton").pressed = canvas_outline.visible get_node("CanvasOutline/Color/ColorPickerButton").color = canvas_outline.color get_node("CanvasOutline/Width/SpinBox").value = canvas_outline.width - -func _process(delta): -# if get_parent().paint_canvas_node != null: -# canvas_outline = get_parent().paint_canvas_node.get_node("CanvasOutline") -# end_time = OS.get_ticks_msec() -# print("[Settings] Found Editor node in %s seconds!" % [(end_time - start_time) / float(1000)]) -# set_process(false) - pass - -func _on_CheckButton_toggled(button_pressed): - canvas_outline.visible = button_pressed - -func _on_ColorPickerButton_color_changed(color): - canvas_outline.color = color - -func _on_SpinBox_value_changed(value): - canvas_outline.width = value + + #Grid settings + get_node("Grids/Grid1Color/ColorPickerButton").color = visual_grid_1.color + get_node("Grids/Grid1Size/SpinBox").value = visual_grid_1.size + get_node("Grids/Grid2Color/ColorPickerButton").color = visual_grid_2.color + get_node("Grids/Grid2Size/SpinBox").value = visual_grid_2.size func _on_Ok_pressed(): hide() +func _on_CanvasOutline_Enabled_value_changed(button_pressed): + canvas_outline.visible = button_pressed + +func _on_CanvasOutline_Color_value_changed(color): + canvas_outline.color = color + +func _on_CanvasOutline_SpinBox_value_changed(value): + canvas_outline.width = value + +func _on_Grids_Grid1Color_value_changed(color): + visual_grid_1.color = color + +func _on_Grids_Grid1Size_value_changed(value): + visual_grid_1.size = value + +func _on_Grids_Grid2Color_value_changed(color): + visual_grid_2.color = color + +func _on_Grids_Grid2Size_value_changed(value): + visual_grid_2.size = value \ No newline at end of file diff --git a/addons/graphics_editor/Settings.tscn b/addons/graphics_editor/Settings.tscn index 907bcbd..5102904 100644 --- a/addons/graphics_editor/Settings.tscn +++ b/addons/graphics_editor/Settings.tscn @@ -3,20 +3,22 @@ [ext_resource path="res://addons/graphics_editor/Settings.gd" type="Script" id=1] [node name="Settings" type="WindowDialog"] +visible = true margin_top = 20.0 margin_right = 310.0 -margin_bottom = 180.0 +margin_bottom = 320.0 window_title = "Settings" script = ExtResource( 1 ) [node name="Ok" type="Button" parent="."] margin_left = 220.0 -margin_top = 130.0 +margin_top = 270.0 margin_right = 300.0 -margin_bottom = 150.0 +margin_bottom = 290.0 text = "Ok" [node name="CanvasOutline" type="Control" parent="."] +editor/display_folded = true margin_left = 10.0 margin_top = 10.0 margin_right = 300.0 @@ -31,6 +33,7 @@ margin_bottom = 14.0 text = "Canvas Outline:" [node name="Enabled" type="Control" parent="CanvasOutline"] +editor/display_folded = true margin_left = 10.0 margin_top = 20.0 margin_right = 290.0 @@ -50,6 +53,7 @@ margin_bottom = 30.0 pressed = true [node name="Color" type="Control" parent="CanvasOutline"] +editor/display_folded = true margin_left = 10.0 margin_top = 50.0 margin_right = 290.0 @@ -67,6 +71,7 @@ margin_right = 280.0 margin_bottom = 20.0 [node name="Width" type="Control" parent="CanvasOutline"] +editor/display_folded = true margin_left = 10.0 margin_top = 80.0 margin_right = 290.0 @@ -86,7 +91,108 @@ margin_bottom = 24.0 max_value = 9999.0 allow_greater = true allow_lesser = true + +[node name="Grids" type="Control" parent="."] +margin_left = 10.0 +margin_top = 120.0 +margin_right = 300.0 +margin_bottom = 260.0 + +[node name="Label" type="Label" parent="Grids"] +margin_right = 100.0 +margin_bottom = 14.0 +text = "Grids:" + +[node name="Grid1Color" type="Control" parent="Grids"] +margin_left = 10.0 +margin_top = 20.0 +margin_right = 290.0 +margin_bottom = 40.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Label" type="Label" parent="Grids/Grid1Color"] +margin_right = 130.0 +margin_bottom = 20.0 +text = "Grid1 Color:" +valign = 1 + +[node name="ColorPickerButton" type="ColorPickerButton" parent="Grids/Grid1Color"] +margin_left = 170.0 +margin_right = 280.0 +margin_bottom = 20.0 + +[node name="Grid2Color" type="Control" parent="Grids"] +margin_left = 10.0 +margin_top = 80.0 +margin_right = 290.0 +margin_bottom = 100.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Label" type="Label" parent="Grids/Grid2Color"] +margin_right = 130.0 +margin_bottom = 20.0 +text = "Grid2 Color:" +valign = 1 + +[node name="ColorPickerButton" type="ColorPickerButton" parent="Grids/Grid2Color"] +margin_left = 170.0 +margin_right = 280.0 +margin_bottom = 20.0 + +[node name="Grid1Size" type="Control" parent="Grids"] +margin_left = 10.0 +margin_top = 50.0 +margin_right = 290.0 +margin_bottom = 70.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Label" type="Label" parent="Grids/Grid1Size"] +margin_right = 130.0 +margin_bottom = 20.0 +text = "Grid1 Size:" +valign = 1 + +[node name="SpinBox" type="SpinBox" parent="Grids/Grid1Size"] +margin_left = 210.0 +margin_right = 284.0 +margin_bottom = 24.0 +max_value = 9999.0 +allow_greater = true +allow_lesser = true + +[node name="Grid2Size" type="Control" parent="Grids"] +margin_left = 10.0 +margin_top = 110.0 +margin_right = 290.0 +margin_bottom = 130.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Label" type="Label" parent="Grids/Grid2Size"] +margin_right = 130.0 +margin_bottom = 20.0 +text = "Grid2 Size:" +valign = 1 + +[node name="SpinBox" type="SpinBox" parent="Grids/Grid2Size"] +margin_left = 210.0 +margin_right = 284.0 +margin_bottom = 24.0 +max_value = 9999.0 +allow_greater = true +allow_lesser = true [connection signal="pressed" from="Ok" to="." method="_on_Ok_pressed"] -[connection signal="toggled" from="CanvasOutline/Enabled/CheckButton" to="." method="_on_CheckButton_toggled"] -[connection signal="color_changed" from="CanvasOutline/Color/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"] -[connection signal="value_changed" from="CanvasOutline/Width/SpinBox" to="." method="_on_SpinBox_value_changed"] +[connection signal="toggled" from="CanvasOutline/Enabled/CheckButton" to="." method="_on_CanvasOutline_Enabled_value_changed"] +[connection signal="color_changed" from="CanvasOutline/Color/ColorPickerButton" to="." method="_on_CanvasOutline_Color_value_changed"] +[connection signal="value_changed" from="CanvasOutline/Width/SpinBox" to="." method="_on_CanvasOutline_SpinBox_value_changed"] +[connection signal="color_changed" from="Grids/Grid1Color/ColorPickerButton" to="." method="_on_Grids_Grid1Color_value_changed"] +[connection signal="color_changed" from="Grids/Grid2Color/ColorPickerButton" to="." method="_on_Grids_Grid2Color_value_changed"] +[connection signal="value_changed" from="Grids/Grid1Size/SpinBox" to="." method="_on_Grids_Grid1Size_value_changed"] +[connection signal="value_changed" from="Grids/Grid2Size/SpinBox" to="." method="_on_Grids_Grid2Size_value_changed"]