Skip to content

Commit

Permalink
Merge pull request #2536 from ericfont/105716-AlbumManager-PageBreak
Browse files Browse the repository at this point in the history
fix #105716 Album option Page/Section Break
  • Loading branch information
lasconic committed Apr 15, 2016
2 parents bdff4e1 + c1c75fe commit 1cf5caf
Show file tree
Hide file tree
Showing 17 changed files with 1,560 additions and 20 deletions.
2 changes: 1 addition & 1 deletion libmscore/measurebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void MeasureBase::undoSetBreak(bool v, LayoutBreak::Type type)
score()->undoAddElement(lb);
}
else {
// remove line break
// remove layout break
for (Element* e : el()) {
if (e->isLayoutBreak() && toLayoutBreak(e)->layoutBreakType() == type) {
score()->undoRemoveElement(e);
Expand Down
16 changes: 10 additions & 6 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ void Score::removeAudio()
// appendScore
//---------------------------------------------------------

bool Score::appendScore(Score* score)
bool Score::appendScore(Score* score, bool addPageBreak, bool addSectionBreak)
{
if (parts().size() < score->parts().size() || staves().size() < score->staves().size())
return false;
Expand All @@ -1761,13 +1761,17 @@ bool Score::appendScore(Score* score)
return false;
int tickOfAppend = lastMeasure->endTick();

if (!lastMeasure->lineBreak() && !lastMeasure->pageBreak()) {
lastMeasure->undoSetBreak(true, LayoutBreak::Type::LINE);
// apply Page/Section Breaks if desired
if (addPageBreak) {
if (!lastMeasure->pageBreak()) {
lastMeasure->undoSetBreak(false, LayoutBreak::Type::LINE); // remove line break if exists
lastMeasure->undoSetBreak(true, LayoutBreak::Type::PAGE); // apply page break
}
}

if (!lastMeasure->sectionBreak()) {
else if (!lastMeasure->lineBreak() && !lastMeasure->pageBreak())
lastMeasure->undoSetBreak(true, LayoutBreak::Type::LINE);
if (addSectionBreak && !lastMeasure->sectionBreak())
lastMeasure->undoSetBreak(true, LayoutBreak::Type::SECTION);
}

// match concert pitch states
if (styleB(StyleIdx::concertPitch) != score->styleB(StyleIdx::concertPitch))
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class Score : public QObject, public ScoreElement {
bool transpose(TransposeMode mode, TransposeDirection, Key transposeKey, int transposeInterval,
bool trKeys, bool transposeChordNames, bool useDoubleSharpsFlats);

bool appendScore(Score*);
bool appendScore(Score*, bool addPageBreak = false, bool addSectionBreak = true);

int pageIdx(Page* page) const { return _pages.indexOf(page); }

Expand Down
6 changes: 3 additions & 3 deletions mscore/album.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Album::print()
// createScore
//---------------------------------------------------------

bool Album::createScore(const QString& fn)
bool Album::createScore(const QString& fn, bool addPageBreak, bool addSectionBreak)
{
loadScores();

Expand Down Expand Up @@ -184,7 +184,7 @@ bool Album::createScore(const QString& fn)

// try to append root score
item->score->doLayout();
if (!score->appendScore(item->score)) {
if (!score->appendScore(item->score, addPageBreak, addSectionBreak)) {
qDebug("Cannot append root score of album item \"%s\".", qPrintable(item->name));
delete score;
return false;
Expand All @@ -196,7 +196,7 @@ bool Album::createScore(const QString& fn)
Score* currentScoreExcerpt = item->score->excerpts().at(i)->partScore();
if (currentScoreExcerpt) {
currentScoreExcerpt->doLayout();
if (!score->excerpts().at(i)->partScore()->appendScore(currentScoreExcerpt)) {
if (!score->excerpts().at(i)->partScore()->appendScore(currentScoreExcerpt, addPageBreak, addSectionBreak)) {
qDebug("Cannot append excerpt %d of album item \"%s\".", i, qPrintable(item->name));
delete score;
return false;
Expand Down
2 changes: 1 addition & 1 deletion mscore/album.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Album {
~Album();

void print();
bool createScore(const QString& fn);
bool createScore(const QString& fn, bool addPageBreak = false, bool addSectionBreak = true);
bool read(const QString& path);
void write(Xml& xml);
bool dirty() const { return _dirty; }
Expand Down
2 changes: 1 addition & 1 deletion mscore/albummanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void AlbumManager::createScoreClicked()
);
if (fn.isEmpty())
return;
if (!album->createScore(fn))
if (!album->createScore(fn, checkBoxAddPageBreak->isChecked(), checkBoxAddSectionBreak->isChecked()))
QMessageBox::critical(mscore, QWidget::tr("MuseScore: Save File"), tr("Error while creating score from album."));
}
}
Expand Down
64 changes: 57 additions & 7 deletions mscore/albummanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,63 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="createScore">
<property name="text">
<string>Join Scores</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxJoinScores">
<property name="minimumSize">
<size>
<width>0</width>
<height>63</height>
</size>
</property>
<property name="title">
<string>Save Joined Score</string>
</property>
<widget class="QPushButton" name="createScore">
<property name="geometry">
<rect>
<x>300</x>
<y>20</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Join Scores</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxAddPageBreak">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>281</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Add page break between scores</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxAddSectionBreak">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>281</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Add section break between scores</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand All @@ -196,6 +244,8 @@
<tabstop>createNew</tabstop>
<tabstop>load</tabstop>
<tabstop>print</tabstop>
<tabstop>checkBoxAddSectionBreak</tabstop>
<tabstop>checkBoxAddPageBreak</tabstop>
<tabstop>createScore</tabstop>
</tabstops>
<resources/>
Expand Down
211 changes: 211 additions & 0 deletions mtest/libmscore/album/album_105716-joined-addPageBreak-ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<lastSystemFillLimit>0</lastSystemFillLimit>
<page-layout>
<page-height>1683.36</page-height>
<page-width>1190.88</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer">Composer</metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle">Title</metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<LayoutBreak>
<subtype>page</subtype>
</LayoutBreak>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
<Measure number="1">
<LayoutBreak>
<subtype>page</subtype>
</LayoutBreak>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
<Measure number="1">
<LayoutBreak>
<subtype>page</subtype>
</LayoutBreak>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
<Measure number="1">
<LayoutBreak>
<subtype>section</subtype>
</LayoutBreak>
<LayoutBreak>
<subtype>page</subtype>
</LayoutBreak>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
<Measure number="1">
<LayoutBreak>
<subtype>page</subtype>
</LayoutBreak>
<LayoutBreak>
<subtype>section</subtype>
</LayoutBreak>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
</Score>
</museScore>
Loading

0 comments on commit 1cf5caf

Please sign in to comment.