Skip to content

Commit

Permalink
page format fixes (minSystemDistance); make vertical space for fret d…
Browse files Browse the repository at this point in the history
…iagram
  • Loading branch information
wschweer committed Dec 10, 2012
1 parent c46a905 commit 23d29f6
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 deletions.
8 changes: 5 additions & 3 deletions libmscore/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ void FretDiagram::layout()
h -= y;
}
setbbox(QRectF(x, y, w, h));
// Element::layout(); // alignment & offset
// setPos(ipos() + QPointF(-w * .5, - (h + _spatium * 1.5)));
setPos(0.0, 0.0);
setPos(-_spatium, -h - _spatium);
adjustReadPos();

MStaff* mstaff = segment()->measure()->mstaff(staffIdx());
mstaff->distanceUp = qMax(mstaff->distanceUp, h + _spatium * 4);

if (_harmony)
_harmony->layout();
}
Expand Down
2 changes: 1 addition & 1 deletion libmscore/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FretDiagram : public Element {
~FretDiagram();
virtual void draw(QPainter*) const;
virtual FretDiagram* clone() const { return new FretDiagram(*this); }
// Segment* segment() const { return (Segment*)parent(); }
Segment* segment() const { return (Segment*)parent(); }
// Measure* measure() const { return (Measure*)parent()->parent(); }

virtual ElementType type() const { return FRET_DIAGRAM; }
Expand Down
31 changes: 26 additions & 5 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,8 @@ void Score::doLayout()

if (layoutMode() == LayoutLine)
layoutLinear();
else {
else
layoutSystems(); // create list of systems
layoutPages(); // create list of pages
}

//---------------------------------------------------
// place Spanner & beams
Expand Down Expand Up @@ -655,6 +653,13 @@ void Score::doLayout()
e->layout();
}
}


if (layoutMode() != LayoutLine) {
layoutSystems2();
layoutPages(); // create list of pages
}

for (Measure* m = firstMeasure(); m; m = m->nextMeasure())
m->layout2();

Expand Down Expand Up @@ -2058,6 +2063,22 @@ void Score::layoutSystems()
_systems.takeLast();
}

//---------------------------------------------------------
// layoutSystems2
// update distanceUp, distanceDown
//---------------------------------------------------------

void Score::layoutSystems2()
{
int n = _systems.size();
for (int i = 0; i < n; ++i) {
System* system = _systems.at(i);
if (!system->isVbox()) {
system->layout2();
}
}
}

//---------------------------------------------------------
// layoutLinear
//---------------------------------------------------------
Expand Down Expand Up @@ -2272,14 +2293,14 @@ void Score::layoutPages()
}
else
tmargin = qMax(pC.tm(), sub);
bmargin = qMax(pC.bm(), slb);
bmargin = pC.bm();
}

tmargin = qMax(tmargin, pC.prevDist);
pC.prevDist = bmargin;

qreal h = pC.sr.height();
if (pC.lastSystem && (pC.y + h + tmargin + bmargin > pC.ey)) {
if (pC.lastSystem && (pC.y + h + tmargin + qMax(bmargin, slb) > pC.ey)) {
//
// prepare next page
//
Expand Down
16 changes: 10 additions & 6 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2815,21 +2815,25 @@ bool Measure::isRepeatMeasure(Part* part)
}

//---------------------------------------------------------
// userDistanceDown
// distanceDown
//---------------------------------------------------------

qreal Measure::userDistanceDown(int i) const
qreal Measure::distanceDown(int i) const
{
return staves[i]->_vspacerDown ? staves[i]->_vspacerDown->gap() : .0;
if (staves[i]->_vspacerDown)
return qMax(staves[i]->distanceDown, staves[i]->_vspacerDown->gap());
return staves[i]->distanceDown;
}

//---------------------------------------------------------
// userDistanceUp
// distanceUp
//---------------------------------------------------------

qreal Measure::userDistanceUp(int i) const
qreal Measure::distanceUp(int i) const
{
return staves[i]->_vspacerUp ? staves[i]->_vspacerUp->gap() : .0;
if (staves[i]->_vspacerUp)
return qMax(staves[i]->distanceUp, staves[i]->_vspacerUp->gap());
return staves[i]->distanceUp;
}

//---------------------------------------------------------
Expand Down
6 changes: 2 additions & 4 deletions libmscore/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ class Measure : public MeasureBase {
Text* noText() const { return _noText; }
void setNo(int n) { _no = n; }
void setNoOffset(int n) { _noOffset = n; }
virtual qreal distanceUp(int i) const { return staves[i]->distanceUp; }
virtual qreal distanceDown(int i) const { return staves[i]->distanceDown; }
virtual qreal userDistanceUp(int i) const;
virtual qreal userDistanceDown(int i) const;
virtual qreal distanceUp(int i) const;
virtual qreal distanceDown(int i) const;

qreal minWidth1() const;
qreal minWidth2() const;
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ class Score : public QObject {

Q_INVOKABLE void doLayout();
void layoutSystems();
void layoutSystems2();
void layoutLinear();
void layoutPages();
void layoutSystemsUndoRedo();
Expand Down
6 changes: 3 additions & 3 deletions libmscore/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ class FSymbol : public Element {

virtual qreal baseLine() const { return 0.0; }
Segment* segment() const { return (Segment*)parent(); }
QFont font() const { return _font; }
int code() const { return _code; }
QFont font() const { return _font; }
int code() const { return _code; }
void setFont(const QFont& f);
void setCode(int val) { _code = val; }
void setCode(int val) { _code = val; }
};

#endif
Expand Down
2 changes: 0 additions & 2 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ void System::layout2()
qreal distUp = 0.0;
foreach(MeasureBase* m, ml) {
distDown = qMax(distDown, m->distanceDown(staffIdx));
distDown = qMax(distDown, m->userDistanceDown(staffIdx));
distUp = qMax(distUp, m->distanceUp(staffIdx));
distUp = qMax(distUp, m->userDistanceUp(staffIdx));
}
s->setDistanceDown(distDown);
s->setDistanceUp(distUp);
Expand Down
2 changes: 2 additions & 0 deletions mscore/importmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ void MidiFile::convertTrack(Score* score, MidiTrack* midiTrack)
chord->setDuration(d.fraction());
Segment* s = measure->getSegment(chord, tick);
s->add(chord);
chord->setUserPlayEvents(true);

int actualTicks = chord->actualTicks();
foreach (MNote* n, notes) {
Expand Down Expand Up @@ -1240,6 +1241,7 @@ qDebug("unmapped drum note 0x%02x %d", mn.pitch(), mn.pitch());
chord->setDurationType(d);
chord->setDuration(d.fraction());
ctick += len;
chord->setUserPlayEvents(true);

int actualTicks = chord->actualTicks();
foreach (MNote* n, notes) {
Expand Down

0 comments on commit 23d29f6

Please sign in to comment.