fix #151121 fix #286497 fix #298638 : fix courtesy clef visbility and add tests

This commit is contained in:
AntonioBL 2020-01-15 23:09:14 +01:00
parent 66c33b0650
commit 1e141fdfcc
5 changed files with 981 additions and 31 deletions

View file

@ -132,14 +132,6 @@ void Clef::layout()
_clefTypes = staff()->clefType(Fraction(0,1));
}
Measure* meas = clefSeg->measure();
if (meas && meas->system() && !score()->lineMode()) {
const auto& ml = meas->system()->measures();
bool found = (std::find(ml.begin(), ml.end(), meas) != ml.end());
bool courtesy = (tick == meas->endTick() && (meas == meas->system()->lastMeasure() || !found));
if (courtesy && (!showCourtesy() || !score()->styleB(Sid::genCourtesyClef) || meas->isFinalMeasureOfSection()))
show = false;
}
// if clef not to show or not compatible with staff group
if (!show) {
setbbox(QRectF());

View file

@ -3735,19 +3735,54 @@ qreal Measure::createEndBarLines(bool isLastMeasureInSystem)
// if end repeat, clef goes after, otherwise clef goes before
Segment* clefSeg = findSegmentR(SegmentType::Clef, ticks());
if (clefSeg) {
Segment* s1;
Segment* s2;
if (repeatEnd()) {
s1 = seg;
s2 = clefSeg;
bool wasVisible = clefSeg->visible();
int visibleInt = 0;
for (int staffIdx = 0; staffIdx < nstaves; ++staffIdx) {
int track = staffIdx * VOICES;
Clef* clef = toClef(clefSeg->element(track));
if (clef) {
bool showCourtesy = score()->genCourtesyClef() && clef->showCourtesy(); // normally show a courtesy clef
// check if the measure is the last measure of the system or the last measure before a frame
bool lastMeasure = isLastMeasureInSystem || (nm ? !(next() == nm) : true);
if (!nm || isFinalMeasureOfSection() || (lastMeasure && !showCourtesy)) {
// hide the courtesy clef in the final measure of a section, or if the measure is the final measure of a system
// and the score style or the clef style is set to "not show courtesy clef",
// or if the clef is at the end of the very last measure of the score
clef->clear();
clefSeg->createShape(staffIdx);
if (visibleInt == 0)
visibleInt = 1;
}
else {
clef->layout();
clefSeg->createShape(staffIdx);
visibleInt = 2;
}
}
}
else {
s1 = clefSeg;
s2 = seg;
}
if (s1->next() != s2) {
_segments.remove(s1);
_segments.insert(s1, s2);
if (visibleInt == 2) // there is at least one visible clef in the clef segment
clefSeg->setVisible(true);
else if (visibleInt == 1) // all (courtesy) clefs in the clef segment are not visible
clefSeg->setVisible(false);
else // should never happen
qDebug("Clef Segment without Clef elements at tick %d/%d",clefSeg->tick().numerator(),clefSeg->tick().denominator());
if ((wasVisible != clefSeg->visible()) && system()) // recompute the width only if necessary
computeMinWidth();
if (seg) {
Segment* s1;
Segment* s2;
if (repeatEnd()) {
s1 = seg;
s2 = clefSeg;
}
else {
s1 = clefSeg;
s2 = seg;
}
if (s1->next() != s2) {
_segments.remove(s1);
_segments.insert(s1, s2);
}
}
}
@ -4111,11 +4146,8 @@ void Measure::addSystemTrailer(Measure* nm)
}
if (clefSegment) {
Clef* clef = toClef(clefSegment->element(track));
if (clef) {
clef->setSmall(true);
if (!nm || !score()->genCourtesyClef() || isFinalMeasure || !clef->showCourtesy())
clef->clear(); // make invisible
}
if (clef)
clef->setSmall(true);
}
}
if (s)

View file

@ -0,0 +1,403 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<maxSystemDistance>20</maxSystemDistance>
<frameSystemDistance>0</frameSystemDistance>
<barWidth>0.2</barWidth>
<endBarWidth>0.4</endBarWidth>
<bracketDistance>0.4</bracketDistance>
<stemWidth>0.2</stemWidth>
<staffLineWidth>0.15</staffLineWidth>
<measureNumberInterval>1</measureNumberInterval>
<measureNumberSystem>0</measureNumberSystem>
<genCourtesyTimesig>0</genCourtesyTimesig>
<sectionPause>2</sectionPause>
<showHeader>1</showHeader>
<evenHeaderL>$p</evenHeaderL>
<evenHeaderR>$:workTitle:</evenHeaderR>
<oddHeaderL>$:workTitle:</oddHeaderL>
<oddHeaderR>$p</oddHeaderR>
<footerOddEven>0</footerOddEven>
<evenFooterL>$:copyright:</evenFooterL>
<evenFooterC>$:plate:</evenFooterC>
<evenFooterR>Version $:version:</evenFooterR>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="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"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>85</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="17"/>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Part>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<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>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="17"/>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<LayoutBreak>
<subtype>line</subtype>
</LayoutBreak>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
<showCourtesyClef>0</showCourtesyClef>
</Clef>
</voice>
</Measure>
<Measure>
<voice>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
<showCourtesyClef>0</showCourtesyClef>
</Clef>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<LayoutBreak>
<subtype>section</subtype>
</LayoutBreak>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
</voice>
</Measure>
<HBox>
<width>5</width>
</HBox>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
<showCourtesyClef>0</showCourtesyClef>
</Clef>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
<Staff id="2">
<Measure>
<voice>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
</Clef>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
<showCourtesyClef>0</showCourtesyClef>
</Clef>
</voice>
</Measure>
<Measure>
<voice>
<Clef>
<concertClefType>G8va</concertClefType>
<transposingClefType>G8va</transposingClefType>
<showCourtesyClef>0</showCourtesyClef>
</Clef>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -0,0 +1,367 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<maxSystemDistance>20</maxSystemDistance>
<frameSystemDistance>0</frameSystemDistance>
<barWidth>0.2</barWidth>
<endBarWidth>0.4</endBarWidth>
<bracketDistance>0.4</bracketDistance>
<stemWidth>0.2</stemWidth>
<staffLineWidth>0.15</staffLineWidth>
<measureNumberInterval>1</measureNumberInterval>
<measureNumberSystem>0</measureNumberSystem>
<genCourtesyTimesig>0</genCourtesyTimesig>
<sectionPause>2</sectionPause>
<showHeader>1</showHeader>
<evenHeaderL>$p</evenHeaderL>
<evenHeaderR>$:workTitle:</evenHeaderR>
<oddHeaderL>$:workTitle:</oddHeaderL>
<oddHeaderR>$p</oddHeaderR>
<footerOddEven>0</footerOddEven>
<evenFooterL>$:copyright:</evenFooterL>
<evenFooterC>$:plate:</evenFooterC>
<evenFooterR>Version $:version:</evenFooterR>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="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"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>85</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<controller ctrl="32" value="17"/>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Part>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<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>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<controller ctrl="32" value="17"/>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<LayoutBreak>
<subtype>line</subtype>
</LayoutBreak>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<LayoutBreak>
<subtype>section</subtype>
</LayoutBreak>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<HBox>
<width>5</width>
</HBox>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
<Staff id="2">
<Measure>
<voice>
<KeySig>
<accidental>0</accidental>
</KeySig>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -35,6 +35,7 @@ class TestClefCourtesy : public QObject, public MTest
void clef_courtesy02();
void clef_courtesy03();
void clef_courtesy_78196();
void clef_courtesy04();
};
//---------------------------------------------------------
@ -54,7 +55,7 @@ static Measure* getMeasure(Score* score, int idx)
return m;
}
static void dropClef(Measure* m, ClefType t)
static void dropClef(Element* m, ClefType t)
{
Clef* clef = new Clef(m->score()); // create a new element, as Measure::drop() will eventually delete it
clef->setClefType(t);
@ -62,7 +63,10 @@ static void dropClef(Measure* m, ClefType t)
dropData.pos = m->pagePos();
dropData.dropElement = clef;
m->score()->startCmd();
m->drop(dropData);
if (m->isMeasure())
toMeasure(m)->drop(dropData);
else
m->findMeasure()->drop(dropData);
m->score()->endCmd();
}
@ -101,9 +105,33 @@ void TestClefCourtesy::clef_courtesy01()
QVERIFY2(seg, "No SegClef in measure 6.");
clefCourt = toClef(seg->element(0));
QVERIFY2(clefCourt, "No courtesy clef element in measure 6.");
// QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden.");
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 6 is NOT hidden.");
QVERIFY(saveCompareScore(score, "clef_courtesy01.mscx", DIR + "clef_courtesy01-ref.mscx"));
Clef* clef = nullptr;
seg = m1->findSegment(SegmentType::HeaderClef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 4.");
clef = static_cast<Clef*>(seg->element(0));
score->startCmd();
clef->undoChangeProperty(Pid::SHOW_COURTESY, false);
Clef* otherClef = clef->otherClef();
if (otherClef)
otherClef->undoChangeProperty(Pid::SHOW_COURTESY, false);
score->doLayout();
score->endCmd();
// check the required courtesy clef is there but hidden
m = m1->prevMeasure();
seg = m->findSegment(SegmentType::Clef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 3.");
clefCourt = static_cast<Clef*>(seg->element(0));
QVERIFY2(clefCourt, "No courtesy clef element in measure 3.");
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is not hidden when showCourtesy is false.");
QVERIFY2(clef->clefType() == ClefType::G8_VA, "Clef type in measure 4 is wrong");
dropClef(clef, ClefType::G15_MA);
QVERIFY2(clef->clefType() == ClefType::G15_MA, "Clef type in measure 4 is wrong");
delete score;
}
@ -148,7 +176,7 @@ void TestClefCourtesy::clef_courtesy02()
QVERIFY2(seg != nullptr, "No SegClef in measure 3.");
clefCourt = toClef(seg->element(0));
QVERIFY2(clefCourt != nullptr, "No courtesy clef element in measure 3.");
// QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden.");
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden.");
clefCourt = nullptr;
m = m2->prevMeasure();
@ -156,7 +184,7 @@ void TestClefCourtesy::clef_courtesy02()
QVERIFY2(seg != nullptr, "No SegClef in measure 6.");
clefCourt = static_cast<Clef*>(seg->element(0));
QVERIFY2(clefCourt != nullptr, "No courtesy clef element in measure 6.");
// QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden.");
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 6 is NOT hidden.");
QVERIFY(saveCompareScore(score, "clef_courtesy02.mscx", DIR + "clef_courtesy02-ref.mscx"));
delete score;
@ -192,7 +220,7 @@ void TestClefCourtesy::clef_courtesy03()
QVERIFY2(seg != nullptr, "No SegClef in measure 1.");
clefCourt = static_cast<Clef*>(seg->element(0));
QVERIFY2(clefCourt != nullptr, "No courtesy clef element in measure 1.");
// QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 1 is NOT hidden.");
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 1 is NOT hidden.");
QVERIFY(saveCompareScore(score, "clef_courtesy03.mscx", DIR + "clef_courtesy03-ref.mscx"));
delete score;
@ -242,6 +270,134 @@ void TestClefCourtesy::clef_courtesy_78196()
QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef at end of measure 6 is NOT hidden.");
}
//---------------------------------------------------------
// clef_courtesy04
// add two clefs mid-score at the beginning of systems for different
// staves and look for courtesy clefs in different "show courtesy" configurations
// also check the behavior after a horizontal frame
//---------------------------------------------------------
void TestClefCourtesy::clef_courtesy04()
{
MasterScore* score = readScore(DIR + "clef_courtesy04.mscx");
Clef* clef = nullptr;
Segment* seg = nullptr;
// drop G1 clef to 4th measure, track 0 and track 4
Measure* m1 = getMeasure(score, 4);
seg = m1->findSegment(SegmentType::HeaderClef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 4.");
clef = toClef(seg->element(0));
QVERIFY2(clef, "No Clef in measure 4, track 0.");
dropClef(clef, ClefType::G8_VA);
clef = toClef(seg->element(4));
QVERIFY2(clef, "No Clef in measure 4, track 4.");
dropClef(clef, ClefType::G8_VA);
// drop G clef to 7th measure, track 4
Measure* m2 = getMeasure(score, 7);
seg = m2->findSegment(SegmentType::HeaderClef, m2->tick());
QVERIFY2(seg, "No SegClef in measure 7.");
clef = toClef(seg->element(4));
QVERIFY2(clef, "No Clef in measure 7, track 4.");
dropClef(clef, ClefType::G);
// check the required courtesy clefs are there and they are shown
Measure* m = m1->prevMeasure();
seg = m->findSegment(SegmentType::Clef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 3.");
clef = toClef(seg->element(0));
QVERIFY2(clef, "No courtesy clef element in measure 3, track 0.");
QVERIFY2(clef->bbox().width() > 0, "Courtesy clef in measure 3 is hidden.");
clef = toClef(seg->element(4));
QVERIFY2(clef, "No courtesy clef element in measure 3, track 4.");
QVERIFY2(clef->bbox().width() > 0, "Courtesy clef in measure 3 is hidden.");
// change "show courtesy" property for the clef in one of the staves
seg = m1->findSegment(SegmentType::HeaderClef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 4.");
clef = toClef(seg->element(0));
score->startCmd();
clef->undoChangeProperty(Pid::SHOW_COURTESY, false);
Clef* otherClef = clef->otherClef();
if (otherClef)
otherClef->undoChangeProperty(Pid::SHOW_COURTESY, false);
score->doLayout();
score->endCmd();
// check the required courtesy clef is there but hidden, and the other one is not hidden
seg = m->findSegment(SegmentType::Clef, m1->tick());
QVERIFY2(seg, "No SegClef in measure 3.");
clef = toClef(seg->element(0));
QVERIFY2(clef, "No courtesy clef element in measure 3 for track 0.");
QVERIFY2(clef->bbox().width() == 0, "Courtesy clef in measure 3, track 0, is not hidden when showCourtesy is false.");
clef = toClef(seg->element(4));
QVERIFY2(clef, "No courtesy clef element in measure 3 for track 4.");
QVERIFY2(clef->bbox().width() > 0, "Courtesy clef in measure 3, track 4, is hidden when showCourtesy is true.");
// drop clefs after a horizontal frame
Measure* m3 = getMeasure(score, 8);
seg = m3->findSegment(SegmentType::HeaderClef, m3->tick());
QVERIFY2(seg, "No SegClef in measure 8.");
// drop G clef to 8th measure, track 0
clef = toClef(seg->element(0));
QVERIFY2(clef, "No Clef in measure 8, track 0.");
dropClef(clef, ClefType::G);
// drop G1 clef to 8th measure, track 4
clef = toClef(seg->element(4));
QVERIFY2(clef, "No Clef in measure 8, track 4.");
dropClef(clef, ClefType::G8_VA);
score->startCmd();
clef->undoChangeProperty(Pid::SHOW_COURTESY, false);
otherClef = clef->otherClef();
if (otherClef)
otherClef->undoChangeProperty(Pid::SHOW_COURTESY, false);
score->doLayout();
score->endCmd();
// check the required courtesy clef is there but hidden, and the other one is not hidden
seg = m2->findSegment(SegmentType::Clef, m3->tick());
QVERIFY2(seg, "No SegClef in measure 7.");
clef = toClef(seg->element(4));
QVERIFY2(clef, "No courtesy clef element in measure 7 for track 4.");
QVERIFY2(clef->bbox().width() == 0, "Courtesy clef in measure 7, track 4, is not hidden when showCourtesy is false.");
clef = toClef(seg->element(0));
QVERIFY2(clef, "No courtesy clef element in measure 7 for track 0.");
QVERIFY2(clef->bbox().width() > 0, "Courtesy clef in measure 7, track 0, is hidden when showCourtesy is true.");
// for the section break case,
// check the not required courtesy clef element is there but it is not shown
m = m2->prevMeasure();
seg = m->findSegment(SegmentType::Clef, m2->tick());
QVERIFY2(seg, "No SegClef in measure 6.");
clef = toClef(seg->element(4));
QVERIFY2(clef, "No courtesy clef element in measure 6, track 4.");
QVERIFY2(clef->bbox().width() == 0, "Courtesy clef in measure 6, track 4, is NOT hidden.");
Measure* m4 = getMeasure(score, 9);
// drop G1 clef to 9th measure, track 0
dropClef(m4, ClefType::G8_VA);
m = m4->prevMeasure();
seg = m->findSegment(SegmentType::Clef, m4->tick());
QVERIFY2(seg, "No SegClef in measure 8.");
clef = toClef(seg->element(0));
QVERIFY2(clef, "No Clef change in measure 8, track 0.");
QVERIFY2(clef->bbox().width() > 0, "Clef change in measure 8, track 0, is hidden.");
score->startCmd();
clef->undoChangeProperty(Pid::SHOW_COURTESY, false);
otherClef = clef->otherClef();
if (otherClef)
otherClef->undoChangeProperty(Pid::SHOW_COURTESY, false);
score->doLayout();
score->endCmd();
QVERIFY2(clef->bbox().width() > 0, "Clef change in measure 8, track 0, is hidden when showCourtesy is true.");
QVERIFY(saveCompareScore(score, "clef_courtesy04.mscx", DIR + "clef_courtesy04-ref.mscx"));
delete score;
}
QTEST_MAIN(TestClefCourtesy)
#include "tst_clef_courtesy.moc"