PixelPaint: Account for rulers on Tool second paint events
This change makes ImageEditor provide an altered PaintEvent to the active tool when rulers are visible. This PaintEvent has a rect that has been adjust to account for the thickness of the rulers. Tools use this rect for Painter clipping and this prevents a Tool's on_second_paint from drawing over top of the rulers
This commit is contained in:
parent
a321df12e1
commit
159f6cf0ac
Notes:
sideshowbarker
2024-07-17 10:16:43 +09:00
Author: https://github.com/tslater2006 Commit: https://github.com/SerenityOS/serenity/commit/159f6cf0ac Pull-request: https://github.com/SerenityOS/serenity/pull/15828 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/gmta
1 changed files with 12 additions and 2 deletions
|
@ -280,8 +280,18 @@ Gfx::IntRect ImageEditor::mouse_indicator_rect_y() const
|
|||
|
||||
void ImageEditor::second_paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
if (m_active_tool)
|
||||
m_active_tool->on_second_paint(m_active_layer, event);
|
||||
if (m_active_tool) {
|
||||
if (m_show_rulers) {
|
||||
auto clipped_event = GUI::PaintEvent(Gfx::IntRect { event.rect().x() + m_ruler_thickness,
|
||||
event.rect().y() + m_ruler_thickness,
|
||||
event.rect().width() - m_ruler_thickness,
|
||||
event.rect().height() - m_ruler_thickness },
|
||||
event.window_size());
|
||||
m_active_tool->on_second_paint(m_active_layer, clipped_event);
|
||||
} else {
|
||||
m_active_tool->on_second_paint(m_active_layer, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(GUI::MouseEvent const& event) const
|
||||
|
|
Loading…
Add table
Reference in a new issue