Skip to content

Commit

Permalink
[MU4] fix #7819 - don't draw page elements onto beyond page bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
wizofaus authored and igorkorsukov committed Jul 13, 2021
1 parent 2b4cfd5 commit abe8d18
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/engraving/draw/ipaintprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class IPaintProvider

virtual void drawPixmap(const PointF& point, const QPixmap& pm) = 0;
virtual void drawTiledPixmap(const RectF& rect, const QPixmap& pm, const PointF& offset = PointF()) = 0;

virtual void setClipRect(const RectF& rect) = 0;
virtual void setClipping(bool enable) = 0;
};

using IPaintProviderPtr = std::shared_ptr<IPaintProvider>;
Expand Down
10 changes: 10 additions & 0 deletions src/engraving/draw/painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,13 @@ void Painter::updateMatrix()
extended->setTransform(st.transform);
}
}

void Painter::setClipRect(const RectF& rect)
{
m_provider->setClipRect(rect);
}

void Painter::setClipping(bool enable)
{
m_provider->setClipping(enable);
}
3 changes: 3 additions & 0 deletions src/engraving/draw/painter.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ class Painter
void drawPixmap(const PointF& point, const QPixmap& pm);
void drawTiledPixmap(const RectF& rect, const QPixmap& pm, const PointF& offset = PointF());

void setClipRect(const RectF& rect);
void setClipping(bool enable);

//! NOTE Provider for tests.
//! We're not ready to use DI (ModuleIoC) here yet
static IPaintProviderPtr extended;
Expand Down
10 changes: 10 additions & 0 deletions src/engraving/draw/qpainterprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,13 @@ void QPainterProvider::drawTiledPixmap(const RectF& rect, const QPixmap& pm, con
{
m_painter->drawTiledPixmap(rect.toQRectF(), pm, QPointF(offset.x(), offset.y()));
}

void QPainterProvider::setClipRect(const RectF& rect)
{
m_painter->setClipRect(rect.toQRectF());
}

void QPainterProvider::setClipping(bool enable)
{
m_painter->setClipping(enable);
}
3 changes: 3 additions & 0 deletions src/engraving/draw/qpainterprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class QPainterProvider : public IPaintProvider
void drawPixmap(const PointF& point, const QPixmap& pm) override;
void drawTiledPixmap(const RectF& rect, const QPixmap& pm, const PointF& offset = PointF()) override;

void setClipRect(const RectF& rect) override;
void setClipping(bool enable) override;

private:
QPainter* m_painter = nullptr;
bool m_overship = false;
Expand Down
3 changes: 3 additions & 0 deletions src/notation/internal/notation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,14 @@ void Notation::paintPages(draw::Painter* painter, const RectF& frameRect, const
PointF pagePosition(page->pos());
painter->translate(pagePosition);
paintForeground(painter, page->bbox());
painter->setClipping(true);
painter->setClipRect(page->bbox());

QList<Element*> elements = page->items(frameRect.translated(-page->pos()));
Ms::paintElements(*painter, elements);

painter->translate(-pagePosition);
painter->setClipping(false);
}
}

Expand Down

0 comments on commit abe8d18

Please sign in to comment.