1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +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

@ -20,13 +20,14 @@ ZoomTool::~ZoomTool()
{
}
void ZoomTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
void ZoomTool::on_mousedown(Layer&, MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right)
auto& raw_event = event.raw_event();
if (raw_event.button() != GUI::MouseButton::Left && raw_event.button() != GUI::MouseButton::Right)
return;
auto scale_factor = (event.button() == GUI::MouseButton::Left) ? m_sensitivity : -m_sensitivity;
m_editor->scale_centered_on_position(event.position(), scale_factor);
auto scale_factor = (raw_event.button() == GUI::MouseButton::Left) ? m_sensitivity : -m_sensitivity;
m_editor->scale_centered_on_position(raw_event.position(), scale_factor);
}
GUI::Widget* ZoomTool::get_properties_widget()