Skip to content

Commit 274c2f0

Browse files
committed
Revert "ENG-34: Fix erroneous space created for melismas"
This reverts the 1st part of PR musescore#8296, which is causing a regression.
1 parent e3f6697 commit 274c2f0

File tree

6 files changed

+24
-731
lines changed

6 files changed

+24
-731
lines changed

libmscore/chordrest.cpp

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ChordRest::ChordRest(Score* s)
6464
_up = true;
6565
_beamMode = Beam::Mode::AUTO;
6666
m_isSmall = false;
67+
_melismaEnd = false;
6768
_crossMeasure = CrossMeasure::UNKNOWN;
6869
}
6970

@@ -79,7 +80,7 @@ ChordRest::ChordRest(const ChordRest& cr, bool link)
7980
_beamMode = cr._beamMode;
8081
_up = cr._up;
8182
m_isSmall = cr.m_isSmall;
82-
_melismaEnds = cr._melismaEnds;
83+
_melismaEnd = cr._melismaEnd;
8384
_crossMeasure = cr._crossMeasure;
8485

8586
for (Lyrics* l : cr._lyrics) { // make deep copy
@@ -1231,21 +1232,20 @@ QString ChordRest::accessibleExtraInfo() const
12311232

12321233
bool ChordRest::isMelismaEnd() const
12331234
{
1234-
return !_melismaEnds.empty();
1235+
return _melismaEnd;
12351236
}
12361237

12371238
//---------------------------------------------------------
1238-
// removeMelismaEnd()
1239-
// removes a Lyrics object from the _melismaEnds set
1240-
// if present by iterating through the set.
1241-
// Returns a boolean representing whether the Lyrics
1242-
// was found.
1243-
// No-op and return false if Lyrics not present in _melismaEnds.
1239+
// setMelismaEnd
12441240
//---------------------------------------------------------
12451241

1246-
void ChordRest::removeMelismaEnd(Lyrics* const l)
1242+
void ChordRest::setMelismaEnd(bool v)
12471243
{
1248-
_melismaEnds.erase(l);
1244+
_melismaEnd = v;
1245+
// TODO: don't take "false" at face value
1246+
// check to see if some other melisma ends here,
1247+
// in which case we can leave this set to true
1248+
// for now, rely on the fact that we'll generate the value correctly on layout
12491249
}
12501250

12511251
//---------------------------------------------------------
@@ -1256,8 +1256,6 @@ Shape ChordRest::shape() const
12561256
{
12571257
Shape shape;
12581258
{
1259-
// Add horizontal spacing for lyrics
1260-
12611259
qreal x1 = 1000000.0;
12621260
qreal x2 = -1000000.0;
12631261
bool adjustWidth = false;
@@ -1267,14 +1265,11 @@ Shape ChordRest::shape() const
12671265
qreal lmargin = score()->styleS(Sid::lyricsMinDistance).val() * spatium() * 0.5;
12681266
qreal rmargin = lmargin;
12691267
Lyrics::Syllabic syl = l->syllabic();
1270-
bool hasHyphen = syl == Lyrics::Syllabic::BEGIN || syl == Lyrics::Syllabic::MIDDLE;
1271-
if (hasHyphen && score()->styleB(Sid::lyricsDashForce))
1268+
if ((syl == Lyrics::Syllabic::BEGIN || syl == Lyrics::Syllabic::MIDDLE) && score()->styleB(Sid::lyricsDashForce))
12721269
rmargin = qMax(rmargin, styleP(Sid::lyricsDashMinLength));
1273-
// for horizontal spacing we only need the lyrics' width:
1270+
// for horizontal spacing we only need the lyrics width:
12741271
x1 = qMin(x1, l->bbox().x() - lmargin + l->pos().x());
1275-
// Melismas (without hyphens) only create right spacing on their last note
1276-
if (!l->isMelisma() || hasHyphen)
1277-
x2 = qMax(x2, l->bbox().x() + l->bbox().width() + rmargin + l->pos().x());
1272+
x2 = qMax(x2, l->bbox().x() + l->bbox().width() + rmargin + l->pos().x());
12781273
if (l->ticks() == Fraction::fromTicks(Lyrics::TEMP_MELISMA_TICKS))
12791274
x2 += spatium();
12801275
adjustWidth = true;
@@ -1284,8 +1279,6 @@ Shape ChordRest::shape() const
12841279
}
12851280

12861281
{
1287-
// Add horizontal spacing for annotations
1288-
12891282
qreal x1 = 1000000.0;
12901283
qreal x2 = -1000000.0;
12911284
bool adjustWidth = false;
@@ -1332,24 +1325,8 @@ Shape ChordRest::shape() const
13321325
}
13331326

13341327
if (isMelismaEnd()) {
1335-
// Add horizontal spacing (only on the right) for melismaEnds
1336-
// in case a melisma syllable extends beyond its last note.
1337-
// TODO: distribute this extra spacing rather than dumping
1338-
// it all on the last note (or otherwise overhaul horizontal spacing).
1339-
// TODO: this doesn't redraw on layout reset (like line breaks),
1340-
// causing temporary incorrect rendering.
1341-
1342-
qreal rmargin = score()->styleS(Sid::lyricsMinDistance).val() * spatium() * 0.5;
13431328
qreal right = rightEdge();
1344-
1345-
for (Lyrics* me : melismaEnds()) {
1346-
if (me->measure()->system() != measure()->system()) // ignore cross-system melisma
1347-
continue;
1348-
// Lyric's right edge relative to Chord by way of page position
1349-
qreal meRight = me->pageBoundingRect().right() + rmargin - pagePos().x();
1350-
right = qMax(right, meRight);
1351-
}
1352-
shape.addHorizontalSpacing(Shape::SPACING_LYRICS, 0, right);
1329+
shape.addHorizontalSpacing(Shape::SPACING_LYRICS, right, right);
13531330
}
13541331

13551332
return shape;

libmscore/chordrest.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ChordRest : public DurationElement {
6161
Beam::Mode _beamMode;
6262
bool _up; // actual stem direction
6363
bool m_isSmall;
64-
std::set<Lyrics*> _melismaEnds; // lyrics ending on this ChordRest, used for spacing
64+
bool _melismaEnd;
6565

6666
// CrossMeasure: combine 2 tied notes if across a bar line and can be combined in a single duration
6767
CrossMeasure _crossMeasure; ///< 0: no cross-measure modification; 1: 1st note of a mod.; -1: 2nd note
@@ -138,10 +138,8 @@ class ChordRest : public DurationElement {
138138
std::vector<Lyrics*>& lyrics() { return _lyrics; }
139139
Lyrics* lyrics(int verse, Placement) const;
140140
int lastVerse(Placement) const;
141-
const std::set<Lyrics*>& melismaEnds() const { return _melismaEnds; }
142-
std::set<Lyrics*>& melismaEnds() { return _melismaEnds; }
143-
void removeMelismaEnd(Lyrics* const l);
144141
bool isMelismaEnd() const;
142+
void setMelismaEnd(bool v);
145143

146144
virtual void add(Element*);
147145
virtual void remove(Element*);

libmscore/lyrics.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void Lyrics::remove(Element* el)
188188
if (!e)
189189
e = score()->findCRinStaff(_separator->tick2(), track());
190190
if (e && e->isChordRest())
191-
toChordRest(e)->removeMelismaEnd(this);
191+
toChordRest(e)->setMelismaEnd(false);
192192
#endif
193193
// Lyrics::remove() and LyricsLine::removeUnmanaged() call each other;
194194
// be sure each finds a clean context
@@ -368,7 +368,7 @@ void Lyrics::layout()
368368
// set melisma end
369369
ChordRest* ecr = score()->findCR(endTick(), track());
370370
if (ecr)
371-
ecr->melismaEnds().insert(this);
371+
ecr->setMelismaEnd(true);
372372
}
373373

374374
}
@@ -525,7 +525,7 @@ void Lyrics::removeFromScore()
525525
// clear melismaEnd flag from end cr
526526
ChordRest* ecr = score()->findCR(endTick(), track());
527527
if (ecr)
528-
ecr->removeMelismaEnd(this);
528+
ecr->setMelismaEnd(false);
529529
}
530530
if (_separator) {
531531
_separator->removeUnmanaged();
@@ -567,13 +567,16 @@ bool Lyrics::setProperty(Pid propertyId, const QVariant& v)
567567
break;
568568
case Pid::LYRIC_TICKS:
569569
if (_ticks.isNotZero()) {
570+
// clear melismaEnd flag from previous end cr
571+
// this might be premature, as there may be other melismas ending there
572+
// but flag will be generated correctly on layout
570573
// TODO: after inserting a measure,
571574
// endTick info is wrong.
572575
// Somehow we need to fix this.
573576
// See https://musescore.org/en/node/285304 and https://musescore.org/en/node/311289
574577
ChordRest* ecr = score()->findCR(endTick(), track());
575578
if (ecr)
576-
ecr->removeMelismaEnd(this);
579+
ecr->setMelismaEnd(false);
577580
}
578581
_ticks = v.value<Fraction>();
579582
break;

libmscore/lyrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Lyrics final : public TextBase {
5151
Syllabic _syllabic;
5252
LyricsLine* _separator;
5353

54+
bool isMelisma() const;
5455
void undoChangeProperty(Pid id, const QVariant&, PropertyFlags ps) override;
5556

5657
protected:
@@ -92,7 +93,6 @@ class Lyrics final : public TextBase {
9293
Fraction ticks() const { return _ticks; }
9394
void setTicks(const Fraction& tick) { _ticks = tick; }
9495
Fraction endTick() const;
95-
bool isMelisma() const;
9696
void removeFromScore();
9797

9898
using ScoreElement::undoChangeProperty;

libmscore/shape.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ void Shape::addHorizontalSpacing(HorizontalSpacingType type, qreal leftEdge, qre
2828
const qreal y = eps * int(type);
2929
if (leftEdge == rightEdge) // HACK zero-width shapes collide with everything currently.
3030
rightEdge += eps;
31-
#ifndef NDEBUG
32-
add(QRectF(leftEdge, y, rightEdge - leftEdge, 0), "Horizontal Spacing");
33-
#else
3431
add(QRectF(leftEdge, y, rightEdge - leftEdge, 0));
35-
#endif
3632
}
3733

3834
//---------------------------------------------------------

0 commit comments

Comments
 (0)