diff --git a/lorien/InfiniteCanvas/InfiniteCanvas.gd b/lorien/InfiniteCanvas/InfiniteCanvas.gd index dc8dc66..035dc1f 100644 --- a/lorien/InfiniteCanvas/InfiniteCanvas.gd +++ b/lorien/InfiniteCanvas/InfiniteCanvas.gd @@ -52,13 +52,13 @@ func _ready() -> void: for child in $SubViewport.get_children(): if child is BaseCursor: - _camera.zoom_changed.connect(Callable(child, "_on_zoom_changed")) - _camera.position_changed.connect(Callable(child, "_on_canvas_position_changed")) + _camera.zoom_changed.connect(child._on_zoom_changed) + _camera.position_changed.connect(child._on_canvas_position_changed) for child in get_children(): if child is CanvasTool: - _camera.is_panning.connect(Callable(child, "_on_is_panning")) - _camera.is_zooming.connect(Callable(child, "_on_is_zooming")) + _camera.panning_toggled.connect(child._on_panning_toggled) + _camera.zooming_toggled.connect(child._on_zooming_toggled) _camera.zoom_changed.connect(_on_zoom_changed) _camera.position_changed.connect(_on_camera_moved) diff --git a/lorien/InfiniteCanvas/PanZoomCamera.gd b/lorien/InfiniteCanvas/PanZoomCamera.gd index 8f404b3..15afcf9 100644 --- a/lorien/InfiniteCanvas/PanZoomCamera.gd +++ b/lorien/InfiniteCanvas/PanZoomCamera.gd @@ -1,9 +1,9 @@ extends Camera2D # ------------------------------------------------------------------------------------------------- -signal is_zooming(value: bool) +signal zooming_toggled(value: bool) signal zoom_changed(value: float) -signal is_panning(value: bool) +signal panning_toggled(value: bool) signal position_changed(value: Vector2) # ------------------------------------------------------------------------------------------------- @@ -41,10 +41,10 @@ func tool_event(event: InputEvent) -> void: if event is InputEventKey: if Utils.is_action_pressed("canvas_pan_key", event): _pan_active = true - is_panning.emit(true) + panning_toggled.emit(true) if Utils.is_action_released("canvas_pan_key", event): _pan_active = false - is_panning.emit(false) + panning_toggled.emit(false) if event is InputEventMouseButton: # Scroll wheel up/down to zoom @@ -59,14 +59,14 @@ func tool_event(event: InputEvent) -> void: if event.button_index == MOUSE_BUTTON_MIDDLE: if !event.ctrl_pressed: _pan_active = event.is_pressed() - is_panning.emit(_pan_active) + panning_toggled.emit(_pan_active) _zoom_active = false - is_zooming.emit(false) + zooming_toggled.emit(false) else: _zoom_active = event.is_pressed() - is_zooming.emit(_zoom_active) + zooming_toggled.emit(_zoom_active) _pan_active = false - is_panning.emit(false) + panning_toggled.emit(false) _start_mouse_pos = get_local_mouse_position() elif event is InputEventMouseMotion: diff --git a/lorien/InfiniteCanvas/Tools/CanvasTool.gd b/lorien/InfiniteCanvas/Tools/CanvasTool.gd index baa2d96..b0c01e3 100644 --- a/lorien/InfiniteCanvas/Tools/CanvasTool.gd +++ b/lorien/InfiniteCanvas/Tools/CanvasTool.gd @@ -36,14 +36,14 @@ func _on_brush_size_changed(size: int) -> void: _cursor.change_size(size) # ------------------------------------------------------------------------------------------------- -func _on_is_panning(is_panning: bool) -> void: - panning_detected = is_panning - eval_disable_stroke() +func _on_panning_toggled(panning_enabled: bool) -> void: + panning_detected = panning_enabled + _eval_disable_stroke() # ------------------------------------------------------------------------------------------------- -func _on_is_zooming(is_zooming: bool) -> void: - zooming_detected = is_zooming - eval_disable_stroke() +func _on_zooming_toggled(zooming_enabled: bool) -> void: + zooming_detected = zooming_enabled + _eval_disable_stroke() # ------------------------------------------------------------------------------------------------- func get_cursor() -> BaseCursor: @@ -102,7 +102,7 @@ func end_stroke() -> void: _canvas.end_stroke() performing_stroke = false -func eval_disable_stroke() -> void: +func _eval_disable_stroke() -> void: disable_stroke = panning_detected || zooming_detected # TODO(gd4): probably don't need this anymore