LyricsLine::LyricsLine(Score* s) : SLine(s) { setFlags(0); setGenerated(true); // no need to save it, as it can be re-generated setDiagonal(false); setLineWidth(Spatium(LYRICS_DASH_DEFAULT_LINE_THICKNESS)); setAnchor(Spanner::Anchor::SEGMENT); _nextLyrics = nullptr; }
void HairpinSegment::editDrag(const EditData& ed) { if (ed.curGrip == Grip::APERTURE) { qreal newHeight = hairpin()->hairpinHeight().val() + ed.delta.y()/spatium()/.5; if (newHeight < 0.5) newHeight = 0.5; hairpin()->setHairpinHeight(Spatium(newHeight)); triggerLayout(); } LineSegment::editDrag(ed); }
StaffType::StaffType() { _lines = 5; _stepOffset = 0; _lineDistance = Spatium(1); _genClef = true; // create clef at beginning of system _showBarlines = true; _slashStyle = false; // do not show stems _genTimesig = true; // whether time signature is shown or not }
TextStyleData::TextStyleData() { family = "FreeSerif"; size = 10.0; bold = false; italic = false; underline = false; hasFrame = false; sizeIsSpatiumDependent = false; frameWidth = Spatium(0); paddingWidth = Spatium(0); frameWidthMM = 0.0; paddingWidthMM = 0.0; frameRound = 25; frameColor = MScore::defaultColor; circle = false; systemFlag = false; foregroundColor = Qt::black; backgroundColor = QColor(255, 255, 255, 0); }
qreal Bracket::width() const { qreal w; if (bracketType() == BRACKET_BRACE) w = point(score()->styleS(ST_akkoladeWidth) + score()->styleS(ST_akkoladeBarDistance)); else if (bracketType() == BRACKET_NORMAL) w = point(score()->styleS(ST_bracketWidth) + score()->styleS(ST_bracketDistance)); else if (bracketType() == BRACKET_SQUARE) w = point(score()->styleS(ST_staffLineWidth) + Spatium(0.5)); return w; }
void EditStaffType::setPercFromDlg(StaffTypePercussion * st) { st->setName(name->text()); st->setLines(lines->value()); st->setLineDistance(Spatium(lineDistance->value())); st->setGenClef(genClef->isChecked()); st->setShowBarlines(showBarlines->isChecked()); st->setGenTimesig(genTimesig->isChecked()); st->setGenKeysig(genKeysigPercussion->isChecked()); st->setShowLedgerLines(showLedgerLinesPercussion->isChecked()); st->setSlashStyle(stemlessPercussion->isChecked()); }
Glissando::Glissando(Score* s) : SLine(s) { setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE); _glissandoType = Type::STRAIGHT; _text = "gliss."; _showText = true; setDiagonal(true); setLineWidth(Spatium(GLISS_DEFAULT_LINE_TICKNESS)); setAnchor(Spanner::Anchor::NOTE); }
TextStyle TextProp::textStyle() const { if (curUnit == 0) ts.setOffsetType(OffsetType::ABS); else if (curUnit == 1) ts.setOffsetType(OffsetType::SPATIUM); ts.setBold(fontBold->isChecked()); ts.setItalic(fontItalic->isChecked()); ts.setUnderline(fontUnderline->isChecked()); ts.setSize(fontSize->value()); QFont f = fontSelect->currentFont(); ts.setFamily(f.family()); ts.setXoff(xOffset->value() / ((ts.offsetType() == OffsetType::ABS) ? INCH : 1.0)); ts.setYoff(yOffset->value() / ((ts.offsetType() == OffsetType::ABS) ? INCH : 1.0)); ts.setFrameColor(frameColor->color()); ts.setForegroundColor(color->color()); ts.setBackgroundColor(bgColor->color()); ts.setFrameWidth(Spatium(frameWidth->value())); ts.setPaddingWidth(Spatium(paddingWidth->value())); ts.setCircle(circleButton->isChecked()); ts.setFrameRound(frameRound->value()); ts.setHasFrame(frame->isChecked()); ts.setSystemFlag(systemFlag->isChecked()); ts.setSizeIsSpatiumDependent(sizeIsSpatiumDependent->isChecked()); Align a = 0; if (alignHCenter->isChecked()) a |= AlignmentFlags::HCENTER; else if (alignRight->isChecked()) a |= AlignmentFlags::RIGHT; if (alignVCenter->isChecked()) a |= AlignmentFlags::VCENTER; else if (alignBottom->isChecked()) a |= AlignmentFlags::BOTTOM; else if (alignBaseline->isChecked()) a |= AlignmentFlags::BASELINE; ts.setAlign(a); return ts; }
Ottava::Ottava(Score* s) : TextLineBase(s, ElementFlag::ON_STAFF | ElementFlag::MOVABLE) { _ottavaType = OttavaType::OTTAVA_8VA; setBeginTextPlace(PlaceText::LEFT); setContinueTextPlace(PlaceText::LEFT); setEndHookType(HookType::HOOK_90); setLineVisible(true); setBeginHookHeight(Spatium(.0)); setEndText(""); initElementStyle(&ottavaStyle); }
qreal Bracket::width() const { qreal w = 0; if (bracketType() == BracketType::BRACE) w = point(score()->styleS(StyleIdx::akkoladeWidth) + score()->styleS(StyleIdx::akkoladeBarDistance)); else if (bracketType() == BracketType::NORMAL) w = point(score()->styleS(StyleIdx::bracketWidth) + score()->styleS(StyleIdx::bracketDistance)); else if (bracketType() == BracketType::SQUARE) w = point(score()->styleS(StyleIdx::staffLineWidth) + Spatium(0.5)); else if (bracketType() == BracketType::LINE) w = point(0.67f * score()->styleS(StyleIdx::bracketWidth) + score()->styleS(StyleIdx::bracketDistance)); return w; }
TextLine::TextLine(Score* s) : TextLineBase(s) { initElementStyle(&textLineStyle); setPlacement(Placement::ABOVE); setBeginText(""); setContinueText(""); setEndText(""); setBeginTextOffset(QPointF(0,0)); setContinueTextOffset(QPointF(0,0)); setEndTextOffset(QPointF(0,0)); setLineVisible(true); setBeginHookType(HookType::NONE); setEndHookType(HookType::NONE); setBeginHookHeight(Spatium(1.5)); setEndHookHeight(Spatium(1.5)); resetProperty(Pid::BEGIN_TEXT_PLACE); resetProperty(Pid::CONTINUE_TEXT_PLACE); resetProperty(Pid::END_TEXT_PLACE); }
bool Hairpin::setProperty(P_ID id, const QVariant& v) { switch (id) { case P_ID::HAIRPIN_TEXTLINE: _useTextLine = v.toBool(); break; case P_ID::HAIRPIN_CIRCLEDTIP: _hairpinCircledTip = v.toBool(); break; case P_ID::HAIRPIN_TYPE: _hairpinType = Type(v.toInt()); setGenerated(false); break; case P_ID::VELO_CHANGE: _veloChange = v.toInt(); break; case P_ID::DYNAMIC_RANGE: _dynRange = Dynamic::Range(v.toInt()); break; case P_ID::LINE_WIDTH: lineWidthStyle = PropertyStyle::UNSTYLED; TextLine::setProperty(id, v); break; case P_ID::HAIRPIN_HEIGHT: hairpinHeightStyle = PropertyStyle::UNSTYLED; _hairpinHeight = Spatium(v.toDouble()); break; case P_ID::HAIRPIN_CONT_HEIGHT: hairpinContHeightStyle = PropertyStyle::UNSTYLED; _hairpinContHeight = Spatium(v.toDouble()); break; default: return TextLine::setProperty(id, v); } score()->setLayoutAll(true); return true; }
void Hairpin::read(XmlReader& e) { foreach(SpannerSegment* seg, spannerSegments()) delete seg; spannerSegments().clear(); int id = e.intAttribute("id", -1); e.addSpanner(id, this); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") _hairpinType = Type(e.readInt()); else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinHeight") { setHairpinHeight(Spatium(e.readDouble())); hairpinHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinContHeight") { setHairpinContHeight(Spatium(e.readDouble())); hairpinContHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinCircledTip") _hairpinCircledTip = e.readInt(); else if (tag == "veloChange") _veloChange = e.readInt(); else if (tag == "dynType") _dynRange = Dynamic::Range(e.readInt()); else if (tag == "useTextLine") _useTextLine = e.readInt(); else if (!TextLine::readProperties(e)) e.unknown(); } }
QVariant TextLineBase::propertyDefault(P_ID id) const { switch (id) { case P_ID::CONTINUE_TEXT: case P_ID::BEGIN_TEXT: case P_ID::END_TEXT: return QString(""); case P_ID::BEGIN_TEXT_PLACE: case P_ID::CONTINUE_TEXT_PLACE: case P_ID::END_TEXT_PLACE: return int(PlaceText::LEFT); case P_ID::BEGIN_HOOK_TYPE: case P_ID::END_HOOK_TYPE: return int(HookType::NONE); case P_ID::BEGIN_HOOK_HEIGHT: case P_ID::END_HOOK_HEIGHT: return Spatium(1.5); case P_ID::BEGIN_FONT_FACE: case P_ID::CONTINUE_FONT_FACE: case P_ID::END_FONT_FACE: return QString("FreeSerif"); case P_ID::BEGIN_FONT_SIZE: case P_ID::CONTINUE_FONT_SIZE: case P_ID::END_FONT_SIZE: return 10.0; case P_ID::BEGIN_FONT_BOLD: case P_ID::BEGIN_FONT_ITALIC: case P_ID::BEGIN_FONT_UNDERLINE: case P_ID::CONTINUE_FONT_BOLD: case P_ID::CONTINUE_FONT_ITALIC: case P_ID::CONTINUE_FONT_UNDERLINE: case P_ID::END_FONT_BOLD: case P_ID::END_FONT_ITALIC: case P_ID::END_FONT_UNDERLINE: return false; case P_ID::BEGIN_TEXT_OFFSET: case P_ID::CONTINUE_TEXT_OFFSET: case P_ID::END_TEXT_OFFSET: return QPointF(); case P_ID::BEGIN_TEXT_ALIGN: case P_ID::CONTINUE_TEXT_ALIGN: case P_ID::END_TEXT_ALIGN: return int(Align::LEFT); case P_ID::LINE_VISIBLE: return true; default: return SLine::propertyDefault(id); } }
TextLine::TextLine(Score* s) : SLine(s) { _beginText = 0; _continueText = 0; _beginHookHeight = Spatium(1.5); _endHookHeight = Spatium(1.5); _beginHook = false; _endHook = false; _beginHookType = HOOK_90; _endHookType = HOOK_90; _lineWidth = Spatium(0.15); _lineStyle = Qt::SolidLine; _beginTextPlace = PLACE_LEFT; _continueTextPlace = PLACE_LEFT; _lineColor = Qt::black; _beginSymbol = noSym; _continueSymbol = noSym; _endSymbol = noSym; _sp = 0; }
void Box::editDrag(const EditData& ed) { if (type() == Element::Type::VBOX) { _boxHeight = Spatium((ed.pos.y() - abbox().y()) / spatium()); if (ed.vRaster) { qreal vRaster = 1.0 / MScore::vRaster(); int n = lrint(_boxHeight.val() / vRaster); _boxHeight = Spatium(vRaster * n); } bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight())); system()->setHeight(height()); score()->doLayoutPages(); } else { _boxWidth += Spatium(ed.delta.x() / spatium()); if (ed.hRaster) { qreal hRaster = 1.0 / MScore::hRaster(); int n = lrint(_boxWidth.val() / hRaster); _boxWidth = Spatium(hRaster * n); } score()->setLayoutAll(true); } layout(); }
void EditStaffType::setFromDlg() { staffType.setName(name->text()); staffType.setLines(lines->value()); staffType.setLineDistance(Spatium(lineDistance->value())); staffType.setGenClef(genClef->isChecked()); staffType.setShowBarlines(showBarlines->isChecked()); staffType.setGenTimesig(genTimesig->isChecked()); if (staffType.group() == StaffGroup::STANDARD) { staffType.setGenKeysig(genKeysigPitched->isChecked()); staffType.setShowLedgerLines(showLedgerLinesPitched->isChecked()); staffType.setSlashStyle(stemlessPitched->isChecked()); } if (staffType.group() == StaffGroup::PERCUSSION) { staffType.setGenKeysig(genKeysigPercussion->isChecked()); staffType.setShowLedgerLines(showLedgerLinesPercussion->isChecked()); staffType.setSlashStyle(stemlessPercussion->isChecked()); } staffType.setDurationFontName(durFontName->currentText()); staffType.setDurationFontSize(durFontSize->value()); staffType.setDurationFontUserY(durY->value()); staffType.setFretFontName(fretFontName->currentText()); staffType.setFretFontSize(fretFontSize->value()); staffType.setFretFontUserY(fretY->value()); staffType.setLinesThrough(linesThroughRadio->isChecked()); staffType.setMinimStyle(minimNoneRadio->isChecked() ? TablatureMinimStyle::NONE : (minimShortRadio->isChecked() ? TablatureMinimStyle::SHORTER : TablatureMinimStyle::SLASHED)); staffType.setOnLines(onLinesRadio->isChecked()); staffType.setShowRests(showRests->isChecked()); staffType.setUpsideDown(upsideDown->isChecked()); staffType.setUseNumbers(numbersRadio->isChecked()); //note values staffType.setStemsDown(stemBelowRadio->isChecked()); staffType.setStemsThrough(stemThroughRadio->isChecked()); if (staffType.group() == StaffGroup::TAB) { staffType.setSlashStyle(true); // assume no note values staffType.setGenDurations(false); // " " if (noteValuesSymb->isChecked()) staffType.setGenDurations(true); if (noteValuesStems->isChecked()) staffType.setSlashStyle(false); } }
bool StaffType::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); int v = e.text().toInt(); if (tag == "name") setName(e.text()); else if (tag == "lines") setLines(v); else if (tag == "lineDistance") setLineDistance(Spatium(e.text().toDouble())); else if (tag == "clef") setGenClef(v); else if (tag == "slashStyle") setSlashStyle(v); else if (tag == "barlines") setShowBarlines(v); else return false; return true; }
bool StaffType::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "name") setName(e.readElementText()); else if (tag == "lines") setLines(e.readInt()); else if (tag == "lineDistance") setLineDistance(Spatium(e.readDouble())); else if (tag == "clef") setGenClef(e.readInt()); else if (tag == "slashStyle") setSlashStyle(e.readInt()); else if (tag == "barlines") setShowBarlines(e.readInt()); else if (tag == "timesig") setGenTimesig(e.readInt()); else return false; return true; }
void TremoloBar::read(XmlReader& e) { while (e.readNextStartElement()) { auto tag = e.name(); if (tag == "point") { PitchValue pv; pv.time = e.intAttribute("time"); pv.pitch = e.intAttribute("pitch"); pv.vibrato = e.intAttribute("vibrato"); _points.append(pv); e.readNext(); } else if (tag == "mag") _userMag = e.readDouble(0.1, 10.0); else if (tag == "lineWidth") setLineWidth(Spatium(e.readDouble())); else if (tag == "play") setPlay(e.readInt()); else e.unknown(); } }
QVariant Pedal::propertyDefault(P_ID propertyId) const { switch (propertyId) { case P_ID::LINE_WIDTH: return score()->styleV(StyleIdx::pedalLineWidth); case P_ID::ALIGN: return QVariant::fromValue(Align::LEFT | Align::BASELINE); case P_ID::LINE_STYLE: return int(score()->styleI(StyleIdx::pedalLineStyle)); case P_ID::BEGIN_TEXT_OFFSET: return score()->styleV(StyleIdx::pedalBeginTextOffset).toPointF(); case P_ID::BEGIN_HOOK_HEIGHT: case P_ID::END_HOOK_HEIGHT: return Spatium(-1.2); default: return TextLineBase::propertyDefault(propertyId); } }
void Pedal::read(XmlReader& e) { if (score()->mscVersion() >= 110) { // setBeginSymbol(SymId::noSym); setEndHook(false); } int id = e.intAttribute("id", -1); e.addSpanner(id, this); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "lineStyle") { setLineStyle(Qt::PenStyle(e.readInt())); lineStyleStyle = PropertyStyle::UNSTYLED; } else if (!TextLine::readProperties(e)) e.unknown(); } }
void VBox::setGrip(int, const QPointF& pt) { setBoxHeight(Spatium(pt.y())); layout(); }
bool Text::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "style") { int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text ; // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(val); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(val); else if (tag == "html-data") { QString s = Xml::htmlToString(e.firstChildElement()); if (score()->mscVersion() <= 114) { s.replace("MScore1", "FreeSerifMscore"); s.replace(QChar(0xe10e), QChar(0x266e)); //natural s.replace(QChar(0xe10c), QChar(0x266f)); // sharp s.replace(QChar(0xe10d), QChar(0x266d)); // flat s.replace(QChar(0xe104), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5e))), // note2_Sym s.replace(QChar(0xe105), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5f))); // note4_Sym //test s.replace(QChar(0xe105), QString("XXX")); s.replace(QChar(0xe106), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd60))); // note8_Sym s.replace(QChar(0xe107), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd61))); // note16_Sym s.replace(QChar(0xe108), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd62))); // note32_Sym s.replace(QChar(0xe109), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd63))); // note64_Sym s.replace(QChar(0xe10a), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dot s.replace(QChar(0xe10b), QString("%1%2%3%4").arg(QChar(0xd834)).arg(QChar(0xdd6d)).arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dotdot s.replace(QChar(0xe167), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0b))); // coda s.replace(QChar(0xe168), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // varcoda s.replace(QChar(0xe169), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // segno if (_doc == 0) createDoc(); _doc->setHtml(s); if (isSimpleText()) { QString s = _doc->toPlainText(); delete _doc; _doc = 0; setText(s); } else { setUnstyled(); setHtml(s); } } else { setHtml(s); } } else if (tag == "subtype") // obsolete ; else if (tag == "frameWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setFrameWidth(Spatium(val.toDouble() / spMM)); } else if (tag == "paddingWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setPaddingWidth(Spatium(val.toDouble() / spMM)); } else if (_textStyle.readProperties(e)) ; else if (!Element::readProperties(e)) return false; return true; }
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)); }
void EditStyle::getValues() { lstyle.set(ST_staffUpperBorder, Spatium(staffUpperBorder->value())); lstyle.set(ST_staffLowerBorder, Spatium(staffLowerBorder->value())); lstyle.set(ST_staffDistance, Spatium(staffDistance->value())); lstyle.set(ST_akkoladeDistance, Spatium(akkoladeDistance->value())); lstyle.set(ST_minSystemDistance, Spatium(minSystemDistance->value())); lstyle.set(ST_maxSystemDistance, Spatium(maxSystemDistance->value())); lstyle.set(ST_lyricsDistance, Spatium(lyricsDistance->value())); lstyle.set(ST_lyricsMinBottomDistance, Spatium(lyricsMinBottomDistance->value())); lstyle.set(ST_lyricsLineHeight, Spatium(lyricsLineHeight->value() * .01)); lstyle.set(ST_systemFrameDistance, Spatium(systemFrameDistance->value())); lstyle.set(ST_frameSystemDistance, Spatium(frameSystemDistance->value())); lstyle.set(ST_minMeasureWidth, Spatium(minMeasureWidth_2->value())); lstyle.set(ST_barWidth, Spatium(barWidth->value())); lstyle.set(ST_endBarWidth, Spatium(endBarWidth->value())); lstyle.set(ST_endBarDistance, Spatium(endBarDistance->value())); lstyle.set(ST_doubleBarWidth, Spatium(doubleBarWidth->value())); lstyle.set(ST_doubleBarDistance, Spatium(doubleBarDistance->value())); lstyle.set(ST_repeatBarTips, showRepeatBarTips->isChecked()); lstyle.set(ST_startBarlineSingle, showStartBarlineSingle->isChecked()); lstyle.set(ST_startBarlineMultiple, showStartBarlineMultiple->isChecked()); lstyle.set(ST_measureSpacing, measureSpacing->value()); lstyle.set(ST_minNoteDistance, Spatium(minNoteDistance->value())); lstyle.set(ST_barNoteDistance, Spatium(barNoteDistance->value())); lstyle.set(ST_barAccidentalDistance, Spatium(barAccidentalDistance->value())); lstyle.set(ST_multiMeasureRestMargin, Spatium(multiMeasureRestMargin->value())); lstyle.set(ST_noteBarDistance, Spatium(noteBarDistance->value())); lstyle.set(ST_showMeasureNumber, showMeasureNumber->isChecked()); lstyle.set(ST_showMeasureNumberOne, showFirstMeasureNumber->isChecked()); lstyle.set(ST_measureNumberInterval, intervalMeasureNumber->value()); lstyle.set(ST_measureNumberSystem, showEverySystemMeasureNumber->isChecked()); lstyle.set(ST_measureNumberAllStaffs, showAllStaffsMeasureNumber->isChecked()); lstyle.set(ST_clefLeftMargin, Spatium(clefLeftMargin->value())); lstyle.set(ST_keysigLeftMargin, Spatium(keysigLeftMargin->value())); lstyle.set(ST_timesigLeftMargin, Spatium(timesigLeftMargin->value())); lstyle.set(ST_clefKeyRightMargin, Spatium(clefKeyRightMargin->value())); lstyle.set(ST_clefBarlineDistance, Spatium(clefBarlineDistance->value())); lstyle.set(ST_staffLineWidth, Spatium(staffLineWidth->value())); lstyle.set(ST_beamWidth, Spatium(beamWidth->value())); lstyle.set(ST_beamDistance, beamDistance->value()); lstyle.set(ST_beamMinLen, Spatium(beamMinLen->value())); lstyle.set(ST_beamNoSlope, beamNoSlope->isChecked()); lstyle.set(ST_graceNoteMag, graceNoteSize->value() * 0.01); lstyle.set(ST_smallStaffMag, smallStaffSize->value() * 0.01); lstyle.set(ST_smallNoteMag, smallNoteSize->value() * 0.01); lstyle.set(ST_smallClefMag, smallClefSize->value() * 0.01); lstyle.set(ST_lastSystemFillLimit, lastSystemFillThreshold->value() * 0.01); lstyle.set(ST_hairpinY, Spatium(hairpinY->value())); lstyle.set(ST_hairpinLineWidth, Spatium(hairpinLineWidth->value())); lstyle.set(ST_hairpinHeight, Spatium(hairpinHeight->value())); lstyle.set(ST_hairpinContHeight, Spatium(hairpinContinueHeight->value())); lstyle.set(ST_genClef, genClef->isChecked()); lstyle.set(ST_genKeysig, genKeysig->isChecked()); lstyle.set(ST_genTimesig, genTimesig->isChecked()); lstyle.set(ST_genCourtesyTimesig, genCourtesyTimesig->isChecked()); lstyle.set(ST_genCourtesyKeysig, genCourtesyKeysig->isChecked()); lstyle.set(ST_genCourtesyClef, genCourtesyClef->isChecked()); bool customChords = false; if (chordsStandard->isChecked()) lstyle.set(ST_chordStyle, QString("std")); else if (chordsJazz->isChecked()) lstyle.set(ST_chordStyle, QString("jazz")); else { lstyle.set(ST_chordStyle, QString("custom")); customChords = true; } lstyle.set(ST_chordsXmlFile, chordsXmlFile->isChecked()); if (lstyle.value(ST_chordDescriptionFile).toString() != chordDescriptionFile->text()) { ChordList* cl = new ChordList(); if (lstyle.value(ST_chordsXmlFile).toBool()) cl->read("chords.xml"); cl->read(chordDescriptionFile->text()); lstyle.setChordList(cl, customChords); lstyle.set(ST_chordDescriptionFile, chordDescriptionFile->text()); } lstyle.set(ST_useStandardNoteNames, useStandardNoteNames->isChecked()); lstyle.set(ST_useGermanNoteNames, useGermanNoteNames->isChecked()); lstyle.set(ST_useSolfeggioNoteNames, useSolfeggioNoteNames->isChecked()); lstyle.set(ST_lowerCaseMinorChords, lowerCaseMinorChords->isChecked()); lstyle.set(ST_concertPitch, concertPitch->isChecked()); lstyle.set(ST_createMultiMeasureRests, multiMeasureRests->isChecked()); lstyle.set(ST_minEmptyMeasures, minEmptyMeasures->value()); lstyle.set(ST_minMMRestWidth, Spatium(minMeasureWidth->value())); lstyle.set(ST_hideEmptyStaves, hideEmptyStaves->isChecked()); lstyle.set(ST_dontHideStavesInFirstSystem, dontHideStavesInFirstSystem->isChecked()); lstyle.set(ST_accidentalNoteDistance, Spatium(accidentalNoteDistance->value())); lstyle.set(ST_accidentalDistance, Spatium(accidentalDistance->value())); lstyle.set(ST_dotMag, dotMag->value() * 0.01); lstyle.set(ST_dotNoteDistance, Spatium(noteDotDistance->value())); lstyle.set(ST_dotDotDistance, Spatium(dotDotDistance->value())); lstyle.set(ST_stemWidth, Spatium(stemWidth->value())); lstyle.set(ST_ledgerLineWidth, Spatium(ledgerLineWidth->value())); lstyle.set(ST_ledgerLineLength, Spatium(ledgerLineLength->value())); lstyle.set(ST_bracketWidth, Spatium(bracketWidth->value())); lstyle.set(ST_bracketDistance, Spatium(bracketDistance->value())); lstyle.set(ST_akkoladeWidth, Spatium(akkoladeWidth->value())); lstyle.set(ST_akkoladeBarDistance, Spatium(akkoladeBarDistance->value())); lstyle.set(ST_propertyDistanceHead, Spatium(propertyDistanceHead->value())); lstyle.set(ST_propertyDistanceStem, Spatium(propertyDistanceStem->value())); lstyle.set(ST_propertyDistance, Spatium(propertyDistance->value())); lstyle.set(ST_articulationMag, articulationMag->value() * 0.01); lstyle.set(ST_shortenStem, shortenStem->isChecked()); lstyle.set(ST_shortStemProgression, Spatium(shortStemProgression->value())); lstyle.set(ST_shortestStem, Spatium(shortestStem->value())); lstyle.set(ST_ArpeggioNoteDistance, Spatium(arpeggioNoteDistance->value())); lstyle.set(ST_ArpeggioLineWidth, Spatium(arpeggioLineWidth->value())); lstyle.set(ST_ArpeggioHookLen, Spatium(arpeggioHookLen->value())); lstyle.set(ST_FixMeasureNumbers, fixNumberMeasures->value()); lstyle.set(ST_FixMeasureWidth, fixMeasureWidth->isChecked()); lstyle.set(ST_SlurEndWidth, Spatium(slurEndLineWidth->value())); lstyle.set(ST_SlurMidWidth, Spatium(slurMidLineWidth->value())); lstyle.set(ST_SlurDottedWidth, Spatium(slurDottedLineWidth->value())); lstyle.set(ST_MusicalSymbolFont, musicalSymbolFont->currentText()); lstyle.set(ST_showHeader, showHeader->isChecked()); lstyle.set(ST_headerStyled, headerStyled->isChecked()); lstyle.set(ST_headerFirstPage, showHeaderFirstPage->isChecked()); lstyle.set(ST_headerOddEven, headerOddEven->isChecked()); if (headerStyled->isChecked()) { lstyle.set(ST_evenHeaderL, evenHeaderL->toPlainText()); lstyle.set(ST_evenHeaderC, evenHeaderC->toPlainText()); lstyle.set(ST_evenHeaderR, evenHeaderR->toPlainText()); lstyle.set(ST_oddHeaderL, oddHeaderL->toPlainText()); lstyle.set(ST_oddHeaderC, oddHeaderC->toPlainText()); lstyle.set(ST_oddHeaderR, oddHeaderR->toPlainText()); } else { lstyle.set(ST_evenHeaderL, evenHeaderL->toHtml()); lstyle.set(ST_evenHeaderC, evenHeaderC->toHtml()); lstyle.set(ST_evenHeaderR, evenHeaderR->toHtml()); lstyle.set(ST_oddHeaderL, oddHeaderL->toHtml()); lstyle.set(ST_oddHeaderC, oddHeaderC->toHtml()); lstyle.set(ST_oddHeaderR, oddHeaderR->toHtml()); } lstyle.set(ST_showFooter, showFooter->isChecked()); lstyle.set(ST_footerStyled, footerStyled->isChecked()); lstyle.set(ST_footerFirstPage, showFooterFirstPage->isChecked()); lstyle.set(ST_footerOddEven, footerOddEven->isChecked()); if (footerStyled->isChecked()) { lstyle.set(ST_evenFooterL, evenFooterL->toPlainText()); lstyle.set(ST_evenFooterC, evenFooterC->toPlainText()); lstyle.set(ST_evenFooterR, evenFooterR->toPlainText()); lstyle.set(ST_oddFooterL, oddFooterL->toPlainText()); lstyle.set(ST_oddFooterC, oddFooterC->toPlainText()); lstyle.set(ST_oddFooterR, oddFooterR->toPlainText()); } else { lstyle.set(ST_evenFooterL, evenFooterL->toHtml()); lstyle.set(ST_evenFooterC, evenFooterC->toHtml()); lstyle.set(ST_evenFooterR, evenFooterR->toHtml()); lstyle.set(ST_oddFooterL, oddFooterL->toHtml()); lstyle.set(ST_oddFooterC, oddFooterC->toHtml()); lstyle.set(ST_oddFooterR, oddFooterR->toHtml()); } // figured bass int idx = comboFBFont->currentIndex(); QString family; if(FiguredBass::fontData(idx, &family, 0, 0, 0)) lstyle.set(ST_figuredBassFontFamily, family); qreal size = doubleSpinFBSize->value(); qreal vPos = doubleSpinFBVertPos->value(); lstyle.set(ST_figuredBassFontSize, size); lstyle.set(ST_figuredBassYOffset, vPos); lstyle.set(ST_figuredBassLineHeight, ((double)spinFBLineHeight->value()) / 100.0); lstyle.set(ST_figuredBassAlignment, radioFBTop->isChecked() ? 0 : 1); lstyle.set(ST_figuredBassStyle, radioFBModern->isChecked() ? 0 : 1); // copy to text style data relevant to it (LineHeight and Style are not in text style); // offsetType is necessarily OFFSET_SPATIUM const TextStyle fbOld = lstyle.textStyle(TEXT_STYLE_FIGURED_BASS); if (family != fbOld.family() || size != fbOld.size() || vPos != fbOld.offset().y() || fbOld.offsetType() != OFFSET_SPATIUM) { TextStyle fbNew(fbOld); fbNew.setFamily(family); fbNew.setSize(size); fbNew.setYoff(vPos); fbNew.setOffsetType(OFFSET_SPATIUM); lstyle.setTextStyle(fbNew); } for (int i = 0; i < ARTICULATIONS; ++i) { QComboBox* cb = static_cast<QComboBox*>(articulationTable->cellWidget(i, 1)); lstyle.setArticulationAnchor(i, ArticulationAnchor(cb->itemData(cb->currentIndex()).toInt())); } lstyle.set(ST_voltaY, Spatium(voltaY->value())); lstyle.set(ST_voltaHook, Spatium(voltaHook->value())); lstyle.set(ST_voltaLineWidth, Spatium(voltaLineWidth->value())); lstyle.set(ST_voltaLineStyle, voltaLineStyle->currentIndex() + 1); lstyle.set(ST_ottavaY, Spatium(ottavaY->value())); lstyle.set(ST_ottavaHook, Spatium(ottavaHook->value())); lstyle.set(ST_ottavaLineWidth, Spatium(ottavaLineWidth->value())); lstyle.set(ST_ottavaLineStyle, ottavaLineStyle->currentIndex() + 1); lstyle.set(ST_ottavaNumbersOnly, ottavaNumbersOnly->isChecked()); lstyle.set(ST_pedalY, Spatium(pedalY->value())); lstyle.set(ST_pedalLineWidth, Spatium(pedalLineWidth->value())); lstyle.set(ST_pedalLineStyle, pedalLineStyle->currentIndex() + 1); lstyle.set(ST_trillY, Spatium(trillY->value())); lstyle.set(ST_harmonyY, Spatium(harmonyY->value())); lstyle.set(ST_harmonyFretDist, Spatium(harmonyFretDist->value())); lstyle.set(ST_minHarmonyDistance, Spatium(minHarmonyDistance->value())); lstyle.set(ST_tabClef, clefTab1->isChecked() ? CLEF_TAB : CLEF_TAB2); lstyle.set(ST_crossMeasureValues, crossMeasureValues->isChecked()); lstyle.set(ST_keySigNaturals, radioKeySigNatNone->isChecked() ? NAT_NONE : (radioKeySigNatBefore->isChecked() ? NAT_BEFORE : NAT_AFTER) ); }
bool TextLine::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "beginHookHeight") { _beginHookHeight = Spatium(e.readDouble()); _beginHook = true; } else if (tag == "beginHookType") _beginHookType = HookType(e.readInt()); else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete _endHookHeight = Spatium(e.readDouble()); _endHook = true; } else if (tag == "endHookType") _endHookType = HookType(e.readInt()); else if (tag == "hookUp") // obsolete _endHookHeight *= qreal(-1.0); else if (tag == "beginSymbol" || tag == "symbol") { // "symbol" is obsolete QString text(e.readElementText()); _beginSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "continueSymbol") { QString text(e.readElementText()); _continueSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "endSymbol") { QString text(e.readElementText()); _endSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "beginSymbolOffset") _beginSymbolOffset = e.readPoint(); else if (tag == "continueSymbolOffset") _continueSymbolOffset = e.readPoint(); else if (tag == "endSymbolOffset") _endSymbolOffset = e.readPoint(); else if (tag == "lineWidth") _lineWidth = Spatium(e.readDouble()); else if (tag == "lineStyle") _lineStyle = Qt::PenStyle(e.readInt()); else if (tag == "beginTextPlace") _beginTextPlace = readPlacement(e); else if (tag == "continueTextPlace") _continueTextPlace = readPlacement(e); else if (tag == "lineColor") _lineColor = e.readColor(); else if (tag == "beginText") { _beginText = new Text(score()); _beginText->setParent(this); _beginText->read(e); } else if (tag == "continueText") { _continueText = new Text(score()); _continueText->setParent(this); _continueText->read(e); } else if (!SLine::readProperties(e)) { qDebug(" ==readSLineProps: failed"); return false; } return true; }
void EditStaff::lineDistanceChanged() { staff->staffType(Fraction(0,1))->setLineDistance(Spatium(lineDistance->value())); }
Score::FileError Score::read114(XmlReader& e) { if (parentScore()) setMscVersion(parentScore()->mscVersion()); for (unsigned int i = 0; i < sizeof(style114)/sizeof(*style114); ++i) style()->set(style114[i].idx, style114[i].val); // old text style defaults TextStyle ts = style()->textStyle("Chord Symbol"); ts.setYoff(-4.0); style()->setTextStyle(ts); TempoMap tm; while (e.readNextStartElement()) { e.setTrack(-1); const QStringRef& tag(e.name()); if (tag == "Staff") readStaff(e); else if (tag == "KeySig") { // not supported KeySig* ks = new KeySig(this); ks->read(e); // customKeysigs.append(ks); delete ks; } else if (tag == "siglist") _sigmap->read(e, _fileDivision); else if (tag == "programVersion") { _mscoreVersion = e.readElementText(); parseVersion(_mscoreVersion); } else if (tag == "programRevision") _mscoreRevision = e.readInt(); else if (tag == "Mag" || tag == "MagIdx" || tag == "xoff" || tag == "Symbols" || tag == "cursorTrack" || tag == "yoff") e.skipCurrentElement(); // obsolete else if (tag == "tempolist") { // store the tempo list to create invisible tempo text later qreal tempo = e.attribute("fix","2.0").toDouble(); tm.setRelTempo(tempo); while (e.readNextStartElement()) { if (e.name() == "tempo") { int tick = e.attribute("tick").toInt(); double tmp = e.readElementText().toDouble(); tick = (tick * MScore::division + _fileDivision/2) / _fileDivision; auto pos = tm.find(tick); if (pos != tm.end()) tm.erase(pos); tm.setTempo(tick, tmp); } else if (e.name() == "relTempo") e.readElementText(); else e.unknown(); } } else if (tag == "playMode") _playMode = PlayMode(e.readInt()); else if (tag == "SyntiSettings") _synthesizerState.read(e); else if (tag == "Spatium") _style.setSpatium (e.readDouble() * MScore::DPMM); else if (tag == "Division") _fileDivision = e.readInt(); else if (tag == "showInvisible") _showInvisible = e.readInt(); else if (tag == "showFrames") _showFrames = e.readInt(); else if (tag == "showMargins") _showPageborders = e.readInt(); else if (tag == "Style") { qreal sp = _style.spatium(); _style.load(e); // adjust this now so chords render properly on read // other style adjustments can wait until reading is finished if (style(StyleIdx::useGermanNoteNames).toBool()) style()->set(StyleIdx::useStandardNoteNames, false); if (_layoutMode == LayoutMode::FLOAT) { // style should not change spatium in // float mode _style.setSpatium(sp); } } else if (tag == "TextStyle") { TextStyle s; s.read(e); qreal spMM = _style.spatium() / MScore::DPMM; if (s.frameWidthMM() != 0.0) s.setFrameWidth(Spatium(s.frameWidthMM() / spMM)); if (s.paddingWidthMM() != 0.0) s.setPaddingWidth(Spatium(s.paddingWidthMM() / spMM)); \ // convert 1.2 text styles s.setName(convertOldTextStyleNames(s.name())); if (s.name() == "Lyrics Odd Lines" || s.name() == "Lyrics Even Lines") s.setAlign((s.align() & ~ Align(AlignmentFlags::VMASK)) | AlignmentFlags::BASELINE); _style.setTextStyle(s); } else if (tag == "page-layout") { if (_layoutMode != LayoutMode::FLOAT && _layoutMode != LayoutMode::SYSTEM) { PageFormat pf; pf.copy(*pageFormat()); pf.read(e, this); setPageFormat(pf); } else e.skipCurrentElement(); } else if (tag == "copyright" || tag == "rights") { Text* text = new Text(this); text->read(e); text->layout(); setMetaTag("copyright", text->plainText()); delete text; } else if (tag == "movement-number") setMetaTag("movementNumber", e.readElementText()); else if (tag == "movement-title") setMetaTag("movementTitle", e.readElementText()); else if (tag == "work-number") setMetaTag("workNumber", e.readElementText()); else if (tag == "work-title") setMetaTag("workTitle", e.readElementText()); else if (tag == "source") setMetaTag("source", e.readElementText()); else if (tag == "metaTag") { QString name = e.attribute("name"); setMetaTag(name, e.readElementText()); } else if (tag == "Part") { Part* part = new Part(this); part->read114(e); _parts.push_back(part); } else if (tag == "Slur") { Slur* slur = new Slur(this); slur->read(e); addSpanner(slur); } else if ((tag == "HairPin") || (tag == "Ottava") || (tag == "TextLine") || (tag == "Volta") || (tag == "Trill") || (tag == "Pedal")) { Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this)); s->read(e); if (s->track() == -1) s->setTrack(e.track()); else e.setTrack(s->track()); // update current track if (s->tick() == -1) s->setTick(e.tick()); else e.initTick(s->tick()); // update current tick if (s->track2() == -1) s->setTrack2(s->track()); if (s->ticks() == 0) { delete s; qDebug("zero spanner %s ticks: %d", s->name(), s->ticks()); } else { addSpanner(s); } } else if (tag == "Excerpt") { if (MScore::noExcerpts) e.skipCurrentElement(); else { Excerpt* ex = new Excerpt(this); ex->read(e); _excerpts.append(ex); } } else if (tag == "Beam") { Beam* beam = new Beam(this); beam->read(e); beam->setParent(0); // _beams.append(beam); } else if (tag == "name") setName(e.readElementText()); else e.unknown(); } if (e.error() != XmlStreamReader::NoError) return FileError::FILE_BAD_FORMAT; int n = nstaves(); for (int idx = 0; idx < n; ++idx) { Staff* s = _staves[idx]; int track = idx * VOICES; // check barLineSpan if (s->barLineSpan() > (n - idx)) { qDebug("read114: invalid bar line span %d (max %d)", s->barLineSpan(), n - idx); s->setBarLineSpan(n - idx); } for (auto i : e.clefs(idx)) { int tick = i.first; ClefType clefId = i.second; Measure* m = tick2measure(tick); if (!m) continue; if ((tick == m->tick()) && m->prevMeasure()) m = m->prevMeasure(); Segment* seg = m->getSegment(Segment::Type::Clef, tick); if (seg->element(track)) static_cast<Clef*>(seg->element(track))->setGenerated(false); else { Clef* clef = new Clef(this); clef->setClefType(clefId); clef->setTrack(track); clef->setParent(seg); clef->setGenerated(false); seg->add(clef); } } // create missing KeySig KeyList* km = s->keyList(); for (auto i = km->begin(); i != km->end(); ++i) { int tick = i->first; if (tick < 0) { qDebug("read114: Key tick %d", tick); continue; } if (tick == 0 && i->second.key() == Key::C) continue; Measure* m = tick2measure(tick); if (!m) //empty score break; Segment* seg = m->getSegment(Segment::Type::KeySig, tick); if (seg->element(track)) static_cast<KeySig*>(seg->element(track))->setGenerated(false); else { KeySigEvent ke = i->second; KeySig* ks = new KeySig(this); ks->setKeySigEvent(ke); ks->setParent(seg); ks->setTrack(track); ks->setGenerated(false); seg->add(ks); } } } for (std::pair<int,Spanner*> p : spanner()) { Spanner* s = p.second; if (s->type() != Element::Type::SLUR) { if (s->type() == Element::Type::VOLTA) { Volta* volta = static_cast<Volta*>(s); volta->setAnchor(Spanner::Anchor::MEASURE); } } if (s->type() == Element::Type::OTTAVA || s->type() == Element::Type::PEDAL || s->type() == Element::Type::TRILL || s->type() == Element::Type::TEXTLINE) { qreal yo = 0; if (s->type() == Element::Type::OTTAVA) { // fix ottava position yo = styleS(StyleIdx::ottavaY).val() * spatium(); if (s->placement() == Element::Placement::BELOW) yo = -yo + s->staff()->height(); } else if (s->type() == Element::Type::PEDAL) { yo = styleS(StyleIdx::pedalY).val() * spatium(); } else if (s->type() == Element::Type::TRILL) { yo = styleS(StyleIdx::trillY).val() * spatium(); } else if (s->type() == Element::Type::TEXTLINE) { yo = -5.0 * spatium(); } if (!s->spannerSegments().isEmpty()) { for (SpannerSegment* seg : s->spannerSegments()) { if (!seg->userOff().isNull()) seg->setUserYoffset(seg->userOff().y() - yo); } } else { s->setUserYoffset(-yo); } } } connectTies(); // // remove "middle beam" flags from first ChordRest in // measure // for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) { int tracks = nstaves() * VOICES; bool first = true; for (int track = 0; track < tracks; ++track) { for (Segment* s = m->first(); s; s = s->next()) { if (s->segmentType() != Segment::Type::ChordRest) continue; ChordRest* cr = static_cast<ChordRest*>(s->element(track)); if (cr) { if(cr->type() == Element::Type::REST) { Rest* r = static_cast<Rest*>(cr); if (!r->userOff().isNull()) { int lineOffset = r->computeLineOffset(); qreal lineDist = r->staff() ? r->staff()->staffType()->lineDistance().val() : 1.0; r->rUserYoffset() -= (lineOffset * .5 * lineDist * r->spatium()); } } if(!first) { switch(cr->beamMode()) { case Beam::Mode::AUTO: case Beam::Mode::BEGIN: case Beam::Mode::END: case Beam::Mode::NONE: break; case Beam::Mode::MID: case Beam::Mode::BEGIN32: case Beam::Mode::BEGIN64: cr->setBeamMode(Beam::Mode::BEGIN); break; case Beam::Mode::INVALID: if (cr->type() == Element::Type::CHORD) cr->setBeamMode(Beam::Mode::AUTO); else cr->setBeamMode(Beam::Mode::NONE); break; } first = false; } } } } } for (MeasureBase* mb = _measures.first(); mb; mb = mb->next()) { if (mb->type() == Element::Type::VBOX) { Box* b = static_cast<Box*>(mb); qreal y = point(styleS(StyleIdx::staffUpperBorder)); b->setBottomGap(y); } } _fileDivision = MScore::division; // // sanity check for barLineSpan and update ottavas // foreach(Staff* staff, _staves) { int barLineSpan = staff->barLineSpan(); int idx = staffIdx(staff); int n = nstaves(); if (idx + barLineSpan > n) { qDebug("bad span: idx %d span %d staves %d", idx, barLineSpan, n); staff->setBarLineSpan(n - idx); } staff->updateOttava(); }
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(); }