mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +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
|
@ -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