Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 22, 2013
1 parent 0eae1ff commit 9c53354
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 35 deletions.
15 changes: 9 additions & 6 deletions libmscore/chord.cpp
Expand Up @@ -1388,7 +1388,6 @@ void Chord::layout()
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

}
// horiz. spacing: leave half width at each side of the (potential) stem
qreal halfHeadWidth = headWidth * 0.5;
Expand Down Expand Up @@ -1495,27 +1494,30 @@ void Chord::layout()
// - position
//-----------------------------------------

qreal stepDistance = _spatium * .5;
int stepOffset = staff()->staffType()->stepOffset();
// qreal stepDistance = _spatium * .5;
// int stepOffset = staff()->staffType()->stepOffset();
int lx = 0.0;

adjustReadPos();

qreal stemWidth5;
// qreal stemWidth5;
qreal noteWidth = _notes.size() ? downNote()->headWidth() :
symbols[score()->symIdx()][quartheadSym].width(magS());
qreal stemX = _up ? noteWidth : 0.0;
#if 0
if (stem()) {
stemWidth5 = stem()->lineWidth() * .5;
_stem->rxpos() = _up ? stemX - stemWidth5 : stemWidth5;
}
else
stemWidth5 = 0.0;
#endif

int n = _notes.size();
for (int i = 0; i < n; ++i) {
Note* note = _notes.at(i);
note->layout();
#if 0
qreal x;

qreal hw = note->headWidth();
Expand All @@ -1531,9 +1533,10 @@ void Chord::layout()
else
x = 0.0;
}

note->rypos() = (note->line() + stepOffset) * stepDistance;
note->rxpos() = x;
note->rypos() = (note->line() + stepOffset) * stepDistance;
#endif
qreal x = note->rxpos();

Accidental* accidental = note->accidental();
if (accidental) {
Expand Down
76 changes: 55 additions & 21 deletions libmscore/layout.cpp
Expand Up @@ -140,7 +140,6 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
endIdx = -1;
}

bool moveLeft = false;
int ll = 1000; // line distance to previous note head
bool isLeft = notes[startIdx]->chord()->up();
int move1 = notes[startIdx]->chord()->staffMove();
Expand Down Expand Up @@ -192,7 +191,6 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
notes[idx-incIdx]->chord()->rxpos() = note->headWidth() - note->point(styleS(ST_stemWidth));
note->rxpos() = 0.0;
}
moveLeft = true;
}
}
if (note->userMirror() == MScore::DH_AUTO) {
Expand All @@ -204,9 +202,6 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
mirror = !mirror;
}
note->setMirror(mirror);
if (mirror) //??
moveLeft = true;

move1 = move;
ll = line;
lastHeadGroup = headGroup;
Expand All @@ -218,7 +213,11 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
// find column for dots
//---------------------------------------------------

QList<AcEl> aclist;
std::vector<AcEl> aclist;

qreal _spatium = spatium();
qreal stepDistance = _spatium * .5;
int stepOffset = staff->staffType()->stepOffset();

qreal dotPosX = 0.0;
int nNotes = notes.size();
Expand All @@ -231,12 +230,46 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
AcEl acel;
acel.note = note;
acel.x = 0.0;
aclist.append(acel);
aclist.push_back(acel);
}
qreal xx = note->pos().x() + note->headWidth() + note->chord()->pos().x();
qreal hw = note->headWidth();
qreal xx = note->pos().x() + hw + note->chord()->pos().x();
if (xx > dotPosX)
dotPosX = xx;

Chord* chord = note->chord();
bool _up = chord->up();

qreal stemX;
if (_up)
stemX = symbols[symIdx()][quartheadSym].width(_spatium / (MScore::DPI * SPATIUM20));
else
stemX = 0;
qreal stemWidth5;
if (chord->stem()) {
stemWidth5 = chord->stem()->lineWidth() * .5;
chord->stem()->rxpos() = _up ? stemX - stemWidth5 : stemWidth5;
}
else
stemWidth5 = 0.0;

qreal x;
if (note->mirror()) {
if (_up)
x = stemX - stemWidth5 * 2;
else
x = stemX - hw + stemWidth5 * 2;
}
else {
if (_up)
x = stemX - hw;
else
x = 0.0;
}
note->rypos() = (note->line() + stepOffset) * stepDistance;
note->rxpos() = x;
}

