void Fermata::layout() { Segment* s = segment(); setPos(QPointF()); if (!s) { // for use in palette setOffset(0.0, 0.0); QRectF b(symBbox(_symId)); setbbox(b.translated(-0.5 * b.width(), 0.0)); return; } if (isStyled(Pid::OFFSET)) setOffset(propertyDefault(Pid::OFFSET).toPointF()); Element* e = s->element(track()); if (e) { if (e->isChord()) rxpos() += score()->noteHeadWidth() * staff()->mag(Fraction(0, 1)) * .5; else rxpos() += e->x() + e->width() * staff()->mag(Fraction(0, 1)) * .5; } QString name = Sym::id2name(_symId); if (placeAbove()) { if (name.endsWith("Below")) _symId = Sym::name2id(name.left(name.size() - 5) + "Above"); } else { rypos() += staff()->height(); if (name.endsWith("Above")) _symId = Sym::name2id(name.left(name.size() - 5) + "Below"); } QRectF b(symBbox(_symId)); setbbox(b.translated(-0.5 * b.width(), 0.0)); autoplaceSegmentElement(styleP(Sid::fermataMinDistance)); }
void VibratoSegment::layout() { if (staff()) setMag(staff()->mag(tick())); if (spanner()->placeBelow()) rypos() = staff() ? staff()->height() : 0.0; if (isSingleType() || isBeginType()) { switch (vibrato()->vibratoType()) { case Vibrato::Type::GUITAR_VIBRATO: symbolLine(SymId::guitarVibratoStroke, SymId::guitarVibratoStroke); break; case Vibrato::Type::GUITAR_VIBRATO_WIDE: symbolLine(SymId::guitarWideVibratoStroke, SymId::guitarWideVibratoStroke); break; case Vibrato::Type::VIBRATO_SAWTOOTH: symbolLine(SymId::wiggleSawtooth, SymId::wiggleSawtooth); break; case Vibrato::Type::VIBRATO_SAWTOOTH_WIDE: symbolLine(SymId::wiggleSawtoothWide, SymId::wiggleSawtoothWide); break; } } else symbolLine(SymId::wiggleVibrato, SymId::wiggleVibrato); if (isStyled(Pid::OFFSET)) roffset() = vibrato()->propertyDefault(Pid::OFFSET).toPointF(); autoplaceSpannerSegment(); }
Sid Ottava::getPropertyStyle(Pid pid) const { Q_ASSERT(int(OttavaType::OTTAVA_22MB) - int(OttavaType::OTTAVA_8VA) == 5); static const Sid ss[24] = { Sid::ottava8VAPlacement, Sid::ottava8VAnoText, Sid::ottava8VBPlacement, Sid::ottava8VBnoText, Sid::ottava15MAPlacement, Sid::ottava15MAnoText, Sid::ottava15MBPlacement, Sid::ottava15MBnoText, Sid::ottava22MAPlacement, Sid::ottava22MAnoText, Sid::ottava22MBPlacement, Sid::ottava22MBnoText, Sid::ottava8VAPlacement, Sid::ottava8VAText, Sid::ottava8VBPlacement, Sid::ottava8VBText, Sid::ottava15MAPlacement, Sid::ottava15MAText, Sid::ottava15MBPlacement, Sid::ottava15MBText, Sid::ottava22MAPlacement, Sid::ottava22MAText, Sid::ottava22MBPlacement, Sid::ottava22MBText, }; switch (pid) { case Pid::OFFSET: return placeAbove() ? Sid::ottavaPosAbove : Sid::ottavaPosBelow; case Pid::PLACEMENT: { int idx = int(_ottavaType) * 2 + (_numbersOnly ? 0 : 12); return ss[idx]; } case Pid::BEGIN_TEXT: case Pid::CONTINUE_TEXT: { int idx = int(_ottavaType) * 2 + (_numbersOnly ? 0 : 12); return ss[idx+1]; // BEGIN_TEXT } case Pid::END_HOOK_HEIGHT: { int idx = int(_ottavaType) * 2 + (_numbersOnly ? 0 : 12); if (isStyled(Pid::PLACEMENT)) return score()->styleI(ss[idx]) == int(Placement::ABOVE) ? Sid::ottavaHookAbove : Sid::ottavaHookBelow; else return placeAbove() ? Sid::ottavaHookAbove : Sid::ottavaHookBelow; } default: return TextLineBase::getPropertyStyle(pid); } }
void LetRing::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(this); for (const StyledProperty& spp : *styledProperties()) { if (!isStyled(spp.pid)) writeProperty(xml, spp.pid); } Element::writeProperties(xml); xml.etag(); }
void Fermata::write(XmlWriter& xml) const { if (!xml.canWrite(this)) { qDebug("%s not written", name()); return; } xml.stag(this); xml.tag("subtype", Sym::id2name(_symId)); writeProperty(xml, Pid::TIME_STRETCH); writeProperty(xml, Pid::PLAY); if (!isStyled(Pid::OFFSET)) writeProperty(xml, Pid::OFFSET); Element::writeProperties(xml); xml.etag(); }
void Ottava::updateStyledProperties() { Q_ASSERT(int(OttavaType::OTTAVA_22MB) - int(OttavaType::OTTAVA_8VA) == 5); static const Sid ss[24] = { Sid::ottava8VAPlacement, Sid::ottava8VAnoText, Sid::ottava8VBPlacement, Sid::ottava8VBnoText, Sid::ottava15MAPlacement, Sid::ottava15MAnoText, Sid::ottava15MBPlacement, Sid::ottava15MBnoText, Sid::ottava22MAPlacement, Sid::ottava22MAnoText, Sid::ottava22MBPlacement, Sid::ottava22MBnoText, Sid::ottava8VAPlacement, Sid::ottava8VAText, Sid::ottava8VBPlacement, Sid::ottava8VBText, Sid::ottava15MAPlacement, Sid::ottava15MAText, Sid::ottava15MBPlacement, Sid::ottava15MBText, Sid::ottava22MAPlacement, Sid::ottava22MAText, Sid::ottava22MBPlacement, Sid::ottava22MBText, }; // switch right substyles depending on _ottavaType and _numbersOnly int idx = int(_ottavaType) * 2 + (_numbersOnly ? 0 : 12); _ottavaStyle[0].sid = ss[idx]; // PLACEMENT _ottavaStyle[2].sid = ss[idx+1]; // BEGIN_TEXT _ottavaStyle[3].sid = ss[idx+1]; // CONTINUE_TEXT if (isStyled(Pid::PLACEMENT)) _ottavaStyle[4].sid = score()->styleI(ss[idx]) == int(Placement::ABOVE) ? Sid::ottavaHookAbove : Sid::ottavaHookBelow; else _ottavaStyle[4].sid = placeAbove() ? Sid::ottavaHookAbove : Sid::ottavaHookBelow; styleChanged(); // this changes all styled properties with flag STYLED MuseScoreCore::mscoreCore->updateInspector(); }
void TrillSegment::layout() { if (staff()) setMag(staff()->mag(tick())); if (spanner()->placeBelow()) rypos() = staff() ? staff()->height() : 0.0; if (isSingleType() || isBeginType()) { Accidental* a = trill()->accidental(); if (a) { a->layout(); a->setMag(a->mag() * .6); qreal _spatium = spatium(); a->setPos(_spatium * 1.3, -2.2 * _spatium); a->setParent(this); } switch (trill()->trillType()) { case Trill::Type::TRILL_LINE: symbolLine(SymId::ornamentTrill, SymId::wiggleTrill); break; case Trill::Type::PRALLPRALL_LINE: symbolLine(SymId::wiggleTrill, SymId::wiggleTrill); break; case Trill::Type::UPPRALL_LINE: symbolLine(SymId::ornamentBottomLeftConcaveStroke, SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); break; case Trill::Type::DOWNPRALL_LINE: symbolLine(SymId::ornamentLeftVerticalStroke, SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); break; } } else symbolLine(SymId::wiggleTrill, SymId::wiggleTrill); if (isStyled(Pid::OFFSET)) roffset() = trill()->propertyDefault(Pid::OFFSET).toPointF(); autoplaceSpannerSegment(); }
void Fingering::layout() { if (parent()) { Fraction tick = parent()->tick(); const Staff* st = staff(); if (st && st->isTabStaff(tick) && !st->staffType(tick)->showTabFingering()) { setbbox(QRectF()); return; } } TextBase::layout(); rypos() = 0.0; // handle placement below if (autoplace() && note()) { Note* n = note(); Chord* chord = n->chord(); bool voices = chord->measure()->hasVoices(chord->staffIdx()); bool tight = voices && chord->notes().size() == 1 && !chord->beam() && tid() != Tid::STRING_NUMBER; qreal headWidth = n->bboxRightPos(); // update offset after drag qreal rebase = 0.0; if (offsetChanged() != OffsetChange::NONE) rebase = rebaseOffset(); // temporarily exclude self from chord shape setAutoplace(false); if (layoutType() == ElementType::CHORD) { Stem* stem = chord->stem(); Segment* s = chord->segment(); Measure* m = s->measure(); qreal sp = spatium(); qreal md = minDistance().val() * sp; SysStaff* ss = m->system()->staff(chord->vStaffIdx()); Staff* vStaff = chord->staff(); // TODO: use current height at tick if (n->mirror()) rxpos() -= n->ipos().x(); rxpos() += headWidth * .5; if (placeAbove()) { if (tight) { if (chord->stem()) rxpos() -= 0.8 * sp; rypos() -= 1.5 * sp; } else { QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos()); SkylineLine sk(false); sk.add(r.x(), r.bottom(), r.width()); qreal d = sk.minDistance(ss->skyline().north()); qreal yd = 0.0; if (d > 0.0 && isStyled(Pid::MIN_DISTANCE)) yd -= d + height() * .25; // force extra space above staff & chord (but not other fingerings) qreal top; if (chord->up() && chord->beam() && stem) { top = stem->y() + stem->bbox().top(); } else { Note* un = chord->upNote(); top = qMin(0.0, un->y() + un->bbox().top()); } top -= md; qreal diff = (bbox().bottom() + ipos().y() + yd + n->y()) - top; if (diff > 0.0) yd -= diff; if (offsetChanged() != OffsetChange::NONE) { // user moved element within the skyline // we may need to adjust minDistance, yd, and/or offset bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height(); rebaseMinDistance(md, yd, sp, rebase, inStaff); } rypos() += yd; } } else { if (tight) { if (chord->stem()) rxpos() += 0.8 * sp; rypos() += 1.5 * sp; } else { QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos()); SkylineLine sk(true); sk.add(r.x(), r.top(), r.width()); qreal d = ss->skyline().south().minDistance(sk); qreal yd = 0.0; if (d > 0.0 && isStyled(Pid::MIN_DISTANCE)) yd += d + height() * .25; // force extra space below staff & chord (but not other fingerings) qreal bottom; if (!chord->up() && chord->beam() && stem) { bottom = stem->y() + stem->bbox().bottom(); } else { Note* dn = chord->downNote(); bottom = qMax(vStaff->height(), dn->y() + dn->bbox().bottom()); } bottom += md; qreal diff = bottom - (bbox().top() + ipos().y() + yd + n->y()); if (diff > 0.0) yd += diff; if (offsetChanged() != OffsetChange::NONE) { // user moved element within the skyline // we may need to adjust minDistance, yd, and/or offset bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height(); rebaseMinDistance(md, yd, sp, rebase, inStaff); } rypos() += yd; } } } else if (tid() == Tid::LH_GUITAR_FINGERING) { // place to left of note qreal left = n->shape().left(); if (left - n->x() > 0.0) rxpos() -= left; else rxpos() -= n->x(); } // for other fingering styles, do not autoplace // restore autoplace setAutoplace(true); } else if (offsetChanged() != OffsetChange::NONE) { // rebase horizontally too, as autoplace may have adjusted it rebaseOffset(false); } setOffsetChanged(false); }