1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 01:29:49 +00:00

Move cursot tool icon visibility to ViewportContainer

I have no idea what I was thinking when I put that code inside Canvas' _input()
This commit is contained in:
Manolis Papadeas 2021-11-22 18:43:06 +02:00
parent 36680795ee
commit 4931e50213
2 changed files with 7 additions and 15 deletions

View file

@ -5,7 +5,6 @@ extends Node2D
var fill_color := Color(0, 0, 0, 0) var fill_color := Color(0, 0, 0, 0)
var current_pixel := Vector2.ZERO var current_pixel := Vector2.ZERO
var can_undo := true var can_undo := true
var cursor_image_has_changed := false
var sprite_changed_this_frame := false # for optimization purposes var sprite_changed_this_frame := false # for optimization purposes
var move_preview_location := Vector2.ZERO var move_preview_location := Vector2.ZERO
@ -78,19 +77,6 @@ func _input(event : InputEvent) -> void:
sprite_changed_this_frame = false sprite_changed_this_frame = false
if Global.has_focus:
if !cursor_image_has_changed:
cursor_image_has_changed = true
if Global.show_left_tool_icon:
Global.left_cursor.visible = true
if Global.show_right_tool_icon:
Global.right_cursor.visible = true
else:
if cursor_image_has_changed:
cursor_image_has_changed = false
Global.left_cursor.visible = false
Global.right_cursor.visible = false
Tools.handle_draw(current_pixel.floor(), event) Tools.handle_draw(current_pixel.floor(), event)
if sprite_changed_this_frame: if sprite_changed_this_frame:

View file

@ -1,12 +1,18 @@
extends ViewportContainer extends ViewportContainer
func _ready():
func _ready() -> void:
material = CanvasItemMaterial.new() material = CanvasItemMaterial.new()
material.blend_mode = CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA material.blend_mode = CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA
func _on_ViewportContainer_mouse_entered() -> void: func _on_ViewportContainer_mouse_entered() -> void:
Global.has_focus = true Global.has_focus = true
Global.left_cursor.visible = true
Global.right_cursor.visible = true
func _on_ViewportContainer_mouse_exited() -> void: func _on_ViewportContainer_mouse_exited() -> void:
Global.has_focus = false Global.has_focus = false
Global.left_cursor.visible = false
Global.right_cursor.visible = false