1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

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.
This commit is contained in:
Crax97 2022-08-29 22:55:40 +02:00 committed by Andreas Kling
parent c9fb380490
commit 3d756e89c8

View file

@ -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(),