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

Compare commits

...

2 commits

4 changed files with 20 additions and 22 deletions

View file

@ -416,13 +416,7 @@ var native_cursors := false:
else:
control.set_custom_cursor()
## Found in Preferences. If [code]true[/code], cursor becomes cross shaped when hovering the canvas.
var cross_cursor := true:
set(value):
cross_cursor = value
if cross_cursor:
main_viewport.mouse_default_cursor_shape = Control.CURSOR_CROSS
else:
main_viewport.mouse_default_cursor_shape = Control.CURSOR_ARROW
var cross_cursor := true
# View menu options
## If [code]true[/code], the canvas is in greyscale.

View file

@ -58,28 +58,30 @@ class Gizmo:
type = _type
direction = _direction
func get_cursor() -> DisplayServer.CursorShape:
var cursor := DisplayServer.CURSOR_MOVE
func get_cursor() -> Input.CursorShape:
var cursor := Input.CURSOR_MOVE
if direction == Vector2i.ZERO:
return DisplayServer.CURSOR_POINTING_HAND
return Input.CURSOR_POINTING_HAND
elif direction == Vector2i(-1, -1) or direction == Vector2i(1, 1): # Top left or bottom right
if Global.mirror_view:
cursor = DisplayServer.CURSOR_BDIAGSIZE
cursor = Input.CURSOR_BDIAGSIZE
else:
cursor = DisplayServer.CURSOR_FDIAGSIZE
cursor = Input.CURSOR_FDIAGSIZE
elif direction == Vector2i(1, -1) or direction == Vector2i(-1, 1): # Top right or bottom left
if Global.mirror_view:
cursor = DisplayServer.CURSOR_FDIAGSIZE
cursor = Input.CURSOR_FDIAGSIZE
else:
cursor = DisplayServer.CURSOR_BDIAGSIZE
cursor = Input.CURSOR_BDIAGSIZE
elif direction == Vector2i(0, -1) or direction == Vector2i(0, 1): # Center top or center bottom
cursor = DisplayServer.CURSOR_VSIZE
cursor = Input.CURSOR_VSIZE
elif direction == Vector2i(-1, 0) or direction == Vector2i(1, 0): # Center left or center right
cursor = DisplayServer.CURSOR_HSIZE
cursor = Input.CURSOR_HSIZE
return cursor
func _ready() -> void:
# It's being set to true only when the big_bounding_rectangle has a size larger than 0
set_process_input(false)
Global.camera.zoom_changed.connect(_update_on_zoom)
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(-1, -1))) # Top left
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(0, -1))) # Center top
@ -167,17 +169,17 @@ func _input(event: InputEvent) -> void:
_gizmo_rotate()
else: # Set the appropriate cursor
if gizmo_hover:
DisplayServer.cursor_set_shape(gizmo_hover.get_cursor())
Input.set_default_cursor_shape(gizmo_hover.get_cursor())
else:
var cursor := DisplayServer.CURSOR_ARROW
var cursor := Input.CURSOR_ARROW
if Global.cross_cursor:
cursor = DisplayServer.CURSOR_CROSS
cursor = Input.CURSOR_CROSS
var layer: BaseLayer = project.layers[project.current_layer]
if not layer.can_layer_get_drawn():
cursor = DisplayServer.CURSOR_FORBIDDEN
cursor = Input.CURSOR_FORBIDDEN
if DisplayServer.cursor_get_shape() != cursor:
DisplayServer.cursor_set_shape(cursor)
Input.set_default_cursor_shape(cursor)
func _move_with_arrow_keys(event: InputEvent) -> void:

View file

@ -305,7 +305,6 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
focus_mode = 2
mouse_default_cursor_shape = 3
stretch = true
script = ExtResource("23")
camera_path = NodePath("SubViewport/Camera2D")

View file

@ -14,9 +14,12 @@ 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)
Global.control.left_cursor.visible = false
Global.control.right_cursor.visible = false
Input.set_default_cursor_shape(Input.CURSOR_ARROW)