From 213d82f39b30425c340b80099846e7266ee7c23c Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 16 Dec 2022 00:31:13 +0000 Subject: [PATCH] PixelPaint: Fix move tool scaling function when zoomed The move tool enters scaling mode when the user mouses within 10 pixels either side of the the bottom right of the active layer boundary. Previously, the bounding box used to determine whether the mouse was at the bottom right of the layer used coordinates that were scaled to the size of the image. This made the size of the area you need to enter proportional the current zoom level. This commit fixes the issue by using non-scaled coordinates to calculate the bounding box, meaning its size is unaffected by the current zoom level. --- Userland/Applications/PixelPaint/Tools/MoveTool.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp index 9de45d8bf6..5906c1c001 100644 --- a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp @@ -50,9 +50,11 @@ void MoveTool::on_mousemove(Layer* layer, MouseEvent& event) return; constexpr int sensitivity = 20; - Gfx::IntPoint grab_rect_position = Gfx::IntPoint(layer->location().x() + layer->size().width() - sensitivity / 2, layer->location().y() + layer->size().height() - sensitivity / 2); - Gfx::IntRect grab_rect = Gfx::IntRect(grab_rect_position, Gfx::IntSize(sensitivity, sensitivity)); - auto updated_is_in_lower_right_corner = grab_rect.contains(event.image_event().position()); // check if the mouse is in the lower right corner + auto bottom_right_layer_coordinates = layer->relative_rect().bottom_right().translated(1); + auto bottom_right_frame_coordinates = m_editor->content_to_frame_position(bottom_right_layer_coordinates).to_rounded(); + auto grab_rect_top_left = bottom_right_frame_coordinates.translated(-sensitivity / 2); + auto grab_rect = Gfx::IntRect(grab_rect_top_left, Gfx::IntSize(sensitivity, sensitivity)); + auto updated_is_in_lower_right_corner = grab_rect.contains(event.raw_event().position()); // check if the mouse is in the lower right corner if (m_mouse_in_resize_corner != updated_is_in_lower_right_corner) { m_mouse_in_resize_corner = updated_is_in_lower_right_corner; m_editor->update_tool_cursor();