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:
Timothy Slater 2022-12-08 20:41:40 -06:00 committed by Sam Atkins
parent a321df12e1
commit 159f6cf0ac
Notes: sideshowbarker 2024-07-17 10:16:43 +09:00

View file

@ -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