mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +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:
parent
635130ef76
commit
0224dc2882
28 changed files with 186 additions and 127 deletions
|
@ -49,12 +49,14 @@ RefPtr<Guide> GuideTool::closest_guide(const Gfx::IntPoint& point)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void GuideTool::on_mousedown(Layer&, GUI::MouseEvent& mouse_event, GUI::MouseEvent& image_event)
|
||||
void GuideTool::on_mousedown(Layer&, MouseEvent& event)
|
||||
{
|
||||
if (!m_editor)
|
||||
return;
|
||||
|
||||
if (mouse_event.button() != GUI::MouseButton::Left)
|
||||
auto& image_event = event.image_event();
|
||||
|
||||
if (image_event.button() != GUI::MouseButton::Left)
|
||||
return;
|
||||
|
||||
m_editor->set_guide_visibility(true);
|
||||
|
@ -83,7 +85,7 @@ void GuideTool::on_mousedown(Layer&, GUI::MouseEvent& mouse_event, GUI::MouseEve
|
|||
}
|
||||
}
|
||||
|
||||
void GuideTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&)
|
||||
void GuideTool::on_mouseup(Layer&, MouseEvent&)
|
||||
{
|
||||
m_guide_origin = 0;
|
||||
m_event_origin = { 0, 0 };
|
||||
|
@ -102,11 +104,12 @@ void GuideTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&)
|
|||
m_selected_guide = nullptr;
|
||||
}
|
||||
|
||||
void GuideTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& image_event)
|
||||
void GuideTool::on_mousemove(Layer&, MouseEvent& event)
|
||||
{
|
||||
if (!m_selected_guide)
|
||||
return;
|
||||
|
||||
auto& image_event = event.image_event();
|
||||
auto delta = image_event.position() - m_event_origin;
|
||||
|
||||
auto relevant_offset = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue