1.2 import: fix placement of dynamics

This commit is contained in:
Werner Schweer 2012-08-23 17:40:04 +02:00
parent 307dfa62e2
commit 93bc053086
17 changed files with 67 additions and 47 deletions

View file

@ -1963,3 +1963,16 @@ QPointF Chord::layoutArticulation(Articulation* a)
a->adjustReadPos();
return QPointF(x, y);
}
//---------------------------------------------------------
// toDefault
//---------------------------------------------------------
void Chord::toDefault()
{
score()->undoChangeProperty(this, P_STEM_DIRECTION, int(MScore::AUTO));
score()->undoChangeProperty(this, P_BEAM_MODE, int(BEAM_AUTO));
ChordRest::toDefault();
}

View file

@ -204,6 +204,7 @@ class Chord : public ChordRest {
virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
virtual void toDefault();
};
#endif

View file

@ -857,21 +857,6 @@ void ChordRest::setBeam(Beam* b)
_beam = b;
}
//---------------------------------------------------------
// toDefault
//---------------------------------------------------------
void ChordRest::toDefault()
{
score()->undoChangeUserOffset(this, QPointF());
if (type() == CHORD) {
score()->undoChangeProperty(this, P_STEM_DIRECTION, int(MScore::AUTO));
score()->undoChangeProperty(this, P_BEAM_MODE, int(BEAM_AUTO));
}
else
score()->undoChangeProperty(this, P_BEAM_MODE, int(BEAM_NO));
}
//---------------------------------------------------------
// setDurationType
//---------------------------------------------------------

View file

@ -119,7 +119,6 @@ class ChordRest : public DurationElement {
void removeAnnotation(Element* e) { _annotations.removeOne(e); }
void layoutArticulations();
virtual void toDefault();
const TDuration& durationType() const { return _durationType; }
void setDurationType(TDuration::DurationType t);

View file

@ -1914,7 +1914,7 @@ void Score::cmdMoveRest(Rest* rest, MScore::Direction dir)
pos.ry() -= spatium();
else if (dir == MScore::DOWN)
pos.ry() += spatium();
undoChangeUserOffset(rest, pos);
undoChangeProperty(rest, P_USER_OFF, pos);
setLayoutAll(false);
}

View file

@ -409,7 +409,7 @@ void Element::scanElements(void* data, void (*func)(void*, Element*), bool all)
void Element::toDefault()
{
if (!_userOff.isNull())
score()->undoChangeUserOffset(this, QPointF());
score()->undoChangeProperty(this, P_USER_OFF, QPointF());
}
//---------------------------------------------------------
@ -887,6 +887,10 @@ void StaffLines::draw(QPainter* painter) const
painter->drawLine(QLineF(x1, y, x2, y));
y = _pos.y() + (lines+2) * dist;
painter->drawLine(QLineF(x1, y, x2, y));
y = _pos.y() + (lines+3) * dist;
painter->drawLine(QLineF(x1, y, x2, y));
y = _pos.y() + (lines+4) * dist;
painter->drawLine(QLineF(x1, y, x2, y));
}
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
painter->drawLines(ll);
@ -1562,7 +1566,6 @@ bool Element::setProperty(P_ID propertyId, const QVariant& v)
}
setGenerated(false);
score()->addRefresh(canvasBoundingRect());
qDebug("Element::setProperty: unknown id %d, data <%s>", propertyId, qPrintable(v.toString()));
return true;
}

View file

@ -68,5 +68,5 @@ void Fingering::toDefault()
score()->layoutFingering(this);
QPointF no(userOff());
setUserOff(o);
score()->undoChangeUserOffset(this, no);
score()->undoChangeProperty(this, P_USER_OFF, no);
}

View file

@ -47,13 +47,13 @@ void HairpinSegment::layout()
switch (subtype()) {
case SEGMENT_SINGLE:
case SEGMENT_BEGIN:
l1 = QLineF(.0, .0, len, h1);
l2 = QLineF(.0, .0, len, - h1);
l1.setLine(.0, .0, len, h1);
l2.setLine(.0, .0, len, - h1);
break;
case SEGMENT_MIDDLE:
case SEGMENT_END:
l1 = QLineF(.0, h2, len, h1);
l2 = QLineF(.0, -h2, len, - h1);
l1.setLine(.0, h2, len, h1);
l2.setLine(.0, -h2, len, - h1);
break;
}
}
@ -62,13 +62,13 @@ void HairpinSegment::layout()
switch(subtype()) {
case SEGMENT_SINGLE:
case SEGMENT_END:
l1 = QLineF(.0, h1, len, 0.0);
l2 = QLineF(.0, -h1, len, 0.0);
l1.setLine(.0, h1, len, 0.0);
l2.setLine(.0, -h1, len, 0.0);
break;
case SEGMENT_BEGIN:
case SEGMENT_MIDDLE:
l1 = QLineF(.0, h1, len, + h2);
l2 = QLineF(.0, -h1, len, - h2);
l1.setLine(.0, h1, len, + h2);
l2.setLine(.0, -h1, len, - h2);
break;
}
}
@ -88,8 +88,8 @@ void HairpinSegment::draw(QPainter* painter) const
{
QPen pen(curColor(), point(score()->styleS(ST_hairpinWidth)));
painter->setPen(pen);
painter->drawLine(QLineF(l1.x1(), l1.y1(), l1.x2(), l1.y2()));
painter->drawLine(QLineF(l2.x1(), l2.y1(), l2.x2(), l2.y2()));
painter->drawLine(l1);
painter->drawLine(l2);
}
//---------------------------------------------------------

View file

@ -1452,8 +1452,8 @@ void Note::setTrack(int val)
void Note::toDefault()
{
score()->undoChangeUserOffset(this, QPointF());
score()->undoChangeUserOffset(chord(), QPointF());
score()->undoChangeProperty(this, P_USER_OFF, QPointF());
score()->undoChangeProperty(chord(), P_USER_OFF, QPointF());
score()->undoChangeProperty(chord(), P_STEM_DIRECTION, MScore::AUTO);
}
@ -1538,7 +1538,7 @@ void Note::endEdit()
{
Chord* ch = chord();
if (ch->notes().size() == 1) {
score()->undoChangeUserOffset(ch, ch->userOff() + userOff());
score()->undoChangeProperty(ch, P_USER_OFF, ch->userOff() + userOff());
setUserOff(QPointF());
score()->setLayoutAll(true);
}

View file

@ -33,6 +33,7 @@ enum P_ID {
P_TPC,
P_HEAD_TYPE,
P_HEAD_GROUP,
P_VELO_TYPE,
P_VELO_OFFSET,
P_ARTICULATION_ANCHOR,
@ -43,6 +44,7 @@ enum P_ID {
P_LEADING_SPACE,
P_TRAILING_SPACE,
P_DISTRIBUTE,
P_MIRROR_HEAD,
P_DOT_POSITION,
P_ONTIME_OFFSET,
@ -53,6 +55,7 @@ enum P_ID {
P_USER_OFF,
P_FRET,
P_STRING,
P_GHOST,
P_TIMESIG_NOMINAL,
P_TIMESIG_ACTUAL,
@ -63,6 +66,7 @@ enum P_ID {
P_P1,
P_P2,
P_GROW_LEFT,
P_GROW_RIGHT,
P_BOX_HEIGHT,
P_BOX_WIDTH,
@ -73,6 +77,7 @@ enum P_ID {
P_TOP_MARGIN,
P_BOTTOM_MARGIN,
P_LAYOUT_BREAK,
P_AUTOSCALE,
P_SIZE,
P_SCALE,
@ -83,6 +88,7 @@ enum P_ID {
P_BEAM_POS,
P_BEAM_MODE,
P_USER_LEN, // used for stems
P_SPACE, // used for spacer
P_TEMPO,
P_TEMPO_FOLLOW_TEXT,

View file

@ -29,6 +29,7 @@
#include "part.h"
#include "sig.h"
#include "box.h"
#include "dynamic.h"
//---------------------------------------------------------
// read114
@ -467,6 +468,16 @@ bool Score::read114(const QDomElement& de)
e->setUserOff(QPointF(e->userOff().x() - s->pos().x(),
e->userOff().y()));
}
else if (e->type() == DYNAMIC) {
// reparent from measure to segment
Dynamic* d = static_cast<Dynamic*>(e);
qreal dy = d->height() - d->baseLine();
e->setUserOff(QPointF(e->userOff().x() - s->pos().x(),
e->userOff().y() + dy));
// printf("Dynamic h %f bl %f d %f\n",
// d->height(), d->baseLine(), dy);
}
}
}

View file

@ -485,3 +485,13 @@ void Rest::setMMWidth(qreal val)
}
}
//---------------------------------------------------------
// toDefault
//---------------------------------------------------------
void Rest::toDefault()
{
score()->undoChangeProperty(this, P_BEAM_MODE, BEAM_NO);
ChordRest::toDefault();
}

View file

@ -53,6 +53,8 @@ class Rest : public ChordRest {
virtual Element* drop(const DropData&);
virtual void layout();
virtual void toDefault();
void setMMWidth(qreal val);
qreal mmWidth() const { return _mmWidth; }
int getSymbol(TDuration::DurationType type, int line, int lines, int* yoffset);

View file

@ -467,7 +467,6 @@ class Score : public QObject {
void undoChangeChordRestLen(ChordRest* cr, const TDuration&);
void undoChangeEndBarLineType(Measure*, BarLineType);
void undoChangeBarLineSpan(Staff*, int);
void undoChangeUserOffset(Element* e, const QPointF& offset);
void undoChangeDynamic(Dynamic* e, int velocity, DynamicType type);
void undoTransposeHarmony(Harmony*, int, int);
void undoExchangeVoice(Measure* measure, int val1, int val2, int staff1, int staff2);

View file

@ -950,7 +950,7 @@ void SlurTie::undoSetSlurDirection(MScore::Direction d)
void SlurTie::toDefault()
{
score()->undoChangeUserOffset(this, QPointF());
score()->undoChangeProperty(this, P_USER_OFF, QPointF());
}
//---------------------------------------------------------
@ -988,7 +988,7 @@ bool SlurTie::setProperty(P_ID propertyId, const QVariant& v)
void SlurSegment::toDefault()
{
score()->undoChangeUserOffset(this, QPointF());
score()->undoChangeProperty(this, P_USER_OFF, QPointF());
score()->undo(new ChangeSlurOffsets(this, QPointF(), QPointF(), QPointF(), QPointF()));
for (int i = 0; i < SLUR_GRIPS; ++i)
ups[i].off = QPointF();

View file

@ -583,15 +583,6 @@ void Score::undoChangeBarLineSpan(Staff* staff, int span)
undo(new ChangeBarLineSpan(staff, span));
}
//---------------------------------------------------------
// undoChangeUserOffset
//---------------------------------------------------------
void Score::undoChangeUserOffset(Element* e, const QPointF& offset)
{
undoChangeProperty(e, P_USER_OFF, offset);
}
//---------------------------------------------------------
// undoChangeDynamic
//---------------------------------------------------------

View file

@ -303,7 +303,7 @@ void InspectorElementElement::apply()
score->startCmd();
QPointF o(offsetX->value() * _spatium, offsetY->value() * _spatium);
if (o != e->pos())
score->undoChangeUserOffset(e, o - e->ipos());
score->undoChangeProperty(e, P_USER_OFF, o - e->ipos());
if (e->color() != color->color())
score->undoChangeProperty(e, P_COLOR, color->color());
if (e->visible() != visible->isChecked())
@ -462,7 +462,7 @@ void InspectorArticulation::apply()
score->startCmd();
if (o != a->pos())
score->undoChangeUserOffset(a, o - a->ipos());
score->undoChangeProperty(a, P_USER_OFF, o - a->ipos());
if (anchor != a->anchor())
score->undoChangeProperty(a, P_ARTICULATION_ANCHOR, int(anchor));
if (d != a->direction())