Merge pull request #522 from mgavioli/Fix_22167_TAB_graces_collide

Fix #22167: graces in TAB's collide with main chord.
This commit is contained in:
Maurizio M. Gavioli 2013-10-31 11:16:12 -07:00
commit 72d2a5e2b4
2 changed files with 34 additions and 20 deletions

View file

@ -1674,26 +1674,25 @@ void Chord::layoutTablature()
qreal _spatium = spatium();
qreal minNoteDistance = score()->styleS(ST_dotNoteDistance).val() * _spatium;
for (Chord* c : _graceNotes)
c->layoutTablature();
while (_ledgerLines) {
LedgerLine* l = _ledgerLines->next();
delete _ledgerLines;
_ledgerLines = l;
}
qreal lll = 0.0; // space to leave at left of chord
qreal rrr = 0.0; // space to leave at right of chord
Note* upnote = upNote();
qreal headWidth = symbols[score()->symIdx()][quartheadSym].width(magS());
StaffTypeTablature* tab = 0;
qreal lll = 0.0; // space to leave at left of chord
qreal rrr = 0.0; // space to leave at right of chord
Note* upnote = upNote();
qreal headWidth = symbols[score()->symIdx()][quartheadSym].width(magS());
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
qreal lineDist = tab->lineDistance().val() *_spatium;
qreal stemX = tab->chordStemPosX(this) *_spatium;
//
// TABLATURE STAVES
//
tab = (StaffTypeTablature*)staff()->staffType();
qreal lineDist = tab->lineDistance().val();
qreal stemX = tab->chordStemPosX(this) *_spatium;
int n = _notes.size();
for (int i = 0; i < n; ++i) {
int numOfNotes = _notes.size();
for (int i = 0; i < numOfNotes; ++i) {
Note* note = _notes.at(i);
note->layout();
// set headWidth to max fret text width
@ -1702,8 +1701,7 @@ void Chord::layoutTablature()
headWidth = fretWidth;
// centre fret string on stem
qreal x = stemX - fretWidth*0.5;
note->setPos(x, _spatium * tab->physStringToVisual(note->string()) * lineDist);
// note->layout2(); // needed? it is repeated later right before computing bbox
note->setPos(x, tab->physStringToVisual(note->string()) * lineDist);
}
// horiz. spacing: leave half width at each side of the (potential) stem
qreal halfHeadWidth = headWidth * 0.5;
@ -1742,8 +1740,9 @@ void Chord::layoutTablature()
_stemSlash = 0;
if (!tab->genDurations() // if tab is not set for duration symbols
|| (track2voice(track()))) { // or not in first voice
//
|| track2voice(track()) // or not in first voice
|| isGrace()) { // or chord is a grace (no dur. symbols for graces
// // wich are not used in hist. tabs anyway)
// no tab duration symbols
//
delete _tabDur; // delete an existing duration symbol
@ -1769,6 +1768,7 @@ void Chord::layoutTablature()
else
_tabDur->setDuration(durationType().type(), dots(), tab);
_tabDur->setParent(this);
// _tabDur->setMag(mag()); // useless to set grace mag: graces have no dur. symbol
_tabDur->layout();
}
else { // symbol not needed: if exists, delete
@ -1816,7 +1816,21 @@ void Chord::layoutTablature()
}
_space.setLw(lll);
_space.setRw(rrr + ipos().x());
_space.setRw(rrr);
int numOfGraces = _graceNotes.size();
if (numOfGraces) {
qreal x = -(_space.lw() + minNoteDistance);
qreal graceMag = score()->styleD(ST_graceNoteMag);
for (int i = numOfGraces-1; i >= 0; --i) {
Chord* c = _graceNotes[i];
x -= c->space().rw();
c->setPos(x, 0);
x -= c->space().lw() + minNoteDistance * graceMag;
}
if (-x > _space.lw())
_space.setLw(-x);
}
for (Element* e : _el) {
e->layout();
@ -1828,7 +1842,7 @@ void Chord::layoutTablature()
}
// bbox();
for (int i = 0; i < _notes.size(); ++i)
for (int i = 0; i < numOfNotes; ++i)
_notes.at(i)->layout2();
QRectF bb;
processSiblings([&bb] (Element* e) { bb |= e->bbox().translated(e->pos()); } );

View file

@ -722,7 +722,7 @@ qreal StaffTypeTablature::chordStemLength(const Chord *chord) const
else {
bool shrt = (minimStyle() == TAB_MINIM_SHORTER) && (chord->durationType().type() == TDuration::V_HALF);
stemLen = (stemsDown() ? STAFFTYPE_TAB_DEFAULTSTEMLEN_DN : STAFFTYPE_TAB_DEFAULTSTEMLEN_UP)
* (shrt ? STAFFTYPE_TAB_SHORTSTEMRATIO : 1.0);
* (shrt ? STAFFTYPE_TAB_SHORTSTEMRATIO : 1.0) * chord->mag();
}
return stemLen;
}