Skip to content

Commit

Permalink
Fix #296528: Footers now appear inside page margins
Browse files Browse the repository at this point in the history
Added the ability to layout a textbase using the bottom margin (the old way used the top margin in every case). This change fixes the issue.

Duplicate of musescore#5902
  • Loading branch information
SKefalidis authored and Jojo-Schmitz committed Sep 29, 2021
1 parent 1a87914 commit 30a25eb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions libmscore/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void Page::drawHeaderFooter(QPainter* p, int area, const QString& ss) const
text->setLayoutToParentWidth(true);
score()->setFooterText(text, area - MAX_HEADERS);
}
text->setLayoutRelativeToBottom(score()->styleB(Sid::footerInsideMargins));
}
text->setParent((Page*)this);
Align flags = Align::LEFT;
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ static const StyleType styleTypes[] {

{ Sid::footerFirstPage, "footerFirstPage", QVariant(true) },
{ Sid::footerOddEven, "footerOddEven", QVariant(true) },
{ Sid::footerInsideMargins, "footerInsideMargins", QVariant(false) },
{ Sid::evenFooterL, "evenFooterL", QVariant(QString()) },
{ Sid::evenFooterC, "evenFooterC", QVariant(QString("$:copyright:")) },
{ Sid::evenFooterR, "evenFooterR", QVariant(QString()) },
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ enum class Sid {
showFooter,
footerFirstPage,
footerOddEven,
footerInsideMargins,
evenFooterL,
evenFooterC,
evenFooterR,
Expand Down
2 changes: 1 addition & 1 deletion libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ void TextBase::layout1()
else if (parent()->isPage()) {
Page* p = toPage(parent());
h = p->height() - p->tm() - p->bm();
yoff = p->tm();
yoff = _layoutRelativeToBottom ? -p->bm() : p->tm(); // used to keep footers inside page margins
}
else if (parent()->isMeasure())
;
Expand Down
10 changes: 6 additions & 4 deletions libmscore/textbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class TextBase : public Element {

QString preEdit; // move to EditData?
bool _layoutToParentWidth { false };
bool _layoutRelativeToBottom { false }; // used to keep footers inside page margins

int hexState { -1 };
bool _primed { 0 };
Expand Down Expand Up @@ -298,11 +299,12 @@ class TextBase : public Element {
qreal lineHeight() const;
virtual qreal baseLine() const override;

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

bool layoutToParentWidth() const { return _layoutToParentWidth; }
void setLayoutToParentWidth(bool v) { _layoutToParentWidth = v; }
bool layoutToParentWidth() const { return _layoutToParentWidth; }
void setLayoutToParentWidth(bool v) { _layoutToParentWidth = v; }
void setLayoutRelativeToBottom(bool v) { _layoutRelativeToBottom = v ; }

virtual void startEdit(EditData&) override;
virtual bool edit(EditData&) override;
Expand Down
1 change: 1 addition & 0 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ Sid::showFooter, false, showFooter, 0 },
{ Sid::footerFirstPage, false, showFooterFirstPage, 0 },
{ Sid::footerOddEven, false, footerOddEven, 0 },
{ Sid::footerInsideMargins, false, footerInsideMargins, 0 },
{ Sid::evenFooterL, false, evenFooterL, 0 },
{ Sid::evenFooterC, false, evenFooterC, 0 },
{ Sid::evenFooterR, false, evenFooterR, 0 },
Expand Down
26 changes: 26 additions & 0 deletions mscore/editstyle.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2699,6 +2699,26 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="footerInsideMargins">
<property name="text">
<string>Inside margins</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -4887,6 +4907,12 @@ By default, they will be placed such as that their right end are at the same lev
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
Expand Down

0 comments on commit 30a25eb

Please sign in to comment.