mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +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
|
@ -63,24 +63,25 @@ void SprayTool::paint_it()
|
|||
layer->did_modify_bitmap(Gfx::IntRect::centered_on(m_last_pos, Gfx::IntSize(base_radius * 2, base_radius * 2)));
|
||||
}
|
||||
|
||||
void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
void SprayTool::on_mousedown(Layer&, MouseEvent& event)
|
||||
{
|
||||
m_color = m_editor->color_for(event);
|
||||
m_last_pos = event.position();
|
||||
auto& layer_event = event.layer_event();
|
||||
m_color = m_editor->color_for(layer_event);
|
||||
m_last_pos = layer_event.position();
|
||||
m_timer->start();
|
||||
paint_it();
|
||||
}
|
||||
|
||||
void SprayTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
void SprayTool::on_mousemove(Layer&, MouseEvent& event)
|
||||
{
|
||||
m_last_pos = event.position();
|
||||
m_last_pos = event.layer_event().position();
|
||||
if (m_timer->is_active()) {
|
||||
paint_it();
|
||||
m_timer->restart(m_timer->interval());
|
||||
}
|
||||
}
|
||||
|
||||
void SprayTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&)
|
||||
void SprayTool::on_mouseup(Layer&, MouseEvent&)
|
||||
{
|
||||
if (m_timer->is_active()) {
|
||||
m_timer->stop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue