fix #24735: correct layout of fret diagrams & chord symbols

This commit is contained in:
Marc Sabatella 2014-06-07 20:23:50 -06:00
parent ec2ea81374
commit 4f42fb0d82
6 changed files with 21 additions and 11 deletions

View file

@ -143,6 +143,7 @@ Harmony::Harmony(Score* s)
_parsedForm = 0;
_leftParen = false;
_rightParen = false;
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
setTextStyleType(TextStyleType::HARMONY); // call after setting of _id
}
@ -872,23 +873,28 @@ void Harmony::layout()
qreal yy = 0.0;
qreal _spatium = spatium();
if (parent()->type() == ElementType::SEGMENT) {
Measure* m = static_cast<Measure*>(parent()->parent());
yy = track() < 0 ? 0.0 : m->system()->staff(staffIdx())->y();
yy -= score()->styleP(StyleIdx::harmonyY);
Segment* s = static_cast<Segment*>(parent());
// look for fret diagram
bool fretsFound = false;
for (Element* e : s->annotations()) {
if (e != this && e->type() == ElementType::FRET_DIAGRAM && e->track() == track()) {
yy += score()->styleP(StyleIdx::harmonyY);
if (e->type() == ElementType::FRET_DIAGRAM && e->track() == track()) {
yy -= score()->styleP(StyleIdx::fretY);
yy -= _spatium * 2;
e->layout();
yy -= e->height();
yy -= score()->styleP(StyleIdx::harmonyFretDist);
fretsFound = true;
break;
}
}
if (!fretsFound)
yy -= score()->styleP(StyleIdx::harmonyY);
}
else if (parent()->type() == ElementType::FRET_DIAGRAM)
else if (parent()->type() == ElementType::FRET_DIAGRAM) {
qDebug("Harmony %s with fret diagram as parent", qPrintable(_textName)); // not possible?
yy = score()->styleP(StyleIdx::harmonyFretDist);
}
yy += textStyle().offset(_spatium).y();
if (!editMode()) {
qreal hb = lineHeight() - Text::baseLine();
@ -930,7 +936,9 @@ void Harmony::layout()
setUserOff(readPos() - ipos());
setReadPos(QPointF());
}
if (parent()->type() == ElementType::FRET_DIAGRAM && parent()->parent()->type() == ElementType::SEGMENT) {
qDebug("Harmony %s with fret diagram as parent and segment as grandparent", qPrintable(_textName));
MStaff* mstaff = static_cast<Segment*>(parent()->parent())->measure()->mstaff(staffIdx());
qreal dist = -(bbox().top());
mstaff->distanceUp = qMax(mstaff->distanceUp, dist + _spatium);

View file

@ -3517,8 +3517,10 @@ qreal Score::computeMinWidth(Segment* fs)
if (e->type() != ElementType::HARMONY || e->track() < track || e->track() >= track+VOICES)
continue;
Harmony* h = static_cast<Harmony*>(e);
//h->layout();
h->calculateBoundingRect();
// call full layout here
// which also triggers layout of associated fret diagram if present
// otherwise the vertical position of the chord symbols cannot be known
h->layout(); // h->calculateBoundingRect();
QRectF b(h->bboxtight().translated(h->pos()));
if (hFound)
hBbox |= b;

View file

@ -34,7 +34,7 @@ else
chord-layout-7 chord-layout-8 chord-layout-9 chord-layout-10 chord-layout-11 chord-layout-12\
accidental-1 accidental-2 accidental-3 accidental-4\
accidental-5 accidental-6 accidental-7 accidental-8\
tie-1 grace-1 grace-2 grace-3 harmony-1 beams-1 beams-2 user-offset-1 user-offset-2\
tie-1 grace-1 grace-2 grace-3 harmony-1 harmony-2 beams-1 beams-2 user-offset-1 user-offset-2\
chord-space-1 tablature-1"
fi

View file

@ -13,7 +13,7 @@ set SRC=mmrest-1,bravura-mmrest,mmrest-2,mmrest-4,mmrest-5,mmrest-6,mmrest-7,mmr
chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10,chord-layout-11,chord-layout-12, ^
accidental-1,accidental-2,accidental-3,accidental-4, ^
accidental-5,accidental-6,accidental-7,accidental-8, ^
tie-1,grace-1,grace-2,grace-3,harmony-1,beams-1,beams-2,user-offset-1,user-offset-2, ^
tie-1,grace-1,grace-2,grace-3,harmony-1,harmony-2,beams-1,beams-2,user-offset-1,user-offset-2, ^
chord-space-1,tablature-1
set MSCORE=..\win32install\bin\mscore.exe

BIN
vtest/harmony-2-ref.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
vtest/harmony-2.mscz Normal file

Binary file not shown.