From 42de5ccb29dc71456bc9ca6ad92f307e43f10d51 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Wed, 24 Jan 2024 03:06:09 +0200 Subject: [PATCH] Remove unneeded has_focus checks --- src/Autoload/Tools.gd | 3 +-- src/UI/Canvas/Canvas.gd | 3 +-- src/UI/Canvas/Indicators.gd | 7 +++---- src/UI/Canvas/MouseGuide.gd | 2 +- src/UI/Canvas/Previews.gd | 7 +++---- src/UI/Canvas/Rulers/Guide.gd | 1 - src/UI/PerspectiveEditor/PerspectiveLine.gd | 4 ++-- src/UI/PerspectiveEditor/VanishingPoint.gd | 1 - 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 4ef87fdf8..1188a9586 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -541,8 +541,7 @@ func handle_draw(position: Vector2i, event: InputEvent) -> void: var project := Global.current_project var text := "[%s×%s]" % [project.size.x, project.size.y] - if Global.has_focus: - text += " %s, %s" % [position.x, position.y] + text += " %s, %s" % [position.x, position.y] if not _slots[MOUSE_BUTTON_LEFT].tool_node.cursor_text.is_empty(): text += " %s" % _slots[MOUSE_BUTTON_LEFT].tool_node.cursor_text if not _slots[MOUSE_BUTTON_RIGHT].tool_node.cursor_text.is_empty(): diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index 29de35cc2..ec1dd888e 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -91,8 +91,7 @@ func _input(event: InputEvent) -> void: Tools.handle_draw(Vector2i(current_pixel.floor()), event) if sprite_changed_this_frame: - if Global.has_focus: - queue_redraw() + queue_redraw() update_selected_cels_textures() diff --git a/src/UI/Canvas/Indicators.gd b/src/UI/Canvas/Indicators.gd index 08ceb727a..e0c864fca 100644 --- a/src/UI/Canvas/Indicators.gd +++ b/src/UI/Canvas/Indicators.gd @@ -2,12 +2,11 @@ extends Node2D func _input(event: InputEvent) -> void: - if Global.has_focus: - if event is InputEventMouse or event is InputEventKey: - queue_redraw() + if event is InputEventMouse or event is InputEventKey: + queue_redraw() func _draw() -> void: # Draw rectangle to indicate the pixel currently being hovered on - if Global.has_focus and Global.can_draw: + if Global.can_draw: Tools.draw_indicator() diff --git a/src/UI/Canvas/MouseGuide.gd b/src/UI/Canvas/MouseGuide.gd index 65a2168c9..6019659b0 100644 --- a/src/UI/Canvas/MouseGuide.gd +++ b/src/UI/Canvas/MouseGuide.gd @@ -29,7 +29,7 @@ func draw_guide_line(): func _input(event: InputEvent) -> void: - if !Global.show_mouse_guides or !Global.can_draw or !Global.has_focus: + if !Global.show_mouse_guides or !Global.can_draw: visible = false return visible = true diff --git a/src/UI/Canvas/Previews.gd b/src/UI/Canvas/Previews.gd index 2f90d6cef..82340a881 100644 --- a/src/UI/Canvas/Previews.gd +++ b/src/UI/Canvas/Previews.gd @@ -2,11 +2,10 @@ extends Node2D func _input(event: InputEvent) -> void: - if Global.has_focus: - if event is InputEventMouse or event is InputEventKey: - queue_redraw() + if event is InputEventMouse or event is InputEventKey: + queue_redraw() func _draw() -> void: - if Global.has_focus and Global.can_draw: + if Global.can_draw: Tools.draw_preview() diff --git a/src/UI/Canvas/Rulers/Guide.gd b/src/UI/Canvas/Rulers/Guide.gd index 6733ad4dd..14e05b0e6 100644 --- a/src/UI/Canvas/Rulers/Guide.gd +++ b/src/UI/Canvas/Rulers/Guide.gd @@ -39,7 +39,6 @@ func _input(_event: InputEvent) -> void: if ( Input.is_action_just_pressed(&"left_mouse") and Global.can_draw - and Global.has_focus and rect.has_point(mouse_pos) ): if ( diff --git a/src/UI/PerspectiveEditor/PerspectiveLine.gd b/src/UI/PerspectiveEditor/PerspectiveLine.gd index cf7d4fabc..6e3ff00dc 100644 --- a/src/UI/PerspectiveEditor/PerspectiveLine.gd +++ b/src/UI/PerspectiveEditor/PerspectiveLine.gd @@ -65,7 +65,7 @@ func _input(event: InputEvent) -> void: var project_size := Global.current_project.size if track_mouse: - if !Global.can_draw or !Global.has_focus or Global.perspective_editor.tracker_disabled: + if !Global.can_draw or Global.perspective_editor.tracker_disabled: hide_perspective_line() return default_color.a = 0.5 @@ -94,7 +94,7 @@ func try_rotate_scale(): var test_line := (points[1] - points[0]).rotated(deg_to_rad(90)).normalized() var from_a := mouse_point - test_line * CIRCLE_RAD * 2 / Global.camera.zoom.x var from_b := mouse_point + test_line * CIRCLE_RAD * 2 / Global.camera.zoom.x - if Input.is_action_just_pressed("left_mouse") and Global.can_draw and Global.has_focus: + if Input.is_action_just_pressed("left_mouse") and Global.can_draw: if ( Geometry2D.segment_intersects_segment(from_a, from_b, points[0], points[1]) or mouse_point.distance_to(points[1]) < CIRCLE_RAD * 2 / Global.camera.zoom.x diff --git a/src/UI/PerspectiveEditor/VanishingPoint.gd b/src/UI/PerspectiveEditor/VanishingPoint.gd index 37d08c16b..15b9ba51a 100644 --- a/src/UI/PerspectiveEditor/VanishingPoint.gd +++ b/src/UI/PerspectiveEditor/VanishingPoint.gd @@ -75,7 +75,6 @@ func _input(_event: InputEvent): if ( Input.is_action_just_pressed("left_mouse") and Global.can_draw - and Global.has_focus and mouse_point.distance_to(start) < 8 / Global.camera.zoom.x ): if (