Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spacing of melisma syllables #1330

Merged
merged 1 commit into from
Sep 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3564,11 +3564,9 @@ qreal Score::computeMinWidth(Segment* fs)
if (!l->isEmpty()) {
l->layout();
lyrics = l;
if (!lyrics->isMelisma()) {
QRectF b(l->bbox().translated(l->pos()));
llw = qMax(llw, -(b.left()+lx+cx));
rrw = qMax(rrw, b.right()+rx+cx);
}
QRectF b(l->bbox().translated(l->pos()));
llw = qMax(llw, -(b.left()+lx+cx));
rrw = qMax(rrw, b.right()+rx+cx);
}
}
}
Expand Down
34 changes: 23 additions & 11 deletions libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@ void Lyrics::layout()
}
}

bool Lyrics::isMelisma() const
{
// entered as melisma using underscore?
if (_ticks > 0)
return true;

// hyphenated?
if (_syllabic == Syllabic::BEGIN || _syllabic == Syllabic::MIDDLE) {
// find next CR on same track and check for existence of lyric in same verse
ChordRest* cr = chordRest();
Segment* s = cr->segment()->next1();
ChordRest* ncr = s ? s->nextChordRest(cr->track()) : nullptr;
if (ncr && !ncr->lyrics(_no))
return true;
}

// default - not a melisma
return false;
}

//---------------------------------------------------------
// layout1
//---------------------------------------------------------
Expand Down Expand Up @@ -235,18 +255,10 @@ void Lyrics::layout1()
else
maxWidth = cr->width(); // TODO: exclude ledger line for multivoice rest?
qreal nominalWidth = symWidth(SymId::noteheadBlack);
bool hyphenatedMelisma = false;
if (_syllabic == Syllabic::BEGIN || _syllabic == Syllabic::MIDDLE) {
// hyphenated syllables representing melismas need to be left aligned
// detecting this means finding next CR on same track and checking for existence of lyric in same verse
Segment* s = cr->segment()->next1();
ChordRest* ncr = s ? s->nextChordRest(cr->track()) : nullptr;
if (ncr && !ncr->lyrics(_no))
hyphenatedMelisma = true;
}
if (_ticks == 0 && !hyphenatedMelisma && (textStyle().align() & AlignmentFlags::HCENTER) && !_verseNumber)

if (!isMelisma() && (textStyle().align() & AlignmentFlags::HCENTER) && !_verseNumber)
x += nominalWidth * .5 - cr->x();
else if (_ticks || hyphenatedMelisma || ((textStyle().align() & AlignmentFlags::HCENTER) && _verseNumber))
else if (isMelisma() || ((textStyle().align() & AlignmentFlags::HCENTER) && _verseNumber))
x += (width() + nominalWidth - maxWidth) * .5 - cr->x();
rxpos() += x;
rypos() += y;
Expand Down
2 changes: 1 addition & 1 deletion libmscore/lyrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Lyrics : public Text {
int ticks() const { return _ticks; }
void setTicks(int tick) { _ticks = tick; }
int endTick() const;
bool isMelisma() const { return _ticks > 0; }
bool isMelisma() const;

void clearSeparator() { _separator.clear(); } // TODO: memory leak
QList<Line*>* separatorList() { return &_separator; }
Expand Down
8 changes: 3 additions & 5 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3203,11 +3203,9 @@ void Measure::layoutX(qreal stretch)
if (!l || l->isEmpty())
continue;
lyrics = l;
if (!lyrics->isMelisma()) {
QRectF b(l->bbox().translated(l->pos()));
llw = qMax(llw, -(b.left()+lx+cx));
rrw = qMax(rrw, b.right()+rx+cx);
}
QRectF b(l->bbox().translated(l->pos()));
llw = qMax(llw, -(b.left()+lx+cx));
rrw = qMax(rrw, b.right()+rx+cx);
}
}
if (lyrics) {
Expand Down
28 changes: 21 additions & 7 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ void System::layoutLyrics(Lyrics* l, Segment* s, int staffIdx)
// single segment
qreal headWidth = score()->noteHeadWidth();
qreal len = seg->pagePos().x() - l->pagePos().x() - x1 + headWidth;
if (len <= 0.0) {
l->clearSeparator();
return;
}
line->setLen(Spatium(len / _spatium));
Lyrics* nl = searchNextLyrics(seg, staffIdx, l->no());
// small correction if next lyrics is moved? not needed if on another system
Expand Down Expand Up @@ -943,15 +947,16 @@ qDebug("Lyrics: melisma end segment not implemented");
Segment* ns = s;

// TODO: the next two values should be style parameters
// TODO: as well as the 0.3 factor a few lines below
const qreal maxl = 0.5 * _spatium * lmag * staffMag; // lyrics hyphen length
const Spatium hlw(0.14 * lmag * staffMag); // hyphen line width
// TODO: as well as the factor a few lines below
const qreal maxl = 0.5 * _spatium * lmag * staffMag; // lyrics hyphen length
const Spatium hlw(0.14 * lmag * staffMag); // hyphen line width

Lyrics* nl = searchNextLyrics(ns, staffIdx, verse);
if (!nl) {
l->clearSeparator();
return;
}
ns = nl->chordRest()->segment();
QList<Line*>* sl = l->separatorList();
Line* line;
if (sl->isEmpty()) {
Expand All @@ -964,16 +969,25 @@ qDebug("Lyrics: melisma end segment not implemented");
qreal x = l->bbox().right();
// convert font size to raster units, scaling if spatium-dependent
qreal size = ts.size();
if(ts.sizeIsSpatiumDependent())
size *= _spatium / (SPATIUM20 * PPI); // <= (MScore::DPI / PPI) * (_spatium / (SPATIUM20 * Mscore::DPI))
if (ts.sizeIsSpatiumDependent())
size *= _spatium / (SPATIUM20 * PPI); // <= (MScore::DPI / PPI) * (_spatium / (SPATIUM20 * Mscore::DPI))
else
size *= MScore::DPI / PPI;
qreal y = -size * staffMag * 0.3; // a conventional percentage of the whole font height
qreal y = -size * staffMag * 0.30; // TODO: make this a style parameter (for now, a conventional percentage of the whole font height)

qreal x1 = x + l->pagePos().x();
qreal x2 = nl->bbox().left() + nl->pagePos().x();
qreal len;
if (x2 < x1 || s->measure()->system()->page() != ns->measure()->system()->page()) {
if (x2 < x1 && s->measure()->system() == ns->measure()->system()) {
// first syllable overlaps second
// no separator needed
l->clearSeparator();
return;
}
else if (s->measure()->system() != ns->measure()->system()) {
// second syllable not on same system as first (perhaps not even same page)
// use right edge of first system as substitute for second syllable
// so hyphen is centered within the space remaining on system
System* system = s->measure()->system();
x2 = system->pagePos().x() + system->bbox().width();
}
Expand Down