fix articulations
This commit is contained in:
parent
badb18d1b0
commit
83fa21774b
2 changed files with 49 additions and 31 deletions
|
@ -2724,28 +2724,41 @@ QPointF Chord::layoutArticulation(Articulation* a)
|
|||
alignToStem = (st == ArticulationType::Staccato && articulations().size() == 1);
|
||||
}
|
||||
else { // if articulation is not beyond a stem
|
||||
int line;
|
||||
int line; // line of note
|
||||
int staffOff; // offset that should account for line spacing
|
||||
int extraOff = 0.0; // offset that should not acocunt for line spacing
|
||||
int lines = (staff()->lines() - 1) * 2; // num. of staff positions within staff
|
||||
int add = (st == ArticulationType::Sforzatoaccent ? 1 : 0); // sforzato accent needs more offset
|
||||
if (bottom) { // if below chord
|
||||
line = downLine(); // staff position (lines and spaces) of chord lowest note
|
||||
int lines = (staff()->lines() - 1) * 2; // num. of staff positions within staff
|
||||
if (line < lines) // if note above staff bottom line
|
||||
// round space pos. to line pos. above ("line & ~1") and move to 2nd space below ("+3")
|
||||
line = ((line-add) & ~1) + 3 + add*2;
|
||||
staffOff = 3 - ((line - add) & 1) + add; // round to next space below
|
||||
else // if note on or below staff bottom line,
|
||||
line += 2 + add; // move 1 whole space below
|
||||
staffOff = 2 + add; // move 1 whole space below
|
||||
if (_spStaff != _spatium) {
|
||||
int clearLine = qMax(line, lines);
|
||||
int headRoom = qMax(clearLine - line, 0);
|
||||
extraOff = staffOff - qMin(staffOff, headRoom);
|
||||
staffOff -= extraOff;
|
||||
}
|
||||
pos.ry() = -a->height() / 2; // symbol is below baseline, shift if a bit up
|
||||
}
|
||||
else { // if above chord
|
||||
line = upLine(); // staff position (lines and spaces) of chord highest note
|
||||
if (line > 0) // if note below staff top line
|
||||
// round space pos. to line pos. below ("(line+1) & ~1") and move to 2nd space above ("-3")
|
||||
line = ((line+1+add) & ~1) - 3 - add*2;
|
||||
staffOff = -3 + ((line + add) & 1) - add; // round to next space above
|
||||
else // if note or or above staff top line
|
||||
line -= 2 + add; // move 1 whole space above
|
||||
staffOff = -2 - add; // move 1 whole space above
|
||||
if (_spStaff != _spatium) {
|
||||
int clearLine = qMin(line, 0);
|
||||
int headRoom = qMax(line - clearLine, 0);
|
||||
extraOff = staffOff + qMin(-staffOff, headRoom);
|
||||
staffOff -= extraOff;
|
||||
}
|
||||
pos.ry() = a->height() / 2; // symbol is on baseline, shift it a bit down
|
||||
}
|
||||
pos.ry() += line * _spStaff2; // convert staff position to sp distance
|
||||
pos.ry() += (line + staffOff) * _spStaff2; // convert staff position to sp distance
|
||||
pos.ry() += extraOff * _spatium2;
|
||||
}
|
||||
if (!staff()->isTabStaff() && !alignToStem) {
|
||||
if (up())
|
||||
|
@ -2804,13 +2817,13 @@ QPointF Chord::layoutArticulation(Articulation* a)
|
|||
}
|
||||
|
||||
if (botGap)
|
||||
chordBotY += _spStaff;
|
||||
chordBotY += _spatium;
|
||||
else
|
||||
chordBotY += _spStaff * .5;
|
||||
chordBotY += _spatium * .5;
|
||||
if (topGap)
|
||||
chordTopY -= _spStaff;
|
||||
chordTopY -= _spatium;
|
||||
else
|
||||
chordTopY -= _spStaff * .5;
|
||||
chordTopY -= _spatium * .5;
|
||||
|
||||
// avoid collisions of staff articulations with chord notes:
|
||||
// gap between note and staff articulation is distance0 + 0.5 spatium
|
||||
|
@ -2862,9 +2875,9 @@ QPointF Chord::layoutArticulation(Articulation* a)
|
|||
|
||||
qreal dist; // distance between occupied area and articulation
|
||||
switch(st) {
|
||||
case ArticulationType::Marcato: dist = 1.0 * _spStaff; break;
|
||||
case ArticulationType::Sforzatoaccent: dist = 1.5 * _spStaff; break;
|
||||
default: dist = score()->styleS(StyleIdx::propertyDistance).val() * _spStaff;
|
||||
case ArticulationType::Marcato: dist = 1.0 * _spatium; break;
|
||||
case ArticulationType::Sforzatoaccent: dist = 1.5 * _spatium; break;
|
||||
default: dist = score()->styleS(StyleIdx::propertyDistance).val() * _spatium;
|
||||
}
|
||||
|
||||
if (aa == ArticulationAnchor::CHORD || aa == ArticulationAnchor::TOP_CHORD || aa == ArticulationAnchor::BOTTOM_CHORD) {
|
||||
|
|
|
@ -475,6 +475,7 @@ void ChordRest::layoutArticulations()
|
|||
return;
|
||||
qreal _spatium = spatium();
|
||||
qreal _spStaff = _spatium * staff()->lineDistance(); // scaled to staff line distance for vert. pos. within a staff
|
||||
qreal _spDist = _spatium; // scaling for distance between articulations
|
||||
|
||||
if (type() == Element::Type::CHORD) {
|
||||
if (_articulations.size() == 1) {
|
||||
|
@ -498,7 +499,9 @@ void ChordRest::layoutArticulations()
|
|||
if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato)
|
||||
&& (st2 == ArticulationType::Marcato)) {
|
||||
QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1);
|
||||
pt.ry() += a1->up() ? -_spStaff * .5 : _spStaff * .5;
|
||||
//if (pt.y() < 0 || pt.y() > staff()->height())
|
||||
// _spDist = _spatium;
|
||||
pt.ry() += a1->up() ? -_spDist * .5 : _spDist * .5;
|
||||
a2->layout();
|
||||
a2->setUp(a1->up());
|
||||
a2->setPos(pt);
|
||||
|
@ -516,7 +519,9 @@ void ChordRest::layoutArticulations()
|
|||
if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato)
|
||||
&& (st2 == ArticulationType::Sforzatoaccent)) {
|
||||
QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1);
|
||||
pt.ry() += a1->up() ? -_spStaff * .7 : _spStaff * .7;
|
||||
//if (pt.y() < 0 || pt.y() > staff()->height())
|
||||
// _spDist = _spatium;
|
||||
pt.ry() += a1->up() ? -_spDist * .7 : _spDist * .7;
|
||||
a2->layout();
|
||||
a2->setUp(a1->up());
|
||||
a2->setPos(pt);
|
||||
|
@ -621,19 +626,19 @@ void ChordRest::layoutArticulations()
|
|||
// aligning horizontally to stem makes sense only for staccato
|
||||
// and only if no other articulations on this side
|
||||
//x = stem->pos().x();
|
||||
int line = lrint((y+0.5*_spatium) / _spatium);
|
||||
if (line <= 4) // align between staff lines
|
||||
y = line * _spatium + _spatium * .5;
|
||||
int line = lrint((y+0.5*_spStaff) / _spStaff);
|
||||
if (line < staff()->lines()) // align between staff lines
|
||||
y = line * _spStaff + _spatium * .5;
|
||||
else
|
||||
y += _spatium;
|
||||
}
|
||||
else {
|
||||
int lines = (staff()->lines() - 1) * 2;
|
||||
if (line < lines)
|
||||
y = (line & ~1) + 3;
|
||||
y = ((line & ~1) + 3) * _spStaff;
|
||||
else
|
||||
y = line + 2;
|
||||
y *= _spatium * .5;
|
||||
y = line * _spStaff + 2 * _spatium;
|
||||
y *= .5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -647,18 +652,18 @@ void ChordRest::layoutArticulations()
|
|||
// aligning horizontally to stem makes sense only for staccato
|
||||
// and only if no other articulations on this side
|
||||
//x = stem->pos().x();
|
||||
int line = lrint((y-0.5*_spatium) / _spatium);
|
||||
int line = lrint((y-0.5*_spStaff) / _spStaff);
|
||||
if (line >= 0) // align between staff lines
|
||||
y = line * _spatium - _spatium * .5;
|
||||
y = line * _spStaff - _spatium * .5;
|
||||
else
|
||||
y -= _spatium;
|
||||
}
|
||||
else {
|
||||
if (line > 0)
|
||||
y = ((line+1) & ~1) - 3;
|
||||
y = (((line+1) & ~1) - 3) * _spStaff;
|
||||
else
|
||||
y = line - 2;
|
||||
y *= _spatium * .5;
|
||||
y = line * _spStaff - 2 * _spatium;
|
||||
y *= .5;
|
||||
}
|
||||
}
|
||||
dy += _spatium * .5;
|
||||
|
@ -721,7 +726,7 @@ void ChordRest::layoutArticulations()
|
|||
if (bottom) {
|
||||
qreal y = chordBotY + dy;
|
||||
if (staffLineCT && (y <= staffBotY -.1 - dy)) {
|
||||
qreal l = y / _spatium;
|
||||
qreal l = y / _spStaff;
|
||||
qreal delta = fabs(l - round(l));
|
||||
if (delta < 0.4) {
|
||||
y += _spatium * .5;
|
||||
|
@ -733,7 +738,7 @@ void ChordRest::layoutArticulations()
|
|||
else {
|
||||
qreal y = chordTopY - dy;
|
||||
if (staffLineCT && (y >= (staffTopY +.1 + dy))) {
|
||||
qreal l = y / _spatium;
|
||||
qreal l = y / _spStaff;
|
||||
qreal delta = fabs(l - round(l));
|
||||
if (delta < 0.4) {
|
||||
y -= _spatium * .5;
|
||||
|
|
Loading…
Reference in a new issue