void SlurSegment::write(Xml& xml, int no) const { if (ups[GRIP_START].off.isNull() && ups[GRIP_END].off.isNull() && ups[GRIP_BEZIER1].off.isNull() && ups[GRIP_BEZIER2].off.isNull() && userOff().isNull() && visible() && (color() == Qt::black) ) return; xml.stag(QString("SlurSegment no=\"%1\"").arg(no)); if (!userOff().isNull()) xml.tag("offset", userOff() / spatium()); if (!(ups[GRIP_START].off.isNull())) xml.tag("o1", ups[GRIP_START].off); if (!(ups[GRIP_BEZIER1].off.isNull())) xml.tag("o2", ups[GRIP_BEZIER1].off); if (!(ups[GRIP_BEZIER2].off.isNull())) xml.tag("o3", ups[GRIP_BEZIER2].off); if (!(ups[GRIP_END].off.isNull())) xml.tag("o4", ups[GRIP_END].off); Element::writeProperties(xml); xml.etag(); }
void Fingering::reset() { QPointF o(userOff()); score()->layoutFingering(this); QPointF no(userOff()); setUserOff(o); score()->undoChangeProperty(this, P_ID::USER_OFF, no); }
void Fingering::reset() { QPointF o(userOff()); score()->layoutFingering(this); QPointF no; TextStyleType tst = textStyleType(); if (tst == TextStyleType::FINGERING || tst == TextStyleType::RH_GUITAR_FINGERING || tst == TextStyleType::STRING_NUMBER) no = userOff(); setUserOff(o); score()->undoChangeProperty(this, P_ID::USER_OFF, no); }
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(); Segment* s = segment(); for (int voice = 0; voice < VOICES; ++voice) { int t = (track() & ~0x3) + voice; Chord* c = static_cast<Chord*>(s->element(t)); if (!c) continue; if (c->type() == CHORD) { qreal noteHeadWidth = score()->noteHeadWidth() * c->mag(); if (c->stem() && !c->up()) // stem down rxpos() += noteHeadWidth * .25; // center on stem + optical correction else rxpos() += noteHeadWidth * .5; // center on note head } else rxpos() += c->width() * .5; break; } }
void LineSegment::editDrag(const EditData& ed) { // Only for resizing according to the diagonal properties QPointF deltaResize(ed.delta.x(), line()->diagonal() ? ed.delta.y() : 0.0); // Only for moving, no y limitaion QPointF deltaMove(ed.delta.x(), ed.delta.y()); switch(ed.curGrip) { case GRIP_LINE_START: // Resize the begin of element (left grip) setUserOff(userOff() + deltaResize); _userOff2 -= deltaResize; break; case GRIP_LINE_END: // Resize the end of element (rigth grip) _userOff2 += deltaResize; break; case GRIP_LINE_MIDDLE: // Move the element (middle grip) setUserOff(userOff() + deltaMove); break; } if ((line()->anchor() == Spanner::ANCHOR_NOTE) && (ed.curGrip == GRIP_LINE_START || ed.curGrip == GRIP_LINE_END)) { // // if we touch a different note, change anchor // Element* e = ed.view->elementNear(ed.pos); if (e && e->type() == NOTE) { SLine* l = line(); if (ed.curGrip == GRIP_LINE_END && e != line()->endElement()) { qDebug("LineSegment: move end anchor"); Note* noteOld = static_cast<Note*>(l->endElement()); Note* noteNew = static_cast<Note*>(e); noteOld->removeSpannerBack(l); noteNew->addSpannerBack(l); l->setEndElement(noteNew); _userOff2 += noteOld->canvasPos() - noteNew->canvasPos(); } else if (ed.curGrip == GRIP_LINE_START && e != l->startElement()) { qDebug("LineSegment: move start anchor (not impl.)"); } } } line()->layout(); }
void Rest::read(QDomElement e, const QList<Tuplet*>& tuplets, QList<Slur*>* slurs) { for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!ChordRest::readProperties(e, tuplets, slurs)) domError(e); } QPointF off(userOff()); setUserOffset(off.x(), off.y()); }
void Rest::read(XmlReader& e) { while (e.readNextStartElement()) { if (!ChordRest::readProperties(e)) e.unknown(); } QPointF off(userOff()); setUserOffset(off.x(), off.y()); }
void Rest::read(const QDomElement& de, QList<Tuplet*>* tuplets, QList<Spanner*>* spanner) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!ChordRest::readProperties(e, tuplets, spanner)) domError(e); } QPointF off(userOff()); setUserOffset(off.x(), off.y()); }
bool SlurSegment::isEdited(SpannerSegment* ss) const { SlurSegment* seg = static_cast<SlurSegment*>(ss); for (int i = 0; i < SLUR_GRIPS; ++i) { if (ups[i] != seg->ups[i]) return true; } if (ss->userOff() != userOff()) return true; return false; }
void LineSegment::editDrag(const EditData& ed) { // Only for resizing according to the diagonal properties QPointF deltaResize(ed.delta.x(), line()->diagonal() ? ed.delta.y() : 0.0); // Only for moving, no y limitaion QPointF deltaMove(ed.delta.x(), ed.delta.y()); switch(ed.curGrip) { case GRIP_LINE_START: // Resize the begin of element (left grip) setUserOff(userOff() + deltaResize); _userOff2 -= deltaResize; break; case GRIP_LINE_END: // Resize the end of element (rigth grip) _userOff2 += deltaResize; break; case GRIP_LINE_MIDDLE: // Move the element (middle grip) setUserOff(userOff() + deltaMove); break; } 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(); }
void LineSegment::setGrip(int grip, const QPointF& p) { QPointF pt(p * spatium()); if (grip == GRIP_LINE_START) { QPointF delta = pt - (pagePos() - gripAnchor(grip)); setUserOff(userOff() + delta); _userOff2 -= delta; } else { setUserOff2(pt - pagePos() - _p2 + gripAnchor(grip)); } layout(); }
QRectF HBox::drag(const EditData& data) { QRectF r(canvasBoundingRect()); qreal diff = data.delta.x(); qreal x1 = userOff().x() + diff; if (parent()->type() == VBOX) { VBox* vb = static_cast<VBox*>(parent()); qreal x2 = parent()->width() - width() - (vb->leftMargin() + vb->rightMargin()) * MScore::DPMM; if (x1 < 0.0) x1 = 0.0; else if (x1 > x2) x1 = x2; } setUserOff(QPointF(x1, 0.0)); setStartDragPosition(data.pos); return canvasBoundingRect() | r; }
void Marker::adjustReadPos() { if (!readPos().isNull()) { QPointF uo; if (score()->mscVersion() <= 114) { // rebase from Measure to Segment uo = userOff(); uo.rx() -= segment()->pos().x(); // 1.2 is always HCENTER aligned if ((align() & ALIGN_HMASK) == 0) // ALIGN_LEFT uo.rx() -= bbox().width() * .5; } else uo = readPos() - ipos(); setUserOff(uo); setReadPos(QPointF()); } }
void SlurSegment::editDrag(const EditData& ed) { qreal _spatium = spatium(); ups[ed.curGrip].off += (ed.delta / _spatium); if (ed.curGrip == GRIP_START || ed.curGrip == GRIP_END) { slurTie()->computeBezier(this); // // move anchor for slurs // Slur* slur = static_cast<Slur*>(slurTie()); Element* e = ed.view->elementNear(ed.pos); if ((slur->type() == SLUR) && ( (ed.curGrip == GRIP_START && (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_BEGIN)) || (ed.curGrip == GRIP_END && (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_END)) ) ) { if (e && e->type() == NOTE) { Chord* chord = static_cast<Note*>(e)->chord(); if ((ed.curGrip == GRIP_END && chord != slur->endElement()) || (ed.curGrip == GRIP_START && chord != slur->startElement())) { changeAnchor(ed.view, ed.curGrip, chord); QPointF p1 = ed.pos - ups[ed.curGrip].p - pagePos(); ups[ed.curGrip].off = p1 / _spatium; return; } } } } else if (ed.curGrip == GRIP_BEZIER1 || ed.curGrip == GRIP_BEZIER2) slurTie()->computeBezier(this); else if (ed.curGrip == GRIP_SHOULDER) { ups[ed.curGrip].off = QPointF(); slurTie()->computeBezier(this, ed.delta); } else if (ed.curGrip == GRIP_DRAG) { ups[GRIP_DRAG].off = QPointF(); setUserOff(userOff() + ed.delta); } }
void Rest::layout() { _space.setLw(0.0); if (parent() && measure() && measure()->isMMRest()) { _space.setRw(point(score()->styleS(StyleIdx::minMMRestWidth))); static const qreal verticalLineWidth = .2; qreal _spatium = spatium(); qreal h = _spatium * (2 + verticalLineWidth); qreal w = _mmWidth + _spatium * verticalLineWidth*.5; bbox().setRect(-_spatium * verticalLineWidth*.5, -h * .5, w, h); // text qreal y = -_spatium * 2.5 - staff()->height() *.5; addbbox(QRectF(0, y, w, _spatium * 2)); // approximation return; } rxpos() = 0.0; if (staff() && staff()->isTabStaff()) { StaffType* tab = staff()->staffType(); // if rests are shown and note values are shown as duration symbols if (tab->showRests() && tab->genDurations()) { TDuration::DurationType type = durationType().type(); int dots = durationType().dots(); // if rest is whole measure, convert into actual type and dot values if (type == TDuration::DurationType::V_MEASURE) { int ticks = measure()->ticks(); TDuration dur = TDuration(Fraction::fromTicks(ticks)).type(); type = dur.type(); dots = dur.dots(); } // symbol needed; if not exist, create, if exists, update duration if (!_tabDur) _tabDur = new TabDurationSymbol(score(), tab, type, dots); else _tabDur->setDuration(type, dots, tab); _tabDur->setParent(this); // needed? _tabDur->setTrack(track()); _tabDur->layout(); setbbox(_tabDur->bbox()); setPos(0.0, 0.0); // no rest is drawn: reset any position might be set for it _space.setLw(0.0); _space.setRw(width()); return; } // if no rests or no duration symbols, delete any dur. symbol and chain into standard staff mngmt // this is to ensure horiz space is reserved for rest, even if they are not diplayed // Rest::draw() will skip their drawing, if not needed if(_tabDur) { delete _tabDur; _tabDur = 0; } } switch(durationType().type()) { case TDuration::DurationType::V_64TH: case TDuration::DurationType::V_32ND: dotline = -3; break; case TDuration::DurationType::V_1024TH: case TDuration::DurationType::V_512TH: case TDuration::DurationType::V_256TH: case TDuration::DurationType::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int stepOffset = 0; if (staff()) stepOffset = staff()->staffType()->stepOffset(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); qreal lineDist = staff() ? staff()->staffType()->lineDistance().val() : 1.0; int lines = staff() ? staff()->lines() : 5; int lineOffset = computeLineOffset(); int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); layoutArticulations(); rypos() = (qreal(yo) + qreal(lineOffset + stepOffset) * .5) * lineDist * _spatium; Spatium rs; if (dots()) { rs = Spatium(score()->styleS(StyleIdx::dotNoteDistance) + dots() * score()->styleS(StyleIdx::dotDotDistance)); } if (dots()) { rs = Spatium(score()->styleS(StyleIdx::dotNoteDistance) + dots() * score()->styleS(StyleIdx::dotDotDistance)); } setbbox(symBbox(_sym)); _space.setRw(width() + point(rs)); }
void Rest::layout() { int lines = staff()->lines(); switch(durationType().type()) { case Duration::V_64TH: case Duration::V_32ND: dotline = -3; break; case Duration::V_256TH: case Duration::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); int lineOffset = 0; if (measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case Duration::V_LONG: lineOffset = up ? -3 : 5; break; case Duration::V_BREVE: lineOffset = up ? -3 : 5; break; case Duration::V_MEASURE: case Duration::V_WHOLE: lineOffset = up ? -4 : 6; break; case Duration::V_HALF: lineOffset = up ? -4 : 4; break; case Duration::V_QUARTER: lineOffset = up ? -4 : 4; break; case Duration::V_EIGHT: lineOffset = up ? -4 : 4; break; case Duration::V_16TH: lineOffset = up ? -6 : 4; break; case Duration::V_32ND: lineOffset = up ? -6 : 6; break; case Duration::V_64TH: lineOffset = up ? -8 : 6; break; case Duration::V_128TH: lineOffset = up ? -8 : 8; break; case Duration::V_256TH: // not available lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case Duration::V_LONG: case Duration::V_BREVE: case Duration::V_MEASURE: case Duration::V_WHOLE: if (lines == 1) lineOffset = -2; break; case Duration::V_HALF: case Duration::V_QUARTER: case Duration::V_EIGHT: case Duration::V_16TH: case Duration::V_32ND: case Duration::V_64TH: case Duration::V_128TH: case Duration::V_256TH: // not available if (lines == 1) lineOffset = -4; break; default: break; } } int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); setYoff(qreal(yo) + qreal(lineOffset) * .5); layoutArticulations(); setPos(0.0, yoff() * _spatium); Spatium rs; if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } Segment* s = segment(); if (s && s->measure() && s->measure()->multiMeasure()) { qreal _spatium = spatium(); qreal h = _spatium * 6.5; qreal w = point(score()->styleS(ST_minMMRestWidth)); setbbox(QRectF(-w * .5, -h + 2 * _spatium, w, h)); } else { if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } setbbox(symbols[score()->symIdx()][_sym].bbox(magS())); } _space.setLw(point(_extraLeadingSpace)); _space.setRw(width() + point(_extraTrailingSpace + rs)); // adjustReadPos(); }
void Rest::layout() { _space.setLw(0.0); if (parent() && measure() && measure()->multiMeasure()) { _space.setRw(point(score()->styleS(ST_minMMRestWidth))); return; } rxpos() = 0.0; if (staff() && staff()->isTabStaff()) { StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType(); // if rests are shown and note values are shown as duration symbols if(tab->showRests() &&tab->genDurations()) { // symbol needed; if not exist, create, if exists, update duration if (!_tabDur) _tabDur = new TabDurationSymbol(score(), tab, durationType().type(), dots()); else _tabDur->setDuration(durationType().type(), dots(), tab); _tabDur->setParent(this); // needed? _tabDur->setTrack(track()); _tabDur->layout(); setbbox(_tabDur->bbox()); setPos(0.0, 0.0); // no rest is drawn: reset any position might be set for it _space.setLw(0.0); _space.setRw(width()); return; } // if no rests or no duration symbols, delete any dur. symbol and chain into standard staff mngmt // this is to ensure horiz space is reserved for rest, even if they are not diplayed // Rest::draw() will skip their drawing, if not needed if(_tabDur) { delete _tabDur; _tabDur = 0; } } switch(durationType().type()) { case TDuration::V_64TH: case TDuration::V_32ND: dotline = -3; break; case TDuration::V_256TH: case TDuration::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int stepOffset = 0; if (staff()) stepOffset = staff()->staffType()->stepOffset(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); qreal lineDist = staff() ? staff()->staffType()->lineDistance().val() : 1.0; int lineOffset = 0; int lines = staff() ? staff()->lines() : 5; if (segment() && measure() && measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case TDuration::V_LONG: lineOffset = up ? -3 : 5; break; case TDuration::V_BREVE: lineOffset = up ? -3 : 5; break; case TDuration::V_MEASURE: if (duration() >= Fraction(2, 1)) // breve symbol lineOffset = up ? -3 : 5; // fall through case TDuration::V_WHOLE: lineOffset = up ? -4 : 6; break; case TDuration::V_HALF: lineOffset = up ? -4 : 4; break; case TDuration::V_QUARTER: lineOffset = up ? -4 : 4; break; case TDuration::V_EIGHT: lineOffset = up ? -4 : 4; break; case TDuration::V_16TH: lineOffset = up ? -6 : 4; break; case TDuration::V_32ND: lineOffset = up ? -6 : 6; break; case TDuration::V_64TH: lineOffset = up ? -8 : 6; break; case TDuration::V_128TH: lineOffset = up ? -8 : 8; break; case TDuration::V_256TH: // not available lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case TDuration::V_LONG: case TDuration::V_BREVE: case TDuration::V_MEASURE: case TDuration::V_WHOLE: if (lines == 1) lineOffset = -2; break; case TDuration::V_HALF: case TDuration::V_QUARTER: case TDuration::V_EIGHT: case TDuration::V_16TH: case TDuration::V_32ND: case TDuration::V_64TH: case TDuration::V_128TH: case TDuration::V_256TH: // not available if (lines == 1) lineOffset = -4; break; default: break; } } int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); layoutArticulations(); rypos() = (qreal(yo) + qreal(lineOffset + stepOffset) * .5) * lineDist * _spatium; Spatium rs; if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } setbbox(symbols[score()->symIdx()][_sym].bbox(magS())); _space.setRw(width() + point(rs)); }