From 40f6a24fdcc83e5abf7693a452fbfe4664364d82 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 1 Feb 2021 21:07:09 +0200 Subject: [PATCH] Made Zoom tool work on the second viewport too --- CHANGELOG.md | 1 + src/Tools/Zoom.gd | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3561dcc..362a914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Laurenz Reinthaler (Schweini07), kleonc, Variable-ind - Improved the "Scale Image" dialog. It now automatically sets the size to the current project's size, has a button to lock aspect ratio, and resizing based on percentage. - Having no active selection no longer treats all the pixels of the canvas as selected. This is also a performance boost, especially for larger images, as Pixelorama no longer has to loop through all of the pixels to select them. - Tile mode rects are now cached for a little speedup. ([#443](https://github.com/Orama-Interactive/Pixelorama/pull/443)) +- The zoom tool now works on the second canvas too. ### Fixed - Fixed issue with pixels being selected outside of the canvas boundaries, when the selection rectangle was outside the canvas and its size got reduced. diff --git a/src/Tools/Zoom.gd b/src/Tools/Zoom.gd index a04d577..75df8a3 100644 --- a/src/Tools/Zoom.gd +++ b/src/Tools/Zoom.gd @@ -33,7 +33,14 @@ func update_config() -> void: func draw_start(_position : Vector2) -> void: - Global.camera.zoom_camera(_zoom_mode * 2 - 1) + var mouse_pos := get_global_mouse_position() + var viewport_rect := Rect2(Global.main_viewport.rect_global_position, Global.main_viewport.rect_size) + var viewport_rect_2 := Rect2(Global.second_viewport.rect_global_position, Global.second_viewport.rect_size) + + if viewport_rect.has_point(mouse_pos): + Global.camera.zoom_camera(_zoom_mode * 2 - 1) + elif viewport_rect_2.has_point(mouse_pos): + Global.camera2.zoom_camera(_zoom_mode * 2 - 1) func draw_move(_position : Vector2) -> void: