1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:08:13 +00:00

PixelPaint: Pass raw mouse event to Tools and wrap them all in a struct

This commit adds a Tool::MouseEvent struct, which contains events that
may be needed by tools: layer-relative, image-relative and raw (editor-
relative) event.

The raw event is used by ZoomTool to properly pan the view. This fixes
a bug which caused image to snap out of sight.
This commit is contained in:
Maciej Zygmanowski 2021-08-25 10:06:00 +02:00 committed by Andreas Kling
parent 635130ef76
commit 0224dc2882
28 changed files with 186 additions and 127 deletions

View file

@ -18,14 +18,15 @@ PickerTool::~PickerTool()
{
}
void PickerTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
void PickerTool::on_mousedown(Layer& layer, MouseEvent& event)
{
if (!layer.rect().contains(event.position()))
auto& layer_event = event.layer_event();
if (!layer.rect().contains(layer_event.position()))
return;
auto color = layer.bitmap().get_pixel(event.position());
if (event.button() == GUI::MouseButton::Left)
auto color = layer.bitmap().get_pixel(layer_event.position());
if (layer_event.button() == GUI::MouseButton::Left)
m_editor->set_primary_color(color);
else if (event.button() == GUI::MouseButton::Right)
else if (layer_event.button() == GUI::MouseButton::Right)
m_editor->set_secondary_color(color);
}