Skip to content

Commit

Permalink
ENG-34: Fix erroneous space created for melismas
Browse files Browse the repository at this point in the history
Previously, melismas were treated the same as normal Lyrics in terms of
horizontal spacing—they would cause a spacer to be added to the
ChordRest to which they were attached, causing an unnecessary gap after
the first note of a melisma.

This commit prevents a melisma from adding a right spacer to
their first ChordRest, and rather creates a right
spacer on the last ChordRest of a lyric if necessary.

In pursuit of this, this commit refactors ChordRest::_melismaEnd(s) from
a bool to a std::set<*Lyrics>, giving a ChordRest a way to access the
melismatic Lyrics that end on it. This change also solves the problem of
said bool being untrustworthy (i.e. erroneously being changed to false
when one of multiple melismas was removed).
  • Loading branch information
iveshenry18 committed Jun 23, 2021
1 parent 8536de8 commit 70bacdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
14 changes: 2 additions & 12 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,19 +1243,9 @@ bool ChordRest::isMelismaEnd() const
// No-op and return false if Lyrics not present in _melismaEnds.
//---------------------------------------------------------

bool ChordRest::removeMelismaEnd(const Lyrics* l)
void ChordRest::removeMelismaEnd(Lyrics* const l)
{
bool found = false;
for (std::set<Lyrics*>::iterator it = _melismaEnds.begin(); it != _melismaEnds.end(); ) {
if (*it == l) {
it = _melismaEnds.erase(it); // Returns next iterator
found = true;
}
else {
++it;
}
}
return found;
_melismaEnds.erase(l);
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/chordrest.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ChordRest : public DurationElement {
int lastVerse(Placement) const;
const std::set<Lyrics*>& melismaEnds() const { return _melismaEnds; }
std::set<Lyrics*>& melismaEnds() { return _melismaEnds; }
bool removeMelismaEnd(const Lyrics* l);
void removeMelismaEnd(Lyrics* const l);
bool isMelismaEnd() const;

virtual void add(Element*);
Expand Down

0 comments on commit 70bacdc

Please sign in to comment.