segment->setDotPosX(staffIdx, dotPosX);

int nAcc = aclist.size();
Expand All @@ -255,23 +288,23 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
// layout bottom accidental
//
if (nAcc > 1) {
note = aclist[nAcc-1].note;
note = aclist[nAcc-1].note; // last note
acc = note->accidental();
int l1 = aclist[0].note->line();
int l2 = note->line();

int st1 = aclist[0].note->accidental()->accidentalType();
int st2 = acc->accidentalType();
int ldiff = st1 == Accidental::ACC_FLAT ? 4 : 5;

if (qAbs(l1-l2) > ldiff) {
aclist[nAcc-1].x = -pnd * acc->mag() - acc->width() - acc->bbox().x();
}
else {
int st2 = acc->accidentalType();
if ((st1 == Accidental::ACC_FLAT) && (st2 == Accidental::ACC_FLAT) && (qAbs(l1-l2) > 2))
aclist[nAcc-1].x = aclist[0].x - acc->width() * .5;
else
aclist[nAcc-1].x = aclist[0].x - acc->width();
aclist[nAcc-1].x = aclist[0].x - acc->width() - pd;
}
}

Expand Down Expand Up @@ -312,16 +345,17 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
}
}

int n = aclist.size();
for (int i = 0; i < n; ++i) {
const AcEl& e = aclist.at(i);
qreal lx = 10000.0;
for (const AcEl& e : aclist) {
Note* note = e.note;
qreal x = e.x;
if (moveLeft) {
Chord* chord = note->chord();
if (((note->mirror() && chord->up()) || (!note->mirror() && !chord->up())))
x -= note->headWidth();
}
qreal x = note->x();
if (x < lx)
lx = x;
}

for (const AcEl& e : aclist) {
Note* note = e.note;
qreal x = e.x + lx - note->x();
note->accidental()->setPos(x, 0);
note->accidental()->adjustReadPos();
}
Expand Down Expand Up @@ -2518,7 +2552,7 @@ void Score::respace(QList<ChordRest*>* elements)
/// segment list fs
//---------------------------------------------------------

qreal Score::computeMinWidth(Segment* fs) const
qreal Score::computeMinWidth(Segment* fs)
{
int _nstaves = nstaves();
if (_nstaves == 0)
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Expand Up @@ -920,7 +920,7 @@ class Score : public QObject {
Q_INVOKABLE void appendMeasures(int);
Q_INVOKABLE void addText(const QString&, const QString&);
Q_INVOKABLE Cursor* newCursor();
qreal computeMinWidth(Segment* fs) const;
qreal computeMinWidth(Segment* fs);
void updateBarLineSpans(int idx, int linesOld, int linesNew);
Sym& sym(int id) { return symbols[symIdx()][id]; }

Expand Down
14 changes: 7 additions & 7 deletions libmscore/stem.cpp
Expand Up @@ -94,12 +94,12 @@ void Stem::layout()
}
else { // non-TAB
// move stem start to note attach point
Note* n = up() ? chord()->downNote() : chord()->upNote();
const Sym& sym = symbols[score()->symIdx()][n->noteHead()];
if (n->mirror())
_up *= -1;
y1 -= sym.attach(n->magS()).y() * _up;
}
Note* n = up() ? chord()->downNote() : chord()->upNote();
const Sym& sym = symbols[score()->symIdx()][n->noteHead()];
if (n->mirror())
_up *= -1;
y1 -= sym.attach(n->magS()).y() * _up;
}
}

line.setLine(0.0, y1, 0.0, l);
Expand Down Expand Up @@ -137,7 +137,7 @@ void Stem::spatiumChanged(qreal oldValue, qreal newValue)
void Stem::draw(QPainter* painter) const
{
// hide if second chord of a cross-measure pair
if(chord() && chord()->crossMeasure() == CROSSMEASURE_SECOND)
if (chord() && chord()->crossMeasure() == CROSSMEASURE_SECOND)
return;

Staff* st = staff();
Expand Down

0 comments on commit 9c53354

Please sign in to comment.