diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index a9eb19bae..08aaf63f8 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 36a68e17f..c424f9619 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 951e4d41a..89c098fa6 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 4df757891..0b278e1be 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