1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

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.
This commit is contained in:
Tim Ledbetter 2022-12-16 00:31:13 +00:00 committed by Sam Atkins
parent 5ba0b551f4
commit 213d82f39b

View file

@ -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<int>();
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();