summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorCrax97 <gsolimeno97@gmail.com>2022-08-29 22:55:40 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-31 12:20:55 +0200
commit3d756e89c86e0b2d061076730ec4440db0e8b49b (patch)
treed6a7b847f80b97c140a80248eb691cce45bdc8ca /Userland
parentc9fb3804909a8ea91a3e0def84120374ce538b7e (diff)
downloadserenity-3d756e89c86e0b2d061076730ec4440db0e8b49b.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp8
1 files 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<GUI::Event::Type>(event.type()),
- image_position.to_rounded<int>(),
+ 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<GUI::Event::Type>(event.type()),
- image_position.to_rounded<int>(),
+ tool_adjusted_image_position,
event.buttons(),
event.button(),
event.modifiers(),