Skip to content

Commit

Permalink
Fix #19374
Browse files Browse the repository at this point in the history
Wide (two-digit) numbers in TAB collide; fixed
  • Loading branch information
mgavioli authored and Maurizio M. Gavioli committed Jan 15, 2013
1 parent 2ec2c65 commit a6cbcd7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
5 changes: 3 additions & 2 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,13 +1342,14 @@ void Chord::layout()

qreal minNoteDistance = score()->styleS(ST_minNoteDistance).val() * _spatium;
bool useTab = false;
StaffTypeTablature* tab = 0;

if (staff() && staff()->isTabStaff()) {
//
// TABLATURE STAVES
//
useTab = true;
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
tab = (StaffTypeTablature*)staff()->staffType();
qreal lineDist = tab->lineDistance().val();
int n = _notes.size();
for (int i = 0; i < n; ++i) {
Expand Down Expand Up @@ -1516,7 +1517,7 @@ void Chord::layout()
int n = _notes.size();
for (int i = 0; i < n; ++i) {
Note* note = _notes.at(i);
qreal lhw = note->headWidth();
qreal lhw = useTab ? note->tabHeadWidth(tab) : note->headWidth();
qreal rr = 0.0;
if (note->mirror()) {
if (up())
Expand Down
45 changes: 35 additions & 10 deletions libmscore/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,56 @@ int Note::noteHead() const

//---------------------------------------------------------
// headWidth
//
// returns the width of the note head symbol
// or the width of the string representation of the fret mark
//---------------------------------------------------------

qreal Note::headWidth() const
{
return symbols[score()->symIdx()][noteHead()].width(magS());
}

qreal Note::tabHeadWidth(StaffTypeTablature* tab) const
{
qreal val;
if (tab && _fret != FRET_NONE && _string != STRING_NONE) {
qreal mags = magS();
QFont f = tab->fretFont();
int size = lrint(tab->fretFontSize() * MScore::DPI / PPI);
f.setPixelSize(size);
QFontMetricsF fm(f);
QString s = tab->fretString(_fret, _ghost);
val = fm.width(s) * mags;
}
else
val = symbols[score()->symIdx()][noteHead()].width(magS());
if (_small)
val *= score()->styleD(ST_smallNoteMag);
return val;
}

//---------------------------------------------------------
// headHeight
//
// returns the height of the note head symbol
// or the height of the string representation of the fret mark
//---------------------------------------------------------

qreal Note::headHeight() const
{
if(tab && _fret != FRET_NONE && _string != STRING_NONE)
return tab->fretBoxH() * magS();
return symbols[score()->symIdx()][noteHead()].height(magS());
}

qreal Note::tabHeadHeight(StaffTypeTablature *tab) const
{
if(tab && _fret != FRET_NONE && _string != STRING_NONE)
return tab->fretBoxH() * magS();
return headHeight();
}

//---------------------------------------------------------
// attach
//---------------------------------------------------------
Expand Down Expand Up @@ -1234,16 +1268,7 @@ void Note::layout()
if (useTablature) {
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
qreal mags = magS();
// QFont f(tab->fretFontName());
QFont f = tab->fretFont();
int size = lrint(tab->fretFontSize() * MScore::DPI / PPI);
f.setPixelSize(size);
QFontMetricsF fm(f);
// // when using letters, "+(_fret > 8)" skips 'j'
// QString s = _ghost ? "X" :
// ( tab->useNumbers() ? QString::number(_fret) : QString('a' + _fret + (_fret > 8)) );
QString s = tab->fretString(_fret, _ghost);
qreal w = fm.width(s) * mags;
qreal w = headWidth(tab);
// center string name to note head
qreal xo = (headWidth() - w) * .5;
bbox().setRect(xo, tab->fretBoxY() * mags, w, tab->fretBoxH() * mags);
Expand Down
3 changes: 3 additions & 0 deletions libmscore/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AccidentalState;
class Accidental;
class NoteDot;
class Spanner;
class StaffTypeTablature;

//---------------------------------------------------------
// NoteVal
Expand Down Expand Up @@ -192,6 +193,8 @@ class Note : public Element {

qreal headWidth() const;
qreal headHeight() const;
qreal tabHeadWidth(StaffTypeTablature* tab = 0) const;
qreal tabHeadHeight(StaffTypeTablature* tab = 0) const;
QPointF attach() const;

int noteHead() const;
Expand Down

0 comments on commit a6cbcd7

Please sign in to comment.