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 ChordRest::layoutArticulations() { if (parent() == 0 || _articulations.isEmpty()) return; qreal _spatium = spatium(); qreal _spStaff = _spatium * staff()->lineDistance(); // scaled to staff line distance for vert. pos. within a staff if (type() == Element::Type::CHORD) { if (_articulations.size() == 1) { static_cast<Chord*>(this)->layoutArticulation(_articulations[0]); return; } if (_articulations.size() == 2) { // // staccato | tenuto + marcato // Articulation* a1 = _articulations[0]; Articulation* a2 = _articulations[1]; ArticulationType st1 = a1->articulationType(); ArticulationType st2 = a2->articulationType(); if ((st2 == ArticulationType::Tenuto || st2 == ArticulationType::Staccato) && (st1 == ArticulationType::Marcato)) { qSwap(a1, a2); qSwap(st1, st2); } if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato) && (st2 == ArticulationType::Marcato)) { QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1); pt.ry() += a1->up() ? -_spStaff * .5 : _spStaff * .5; a2->layout(); a2->setUp(a1->up()); a2->setPos(pt); a2->adjustReadPos(); return; } // // staccato | tenuto + sforzato // if ((st2 == ArticulationType::Tenuto || st2 == ArticulationType::Staccato) && (st1 == ArticulationType::Sforzatoaccent)) { qSwap(a1, a2); qSwap(st1, st2); } if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato) && (st2 == ArticulationType::Sforzatoaccent)) { QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1); pt.ry() += a1->up() ? -_spStaff * .7 : _spStaff * .7; a2->layout(); a2->setUp(a1->up()); a2->setPos(pt); a2->adjustReadPos(); return; } } } qreal x = centerX(); qreal distance0 = score()->styleS(StyleIdx::propertyDistance).val() * _spatium; qreal distance1 = score()->styleS(StyleIdx::propertyDistanceHead).val() * _spatium; qreal distance2 = score()->styleS(StyleIdx::propertyDistanceStem).val() * _spatium; qreal chordTopY = upPos(); // note position of highest note qreal chordBotY = downPos(); // note position of lowest note qreal staffTopY = -distance2; qreal staffBotY = staff()->height() + distance2; // avoid collisions of staff articulations with chord notes: // gap between note and staff articulation is distance0 + 0.5 spatium if (type() == Element::Type::CHORD) { Chord* chord = static_cast<Chord*>(this); Stem* stem = chord->stem(); if (stem) { qreal y = stem->pos().y() + pos().y(); if (up() && stem->stemLen() < 0.0) y += stem->stemLen(); else if (!up() && stem->stemLen() > 0.0) y -= stem->stemLen(); if (beam()) { qreal bw = score()->styleS(StyleIdx::beamWidth).val() * _spatium; y += up() ? -bw : bw; } if (up()) staffTopY = qMin(staffTopY, qreal(y - 0.5 * _spatium)); else staffBotY = qMax(staffBotY, qreal(y + 0.5 * _spatium)); } } staffTopY = qMin(staffTopY, qreal(chordTopY - distance0 - 0.5 * _spatium)); staffBotY = qMax(staffBotY, qreal(chordBotY + distance0 + 0.5 * _spatium)); qreal dy = 0.0; int n = _articulations.size(); for (int i = 0; i < n; ++i) { Articulation* a = _articulations.at(i); // // determine MScore::Direction // if (a->direction() != MScore::Direction::AUTO) { a->setUp(a->direction() == MScore::Direction::UP); } else { if (a->anchor() == ArticulationAnchor::CHORD) a->setUp(!up()); else a->setUp(a->anchor() == ArticulationAnchor::TOP_STAFF || a->anchor() == ArticulationAnchor::TOP_CHORD); } } // // pass 1 // place tenuto and staccato // for (int i = 0; i < n; ++i) { Articulation* a = _articulations.at(i); a->layout(); ArticulationAnchor aa = a->anchor(); if ((a->articulationType() != ArticulationType::Tenuto) && (a->articulationType() != ArticulationType::Staccato)) continue; if (aa != ArticulationAnchor::CHORD && aa != ArticulationAnchor::TOP_CHORD && aa != ArticulationAnchor::BOTTOM_CHORD) continue; bool bottom; if ((aa == ArticulationAnchor::CHORD) && measure()->hasVoices(a->staffIdx())) bottom = !up(); else bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up()); bool headSide = bottom == up(); dy += distance1; qreal y; Chord* chord = static_cast<Chord*>(this); if (bottom) { int line = downLine(); y = chordBotY + dy; if (!headSide && type() == Element::Type::CHORD && chord->stem()) { Stem* stem = chord->stem(); y = chordTopY + stem->stemLen(); if (chord->beam()) y += score()->styleS(StyleIdx::beamWidth).val() * _spatium * .5; x = stem->pos().x(); int line = lrint((y+0.5*_spatium) / _spatium); if (line <= 4) // align between staff lines y = line * _spatium + _spatium * .5; else y += _spatium; } else { int lines = (staff()->lines() - 1) * 2; if (line < lines) y = (line & ~1) + 3; else y = line + 2; y *= _spatium * .5; } } else { int line = upLine(); y = chordTopY - dy; if (!headSide && type() == Element::Type::CHORD && chord->stem()) { Stem* stem = chord->stem(); y = chordBotY + stem->stemLen(); if (chord->beam()) y -= score()->styleS(StyleIdx::beamWidth).val() * _spatium * .5; x = stem->pos().x(); int line = lrint((y-0.5*_spatium) / _spatium); if (line >= 0) // align between staff lines y = line * _spatium - _spatium * .5; else y -= _spatium; } else { if (line > 0) y = ((line+1) & ~1) - 3; else y = line - 2; y *= _spatium * .5; } } dy += _spatium * .5; a->setPos(x, y); } // reserve space for slur bool botGap = false; bool topGap = false; #if 0 // TODO-S: optimize for (Spanner* sp = _spannerFor; sp; sp = sp->next()) { if (sp->type() != SLUR) continue; Slur* s = static_cast<Slur*>(sp); if (s->up()) topGap = true; else botGap = true; } for (Spanner* sp = _spannerBack; sp; sp = sp->next()) { if (sp->type() != SLUR) continue; Slur* s = static_cast<Slur*>(sp); if (s->up()) topGap = true; else botGap = true; } #endif if (botGap) chordBotY += _spatium; if (topGap) chordTopY -= _spatium; // // pass 2 // place all articulations with anchor at chord/rest // n = _articulations.size(); for (int i = 0; i < n; ++i) { Articulation* a = _articulations.at(i); a->layout(); ArticulationAnchor aa = a->anchor(); if ((a->articulationType() == ArticulationType::Tenuto) || (a->articulationType() == ArticulationType::Staccato)) continue; if (aa != ArticulationAnchor::CHORD && aa != ArticulationAnchor::TOP_CHORD && aa != ArticulationAnchor::BOTTOM_CHORD) continue; // for tenuto and staccate check for staff line collision bool staffLineCT = a->articulationType() == ArticulationType::Tenuto || a->articulationType() == ArticulationType::Staccato; // qreal sh = a->bbox().height() * mag(); bool bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up()); dy += distance1; if (bottom) { qreal y = chordBotY + dy; if (staffLineCT && (y <= staffBotY -.1 - dy)) { qreal l = y / _spatium; qreal delta = fabs(l - round(l)); if (delta < 0.4) { y += _spatium * .5; dy += _spatium * .5; } } a->setPos(x, y); // - a->bbox().y() + a->bbox().height() * .5); } else { qreal y = chordTopY - dy; if (staffLineCT && (y >= (staffTopY +.1 + dy))) { qreal l = y / _spatium; qreal delta = fabs(l - round(l)); if (delta < 0.4) { y -= _spatium * .5; dy += _spatium * .5; } } a->setPos(x, y); // + a->bbox().y() - a->bbox().height() * .5); } } // // pass 3 // now place all articulations with staff top or bottom anchor // qreal dyTop = staffTopY; qreal dyBot = staffBotY; /* if ((upPos() - _spatium) < dyTop) dyTop = upPos() - _spatium; if ((downPos() + _spatium) > dyBot) dyBot = downPos() + _spatium; */ for (int i = 0; i < n; ++i) { Articulation* a = _articulations.at(i); ArticulationAnchor aa = a->anchor(); if (aa == ArticulationAnchor::TOP_STAFF || aa == ArticulationAnchor::BOTTOM_STAFF) { if (a->up()) { a->setPos(x, dyTop); dyTop -= distance0; } else { a->setPos(x, dyBot); dyBot += distance0; } } a->adjustReadPos(); } }
void ChordRest::writeProperties(Xml& xml) const { DurationElement::writeProperties(xml); // // Beam::Mode default: // REST - Beam::Mode::NONE // CHORD - Beam::Mode::AUTO // if ((type() == Element::Type::REST && _beamMode != Beam::Mode::NONE) || (type() == Element::Type::CHORD && _beamMode != Beam::Mode::AUTO)) { QString s; switch(_beamMode) { case Beam::Mode::AUTO: s = "auto"; break; case Beam::Mode::BEGIN: s = "begin"; break; case Beam::Mode::MID: s = "mid"; break; case Beam::Mode::END: s = "end"; break; case Beam::Mode::NONE: s = "no"; break; case Beam::Mode::BEGIN32: s = "begin32"; break; case Beam::Mode::BEGIN64: s = "begin64"; break; case Beam::Mode::INVALID: s = "?"; break; } xml.tag("BeamMode", s); } writeProperty(xml, P_ID::SMALL); if (actualDurationType().dots()) xml.tag("dots", actualDurationType().dots()); writeProperty(xml, P_ID::STAFF_MOVE); if (actualDurationType().isValid()) xml.tag("durationType", actualDurationType().name()); if (!duration().isZero() && (!actualDurationType().fraction().isValid() || (actualDurationType().fraction() != duration()))) xml.fTag("duration", duration()); foreach(const Articulation* a, _articulations) a->write(xml); #ifndef NDEBUG if (_beam && (MScore::testMode || !_beam->generated())) xml.tag("Beam", _beam->id()); #else if (_beam && !_beam->generated()) xml.tag("Beam", _beam->id()); #endif foreach(Lyrics* lyrics, _lyricsList) { if (lyrics) lyrics->write(xml); } if (!isGrace()) { Fraction t(globalDuration()); if (staff()) t *= staff()->timeStretch(xml.curTick); xml.curTick += t.ticks(); } for (auto i : score()->spanner()) { // TODO: dont search whole list Spanner* s = i.second; if (s->generated() || s->type() != Element::Type::SLUR || !xml.canWrite(s)) continue; if (s->startElement() == this) { int id = xml.spannerId(s); xml.tagE(QString("Slur type=\"start\" id=\"%1\"").arg(id)); } else if (s->endElement() == this) { int id = xml.spannerId(s); xml.tagE(QString("Slur type=\"stop\" id=\"%1\"").arg(id)); } } }
bool ChordRest::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "durationType") { setDurationType(e.readElementText()); if (actualDurationType().type() != TDuration::DurationType::V_MEASURE) { if ((type() == Element::Type::REST) && // for backward compatibility, convert V_WHOLE rests to V_MEASURE // if long enough to fill a measure. // OTOH, freshly created (un-initialized) rests have numerator == 0 (< 4/4) // (see Fraction() constructor in fraction.h; this happens for instance // when pasting selection from clipboard): they should not be converted duration().numerator() != 0 && // rest durations are initialized to full measure duration when // created upon reading the <Rest> tag (see Measure::read() ) // so a V_WHOLE rest in a measure of 4/4 or less => V_MEASURE (actualDurationType()==TDuration::DurationType::V_WHOLE && duration() <= Fraction(4, 4)) ) { // old pre 2.0 scores: convert setDurationType(TDuration::DurationType::V_MEASURE); } else // not from old score: set duration fraction from duration type setDuration(actualDurationType().fraction()); } else { if (score()->mscVersion() < 115) { SigEvent event = score()->sigmap()->timesig(e.tick()); setDuration(event.timesig()); } } } else if (tag == "BeamMode") { QString val(e.readElementText()); Beam::Mode bm = Beam::Mode::AUTO; if (val == "auto") bm = Beam::Mode::AUTO; else if (val == "begin") bm = Beam::Mode::BEGIN; else if (val == "mid") bm = Beam::Mode::MID; else if (val == "end") bm = Beam::Mode::END; else if (val == "no") bm = Beam::Mode::NONE; else if (val == "begin32") bm = Beam::Mode::BEGIN32; else if (val == "begin64") bm = Beam::Mode::BEGIN64; else bm = Beam::Mode(val.toInt()); _beamMode = Beam::Mode(bm); } else if (tag == "Attribute" || tag == "Articulation") { // obsolete: "Attribute" Articulation* atr = new Articulation(score()); atr->read(e); add(atr); } else if (tag == "leadingSpace") { qDebug("ChordRest: leadingSpace obsolete"); // _extraLeadingSpace = Spatium(val.toDouble()); e.skipCurrentElement(); } else if (tag == "trailingSpace") { qDebug("ChordRest: trailingSpace obsolete"); // _extraTrailingSpace = Spatium(val.toDouble()); e.skipCurrentElement(); } else if (tag == "Beam") { int id = e.readInt(); Beam* beam = e.findBeam(id); if (beam) beam->add(this); // also calls this->setBeam(beam) else qDebug("Beam id %d not found", id); } else if (tag == "small") _small = e.readInt(); else if (tag == "duration") setDuration(e.readFraction()); else if (tag == "ticklen") { // obsolete (version < 1.12) int mticks = score()->sigmap()->timesig(e.tick()).timesig().ticks(); int i = e.readInt(); if (i == 0) i = mticks; if ((type() == Element::Type::REST) && (mticks == i)) { setDurationType(TDuration::DurationType::V_MEASURE); setDuration(Fraction::fromTicks(i)); } else { Fraction f = Fraction::fromTicks(i); setDuration(f); setDurationType(TDuration(f)); } } else if (tag == "dots") setDots(e.readInt()); else if (tag == "move") _staffMove = e.readInt(); else if (tag == "Slur") { int id = e.intAttribute("id"); if (id == 0) id = e.intAttribute("number"); // obsolete Spanner* spanner = e.findSpanner(id); if (!spanner) qDebug("ChordRest::read(): Slur id %d not found", id); else { QString atype(e.attribute("type")); if (atype == "start") { spanner->setTick(e.tick()); if (spanner->ticks() > 0) // stop has been read first, ticks is tick2 - (-1) spanner->setTick2(spanner->ticks() - 1); spanner->setTrack(track()); if (spanner->type() == Element::Type::SLUR) spanner->setStartElement(this); if (e.pasteMode()) { for (Element* e : spanner->linkList()) { if (e == spanner) continue; Spanner* ls = static_cast<Spanner*>(e); ls->setTick(spanner->tick()); for (Element* ee : linkList()) { ChordRest* cr = static_cast<ChordRest*>(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack(cr->track()); if (ls->type() == Element::Type::SLUR) ls->setStartElement(cr); break; } } } } } else if (atype == "stop") { spanner->setTick2(e.tick()); spanner->setTrack2(track()); if (spanner->type() == Element::Type::SLUR) spanner->setEndElement(this); Chord* start = static_cast<Chord*>(spanner->startElement()); if (start) spanner->setTrack(start->track()); if (e.pasteMode()) { for (Element* e : spanner->linkList()) { if (e == spanner) continue; Spanner* ls = static_cast<Spanner*>(e); ls->setTick2(spanner->tick2()); for (Element* ee : linkList()) { ChordRest* cr = static_cast<ChordRest*>(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack2(cr->track()); if (ls->type() == Element::Type::SLUR) ls->setEndElement(cr); break; } } } } } else qDebug("ChordRest::read(): unknown Slur type <%s>", qPrintable(atype)); } e.readNext(); } else if (tag == "Lyrics" /*|| tag == "FiguredBass"*/) { Element* element = Element::name2Element(tag, score()); element->setTrack(e.track()); element->read(e); add(element); } else if (tag == "pos") { QPointF pt = e.readPoint(); if (score()->mscVersion() > 114) setUserOff(pt * spatium()); } else if (tag == "offset") { if (score()->mscVersion() > 114) // || voice() >= 2) { DurationElement::readProperties(e); else if (type() == Element::Type::REST) { DurationElement::readProperties(e); setUserXoffset(0.0); // honor Y offset but not X for rests in older scores } else e.skipCurrentElement(); // ignore manual layout otherwise } else if (DurationElement::readProperties(e)) return true; else return false; return true; }
void ScoreAccessibility::currentInfoChanged() { clearAccessibilityInfo(); statusBarLabel = new QLabel(mainWindow->statusBar()); ScoreView* scoreView = static_cast<MuseScore*>(mainWindow)->currentScoreView(); Score* score = scoreView->score(); if (score->selection().isSingle()) { Element* e = score->selection().element(); if (!e) { return; } Element* el = e->isSpannerSegment() ? static_cast<SpannerSegment*>(e)->spanner() : e; QString barsAndBeats = ""; std::pair<int, float> bar_beat; if (el->isSpanner()){ Spanner* s = static_cast<Spanner*>(el); bar_beat = barbeat(s->startSegment()); barsAndBeats += tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second)); Segment* seg = s->endSegment(); if(!seg) seg = score->lastSegment()->prev1MM(Segment::Type::ChordRest); if (seg->tick() != score->lastSegment()->prev1MM(Segment::Type::ChordRest)->tick() && s->type() != Element::Type::SLUR && s->type() != Element::Type::TIE ) seg = seg->prev1MM(Segment::Type::ChordRest); bar_beat = barbeat(seg); barsAndBeats += "; " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second)); } else { std::pair<int, float>bar_beat = barbeat(el); if (bar_beat.first) { barsAndBeats += " " + tr("Measure: %1").arg(QString::number(bar_beat.first)); if (bar_beat.second) barsAndBeats += "; " + tr("Beat: %1").arg(QString::number(bar_beat.second)); } } QString rez = e->accessibleInfo(); if (!barsAndBeats.isEmpty()) rez += "; " + barsAndBeats; QString staff = ""; if (e->staffIdx() + 1) { staff = tr("Staff %1").arg(QString::number(e->staffIdx() + 1)); rez = QString("%1; %2").arg(rez).arg(staff); } statusBarLabel->setText(rez); QString screenReaderRez = QString("%1%2 %3 %4").arg(e->screenReaderInfo()).arg(barsAndBeats).arg(staff).arg(e->accessibleExtraInfo()); score->setAccessibleInfo(screenReaderRez); } else if (score->selection().isRange()) { QString barsAndBeats = ""; std::pair<int, float> bar_beat; bar_beat = barbeat(score->selection().startSegment()); barsAndBeats += " " + tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second)); Segment* endSegment = score->selection().endSegment(); if (!endSegment) endSegment = score->lastSegment(); else endSegment = endSegment->prev1MM(); bar_beat = barbeat(endSegment); barsAndBeats += " " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second)); statusBarLabel->setText(tr("Range Selection") + barsAndBeats); score->setAccessibleInfo(tr("Range Selection") + barsAndBeats); } else if (score->selection().isList()) { statusBarLabel->setText(tr("List Selection")); score->setAccessibleInfo(tr("List Selection")); } mainWindow->statusBar()->addWidget(statusBarLabel); }