From d4b42534bb1cb7440fa7f595ee7e241a7d877ca0 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 25 Dec 2019 21:17:29 +0200 Subject: [PATCH] Added sliders for brush size & 2 new custom brushes Also, in Canvas.gd's _draw() method, draw_set_transform() is called again after the circle brush drawings, to reset the transform to its default state. --- Brushes/hline_3x3.png | Bin 0 -> 72 bytes Brushes/vline_3x3.png | Bin 0 -> 79 bytes Main.tscn | 33 +++++++++++++++++++++++++++------ Scripts/Canvas.gd | 6 ++++-- Scripts/Global.gd | 4 ++++ Scripts/Main.gd | 4 ++++ 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 Brushes/hline_3x3.png create mode 100644 Brushes/vline_3x3.png diff --git a/Brushes/hline_3x3.png b/Brushes/hline_3x3.png new file mode 100644 index 0000000000000000000000000000000000000000..7d7eed92caf4920e43b38675543227dc5ac6c810 GIT binary patch literal 72 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y@!3HFyABb!LQv9ASjv*W~lT#8Bew=4uW#ANK VWGuFB`3IC@@O1TaS?83{1OUZ94;BCb literal 0 HcmV?d00001 diff --git a/Brushes/vline_3x3.png b/Brushes/vline_3x3.png new file mode 100644 index 0000000000000000000000000000000000000000..fe47583b58889c6ad828f2223efd0294bded051f GIT binary patch literal 79 zcmeAS@N?(olHy`uVBq!ia0vp^j6lrH!3HFQ?xr>YDKSqM#}JO0tOpr+fxJTs-~P=N bO>ivWR$^qi&auS|D8}IF>gTe~DWM4fK3EYs literal 0 HcmV?d00001 diff --git a/Main.tscn b/Main.tscn index 13c6b9812..8e9089d49 100644 --- a/Main.tscn +++ b/Main.tscn @@ -250,7 +250,6 @@ text = "[64×64]" align = 2 [node name="UI" type="HBoxContainer" parent="MenuAndUI"] -editor/display_folded = true margin_top = 28.0 margin_right = 1152.0 margin_bottom = 648.0 @@ -399,7 +398,6 @@ button_mask = 3 texture_normal = ExtResource( 9 ) [node name="ColorAndToolOptions" type="VBoxContainer" parent="MenuAndUI/UI/ToolPanel/Tools"] -editor/display_folded = true margin_top = 159.0 margin_right = 208.0 margin_bottom = 612.0 @@ -541,9 +539,19 @@ margin_right = 58.0 margin_bottom = 16.0 text = "Brush size:" -[node name="LeftBrushSizeEdit" type="SpinBox" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushSize"] +[node name="LeftBrushSizeSlider" type="HSlider" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushSize"] margin_left = 62.0 -margin_right = 116.0 +margin_right = 150.0 +margin_bottom = 17.0 +size_flags_horizontal = 3 +size_flags_vertical = 1 +min_value = 1.0 +value = 1.0 +allow_greater = true + +[node name="LeftBrushSizeEdit" type="SpinBox" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushSize"] +margin_left = 154.0 +margin_right = 208.0 margin_bottom = 17.0 mouse_default_cursor_shape = 2 min_value = 1.0 @@ -626,6 +634,7 @@ hint_tooltip = "LDAMOUNT_HT" value = 10.0 [node name="LeftMirroring" type="VBoxContainer" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions"] +editor/display_folded = true margin_top = 96.0 margin_right = 208.0 margin_bottom = 131.0 @@ -719,9 +728,19 @@ margin_right = 58.0 margin_bottom = 16.0 text = "Brush size:" -[node name="RightBrushSizeEdit" type="SpinBox" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushSize"] +[node name="RightBrushSizeSlider" type="HSlider" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushSize"] margin_left = 62.0 -margin_right = 116.0 +margin_right = 150.0 +margin_bottom = 17.0 +size_flags_horizontal = 3 +size_flags_vertical = 1 +min_value = 1.0 +value = 1.0 +allow_greater = true + +[node name="RightBrushSizeEdit" type="SpinBox" parent="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushSize"] +margin_left = 154.0 +margin_right = 208.0 margin_bottom = 17.0 mouse_default_cursor_shape = 2 min_value = 1.0 @@ -1891,6 +1910,7 @@ visible = false [connection signal="pressed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorDefaultsCenter/ColorDefaults" to="." method="_on_ColorDefaults_pressed"] [connection signal="toggled" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftIndicatorCheckbox" to="." method="_on_LeftIndicatorCheckbox_toggled"] [connection signal="pressed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushType/LeftBrushTypeButton" to="." method="_on_LeftBrushTypeButton_pressed"] +[connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushSize/LeftBrushSizeSlider" to="." method="_on_LeftBrushSizeEdit_value_changed"] [connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftBrushSize/LeftBrushSizeEdit" to="." method="_on_LeftBrushSizeEdit_value_changed"] [connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftColorInterpolation/LeftInterpolateFactor" to="." method="_on_LeftInterpolateFactor_value_changed"] [connection signal="item_selected" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftFillArea/LeftFillAreaOptions" to="." method="_on_LeftFillAreaOptions_item_selected"] @@ -1900,6 +1920,7 @@ visible = false [connection signal="toggled" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/LeftToolOptions/LeftMirroring/LeftMirrorButtons/LeftVerticalMirroring" to="." method="_on_LeftVerticalMirroring_toggled"] [connection signal="toggled" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightIndicatorCheckbox" to="." method="_on_RightIndicatorCheckbox_toggled"] [connection signal="pressed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushType/RightBrushTypeButton" to="." method="_on_RightBrushTypeButton_pressed"] +[connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushSize/RightBrushSizeSlider" to="." method="_on_RightBrushSizeEdit_value_changed"] [connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightBrushSize/RightBrushSizeEdit" to="." method="_on_RightBrushSizeEdit_value_changed"] [connection signal="value_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightColorInterpolation/RightInterpolateFactor" to="." method="_on_RightInterpolateFactor_value_changed"] [connection signal="item_selected" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/RightToolOptions/RightFillArea/RightFillAreaOptions" to="." method="_on_RightFillAreaOptions_item_selected"] diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 8251d62c2..ef02b42fd 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -450,9 +450,10 @@ func _draw() -> void: draw_rect(Rect2(start_pos_x, start_pos_y, Global.left_brush_size, Global.left_brush_size), Color.blue, false) elif Global.current_left_brush_type == Global.BRUSH_TYPES.CIRCLE: if Global.current_left_tool == "Pencil" || Global.current_left_tool == "Eraser": - draw_set_transform(mouse_pos, 0, Vector2.ONE) + draw_set_transform(mouse_pos, rotation, scale) for rect in Global.left_circle_points: draw_rect(Rect2(rect, Vector2.ONE), Color.blue, false) + draw_set_transform(position, rotation, scale) else: if Global.current_left_tool == "Pencil" || Global.current_left_tool == "Eraser": var custom_brush_size = Global.custom_left_brush_image.get_size() - Vector2.ONE @@ -467,9 +468,10 @@ func _draw() -> void: draw_rect(Rect2(start_pos_x, start_pos_y, Global.right_brush_size, Global.right_brush_size), Color.red, false) elif Global.current_right_brush_type == Global.BRUSH_TYPES.CIRCLE: if Global.current_right_tool == "Pencil" || Global.current_right_tool == "Eraser": - draw_set_transform(mouse_pos, 0, Vector2.ONE) + draw_set_transform(mouse_pos, rotation, scale) for rect in Global.right_circle_points: draw_rect(Rect2(rect, Vector2.ONE), Color.red, false) + draw_set_transform(position, rotation, scale) else: if Global.current_right_tool == "Pencil" || Global.current_right_tool == "Eraser": var custom_brush_size = Global.custom_right_brush_image.get_size() - Vector2.ONE diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 8d2346cb2..3bd67d7f6 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -162,7 +162,9 @@ var project_brush_container : GridContainer var left_brush_size_container : Container var right_brush_size_container : Container var left_brush_size_edit : SpinBox +var left_brush_size_slider : HSlider var right_brush_size_edit : SpinBox +var right_brush_size_slider : HSlider var left_color_interpolation_container : Container var right_color_interpolation_container : Container @@ -265,7 +267,9 @@ func _ready() -> void: left_brush_size_container = find_node_by_name(left_tool_options_container, "LeftBrushSize") right_brush_size_container = find_node_by_name(right_tool_options_container, "RightBrushSize") left_brush_size_edit = find_node_by_name(left_brush_size_container, "LeftBrushSizeEdit") + left_brush_size_slider = find_node_by_name(left_brush_size_container, "LeftBrushSizeSlider") right_brush_size_edit = find_node_by_name(right_brush_size_container, "RightBrushSizeEdit") + right_brush_size_slider = find_node_by_name(right_brush_size_container, "RightBrushSizeSlider") left_color_interpolation_container = find_node_by_name(left_tool_options_container, "LeftColorInterpolation") right_color_interpolation_container = find_node_by_name(right_tool_options_container, "RightColorInterpolation") diff --git a/Scripts/Main.gd b/Scripts/Main.gd index e6c759523..1b70f58bc 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -875,11 +875,15 @@ func _on_RightBrushTypeButton_pressed() -> void: Global.brush_type_window_position = "right" func _on_LeftBrushSizeEdit_value_changed(value) -> void: + Global.left_brush_size_edit.value = value + Global.left_brush_size_slider.value = value var new_size = int(value) Global.left_brush_size = new_size update_left_custom_brush() func _on_RightBrushSizeEdit_value_changed(value) -> void: + Global.right_brush_size_edit.value = value + Global.right_brush_size_slider.value = value var new_size = int(value) Global.right_brush_size = new_size update_right_custom_brush()