diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index b11e15f56..7f0671f89 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -308,7 +308,7 @@ func draw_indicator() -> void: func draw_indicator_at(position : Vector2, offset : Vector2, color : Color) -> void: - var canvas = Global.canvas + var canvas = Global.canvas.indicators if _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM] and not _draw_line: position -= (_brush_image.get_size() / 2).floor() position -= offset diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index 7f5a4b79d..3def832b1 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -10,6 +10,7 @@ var cursor_image_has_changed := false var sprite_changed_this_frame := false # for optimization purposes onready var grid = $Grid +onready var indicators = $Indicators # Called when the node enters the scene tree for the first time. @@ -44,10 +45,6 @@ func _draw() -> void: draw_texture(current_cels[i].image_texture, Vector2(location.x + size.x, location.y), modulate_color) # Right draw_texture(current_cels[i].image_texture, location + size, modulate_color) # Down right - # Draw rectangle to indicate the pixel currently being hovered on - if Global.has_focus and Global.can_draw: - Tools.draw_indicator() - func _input(event : InputEvent) -> void: # Don't process anything below if the input isn't a mouse event, or Shift/Ctrl. diff --git a/src/UI/Canvas/Canvas.tscn b/src/UI/Canvas/Canvas.tscn index 77825b2be..51620d6b8 100644 --- a/src/UI/Canvas/Canvas.tscn +++ b/src/UI/Canvas/Canvas.tscn @@ -1,10 +1,14 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1] [ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2] +[ext_resource path="res://src/UI/Canvas/Indicators.gd" type="Script" id=3] [node name="Canvas" type="Node2D"] script = ExtResource( 1 ) [node name="Grid" type="Node2D" parent="."] script = ExtResource( 2 ) + +[node name="Indicators" type="Node2D" parent="."] +script = ExtResource( 3 ) diff --git a/src/UI/Canvas/Indicators.gd b/src/UI/Canvas/Indicators.gd new file mode 100644 index 000000000..f979f6439 --- /dev/null +++ b/src/UI/Canvas/Indicators.gd @@ -0,0 +1,12 @@ +extends Node2D + + +func _input(event : InputEvent) -> void: + if Global.has_focus and event is InputEventMouseMotion: + update() + + +func _draw() -> void: + # Draw rectangle to indicate the pixel currently being hovered on + if Global.has_focus and Global.can_draw: + Tools.draw_indicator()