Skip to content

Commit

Permalink
fix #40291: voice 3/3 rests in rhythmic slash notation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Nov 30, 2014
1 parent 9b2266e commit 117ab2c
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 63 deletions.
27 changes: 16 additions & 11 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2658,18 +2658,23 @@ void Score::cmdSlashRhythm()
QList<Chord*> chords;
// loop through all notes in selection
foreach (Element* e, selection().elements()) {
if (e->type() != Element::Type::NOTE)
if (e->voice() >= 2 && e->type() == Element::Type::REST) {
Rest* r = static_cast<Rest*>(e);
r->setAccent(!r->accent());
continue;
Note* n = static_cast<Note*>(e);
if (n->noteType() != NoteType::NORMAL)
continue;
Chord* c = n->chord();
// check for duplicates (chords with multiple notes)
if (chords.contains(c))
continue;
chords.append(c);
// toggle slash setting
c->setSlash(!c->slash(), false);
}
else if (e->type() == Element::Type::NOTE) {
Note* n = static_cast<Note*>(e);
if (n->noteType() != NoteType::NORMAL)
continue;
Chord* c = n->chord();
// check for duplicates (chords with multiple notes)
if (chords.contains(c))
continue;
chords.append(c);
// toggle slash setting
c->setSlash(!c->slash(), false);
}
}
setLayoutAll(true);
}
Expand Down
29 changes: 29 additions & 0 deletions libmscore/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,35 @@ qreal Rest::stemPosX() const
return bbox().left();
}

//---------------------------------------------------------
// accent
//---------------------------------------------------------

bool Rest::accent()
{
return (voice() >= 2 && small());
}

//---------------------------------------------------------
// setAccent
//---------------------------------------------------------

void Rest::setAccent(bool flag)
{
undoChangeProperty(P_ID::SMALL, flag);
if (voice() % 2 == 0) {
if (flag) {
qreal yOffset = -(bbox().bottom());
if (durationType() >= TDuration::DurationType::V_HALF)
yOffset -= staff()->spatium() * 0.5;
undoChangeProperty(P_ID::USER_OFF, QPointF(0.0, yOffset));
}
else {
undoChangeProperty(P_ID::USER_OFF, QPointF());
}
}
}

//---------------------------------------------------------
// accessibleInfo
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions libmscore/rest.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class Rest : public ChordRest {
SymId sym() const { return _sym; }
int computeLineOffset();
bool isFullMeasureRest() const { return durationType() == TDuration::DurationType::V_MEASURE; }
bool accent();
void setAccent(bool flag);

virtual int upLine() const;
virtual int downLine() const;
Expand Down
19 changes: 4 additions & 15 deletions mtest/libmscore/tools/undoSlashRhythm.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,10 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<Rest>
<track>2</track>
<durationType>quarter</durationType>
<Note>
<track>2</track>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</Rest>
<Beam id="5">
<track>2</track>
<l1>-5</l1>
Expand Down Expand Up @@ -813,16 +808,10 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<Rest>
<track>6</track>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<track>6</track>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
</Rest>
<Beam id="13">
<track>6</track>
<l1>-5</l1>
Expand Down
28 changes: 6 additions & 22 deletions mtest/libmscore/tools/undoSlashRhythm01-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -538,21 +538,12 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<offset x="0" y="-0.5"/>
<Rest>
<offset x="0" y="-1.32"/>
<track>2</track>
<small>1</small>
<durationType>quarter</durationType>
<Note>
<track>2</track>
<pitch>72</pitch>
<tpc>14</tpc>
<head>5</head>
<play>0</play>
<fixed>1</fixed>
<fixedLine>-1</fixedLine>
</Note>
</Chord>
</Rest>
<Beam id="5">
<track>2</track>
<l1>-15</l1>
Expand Down Expand Up @@ -969,19 +960,12 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<Rest>
<offset x="0" y="-1.32"/>
<track>6</track>
<small>1</small>
<durationType>quarter</durationType>
<Note>
<track>6</track>
<pitch>38</pitch>
<tpc>16</tpc>
<play>0</play>
<fixed>1</fixed>
<fixedLine>-1</fixedLine>
</Note>
</Chord>
</Rest>
<Beam id="13">
<track>6</track>
<l1>-13</l1>
Expand Down
19 changes: 4 additions & 15 deletions mtest/libmscore/tools/undoSlashRhythm02-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,10 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<Rest>
<track>2</track>
<durationType>quarter</durationType>
<Note>
<track>2</track>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</Rest>
<Beam id="5">
<track>2</track>
<l1>-15</l1>
Expand Down Expand Up @@ -813,16 +808,10 @@
<duration z="4" n="4"/>
</Rest>
<tick>3840</tick>
<Chord>
<Rest>
<track>6</track>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<track>6</track>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
</Rest>
<Beam id="13">
<track>6</track>
<l1>-13</l1>
Expand Down
Binary file modified vtest/slash-2-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vtest/slash-2.mscz
Binary file not shown.

0 comments on commit 117ab2c

Please sign in to comment.