mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:27:35 +00:00
PixelPaint: Fix off-by-one in on_second_paint() clip rect
Previously the clip rect did not include the 1px border at the edges of the rulers.
This commit is contained in:
parent
5e29e04122
commit
efb2bed525
2 changed files with 13 additions and 5 deletions
|
@ -134,6 +134,16 @@ void ImageEditor::update_modified()
|
||||||
on_modified_change(is_modified());
|
on_modified_change(is_modified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx::IntRect ImageEditor::subtract_rulers_from_rect(Gfx::IntRect const& rect) const
|
||||||
|
{
|
||||||
|
Gfx::IntRect clipped_rect {};
|
||||||
|
clipped_rect.set_top(max(rect.y(), m_ruler_thickness + 1));
|
||||||
|
clipped_rect.set_left(max(rect.x(), m_ruler_thickness + 1));
|
||||||
|
clipped_rect.set_bottom(rect.bottom());
|
||||||
|
clipped_rect.set_right(rect.right());
|
||||||
|
return clipped_rect;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageEditor::paint_event(GUI::PaintEvent& event)
|
void ImageEditor::paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
GUI::Frame::paint_event(event);
|
GUI::Frame::paint_event(event);
|
||||||
|
@ -282,11 +292,7 @@ void ImageEditor::second_paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
if (m_active_tool) {
|
if (m_active_tool) {
|
||||||
if (m_show_rulers) {
|
if (m_show_rulers) {
|
||||||
auto clipped_event = GUI::PaintEvent(Gfx::IntRect { event.rect().x() + m_ruler_thickness,
|
auto clipped_event = GUI::PaintEvent(subtract_rulers_from_rect(event.rect()), event.window_size());
|
||||||
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);
|
m_active_tool->on_second_paint(m_active_layer, clipped_event);
|
||||||
} else {
|
} else {
|
||||||
m_active_tool->on_second_paint(m_active_layer, event);
|
m_active_tool->on_second_paint(m_active_layer, event);
|
||||||
|
|
|
@ -148,6 +148,8 @@ private:
|
||||||
|
|
||||||
virtual void selection_did_change() override;
|
virtual void selection_did_change() override;
|
||||||
|
|
||||||
|
Gfx::IntRect subtract_rulers_from_rect(Gfx::IntRect const& rect) const;
|
||||||
|
|
||||||
GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const;
|
GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const;
|
||||||
GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const;
|
GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue