From 59254b943f1c59f322c50339d0ff5a0f5e3f5ab4 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 21 Dec 2024 03:44:54 +0200 Subject: [PATCH] Attempt to fix left tool preview not being shown when a right tool with a preview is selected Maybe fixes #1157 --- src/Tools/BaseShapeDrawer.gd | 3 +-- src/Tools/DesignTools/LineTool.gd | 3 +-- src/Tools/SelectionTools/EllipseSelect.gd | 3 +-- src/Tools/SelectionTools/Lasso.gd | 3 +-- src/Tools/SelectionTools/PaintSelect.gd | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Tools/BaseShapeDrawer.gd b/src/Tools/BaseShapeDrawer.gd index 5111b626f..0f2de462c 100644 --- a/src/Tools/BaseShapeDrawer.gd +++ b/src/Tools/BaseShapeDrawer.gd @@ -148,6 +148,7 @@ func draw_end(pos: Vector2i) -> void: _start = Vector2i.ZERO _dest = Vector2i.ZERO _drawing = false + Global.canvas.previews_sprite.texture = null _displace_origin = false cursor_text = "" super.draw_end(pos) @@ -174,8 +175,6 @@ func draw_preview() -> void: image.set_pixelv(point, Color.WHITE) var texture := ImageTexture.create_from_image(image) canvas.texture = texture - else: - canvas.texture = null func _draw_shape(origin: Vector2i, dest: Vector2i) -> void: diff --git a/src/Tools/DesignTools/LineTool.gd b/src/Tools/DesignTools/LineTool.gd index 5e8917f0d..4bd4da3e7 100644 --- a/src/Tools/DesignTools/LineTool.gd +++ b/src/Tools/DesignTools/LineTool.gd @@ -142,6 +142,7 @@ func draw_end(pos: Vector2i) -> void: _start = Vector2.ZERO _dest = Vector2.ZERO _drawing = false + Global.canvas.previews_sprite.texture = null _displace_origin = false cursor_text = "" super.draw_end(pos) @@ -163,8 +164,6 @@ func draw_preview() -> void: image.set_pixelv(point, Color.WHITE) var texture := ImageTexture.create_from_image(image) canvas.texture = texture - else: - canvas.texture = null func _draw_shape() -> void: diff --git a/src/Tools/SelectionTools/EllipseSelect.gd b/src/Tools/SelectionTools/EllipseSelect.gd index 1d4234d4d..ce8d4a8f5 100644 --- a/src/Tools/SelectionTools/EllipseSelect.gd +++ b/src/Tools/SelectionTools/EllipseSelect.gd @@ -68,8 +68,6 @@ func draw_preview() -> void: image.set_pixelv(point, Color.WHITE) var texture := ImageTexture.create_from_image(image) canvas.texture = texture - else: - canvas.texture = null func apply_selection(_position: Vector2i) -> void: @@ -111,6 +109,7 @@ func apply_selection(_position: Vector2i) -> void: Global.canvas.selection.big_bounding_rectangle = project.selection_map.get_used_rect() Global.canvas.selection.commit_undo("Select", undo_data) + Global.canvas.previews_sprite.texture = null func set_ellipse(selection_map: SelectionMap, pos: Vector2i) -> void: diff --git a/src/Tools/SelectionTools/Lasso.gd b/src/Tools/SelectionTools/Lasso.gd index 0797eea6e..3ddc9a1fb 100644 --- a/src/Tools/SelectionTools/Lasso.gd +++ b/src/Tools/SelectionTools/Lasso.gd @@ -54,8 +54,6 @@ func draw_preview() -> void: image.set_pixelv(draw_point, Color.WHITE) var texture := ImageTexture.create_from_image(image) canvas.texture = texture - else: - canvas.texture = null func apply_selection(_position) -> void: @@ -82,6 +80,7 @@ func apply_selection(_position) -> void: Global.canvas.selection.commit_undo("Select", undo_data) _draw_points.clear() _last_position = Vector2.INF + Global.canvas.previews_sprite.texture = null func lasso_selection( diff --git a/src/Tools/SelectionTools/PaintSelect.gd b/src/Tools/SelectionTools/PaintSelect.gd index d692964b9..a061dfd1f 100644 --- a/src/Tools/SelectionTools/PaintSelect.gd +++ b/src/Tools/SelectionTools/PaintSelect.gd @@ -82,8 +82,6 @@ func draw_preview() -> void: image.set_pixelv(draw_point, Color.WHITE) var texture := ImageTexture.create_from_image(image) canvas.texture = texture - else: - canvas.texture = null func apply_selection(pos: Vector2i) -> void: @@ -111,6 +109,7 @@ func apply_selection(pos: Vector2i) -> void: Global.canvas.selection.commit_undo("Select", undo_data) _draw_points.clear() _last_position = Vector2.INF + Global.canvas.previews_sprite.texture = null func paint_selection(