mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Remove Global.has_focus completely
Might be a risky change, but I haven't noticed any bugs so far
This commit is contained in:
parent
42de5ccb29
commit
4e9b657077
|
@ -117,8 +117,6 @@ var current_project_index := 0:
|
|||
var can_draw := false
|
||||
## (Intended to be used as getter only) Tells if the user allowed to move the guide while on canvas.
|
||||
var move_guides_on_canvas := true
|
||||
## Tells if the canvas in currently in focus.
|
||||
var has_focus := false
|
||||
|
||||
var play_only_tags := true ## If [code]true[/code], animation plays only on frames of the same tag.
|
||||
## (Intended to be used as getter only) Tells if the x-symmetry guide ( -- ) is visible.
|
||||
|
|
|
@ -206,7 +206,6 @@ func _notification(what: int) -> void:
|
|||
# If the mouse exits the window and another application has the focus,
|
||||
# pause the application
|
||||
NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
Global.has_focus = false
|
||||
if Global.pause_when_unfocused:
|
||||
get_tree().paused = true
|
||||
NOTIFICATION_WM_MOUSE_EXIT:
|
||||
|
@ -217,12 +216,6 @@ func _notification(what: int) -> void:
|
|||
get_tree().paused = false
|
||||
NOTIFICATION_APPLICATION_FOCUS_IN:
|
||||
get_tree().paused = false
|
||||
var mouse_pos := get_global_mouse_position()
|
||||
var viewport_rect := Rect2(
|
||||
Global.main_viewport.global_position, Global.main_viewport.size
|
||||
)
|
||||
if viewport_rect.has_point(mouse_pos):
|
||||
Global.has_focus = true
|
||||
|
||||
|
||||
func _on_files_dropped(files: PackedStringArray) -> void:
|
||||
|
|
|
@ -3,11 +3,17 @@ extends FlowContainer
|
|||
var pen_inverted := false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Ensure to only call _input() if the cursor is inside the main canvas viewport
|
||||
Global.main_viewport.mouse_entered.connect(set_process_input.bind(true))
|
||||
Global.main_viewport.mouse_exited.connect(set_process_input.bind(false))
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
pen_inverted = event.pen_inverted
|
||||
return
|
||||
if not Global.has_focus or not Global.can_draw:
|
||||
if not Global.can_draw:
|
||||
return
|
||||
for action in ["undo", "redo"]:
|
||||
if event.is_action_pressed(action):
|
||||
|
|
|
@ -12,13 +12,11 @@ func _ready() -> void:
|
|||
|
||||
func _on_ViewportContainer_mouse_entered() -> void:
|
||||
camera.set_process_input(true)
|
||||
Global.has_focus = true
|
||||
Global.control.left_cursor.visible = Global.show_left_tool_icon
|
||||
Global.control.right_cursor.visible = Global.show_right_tool_icon
|
||||
|
||||
|
||||
func _on_ViewportContainer_mouse_exited() -> void:
|
||||
camera.set_process_input(false)
|
||||
Global.has_focus = false
|
||||
Global.control.left_cursor.visible = false
|
||||
Global.control.right_cursor.visible = false
|
||||
|
|
Loading…
Reference in a new issue