1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Fix cursor blinking at the edge of canvas (#1075)

* fix: mouse blinking at the edge of painting canvas

* format: reformat src/UI/ViewportContainer.gd

* format: reformat according to gdlint

* refactor: removed unused code comments
This commit is contained in:
Hamster 2024-08-13 00:44:48 +08:00 committed by GitHub
parent 15c186d8a1
commit 77f6860f7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 18 deletions

View file

@ -420,7 +420,3 @@ 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"]

View file

@ -2,6 +2,8 @@ extends SubViewportContainer
@export var camera_path: NodePath
var _mouse_inside = false
@onready var camera := get_node(camera_path) as CanvasCamera
@ -10,17 +12,20 @@ func _ready() -> void:
material.blend_mode = CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA
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)
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)