From 3d756e89c86e0b2d061076730ec4440db0e8b49b Mon Sep 17 00:00:00 2001 From: Crax97 Date: Mon, 29 Aug 2022 22:55:40 +0200 Subject: [PATCH] PixelPaint: Ask the current tool for the preferred pixel location When handling mouse events, different tools may want to interact with a different pixel in the image for the same input position. --- Userland/Applications/PixelPaint/ImageEditor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index aa76f0e593..81e3ad73e0 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -269,9 +269,11 @@ void ImageEditor::second_paint_event(GUI::PaintEvent& event) GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(GUI::MouseEvent const& event) const { auto image_position = frame_to_content_position(event.position()); + auto tool_adjusted_image_position = m_active_tool->point_position_to_preferred_cell(image_position); + return { static_cast(event.type()), - image_position.to_rounded(), + tool_adjusted_image_position, event.buttons(), event.button(), event.modifiers(), @@ -286,9 +288,11 @@ GUI::MouseEvent ImageEditor::event_adjusted_for_layer(GUI::MouseEvent const& eve { auto image_position = frame_to_content_position(event.position()); image_position.translate_by(-layer.location().x(), -layer.location().y()); + auto tool_adjusted_image_position = m_active_tool->point_position_to_preferred_cell(image_position); + return { static_cast(event.type()), - image_position.to_rounded(), + tool_adjusted_image_position, event.buttons(), event.button(), event.modifiers(),