Skip to content

Commit

Permalink
update for simpletext; enhanced text compatibility with 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Oct 4, 2012
1 parent 038f2f1 commit 2baa661
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 208 deletions.
13 changes: 6 additions & 7 deletions libmscore/element.cpp
Expand Up @@ -487,7 +487,6 @@ QRectF Element::drag(const EditData& data)
int n = lrint(y / vRaster);
y = vRaster * n;
}
printf("drag %s\n", name());
setUserOff(QPointF(x, y));
return canvasBoundingRect() | r;
}
Expand Down Expand Up @@ -704,16 +703,16 @@ bool Element::readProperties(const QDomElement& e)
qreal _spatium = spatium();
QPointF pt(readPoint(e) * _spatium);
setUserOff(pt);
_readPos = QPointF();
// _readPos = QPointF();
}
else if (tag == "pos") {
if (score()->mscVersion() > 114
|| (type() != TEXT && type() != DYNAMIC)
) {
// if (score()->mscVersion() > 114
// || (type() != TEXT && type() != DYNAMIC)
// ) {
qreal _spatium = spatium();
setUserOff(QPointF());
// setUserOff(QPointF());
_readPos = readPoint(e) * _spatium;
}
// }
}
else if (tag == "voice")
setTrack((_track/VOICES)*VOICES + val.toInt());
Expand Down
2 changes: 1 addition & 1 deletion libmscore/element.h
Expand Up @@ -324,7 +324,7 @@ class Element : public QObject {
void setGenerated(bool val) { _generated = val; }

const QPointF& ipos() const { return _pos; }
virtual QPointF pos() const { return _pos + _userOff; }
virtual const QPointF pos() const { return _pos + _userOff; }
virtual qreal x() const { return _pos.x() + _userOff.x(); }
virtual qreal y() const { return _pos.y() + _userOff.y(); }
void setPos(qreal x, qreal y) { _pos.rx() = x, _pos.ry() = y; }
Expand Down
51 changes: 19 additions & 32 deletions libmscore/repeat.cpp
Expand Up @@ -72,7 +72,7 @@ void RepeatMeasure::layout()
Marker::Marker(Score* s)
: Text(s)
{
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE | ELEMENT_ON_STAFF);
setTextStyle(s->textStyle(TEXT_STYLE_REPEAT));
}

Expand All @@ -85,27 +85,27 @@ void Marker::setMarkerType(MarkerType t)
_markerType = t;
switch(t) {
case MARKER_SEGNO:
setHtml(symToHtml(symbols[score()->symIdx()][segnoSym], 8, &textStyle()));
setText(symbols[score()->symIdx()][segnoSym].toString());
setLabel("segno");
break;

case MARKER_VARSEGNO:
setHtml(symToHtml(symbols[score()->symIdx()][varsegnoSym], 8, &textStyle()));
setText(symbols[score()->symIdx()][varsegnoSym].toString());
setLabel("varsegno");
break;

case MARKER_CODA:
setHtml(symToHtml(symbols[score()->symIdx()][codaSym], 8, &textStyle()));
setText(symbols[score()->symIdx()][codaSym].toString());
setLabel("codab");
break;

case MARKER_VARCODA:
setHtml(symToHtml(symbols[score()->symIdx()][varcodaSym], 8));
setText(symbols[score()->symIdx()][varcodaSym].toString());
setLabel("varcoda");
break;

case MARKER_CODETTA:
setHtml(symToHtml(symbols[score()->symIdx()][codaSym], symbols[score()->symIdx()][codaSym], 8));
setText(symbols[score()->symIdx()][codaSym].toString());
setLabel("codetta");
break;

Expand Down Expand Up @@ -137,27 +137,25 @@ void Marker::styleChanged()
setMarkerType(_markerType);
}

//---------------------------------------------------------
// layout
//---------------------------------------------------------

void Marker::layout()
{
Text::layout();
}

//---------------------------------------------------------
// adjustReadPos
//---------------------------------------------------------

void Marker::adjustReadPos()
{
if (!readPos().isNull()) {
QPointF uo = readPos() - ipos();
QPointF uo;
if (score()->mscVersion() <= 114) {
// rebase from Measure to Segment
uo.rx() -= segment()->ipos().x();
uo = userOff();
uo.rx() -= segment()->pos().x();
// 1.2 is always HCENTER aligned
printf("align %x\n", int(align()));
if ((align() & ALIGN_HMASK) == 0) // ALIGN_LEFT
uo.rx() -= bbox().width() * .5;
}
else
uo = readPos() - ipos();
setUserOff(uo);
setReadPos(QPointF());
}
Expand Down Expand Up @@ -203,22 +201,22 @@ void Marker::read(const QDomElement& de)
else if (!Text::readProperties(e))
domError(e);
}
switch(mt) {
switch (mt) {
case MARKER_SEGNO:
case MARKER_VARSEGNO:
case MARKER_CODA:
case MARKER_VARCODA:
case MARKER_CODETTA:
setTextStyle(score()->textStyle(TEXT_STYLE_REPEAT_LEFT));
setTextStyleType(TEXT_STYLE_REPEAT_LEFT);
break;

case MARKER_FINE:
case MARKER_TOCODA:
setTextStyle(score()->textStyle(TEXT_STYLE_REPEAT_RIGHT));
setTextStyleType(TEXT_STYLE_REPEAT_RIGHT);
break;

case MARKER_USER:
setTextStyle(score()->textStyle(TEXT_STYLE_REPEAT));
setTextStyleType(TEXT_STYLE_REPEAT);
break;
}
setMarkerType(mt);
Expand All @@ -236,17 +234,6 @@ void Marker::write(Xml& xml) const
xml.etag();
}

#if 0
//---------------------------------------------------------
// dragAnchor
//---------------------------------------------------------

QLineF Marker::dragAnchor() const
{
return QLineF(measure()->pagePos(), pagePos());
}
#endif

//---------------------------------------------------------
// Jump
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion libmscore/repeat.h
Expand Up @@ -79,7 +79,6 @@ class Marker : public Text {
QString label() const { return _label; }
void setLabel(const QString& s) { _label = s; }

virtual void layout();
virtual void styleChanged();
virtual bool systemFlag() const { return true; }
virtual void adjustReadPos();
Expand Down
2 changes: 0 additions & 2 deletions libmscore/scorefile.cpp
Expand Up @@ -784,8 +784,6 @@ Score::FileError Score::read1(const QDomElement& de, bool ignoreVersionError)
le->setLid(this, id++);
_elinks.clear();

printf("===version %d\n", _mscVersion);

// _mscVersion is needed used during layout
// _mscVersion = MSCVERSION; // for later drag & drop usage

Expand Down

0 comments on commit 2baa661

Please sign in to comment.