improve 1.2 import of dynamics

This commit is contained in:
Werner Schweer 2012-10-24 13:15:46 +02:00
parent a72b47bd05
commit 763af76767
5 changed files with 40 additions and 7 deletions

View file

@ -130,8 +130,26 @@ void Dynamic::read(const QDomElement& de)
else if (!Text::readProperties(e))
domError(e);
}
if (score()->mscVersion() < 118)
if (score()->mscVersion() < 118) {
setTextStyleType(TEXT_STYLE_DYNAMICS2);
}
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void Dynamic::layout()
{
if (!readPos().isNull()) {
if (score()->mscVersion() < 118) {
setReadPos(QPointF());
// hack: 1.2 boundingBoxes are a bit wider which results
// in symbols moved right
setUserXoffset(userOff().x() - spatium() * .6);
}
}
Text::layout();
}
//---------------------------------------------------------

View file

@ -59,6 +59,7 @@ class Dynamic : public Text {
QString subtypeName() const;
int subtype() const { return _subtype; }
virtual void layout();
virtual void write(Xml& xml) const;
virtual void read(const QDomElement&);

View file

@ -2086,10 +2086,9 @@ void Measure::read(const QDomElement& de, int staffIdx)
else if (tag == "TimeSig") {
TimeSig* ts = new TimeSig(score());
ts->setTrack(score()->curTrack);
// parent must be set before read
ts->read(e);
segment = getSegment(Segment::SegTimeSig, score()->curTick);
segment->add(ts);
ts->read(e);
if (score()->mscVersion() > 114) {
// in <= 114 sigmap is part of the mscx file

View file

@ -38,6 +38,7 @@ TimeSig::TimeSig(Score* s)
_sig.set(0, 1); // initialize to invalid
_subtype = TSIG_NORMAL;
customText = false;
needLayout = true;
}
//---------------------------------------------------------
@ -208,7 +209,7 @@ void TimeSig::read(const QDomElement& de)
else
_subtype = TSIG_NORMAL;
}
layout1();
needLayout = true;
}
//---------------------------------------------------------
@ -293,6 +294,7 @@ void TimeSig::layout1()
pz *= im; // convert positions to raster units
pn *= im;
needLayout = false;
// adjustReadPos();
}
@ -451,6 +453,16 @@ QVariant TimeSig::propertyDefault(P_ID id) const
void TimeSig::spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/)
{
layout1();
needLayout = true;
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void TimeSig::layout()
{
if (needLayout)
layout1();
}

View file

@ -52,13 +52,16 @@ class TimeSig : public Element {
Q_PROPERTY(int denominatorStretch READ denominatorStretch)
TimeSigType _subtype;
bool _showCourtesySig;
QString _numeratorString; // calculated from actualSig() if !customText
QString _denominatorString;
QPointF pz, pn;
Fraction _sig;
Fraction _stretch; // localSig / globalSig
bool _showCourtesySig;
bool customText; // if false, sz and sn are calculated from actualSig()
bool needLayout;
void layout1();
public:
TimeSig(Score* = 0);
@ -74,7 +77,7 @@ class TimeSig : public Element {
void draw(QPainter*) const;
void write(Xml& xml) const;
void read(const QDomElement&);
void layout1();
void layout();
Space space() const;
Fraction sig() const { return _sig; }