From ea8bfcd25d5d6eeb6f0ac6f2d0f56a9013e9d1fb Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 4 May 2021 19:26:06 +0300 Subject: [PATCH] Remove drawn_rect from Selection.gd and use draw_preview() in RectSelect.gd instead --- src/Tools/SelectionTools/RectSelect.gd | 17 +++++++++++++---- src/UI/Canvas/Selection.gd | 2 -- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Tools/SelectionTools/RectSelect.gd b/src/Tools/SelectionTools/RectSelect.gd index 0dfdc45fd..0ca0a9ca5 100644 --- a/src/Tools/SelectionTools/RectSelect.gd +++ b/src/Tools/SelectionTools/RectSelect.gd @@ -32,21 +32,30 @@ func draw_move(position : Vector2) -> void: _start_pos += position - _offset _rect = _get_result_rect(_start_pos, position) _set_cursor_text(_rect) - Global.canvas.selection.drawn_rect = _rect - Global.canvas.selection.update() _offset = position func draw_end(position : Vector2) -> void: .draw_end(position) _rect = Rect2(0, 0, 0, 0) - Global.canvas.selection.drawn_rect = _rect - Global.canvas.selection.update() _square = false _expand_from_center = false _displace_origin = false +func draw_preview() -> void: + if !_move: + var canvas : Node2D = Global.canvas.previews + var _position := canvas.position + var _scale := canvas.scale + if Global.mirror_view: + _position.x = _position.x + Global.current_project.size.x + _scale.x = -1 + canvas.draw_set_transform(_position, canvas.rotation, _scale) + canvas.draw_rect(_rect, Color.black, false) + canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale) + + func apply_selection(_position) -> void: if !_add and !_subtract and !_intersect: Global.canvas.selection.clear_selection() diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index 33629122b..277dc413a 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -54,7 +54,6 @@ var original_offset := Vector2.ZERO var preview_image := Image.new() var preview_image_texture := ImageTexture.new() var undo_data : Dictionary -var drawn_rect := Rect2(0, 0, 0, 0) var gizmos := [] # Array of Gizmos var dragged_gizmo : Gizmo = null var prev_angle := 0 @@ -143,7 +142,6 @@ func _draw() -> void: _position.x = _position.x + Global.current_project.size.x _scale.x = -1 draw_set_transform(_position, rotation, _scale) - draw_rect(drawn_rect, Color.black, false) if big_bounding_rectangle.size != Vector2.ZERO: for gizmo in gizmos: # Draw gizmos draw_rect(gizmo.rect, Color.black)