From 29f9601d8ab17bb5feadb2b8720f01500db5eaad Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 17 Aug 2024 00:59:48 +0300 Subject: [PATCH] Revert "Fix cursor blinking at the edge of canvas (#1075)" This reverts commit 77f6860f7a85c8a2238e8a428dec3138383e64c5. --- src/UI/UI.tscn | 4 ++++ src/UI/ViewportContainer.gd | 33 ++++++++++++++------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index 844ad29ef..33f01a452 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -420,3 +420,7 @@ layout_mode = 2 [connection signal="mouse_entered" from="DockableContainer/Main Canvas/HorizontalRuler" to="DockableContainer/Main Canvas/HorizontalRuler" method="_on_HorizontalRuler_mouse_entered"] [connection signal="pressed" from="DockableContainer/Main Canvas/HorizontalRuler" to="DockableContainer/Main Canvas/HorizontalRuler" method="_on_HorizontalRuler_pressed"] [connection signal="pressed" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/VerticalRuler" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/VerticalRuler" method="_on_VerticalRuler_pressed"] +[connection signal="mouse_entered" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" method="_on_ViewportContainer_mouse_entered"] +[connection signal="mouse_exited" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" method="_on_ViewportContainer_mouse_exited"] +[connection signal="mouse_entered" from="DockableContainer/Second Canvas" to="DockableContainer/Second Canvas" method="_on_ViewportContainer_mouse_entered"] +[connection signal="mouse_exited" from="DockableContainer/Second Canvas" to="DockableContainer/Second Canvas" method="_on_ViewportContainer_mouse_exited"] diff --git a/src/UI/ViewportContainer.gd b/src/UI/ViewportContainer.gd index 603a078fb..e0966199b 100644 --- a/src/UI/ViewportContainer.gd +++ b/src/UI/ViewportContainer.gd @@ -2,8 +2,6 @@ extends SubViewportContainer @export var camera_path: NodePath -var _mouse_inside = false - @onready var camera := get_node(camera_path) as CanvasCamera @@ -12,20 +10,17 @@ func _ready() -> void: material.blend_mode = CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA -func _input(event): - if event is InputEventMouseMotion: - if get_global_rect().has_point(event.position): - if !_mouse_inside: - _mouse_inside = true - camera.set_process_input(true) - Global.control.left_cursor.visible = Global.show_left_tool_icon - Global.control.right_cursor.visible = Global.show_right_tool_icon - if Global.cross_cursor: - Input.set_default_cursor_shape(Input.CURSOR_CROSS) - else: - if _mouse_inside: - _mouse_inside = false - camera.drag = false - Global.control.left_cursor.visible = false - Global.control.right_cursor.visible = false - Input.set_default_cursor_shape(Input.CURSOR_ARROW) +func _on_ViewportContainer_mouse_entered() -> void: + camera.set_process_input(true) + Global.control.left_cursor.visible = Global.show_left_tool_icon + Global.control.right_cursor.visible = Global.show_right_tool_icon + if Global.cross_cursor: + Input.set_default_cursor_shape(Input.CURSOR_CROSS) + + +func _on_ViewportContainer_mouse_exited() -> void: + camera.set_process_input(false) + camera.drag = false + Global.control.left_cursor.visible = false + Global.control.right_cursor.visible = false + Input.set_default_cursor_shape(Input.CURSOR_ARROW)