mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +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
Notes:
sideshowbarker
2024-07-18 05:14:29 +09:00
Author: https://github.com/sppmacd
Commit: 0224dc2882
Pull-request: https://github.com/SerenityOS/serenity/pull/9593
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/joebentley
Reviewed-by: https://github.com/nico
28 changed files with 186 additions and 127 deletions
|
@ -23,19 +23,22 @@ MoveTool::~MoveTool()
|
|||
{
|
||||
}
|
||||
|
||||
void MoveTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent& image_event)
|
||||
void MoveTool::on_mousedown(Layer& layer, MouseEvent& event)
|
||||
{
|
||||
if (event.button() != GUI::MouseButton::Left)
|
||||
auto& layer_event = event.layer_event();
|
||||
auto& image_event = event.image_event();
|
||||
if (layer_event.button() != GUI::MouseButton::Left)
|
||||
return;
|
||||
if (!layer.rect().contains(event.position()))
|
||||
if (!layer.rect().contains(layer_event.position()))
|
||||
return;
|
||||
m_layer_being_moved = layer;
|
||||
m_event_origin = image_event.position();
|
||||
m_layer_origin = layer.location();
|
||||
}
|
||||
|
||||
void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& image_event)
|
||||
void MoveTool::on_mousemove(Layer&, MouseEvent& event)
|
||||
{
|
||||
auto& image_event = event.image_event();
|
||||
if (!m_layer_being_moved)
|
||||
return;
|
||||
auto delta = image_event.position() - m_event_origin;
|
||||
|
@ -43,9 +46,10 @@ void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& image_eve
|
|||
m_editor->layers_did_change();
|
||||
}
|
||||
|
||||
void MoveTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
void MoveTool::on_mouseup(Layer&, MouseEvent& event)
|
||||
{
|
||||
if (event.button() != GUI::MouseButton::Left)
|
||||
auto& layer_event = event.layer_event();
|
||||
if (layer_event.button() != GUI::MouseButton::Left)
|
||||
return;
|
||||
m_layer_being_moved = nullptr;
|
||||
m_editor->did_complete_action();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue