Skip to content

Commit 8a9eaac

Browse files
committed
ENG-9: Limit copyright info to first page
Currently, MuseScore displays copyright metadata in a centered footer. This results in the information being displayed on every page, which is inconsistent with many published scores. This commit hides the footers on import and rather creates a VBox, populates it with the copyright metadata, and places it at the bottom of the first page (either below the first explicit pagebreak, or below the last system of the first page after an initial layout).
1 parent cd0ea90 commit 8a9eaac

File tree

8 files changed

+13680
-4
lines changed

8 files changed

+13680
-4
lines changed

importexport/musicxml/importmxmlpass1.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static VBox* addCreditWords(Score* const score, const CreditWordsList& crWords,
781781
}
782782

783783
//---------------------------------------------------------
784-
// createMeasuresAndVboxes
784+
// createDefaultHeader
785785
//---------------------------------------------------------
786786

787787
void MusicXMLParserPass1::createDefaultHeader(Score* const score)
@@ -1163,8 +1163,13 @@ void MusicXMLParserPass1::identification()
11631163
QString strType = _e.attributes().value("type").toString();
11641164
_score->setMetaTag(strType, _e.readElementText());
11651165
}
1166-
else if (_e.name() == "rights")
1167-
_score->setMetaTag("copyright", _e.readElementText());
1166+
else if (_e.name() == "rights") {
1167+
_score->setMetaTag("copyright", _e.readElementText().trimmed());
1168+
bool copyrightFirstPageOnly = true; // TODO: expose as import setting
1169+
if (copyrightFirstPageOnly)
1170+
// Somewhat temporary fix: hide footer and make copyright a text box
1171+
_score->setStyleValue(Sid::showFooter, false);
1172+
}
11681173
else if (_e.name() == "encoding") {
11691174
// TODO
11701175
while (_e.readNextStartElement()) {

importexport/musicxml/importmxmlpass2.cpp

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@
5858
#include "libmscore/system.h"
5959
#include "libmscore/tempo.h"
6060
#include "libmscore/tempotext.h"
61+
#include "libmscore/text.h"
6162
#include "libmscore/tie.h"
6263
#include "libmscore/timesig.h"
6364
#include "libmscore/tremolo.h"
6465
#include "libmscore/trill.h"
6566
#include "libmscore/utils.h"
67+
#include "libmscore/box.h"
6668
#include "libmscore/volta.h"
6769
#include "libmscore/textline.h"
6870
#include "libmscore/barline.h"
@@ -619,6 +621,52 @@ static void setPartInstruments(MxmlLogger* logger, const QXmlStreamReader* const
619621
}
620622
}
621623
}
624+
625+
//---------------------------------------------------------
626+
// addCopyrightVBox
627+
//---------------------------------------------------------
628+
629+
static MeasureBase* findFirstPageBreak(Score* score)
630+
{
631+
for (MeasureBase* mb = score->first(); mb; mb = mb->next())
632+
if (mb->pageBreak())
633+
return mb;
634+
// If no imported pageBreaks, find the last measure of the
635+
// second-to-last or last system of the first page
636+
score->doLayout();
637+
if (score->pages().size() == 1) return score->last();
638+
auto firstPageSystems = score->pages().first()->systems();
639+
MeasureBase* lastMeasureOfFirstPageAdjusted = firstPageSystems[firstPageSystems.length() - 2]->measures().back();
640+
return lastMeasureOfFirstPageAdjusted ? lastMeasureOfFirstPageAdjusted : score->last();
641+
}
642+
643+
//---------------------------------------------------------
644+
// addCopyrightVBox
645+
//---------------------------------------------------------
646+
647+
/**
648+
Adds VBox at the end of the first page with copyright info
649+
*/
650+
651+
void MusicXMLParserPass2::addCopyrightVBox()
652+
{
653+
if (_score->metaTag("copyright").isEmpty())
654+
return;
655+
Text* copyrightText = new Text(_score);
656+
VBox* copyrightVBox = new VBox(_score);
657+
copyrightText->setPlainText(_score->metaTag("copyright"));
658+
copyrightText->setAlign(Align::BASELINE | Align::HCENTER);
659+
copyrightText->setPropertyFlags(Pid::ALIGN, PropertyFlags::UNSTYLED);
660+
copyrightVBox->add(copyrightText);
661+
copyrightVBox->setAutoSizeEnabled(true);
662+
MeasureBase* mb = findFirstPageBreak(_score);
663+
_score->addMeasure(copyrightVBox, mb->next());
664+
copyrightVBox->setPageBreak(true);
665+
if (mb->pageBreak()) {
666+
mb->setPageBreak(false);
667+
mb->setLineBreak(true);
668+
}
669+
}
622670

623671
//---------------------------------------------------------
624672
// text2syms
@@ -1893,10 +1941,16 @@ void MusicXMLParserPass2::scorePartwise()
18931941
_score->lastMeasure()->setEndBarLineType(BarLineType::NORMAL, 0);
18941942

18951943
_score->connectArpeggios();
1896-
_score->fixupLaissezVibrer();
1944+
_score->fixupLaissezVibrer();
18971945
cleanFretDiagrams(_score->firstMeasure());
18981946
if (_pass1.hasInferredHeaderText())
18991947
reformatHeaderVBox(_score->measures()->first());
1948+
1949+
bool copyrightFirstPageOnly = true; // TODO: expose as import setting
1950+
if (copyrightFirstPageOnly)
1951+
// Somewhat temporary fix: hide footer and make copyright a text box
1952+
addCopyrightVBox();
1953+
19001954
cleanUpLayoutBreaks(_score, _logger);
19011955
}
19021956

importexport/musicxml/importmxmlpass2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ class MusicXMLParserPass2 {
305305
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QString& text, const bool print);
306306
void staffDetails(const QString& partId);
307307
void staffTuning(StringData* t);
308+
void addCopyrightVBox();
308309
void skipLogCurrElem();
309310

310311
// multi-measure rest state handling

0 commit comments

Comments
 (0)