From 159f6cf0ac51e7dca38c6763c7fe2b63dddbd04d Mon Sep 17 00:00:00 2001 From: Timothy Slater Date: Thu, 8 Dec 2022 20:41:40 -0600 Subject: [PATCH] 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 --- Userland/Applications/PixelPaint/ImageEditor.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 8de57a6fb9..66f56ec9d8 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -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