Skip to content

Commit

Permalink
remove collisions between header and music
Browse files Browse the repository at this point in the history
add x,y coordinates to Sid::headerOffset

fix failing CI tests

fix CI test errors
  • Loading branch information
Nick-Mazuk committed Sep 21, 2021
1 parent 0f3fb37 commit 37e8cbe
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/engraving/layout/layoutpage.cpp
Expand Up @@ -102,7 +102,8 @@ void LayoutPage::collectPage(const LayoutOptions& options, LayoutContext& ctx)
{
const qreal slb = ctx.score()->styleP(Sid::staffLowerBorder);
bool breakPages = ctx.score()->layoutMode() != LayoutMode::SYSTEM;
qreal footerExtension = qMax(0.0, ctx.page->footerHeight() - ctx.score()->styleP(Sid::footerOffset)); // how much the footer extends above the margin
qreal footerExtension = qMax(0.0, ctx.page->footerHeight() - ctx.score()->styleV(Sid::footerOffset).value<PointF>().y()); // how much the footer extends above the margin
qreal headerExtension = qMax(0.0, ctx.page->headerHeight() - ctx.score()->styleV(Sid::headerOffset).value<PointF>().y()); // how much the header extends below the margin
qreal endY = ctx.page->height() - ctx.page->bm() - footerExtension;
qreal y = 0.0;

Expand All @@ -116,7 +117,7 @@ void LayoutPage::collectPage(const LayoutOptions& options, LayoutContext& ctx)
ctx.page->system(0)->restoreLayout2();
y = ctx.page->system(0)->y() + ctx.page->system(0)->height();
} else {
y = ctx.page->tm();
y = ctx.page->tm() + headerExtension;
}
for (int i = 1; i < pSystems; ++i) {
System* cs = ctx.page->system(i);
Expand Down
12 changes: 6 additions & 6 deletions src/engraving/libmscore/page.cpp
Expand Up @@ -265,9 +265,9 @@ qreal Page::headerHeight() const
Text* headerCenter = layoutHeaderFooter(1, s2);
Text* headerRight = layoutHeaderFooter(2, s3);

qreal headerLeftHeight = headerLeft ? headerLeft->height() : 0.0;
qreal headerCenterHeight = headerCenter ? headerCenter->height() : 0.0;
qreal headerRightHeight = headerRight ? headerRight->height() : 0.0;
qreal headerLeftHeight = headerLeft ? headerLeft->visibleHeight() : 0.0;
qreal headerCenterHeight = headerCenter ? headerCenter->visibleHeight() : 0.0;
qreal headerRightHeight = headerRight ? headerRight->visibleHeight() : 0.0;
return qMax(headerLeftHeight, qMax(headerCenterHeight, headerRightHeight));
}

Expand Down Expand Up @@ -304,9 +304,9 @@ qreal Page::footerHeight() const
Text* footerCenter = layoutHeaderFooter(4, s2);
Text* footerRight = layoutHeaderFooter(5, s3);

qreal footerLeftHeight = footerLeft ? footerLeft->height() : 0.0;
qreal footerCenterHeight = footerCenter ? footerCenter->height() : 0.0;
qreal footerRightHeight = footerRight ? footerRight->height() : 0.0;
qreal footerLeftHeight = footerLeft ? footerLeft->visibleHeight() : 0.0;
qreal footerCenterHeight = footerCenter ? footerCenter->visibleHeight() : 0.0;
qreal footerRightHeight = footerRight ? footerRight->visibleHeight() : 0.0;

qreal footerHeight = qMax(footerLeftHeight, qMax(footerCenterHeight, footerRightHeight));

Expand Down
33 changes: 29 additions & 4 deletions src/engraving/libmscore/textbase.cpp
Expand Up @@ -2013,15 +2013,12 @@ void TextBase::layout1()
for (int i = 0; i < rows(); ++i) {
TextBlock* t = &_layout[i];
t->layout(this);
// if the text block is empty, ignore it
const RectF* r = &t->boundingRect();

if (r->height() == 0) {
r = &_layout[i - i].boundingRect();
}
if (t->columns() != 0) {
y += t->lineSpacing();
}
y += t->lineSpacing();
t->setY(y);
bb |= r->translated(0.0, y);
}
Expand Down Expand Up @@ -2135,6 +2132,34 @@ qreal TextBase::lineHeight() const
return fontMetrics().height();
}

//---------------------------------------------------------
// visibleHeight
//---------------------------------------------------------

qreal TextBase::visibleHeight()
{
RectF bb;
qreal y = 0;

// adjust the bounding box for the text item
for (int i = 0; i < rows(); ++i) {
TextBlock* t = &_layout[i];
if (t->columns() == 0 && i != rows() - 1) {
continue;
}
t->layout(this);
const RectF* r = &t->boundingRect();

if (r->height() == 0) {
r = &_layout[i - i].boundingRect();
}
y += t->lineSpacing();
t->setY(y);
bb |= r->translated(0.0, y);
}
return bb.height();
}

//---------------------------------------------------------
// baseLine
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/engraving/libmscore/textbase.h
Expand Up @@ -340,6 +340,7 @@ class TextBase : public EngravingItem
qreal lineSpacing() const;
qreal lineHeight() const;
virtual qreal baseLine() const override;
qreal visibleHeight();

bool empty() const { return xmlText().isEmpty(); }
void clear() { setXmlText(QString()); }
Expand Down

0 comments on commit 37e8cbe

Please sign in to comment.