From afacaf525778558aba441f1a02beac96748bb618 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:28:49 +0100 Subject: [PATCH 01/12] Add Flip X, Flip Y, Rotate 90, Rotate 180, Rotate 270 --- src/Tools/BaseDraw.gd | 55 +++++++++++++++++++++++++++++++++++++++++ src/Tools/BaseDraw.tscn | 35 ++++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 6f862f2cc02..36a68e17f21 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -3,6 +3,11 @@ extends BaseTool var _brush := Brushes.get_default_brush() var _brush_size := 1 var _brush_size_dynamics := 1 +var _brush_flip_x := false +var _brush_flip_y := false +var _brush_rotate_90 := false +var _brush_rotate_180 := false +var _brush_rotate_270 := false var _cache_limit := 3 var _brush_interpolate := 0 var _brush_image := Image.new() @@ -122,6 +127,11 @@ func set_config(config: Dictionary) -> void: func update_config() -> void: $Brush/BrushSize.value = _brush_size $ColorInterpolation.value = _brush_interpolate + $Flip/FlipX.button_pressed = _brush_flip_x + $Flip/FlipY.button_pressed = _brush_flip_y + $Rotate/Rotate90.button_pressed = _brush_rotate_90 + $Rotate/Rotate180.button_pressed = _brush_rotate_180 + $Rotate/Rotate270.button_pressed = _brush_rotate_270 update_brush() @@ -151,12 +161,15 @@ func update_brush() -> void: var random := randi() % _brush.random.size() _orignal_brush_image = _brush.random[random] _brush_image = _create_blended_brush_image(_orignal_brush_image) + update_brush_image_flip_and_rotate() _brush_texture = ImageTexture.create_from_image(_brush_image) update_mirror_brush() _stroke_dimensions = _brush_image.get_size() _indicator = _create_brush_indicator() _polylines = _create_polylines(_indicator) $Brush/Type/Texture.texture = _brush_texture + #$Brush/Type/Texture.set_flip_v(Tools.brush_flip_x) + #$Brush/Type/Texture.set_flip_h(Tools.brush_flip_y) $ColorInterpolation.visible = _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM] @@ -166,6 +179,7 @@ func update_random_image() -> void: var random := randi() % _brush.random.size() _brush_image = _create_blended_brush_image(_brush.random[random]) _orignal_brush_image = _brush_image + update_brush_image_flip_and_rotate() _brush_texture = ImageTexture.create_from_image(_brush_image) _indicator = _create_brush_indicator() update_mirror_brush() @@ -180,6 +194,19 @@ func update_mirror_brush() -> void: _mirror_brushes.xy.flip_y() +func update_brush_image_flip_and_rotate() -> void: + if _brush_flip_x == true: + _brush_image.flip_x() + if _brush_flip_y == true: + _brush_image.flip_y() + if _brush_rotate_90 == true: + _brush_image.rotate_90(CLOCKWISE) + if _brush_rotate_180 == true: + _brush_image.rotate_180() + if _brush_rotate_270 == true: + _brush_image.rotate_90(COUNTERCLOCKWISE) + + func update_mask(can_skip := true) -> void: if can_skip and Tools.dynamics_alpha == Tools.Dynamics.NONE: if _mask: @@ -241,6 +268,7 @@ func draw_end(pos: Vector2i) -> void: match _brush.type: Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM: _brush_image = _create_blended_brush_image(_orignal_brush_image) + update_brush_image_flip_and_rotate() _brush_texture = ImageTexture.create_from_image(_brush_image) update_mirror_brush() _stroke_dimensions = _brush_image.get_size() @@ -279,6 +307,7 @@ func _prepare_tool() -> void: Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM: # save _brush_image for safe keeping _brush_image = _create_blended_brush_image(_orignal_brush_image) + update_brush_image_flip_and_rotate() _brush_texture = ImageTexture.create_from_image(_brush_image) update_mirror_brush() _stroke_dimensions = _brush_image.get_size() @@ -707,3 +736,29 @@ func _pick_color(pos: Vector2i) -> void: else MOUSE_BUTTON_RIGHT ) Tools.assign_color(color, button, false) + + + +func _on_flip_x_toggled(button_pressed: bool) -> void: + _brush_flip_x = button_pressed + update_brush() + + +func _on_flip_y_toggled(button_pressed: bool) -> void: + _brush_flip_y = button_pressed + update_brush() + + +func _on_rotate_90_toggled(button_pressed: bool) -> void: + _brush_rotate_90 = button_pressed + update_brush() + + +func _on_rotate_180_toggled(button_pressed: bool) -> void: + _brush_rotate_180 = button_pressed + update_brush() + + +func _on_rotate_270_toggled(button_pressed: bool) -> void: + _brush_rotate_270 = button_pressed + update_brush() diff --git a/src/Tools/BaseDraw.tscn b/src/Tools/BaseDraw.tscn index b05261e5672..d84827e37f3 100644 --- a/src/Tools/BaseDraw.tscn +++ b/src/Tools/BaseDraw.tscn @@ -25,7 +25,33 @@ anti_aliasing = false [node name="ToolOptions" instance=ExtResource("2")] script = ExtResource("3") -[node name="Brush" type="HBoxContainer" parent="." index="2"] +[node name="Flip" type="HBoxContainer" parent="." index="2"] +layout_mode = 2 + +[node name="FlipX" type="CheckBox" parent="Flip" index="0"] +layout_mode = 2 +text = "Flip X" + +[node name="FlipY" type="CheckBox" parent="Flip" index="1"] +layout_mode = 2 +text = "Flip Y" + +[node name="Rotate" type="HBoxContainer" parent="." index="3"] +layout_mode = 2 + +[node name="Rotate90" type="CheckBox" parent="Rotate" index="0"] +layout_mode = 2 +text = "R 90" + +[node name="Rotate180" type="CheckBox" parent="Rotate" index="1"] +layout_mode = 2 +text = "R 180" + +[node name="Rotate270" type="CheckBox" parent="Rotate" index="2"] +layout_mode = 2 +text = "R 270" + +[node name="Brush" type="HBoxContainer" parent="." index="4"] layout_mode = 2 alignment = 1 @@ -59,12 +85,17 @@ suffix = "px" global_increment_action = "brush_size_increment" global_decrement_action = "brush_size_decrement" -[node name="ColorInterpolation" parent="." index="3" instance=ExtResource("1")] +[node name="ColorInterpolation" parent="." index="5" instance=ExtResource("1")] visible = false layout_mode = 2 tooltip_text = "0: Color from the brush itself, 100: the currently selected color" prefix = "Brush color from:" +[connection signal="toggled" from="Flip/FlipX" to="." method="_on_flip_x_toggled"] +[connection signal="toggled" from="Flip/FlipY" to="." method="_on_flip_y_toggled"] +[connection signal="toggled" from="Rotate/Rotate90" to="." method="_on_rotate_90_toggled"] +[connection signal="toggled" from="Rotate/Rotate180" to="." method="_on_rotate_180_toggled"] +[connection signal="toggled" from="Rotate/Rotate270" to="." method="_on_rotate_270_toggled"] [connection signal="pressed" from="Brush/Type" to="." method="_on_BrushType_pressed"] [connection signal="value_changed" from="Brush/BrushSize" to="." method="_on_BrushSize_value_changed"] [connection signal="value_changed" from="ColorInterpolation" to="." method="_on_InterpolateFactor_value_changed"] From 706222c987d317842e5c9385ebfeeea304015800 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:35:20 +0100 Subject: [PATCH 02/12] node placement --- src/Tools/DesignTools/Pencil.tscn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tools/DesignTools/Pencil.tscn b/src/Tools/DesignTools/Pencil.tscn index 40ae6992ceb..1d56b0df8ff 100644 --- a/src/Tools/DesignTools/Pencil.tscn +++ b/src/Tools/DesignTools/Pencil.tscn @@ -7,23 +7,23 @@ [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("3") -[node name="Overwrite" type="CheckBox" parent="." index="4"] +[node name="Overwrite" type="CheckBox" parent="." index="6"] layout_mode = 2 tooltip_text = "Overwrites color instead of blending it. This option is only relevant with colors that are not fully opaque" mouse_default_cursor_shape = 2 text = "Overwrite color" -[node name="FillInside" type="CheckBox" parent="." index="5"] +[node name="FillInside" type="CheckBox" parent="." index="7"] layout_mode = 2 mouse_default_cursor_shape = 2 text = "Fill inside" -[node name="SpacingMode" type="CheckBox" parent="." index="6"] +[node name="SpacingMode" type="CheckBox" parent="." index="8"] layout_mode = 2 mouse_default_cursor_shape = 2 text = "Spacing" -[node name="Spacing" parent="." index="7" instance=ExtResource("2")] +[node name="Spacing" parent="." index="9" instance=ExtResource("2")] visible = false layout_mode = 2 allow_greater = true From c7fdc9a32ef0dd74fff4c16a933d74c9bda7fd33 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:25:00 +0100 Subject: [PATCH 03/12] flip_rotate for BrushButton --- src/Autoload/Tools.gd | 1 + src/Tools/BaseDraw.gd | 4 ++-- src/UI/Buttons/BrushButton.gd | 12 ++++++++++++ src/UI/Buttons/BrushButton.tscn | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index a9eb19bae71..08aaf63f8e3 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -1,6 +1,7 @@ extends Node signal color_changed(color, button) +signal flip_rotate(flip_x, flip_y, rotate_90, rotate_180, rotate_270) enum Dynamics { NONE, PRESSURE, VELOCITY } diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 36a68e17f21..c424f96191f 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -59,6 +59,8 @@ func _on_BrushType_pressed() -> void: if child is GridContainer: child.columns = columns Global.brushes_popup.popup(Rect2(pop_position, Vector2(size_x, size_y))) + Tools.flip_rotate.emit(_brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270) + func _on_Brush_selected(brush: Brushes.Brush) -> void: @@ -168,8 +170,6 @@ func update_brush() -> void: _indicator = _create_brush_indicator() _polylines = _create_polylines(_indicator) $Brush/Type/Texture.texture = _brush_texture - #$Brush/Type/Texture.set_flip_v(Tools.brush_flip_x) - #$Brush/Type/Texture.set_flip_h(Tools.brush_flip_y) $ColorInterpolation.visible = _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM] diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index 951e4d41abd..89c098fa664 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -2,6 +2,9 @@ extends BaseButton var brush = Global.brushes_popup.Brush.new() +func _ready() -> void: + Tools.flip_rotate.connect(_flip_rotate_updated) + func _on_BrushButton_pressed() -> void: # Delete the brush on middle mouse press @@ -26,3 +29,12 @@ func _on_BrushButton_mouse_entered() -> void: func _on_BrushButton_mouse_exited() -> void: if brush.type == Global.brushes_popup.CUSTOM: $DeleteButton.visible = false + +func _flip_rotate_updated(flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool,rotate_270: bool): + $BrushTexture.set_flip_v(flip_x) + $BrushTexture.set_flip_v(flip_y) + var _rotation = 0 + if rotate_90 ==true : _rotation += 90 + if rotate_180 ==true : _rotation += 180 + if rotate_270 ==true : _rotation += 270 + $BrushTexture.rotation_degrees = _rotation diff --git a/src/UI/Buttons/BrushButton.tscn b/src/UI/Buttons/BrushButton.tscn index 4df757891b1..0b278e1be2f 100644 --- a/src/UI/Buttons/BrushButton.tscn +++ b/src/UI/Buttons/BrushButton.tscn @@ -19,6 +19,7 @@ offset_left = 2.0 offset_top = 2.0 offset_right = -2.0 offset_bottom = -2.0 +pivot_offset = Vector2(16, 16) expand_mode = 1 stretch_mode = 6 From 10db8f875f5298305658403ab9970e80bbc8d86e Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:40:46 +0100 Subject: [PATCH 04/12] flip corrected for BrushButton (x, y was reversed) --- src/UI/Buttons/BrushButton.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index 89c098fa664..6df3d4b7bbb 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -31,7 +31,7 @@ func _on_BrushButton_mouse_exited() -> void: $DeleteButton.visible = false func _flip_rotate_updated(flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool,rotate_270: bool): - $BrushTexture.set_flip_v(flip_x) + $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) var _rotation = 0 if rotate_90 ==true : _rotation += 90 From 8bbcc21ec6039d46a67f83376ecd5671460c3da8 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:21:29 +0100 Subject: [PATCH 05/12] code changed for github static checks --- src/Tools/BaseDraw.gd | 26 +++++++++++++------------- src/UI/Buttons/BrushButton.gd | 15 +++++++++++---- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index c424f96191f..3f74d24442c 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -59,8 +59,9 @@ func _on_BrushType_pressed() -> void: if child is GridContainer: child.columns = columns Global.brushes_popup.popup(Rect2(pop_position, Vector2(size_x, size_y))) - Tools.flip_rotate.emit(_brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270) - + Tools.flip_rotate.emit( + _brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270 + ) func _on_Brush_selected(brush: Brushes.Brush) -> void: @@ -195,16 +196,16 @@ func update_mirror_brush() -> void: func update_brush_image_flip_and_rotate() -> void: - if _brush_flip_x == true: - _brush_image.flip_x() - if _brush_flip_y == true: - _brush_image.flip_y() - if _brush_rotate_90 == true: - _brush_image.rotate_90(CLOCKWISE) - if _brush_rotate_180 == true: - _brush_image.rotate_180() - if _brush_rotate_270 == true: - _brush_image.rotate_90(COUNTERCLOCKWISE) + if _brush_flip_x == true: + _brush_image.flip_x() + if _brush_flip_y == true: + _brush_image.flip_y() + if _brush_rotate_90 == true: + _brush_image.rotate_90(CLOCKWISE) + if _brush_rotate_180 == true: + _brush_image.rotate_180() + if _brush_rotate_270 == true: + _brush_image.rotate_90(COUNTERCLOCKWISE) func update_mask(can_skip := true) -> void: @@ -738,7 +739,6 @@ func _pick_color(pos: Vector2i) -> void: Tools.assign_color(color, button, false) - func _on_flip_x_toggled(button_pressed: bool) -> void: _brush_flip_x = button_pressed update_brush() diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index 6df3d4b7bbb..fe33b172ce1 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -2,6 +2,7 @@ extends BaseButton var brush = Global.brushes_popup.Brush.new() + func _ready() -> void: Tools.flip_rotate.connect(_flip_rotate_updated) @@ -30,11 +31,17 @@ func _on_BrushButton_mouse_exited() -> void: if brush.type == Global.brushes_popup.CUSTOM: $DeleteButton.visible = false -func _flip_rotate_updated(flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool,rotate_270: bool): + +func _flip_rotate_updated( + flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool,rotate_270: bool +): $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) var _rotation = 0 - if rotate_90 ==true : _rotation += 90 - if rotate_180 ==true : _rotation += 180 - if rotate_270 ==true : _rotation += 270 + if rotate_90 == true: + _rotation += 90 + if rotate_180 == true: + _rotation += 180 + if rotate_270 == true: + _rotation += 270 $BrushTexture.rotation_degrees = _rotation From 01664dd058761935e996c8e8efc0371b820e94cd Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:26:59 +0100 Subject: [PATCH 06/12] github static checks --- src/UI/Buttons/BrushButton.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index fe33b172ce1..a81f0a4b971 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -33,7 +33,7 @@ func _on_BrushButton_mouse_exited() -> void: func _flip_rotate_updated( - flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool,rotate_270: bool + flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool, rotate_270: bool ): $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) From eb77d05cc3643892c5a3fd2426a3db4bbe3b2d14 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:32:07 +0100 Subject: [PATCH 07/12] github static checks 2 --- src/UI/Buttons/BrushButton.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index a81f0a4b971..93a23ee7d8d 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -37,11 +37,11 @@ func _flip_rotate_updated( ): $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) - var _rotation = 0 + var _rotation_BrushTexture = 0 if rotate_90 == true: - _rotation += 90 + _rotation_BrushTexture += 90 if rotate_180 == true: - _rotation += 180 + _rotation_BrushTexture += 180 if rotate_270 == true: - _rotation += 270 - $BrushTexture.rotation_degrees = _rotation + _rotation_BrushTexture += 270 + $BrushTexture.rotation_degrees = _rotation_BrushTexture From 39e3e7e38d3ce78eda9c5ac3832e96c7a51eb855 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:42:12 +0100 Subject: [PATCH 08/12] remove " _ " before my variable name hope this was the problem --- src/UI/Buttons/BrushButton.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index 93a23ee7d8d..403e700cfd3 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -37,11 +37,11 @@ func _flip_rotate_updated( ): $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) - var _rotation_BrushTexture = 0 + var rotation_BrushTexture = 0 if rotate_90 == true: - _rotation_BrushTexture += 90 + rotation_BrushTexture += 90 if rotate_180 == true: - _rotation_BrushTexture += 180 + rotation_BrushTexture += 180 if rotate_270 == true: - _rotation_BrushTexture += 270 - $BrushTexture.rotation_degrees = _rotation_BrushTexture + rotation_BrushTexture += 270 + $BrushTexture.rotation_degrees = rotation_BrushTexture From c37295ef3bc3423ab598d695784bc9aab4f4e755 Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:54:27 +0100 Subject: [PATCH 09/12] var brush_texture_rotation --- src/UI/Buttons/BrushButton.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UI/Buttons/BrushButton.gd b/src/UI/Buttons/BrushButton.gd index 403e700cfd3..49cfa6a1b25 100644 --- a/src/UI/Buttons/BrushButton.gd +++ b/src/UI/Buttons/BrushButton.gd @@ -37,11 +37,11 @@ func _flip_rotate_updated( ): $BrushTexture.set_flip_h(flip_x) $BrushTexture.set_flip_v(flip_y) - var rotation_BrushTexture = 0 + var brush_texture_rotation = 0 if rotate_90 == true: - rotation_BrushTexture += 90 + brush_texture_rotation += 90 if rotate_180 == true: - rotation_BrushTexture += 180 + brush_texture_rotation += 180 if rotate_270 == true: - rotation_BrushTexture += 270 - $BrushTexture.rotation_degrees = rotation_BrushTexture + brush_texture_rotation += 270 + $BrushTexture.rotation_degrees = brush_texture_rotation From 0193a92b09ff47b356b967fe41e7521d71ad3b5b Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sun, 3 Mar 2024 11:11:27 +0100 Subject: [PATCH 10/12] Hide Flip/Rotate buttons where it is unnecessary --- src/Tools/DesignTools/EllipseTool.tscn | 6 ++++++ src/Tools/DesignTools/LineTool.tscn | 8 +++++++- src/Tools/DesignTools/RectangleTool.tscn | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Tools/DesignTools/EllipseTool.tscn b/src/Tools/DesignTools/EllipseTool.tscn index 73e0366580c..269786387d4 100644 --- a/src/Tools/DesignTools/EllipseTool.tscn +++ b/src/Tools/DesignTools/EllipseTool.tscn @@ -5,3 +5,9 @@ [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") + +[node name="Flip" parent="." index="4"] +visible = false + +[node name="Rotate" parent="." index="5"] +visible = false diff --git a/src/Tools/DesignTools/LineTool.tscn b/src/Tools/DesignTools/LineTool.tscn index f10be6fbf74..1353388c971 100644 --- a/src/Tools/DesignTools/LineTool.tscn +++ b/src/Tools/DesignTools/LineTool.tscn @@ -16,7 +16,13 @@ suffix = "px" global_increment_action = "brush_size_increment" global_decrement_action = "brush_size_decrement" -[node name="Brush" parent="." index="3"] +[node name="Flip" parent="." index="3"] +visible = false + +[node name="Rotate" parent="." index="4"] +visible = false + +[node name="Brush" parent="." index="5"] visible = false [connection signal="value_changed" from="ThicknessSlider" to="." method="_on_Thickness_value_changed"] diff --git a/src/Tools/DesignTools/RectangleTool.tscn b/src/Tools/DesignTools/RectangleTool.tscn index a2aa05834c1..195afdbb539 100644 --- a/src/Tools/DesignTools/RectangleTool.tscn +++ b/src/Tools/DesignTools/RectangleTool.tscn @@ -5,3 +5,9 @@ [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") + +[node name="Flip" parent="." index="4"] +visible = false + +[node name="Rotate" parent="." index="5"] +visible = false From 7328f323d2463c77ed0a227fcf1d8e0e10ce5abb Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sun, 3 Mar 2024 21:58:56 +0100 Subject: [PATCH 11/12] share brush button + the code for --- src/Autoload/Tools.gd | 1 + src/Tools/BaseDraw.gd | 46 ++++++++++++++++++++++++ src/Tools/BaseDraw.tscn | 5 +++ src/Tools/DesignTools/EllipseTool.tscn | 3 ++ src/Tools/DesignTools/LineTool.tscn | 3 ++ src/Tools/DesignTools/RectangleTool.tscn | 3 ++ 6 files changed, 61 insertions(+) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 08aaf63f8e3..5146e4b0e7d 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -2,6 +2,7 @@ extends Node signal color_changed(color, button) signal flip_rotate(flip_x, flip_y, rotate_90, rotate_180, rotate_270) +signal share_brush_config(_brush, _size, _flip_x, _flip_y, _rotate_90, _rotate_180, _rotate_270) enum Dynamics { NONE, PRESSURE, VELOCITY } diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 3f74d24442c..7259871adf1 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -8,6 +8,8 @@ var _brush_flip_y := false var _brush_rotate_90 := false var _brush_rotate_180 := false var _brush_rotate_270 := false +var _i_shared_my_brush := false +var _brush_sharing_check := false var _cache_limit := 3 var _brush_interpolate := 0 var _brush_image := Image.new() @@ -42,6 +44,7 @@ func _ready() -> void: Global.global_tool_options.dynamics_changed.connect(_reset_dynamics) Tools.color_changed.connect(_on_Color_changed) Global.brushes_popup.brush_removed.connect(_on_Brush_removed) + Tools.share_brush_config.connect(_update_brush_config) func _on_BrushType_pressed() -> void: @@ -66,6 +69,8 @@ func _on_BrushType_pressed() -> void: func _on_Brush_selected(brush: Brushes.Brush) -> void: _brush = brush + if _brush_sharing_check == true: + _sharing_brush() update_brush() save_config() @@ -73,6 +78,8 @@ func _on_Brush_selected(brush: Brushes.Brush) -> void: func _on_BrushSize_value_changed(value: float) -> void: if _brush_size != int(value): _brush_size = int(value) + if _brush_sharing_check == true: + _sharing_brush() _brush_size_dynamics = _brush_size if Tools.dynamics_size != Tools.Dynamics.NONE: _brush_size_dynamics = Tools.brush_size_min @@ -138,6 +145,29 @@ func update_config() -> void: update_brush() +func _update_brush_config( + b_brush, b_size, b_flip_x, b_flip_y, b_rotate_90, b_rotate_180, b_rotate_270 + )-> void: + if _i_shared_my_brush == false: + _brush = b_brush + _brush_size = b_size + _brush_flip_x = b_flip_x + _brush_flip_y = b_flip_y + _brush_rotate_90 = b_rotate_90 + _brush_rotate_180 = b_rotate_180 + _brush_rotate_270 = b_rotate_270 + update_config() + else: + _i_shared_my_brush = false + + +func _sharing_brush() -> void: + _i_shared_my_brush = true + Tools.share_brush_config.emit( + _brush, _brush_size, _brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270 + ) + + func update_brush() -> void: $Brush/BrushSize.suffix = "px" # Assume we are using default brushes match _brush.type: @@ -741,24 +771,40 @@ func _pick_color(pos: Vector2i) -> void: func _on_flip_x_toggled(button_pressed: bool) -> void: _brush_flip_x = button_pressed + if _brush_sharing_check == true: + _sharing_brush() update_brush() func _on_flip_y_toggled(button_pressed: bool) -> void: _brush_flip_y = button_pressed + if _brush_sharing_check == true: + _sharing_brush() update_brush() func _on_rotate_90_toggled(button_pressed: bool) -> void: _brush_rotate_90 = button_pressed + if _brush_sharing_check == true: + _sharing_brush() update_brush() func _on_rotate_180_toggled(button_pressed: bool) -> void: _brush_rotate_180 = button_pressed + if _brush_sharing_check == true: + _sharing_brush() update_brush() func _on_rotate_270_toggled(button_pressed: bool) -> void: _brush_rotate_270 = button_pressed + if _brush_sharing_check == true: + _sharing_brush() update_brush() + + +func _on_share_brush_config_toggled(button_pressed: bool) -> void: + _brush_sharing_check = button_pressed + if _brush_sharing_check == true: + _sharing_brush() diff --git a/src/Tools/BaseDraw.tscn b/src/Tools/BaseDraw.tscn index d84827e37f3..965e0bc89da 100644 --- a/src/Tools/BaseDraw.tscn +++ b/src/Tools/BaseDraw.tscn @@ -91,6 +91,10 @@ layout_mode = 2 tooltip_text = "0: Color from the brush itself, 100: the currently selected color" prefix = "Brush color from:" +[node name="ShareBrushConfig" type="CheckBox" parent="." index="6"] +layout_mode = 2 +text = "Share Brush Config" + [connection signal="toggled" from="Flip/FlipX" to="." method="_on_flip_x_toggled"] [connection signal="toggled" from="Flip/FlipY" to="." method="_on_flip_y_toggled"] [connection signal="toggled" from="Rotate/Rotate90" to="." method="_on_rotate_90_toggled"] @@ -99,3 +103,4 @@ prefix = "Brush color from:" [connection signal="pressed" from="Brush/Type" to="." method="_on_BrushType_pressed"] [connection signal="value_changed" from="Brush/BrushSize" to="." method="_on_BrushSize_value_changed"] [connection signal="value_changed" from="ColorInterpolation" to="." method="_on_InterpolateFactor_value_changed"] +[connection signal="toggled" from="ShareBrushConfig" to="." method="_on_share_brush_config_toggled"] diff --git a/src/Tools/DesignTools/EllipseTool.tscn b/src/Tools/DesignTools/EllipseTool.tscn index 269786387d4..66f07fc777f 100644 --- a/src/Tools/DesignTools/EllipseTool.tscn +++ b/src/Tools/DesignTools/EllipseTool.tscn @@ -11,3 +11,6 @@ visible = false [node name="Rotate" parent="." index="5"] visible = false + +[node name="ShareBrushConfig" parent="." index="8"] +visible = false diff --git a/src/Tools/DesignTools/LineTool.tscn b/src/Tools/DesignTools/LineTool.tscn index 1353388c971..96d64113a37 100644 --- a/src/Tools/DesignTools/LineTool.tscn +++ b/src/Tools/DesignTools/LineTool.tscn @@ -25,4 +25,7 @@ visible = false [node name="Brush" parent="." index="5"] visible = false +[node name="ShareBrushConfig" parent="." index="7"] +visible = false + [connection signal="value_changed" from="ThicknessSlider" to="." method="_on_Thickness_value_changed"] diff --git a/src/Tools/DesignTools/RectangleTool.tscn b/src/Tools/DesignTools/RectangleTool.tscn index 195afdbb539..be5af8f5fd0 100644 --- a/src/Tools/DesignTools/RectangleTool.tscn +++ b/src/Tools/DesignTools/RectangleTool.tscn @@ -11,3 +11,6 @@ visible = false [node name="Rotate" parent="." index="5"] visible = false + +[node name="ShareBrushConfig" parent="." index="8"] +visible = false From 39b52437558a93960d1988a61ecb6599f5f3e41a Mon Sep 17 00:00:00 2001 From: RorotoSic <70805756+RorotoSic@users.noreply.github.com> Date: Sun, 3 Mar 2024 22:34:14 +0100 Subject: [PATCH 12/12] static checks 01 --- src/Tools/BaseDraw.gd | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 7259871adf1..087bae9ba3e 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -147,25 +147,31 @@ func update_config() -> void: func _update_brush_config( b_brush, b_size, b_flip_x, b_flip_y, b_rotate_90, b_rotate_180, b_rotate_270 - )-> void: - if _i_shared_my_brush == false: - _brush = b_brush - _brush_size = b_size - _brush_flip_x = b_flip_x - _brush_flip_y = b_flip_y - _brush_rotate_90 = b_rotate_90 - _brush_rotate_180 = b_rotate_180 - _brush_rotate_270 = b_rotate_270 - update_config() - else: - _i_shared_my_brush = false +) -> void: + if _i_shared_my_brush == false: + _brush = b_brush + _brush_size = b_size + _brush_flip_x = b_flip_x + _brush_flip_y = b_flip_y + _brush_rotate_90 = b_rotate_90 + _brush_rotate_180 = b_rotate_180 + _brush_rotate_270 = b_rotate_270 + update_config() + else: + _i_shared_my_brush = false func _sharing_brush() -> void: _i_shared_my_brush = true Tools.share_brush_config.emit( - _brush, _brush_size, _brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270 - ) + _brush, + _brush_size, + _brush_flip_x, + _brush_flip_y, + _brush_rotate_90, + _brush_rotate_180, + _brush_rotate_270 + ) func update_brush() -> void: