void ChordRest::add(Element* e) { e->setParent(this); e->setTrack(track()); switch(e->type()) { case Element::Type::ARTICULATION: { Articulation* a = static_cast<Articulation*>(e); _articulations.push_back(a); if (a->timeStretch() != 1.0) score()->fixTicks(); // update tempo map } break; case Element::Type::LYRICS: { Lyrics* l = static_cast<Lyrics*>(e); int size = _lyricsList.size(); if (l->no() >= size) { for (int i = size-1; i < l->no(); ++i) _lyricsList.append(0); } _lyricsList[l->no()] = l; } break; default: qFatal("ChordRest::add: unknown element %s", e->name()); break; } }
void ChordRest::remove(Element* e) { switch (e->type()) { case Element::Type::ARTICULATION: { Articulation* a = static_cast<Articulation*>(e); if (!_articulations.removeOne(a)) qDebug("ChordRest::remove(): articulation not found"); if (a->timeStretch() != 1.0) score()->fixTicks(); // update tempo map } break; case Element::Type::LYRICS: { for (int i = 0; i < _lyricsList.size(); ++i) { if (_lyricsList[i] != e) continue; _lyricsList[i] = 0; while (!_lyricsList.isEmpty() && _lyricsList.back() == 0) _lyricsList.takeLast(); return; } } qDebug("ChordRest::remove: %s %p not found", e->name(), e); break; default: qFatal("ChordRest::remove: unknown element <%s>", e->name()); } }
Element* BarLine::drop(const DropData& data) { Element* e = data.element; int type = e->type(); if (type == BAR_LINE) { BarLine* bl = static_cast<BarLine*>(e); BarLineType st = bl->subtype(); if (st == subtype()) { delete e; return 0; } Measure* m = segment()->measure(); if (st == START_REPEAT) { m = m->nextMeasure(); if (m == 0) { delete e; return 0; } } m->drop(data); } else if (type == ARTICULATION) { Articulation* atr = static_cast<Articulation*>(e); atr->setParent(this); atr->setTrack(track()); score()->select(atr, SELECT_SINGLE, 0); score()->undoAddElement(atr); } return 0; }
ChordRest::ChordRest(const ChordRest& cr, bool link) : DurationElement(cr) { _durationType = cr._durationType; _staffMove = cr._staffMove; _beam = 0; _tabDur = 0; // tab sur. symb. depends upon context: can't be // simply copied from another CR for (Articulation* a : cr._articulations) { // make deep copy Articulation* na = new Articulation(*a); if (link) na->linkTo(a); na->setParent(this); na->setTrack(track()); _articulations.append(na); } _beamMode = cr._beamMode; _up = cr._up; _small = cr._small; _crossMeasure = cr._crossMeasure; _space = cr._space; for (Lyrics* l : cr._lyricsList) { // make deep copy if (l == 0) continue; Lyrics* nl = new Lyrics(*l); if (link) nl->linkTo(l); nl->setParent(this); nl->setTrack(track()); _lyricsList.append(nl); } }
Palette* MuseScore::newArticulationsPalette() { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Articulations && Ornaments")); sp->setGrid(42, 25); sp->setDrawGrid(true); for (int i = 0; i < int(ArticulationType::ARTICULATIONS); ++i) { Articulation* s = new Articulation(gscore); s->setArticulationType(ArticulationType(i)); sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeUserName()))); } Bend* bend = new Bend(gscore); bend->points().append(PitchValue(0, 0, false)); bend->points().append(PitchValue(15, 100, false)); bend->points().append(PitchValue(60, 100, false)); sp->append(bend, qApp->translate("articulation", "Bend")); TremoloBar* tb = new TremoloBar(gscore); tb->points().append(PitchValue(0, 0, false)); // "Dip" tb->points().append(PitchValue(30, -100, false)); tb->points().append(PitchValue(60, 0, false)); sp->append(tb, qApp->translate("articulation", "Tremolo Bar")); return sp; }
void BarLine::layout() { qreal y1, y2; getY(&y1, &y2); qreal _spatium = spatium(); qreal dw = layoutWidth(score(), barLineType(), magS()); QRectF r(0.0, y1, dw, y2-y1); if (score()->styleB(ST_repeatBarTips)) { qreal mags = magS(); int si = score()->symIdx(); switch (barLineType()) { case START_REPEAT: r |= symbols[si][brackettipsRightUp].bbox(mags).translated(0, y1); r |= symbols[si][brackettipsRightDown].bbox(mags).translated(0, y2); break; case END_REPEAT: r |= symbols[si][brackettipsLeftUp].bbox(mags).translated(0, y1); r |= symbols[si][brackettipsLeftDown].bbox(mags).translated(0, y2); break; case END_START_REPEAT: { qreal lw = point(score()->styleS(ST_barWidth)); qreal lw2 = point(score()->styleS(ST_endBarWidth)); qreal d1 = point(score()->styleS(ST_endBarDistance)); const Sym& dotsym = symbols[score()->symIdx()][dotSym]; qreal dotw = dotsym.width(mags); qreal x = dotw + 2 * d1 + lw + lw2 * .5; // thick bar r |= symbols[si][brackettipsRightUp].bbox(mags).translated(x, y1); r |= symbols[si][brackettipsRightDown].bbox(mags).translated(x, y2); r |= symbols[si][brackettipsLeftUp].bbox(mags).translated(x, y1); r |= symbols[si][brackettipsLeftDown].bbox(mags).translated(x, y2); } break; default: break; } } foreach(Element* e, _el) { e->layout(); if (e->type() == ARTICULATION) { Articulation* a = static_cast<Articulation*>(e); MScore::Direction dir = a->direction(); qreal distance = 0.5 * _spatium; qreal x = width() * .5; if (dir == MScore::DOWN) { qreal botY = y2 + distance; a->setPos(QPointF(x, botY)); } else { qreal topY = y1 - distance; a->setPos(QPointF(x, topY)); } } }
void BarLine::read(XmlReader& e) { // if bar line belongs to a staff, span values default to staff values if (staff()) { _span = staff()->barLineSpan(); _spanFrom = staff()->barLineFrom(); _spanTo = staff()->barLineTo(); } while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") { bool ok; const QString& val(e.readElementText()); int i = val.toInt(&ok); if (!ok) setBarLineType(val); else { BarLineType ct = NORMAL_BAR; switch (i) { default: case 0: ct = NORMAL_BAR; break; case 1: ct = DOUBLE_BAR; break; case 2: ct = START_REPEAT; break; case 3: ct = END_REPEAT; break; case 4: ct = BROKEN_BAR; break; case 5: ct = END_BAR; break; case 6: ct = END_START_REPEAT; break; case 7: ct = DOTTED_BAR; break; } setBarLineType(ct); } if (parent() && parent()->type() == SEGMENT) { Measure* m = static_cast<Segment*>(parent())->measure(); if (barLineType() != m->endBarLineType()) _customSubtype = true; } } else if (tag == "customSubtype") _customSubtype = e.readInt(); else if (tag == "span") { _span = e.readInt(); _spanFrom = e.intAttribute("from", _spanFrom); _spanTo = e.intAttribute("to", _spanTo); // WARNING: following statements assume staff and staff bar line spans are correctly set if (staff() && (_span != staff()->barLineSpan() || _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo())) _customSpan = true; } else if (tag == "Articulation") { Articulation* a = new Articulation(score()); a->read(e); add(a); } else if (!Element::readProperties(e)) e.unknown(); } }
void BarLine::read(const QDomElement& de) { // if bar line belongs to a staff, span values default to staff values if(staff()) { _span = staff()->barLineSpan(); _spanFrom = staff()->barLineFrom(); _spanTo = staff()->barLineTo(); } for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "subtype") { bool ok; int i = val.toInt(&ok); if (!ok) setSubtype(val); else { BarLineType ct = NORMAL_BAR; switch (i) { default: case 0: ct = NORMAL_BAR; break; case 1: ct = DOUBLE_BAR; break; case 2: ct = START_REPEAT; break; case 3: ct = END_REPEAT; break; case 4: ct = BROKEN_BAR; break; case 5: ct = END_BAR; break; case 6: ct = END_START_REPEAT; break; case 7: ct = DOTTED_BAR; break; } setSubtype(ct); } if(parent() && parent()->type() == SEGMENT) { Measure* m = static_cast<Segment*>(parent())->measure(); if(subtype() != m->endBarLineType()) setCustomSubtype(true); } } else if (tag == "customSubtype") setCustomSubtype(val.toInt() != 0); else if (tag == "span") { _span = val.toInt(); _spanFrom = e.attribute("from", QString::number(_spanFrom)).toInt(); _spanTo = e.attribute("to", QString::number(_spanTo)).toInt(); // WARNING: following statements assume staff and staff bar line spans are correctly set if(staff() && (_span != staff()->barLineSpan() || _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo())) _customSpan = true; } else if (tag == "Articulation") { Articulation* a = new Articulation(score()); a->read(e); add(a); } else if (!Element::readProperties(e)) domError(e); } }
void TestNote::grace() { Score* score = readScore(DIR + "grace.mscx"); score->doLayout(); Chord* chord = score->firstMeasure()->findChord(0, 0); Note* note = chord->upNote(); // create score->setGraceNote(chord, note->pitch(), NoteType::APPOGGIATURA, MScore::division/2); Chord* gc = chord->graceNotes().first(); Note* gn = gc->notes().first(); // Note* n = static_cast<Note*>(writeReadElement(gn)); // QCOMPARE(n->noteType(), NoteType::APPOGGIATURA); // delete n; // tie score->startCmd(); score->select(gn); score->cmdAddTie(); score->endCmd(); // n = static_cast<Note*>(writeReadElement(gn)); // QVERIFY(n->tieFor() != 0); // delete n; // tremolo score->startCmd(); Tremolo* tr = new Tremolo(score); tr->setTremoloType(TremoloType::R16); tr->setParent(gc); tr->setTrack(gc->track()); score->undoAddElement(tr); score->endCmd(); // Chord* c = static_cast<Chord*>(writeReadElement(gc)); // QVERIFY(c->tremolo() != 0); // delete c; // articulation score->startCmd(); Articulation* ar = new Articulation(score); ar->setArticulationType(ArticulationType::Sforzatoaccent); ar->setParent(gc); ar->setTrack(gc->track()); score->undoAddElement(ar); score->endCmd(); // c = static_cast<Chord*>(writeReadElement(gc)); // QVERIFY(c->articulations().size() == 1); // delete c; QVERIFY(saveCompareScore(score, "grace-test.mscx", DIR + "grace-ref.mscx")); }
Element* Rest::drop(const DropData& data) { Element* e = data.element; switch (e->type()) { case ElementType::ARTICULATION: { Articulation* a = static_cast<Articulation*>(e); if (a->articulationType() != ArticulationType::Fermata || !score()->addArticulation(this, a)) { delete e; e = 0; } } return e; case ElementType::CHORD: { Chord* c = static_cast<Chord*>(e); Note* n = c->upNote(); Direction dir = c->stemDirection(); // score()->select(0, SelectType::SINGLE, 0); NoteVal nval; nval.pitch = n->pitch(); nval.headGroup = n->headGroup(); Fraction d = score()->inputState().duration().fraction(); if (!d.isZero()) { Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir); if (seg) { ChordRest* cr = static_cast<ChordRest*>(seg->element(track())); if (cr) score()->nextInputPos(cr, true); } } delete e; } break; case ElementType::REPEAT_MEASURE: delete e; if (durationType().type() == TDuration::DurationType::V_MEASURE) { measure()->cmdInsertRepeatMeasure(staffIdx()); } break; default: return ChordRest::drop(data); } return 0; }
static qreal fixArticulations(qreal yo, Chord* c, qreal _up) { // // handle special case of tenuto and staccato; // QList<Articulation*>* al = c->getArticulations(); if (al->size() >= 2) { Articulation* a = al->at(1); if (a->subtype() == Articulation_Tenuto || a->subtype() == Articulation_Staccato) return a->y() + (a->height() + c->score()->spatium() * .3) * _up; } else if (al->size() >= 1) { Articulation* a = al->at(0); if (a->subtype() == Articulation_Tenuto || a->subtype() == Articulation_Staccato) return a->y() + (a->height() + c->score()->spatium() * .3) * _up; } return yo; }
void MuseScore::noteAttributesMenu() { if (noteAttributesPalette == 0) { Palette* sp = new Palette(); sp->resize(400, 300); noteAttributesPalette = new PaletteScrollArea(sp); noteAttributesPalette->setRestrictHeight(false); noteAttributesPalette->setWindowTitle(tr("MuseScore: Articulations & Ornaments")); unsigned nn = ARTICULATIONS; sp->setGrid(42, 30); for (unsigned i = 0; i < nn; ++i) { Articulation* s = new Articulation(gscore); s->setSubtype(ArticulationType(i)); sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeName()))); } } noteAttributesPalette->show(); noteAttributesPalette->raise(); }
void InspectorArticulation::setElement(Element* e) { Articulation* a = static_cast<Articulation*>(e); qreal _spatium = e->score()->spatium(); ar.elementName->setText(e->name()); ar.x->blockSignals(true); ar.y->blockSignals(true); ar.direction->blockSignals(true); ar.anchor->blockSignals(true); ar.x->setValue(a->pos().x() / _spatium); ar.y->setValue(a->pos().y() / _spatium); ar.direction->setCurrentIndex(int(a->direction())); ar.anchor->setCurrentIndex(int(a->anchor())); ar.x->blockSignals(false); ar.y->blockSignals(false); ar.direction->blockSignals(false); ar.anchor->blockSignals(false); }
Element* Rest::drop(const DropData& data) { Element* e = data.element; switch (e->type()) { case ARTICULATION: { Articulation* a = static_cast<Articulation*>(e); if (a->articulationType() != Articulation_Fermata || !score()->addArticulation(this, a)) { delete e; e = 0; } } return e; case CHORD: { Chord* c = static_cast<Chord*>(e); Note* n = c->upNote(); MScore::Direction dir = c->stemDirection(); // score()->select(0, SELECT_SINGLE, 0); NoteVal nval; nval.pitch = n->pitch(); nval.headGroup = n->headGroup(); Fraction d = score()->inputState().duration().fraction(); if (!d.isZero()) { Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir); if (seg) { ChordRest* cr = static_cast<ChordRest*>(seg->element(track())); if (cr) score()->nextInputPos(cr, true); } } delete e; } break; default: return ChordRest::drop(data); } return 0; }
void BarLine::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "subtype") { bool ok; int i = val.toInt(&ok); if (!ok) setSubtype(val); else { BarLineType ct = NORMAL_BAR; switch (i) { default: case 0: ct = NORMAL_BAR; break; case 1: ct = DOUBLE_BAR; break; case 2: ct = START_REPEAT; break; case 3: ct = END_REPEAT; break; case 4: ct = BROKEN_BAR; break; case 5: ct = END_BAR; break; case 6: ct = END_START_REPEAT; break; } setSubtype(ct); } } else if (tag == "span") _span = val.toInt(); else if (tag == "Articulation") { Articulation* a = new Articulation(score()); a->read(e); add(a); } else if (!Element::readProperties(e)) domError(e); } }
Palette* MuseScore::newArticulationsPalette(bool basic) { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Articulations && Ornaments")); sp->setGrid(42, 25); sp->setDrawGrid(true); if (basic) { static std::vector<ArticulationType> art { ArticulationType::Fermata, ArticulationType::Sforzatoaccent, ArticulationType::Staccato, ArticulationType::Tenuto, ArticulationType::Portato, ArticulationType::Marcato, ArticulationType::Trill }; for (auto i : art) { Articulation* s = new Articulation(gscore); s->setArticulationType(i); sp->append(s, qApp->translate("articulation", s->subtypeUserName().toUtf8().constData())); } } else { for (int i = 0; i < int(ArticulationType::ARTICULATIONS); ++i) { Articulation* s = new Articulation(gscore); s->setArticulationType(ArticulationType(i)); sp->append(s, qApp->translate("articulation", s->subtypeUserName().toUtf8().constData())); } Bend* bend = new Bend(gscore); bend->points().append(PitchValue(0, 0, false)); bend->points().append(PitchValue(15, 100, false)); bend->points().append(PitchValue(60, 100, false)); sp->append(bend, qApp->translate("articulation", "Bend")); TremoloBar* tb = new TremoloBar(gscore); tb->points().append(PitchValue(0, 0, false)); // "Dip" tb->points().append(PitchValue(30, -100, false)); tb->points().append(PitchValue(60, 0, false)); sp->append(tb, qApp->translate("articulation", "Tremolo bar")); } return sp; }
void InspectorArticulation::apply() { Articulation* a = static_cast<Articulation*>(inspector->element()); Score* score = a->score(); qreal _spatium = score->spatium(); QPointF o(ar.x->value() * _spatium, ar.y->value() * _spatium); score->startCmd(); if (o != a->pos()) score->undoChangeUserOffset(a, o - a->ipos()); Direction d = Direction(ar.direction->currentIndex()); ArticulationAnchor anchor = ArticulationAnchor(ar.anchor->currentIndex()); if (anchor != a->anchor()) score->undoChangeProperty(a, P_ARTICULATION_ANCHOR, int(anchor)); if (d != a->direction()) score->undoChangeProperty(a, P_DIRECTION, int(d)); score->endCmd(); mscore->endCmd(); }
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 MuseData::readNote(Part* part, const QString& s) { // a b c d e f g static int table[7] = { 9, 11, 0, 2, 4, 5, 7 }; int step = s[0].toLatin1() - 'A'; int alter = 0; int octave = 0; for (int i = 1; i < 3; ++i) { if (s[i] == '#') alter += 1; else if (s[i] == 'f') alter -= 1; else if (s[i].isDigit()) { octave = s.mid(i,1).toInt(); break; } } MScore::Direction dir = MScore::AUTO; if (s.size() >= 23) { if (s[22] == 'u') dir = MScore::UP; else if (s[22] == 'd') dir = MScore::DOWN; } int staffIdx = 0; if (s.size() >= 24) { if (s[23].isDigit()) staffIdx = s.mid(23,1).toInt() - 1; } Staff* staff = part->staff(staffIdx); int gstaff = staff->idx(); int pitch = table[step] + alter + (octave + 1) * 12; if (pitch < 0) pitch = 0; if (pitch > 127) pitch = 127; int ticks = s.mid(5, 3).toInt(); ticks = (ticks * MScore::division + _division/2) / _division; int tick = curTick; curTick += ticks; Tuplet* tuplet = 0; if (s.size() >= 22) { int a = 1; int b = 1; if (s[19] != ' ') { a = s[19].toLatin1() - '0'; if (a == 3 && s[20] != ':') b = 2; else { b = s[21].toLatin1() - '0'; } } if (a == 3 && b == 2) { // triplet if (chordRest && chordRest->tuplet() && ntuplet) { tuplet = chordRest->tuplet(); } else { tuplet = new Tuplet(score); tuplet->setTrack(gstaff * VOICES); tuplet->setTick(tick); ntuplet = a; tuplet->setRatio(Fraction(a, b)); measure->add(tuplet); } } else if (a == 1 && b == 1) ; else qDebug("unsupported tuple %d/%d", a, b); } Chord* chord = new Chord(score); chordRest = chord; chord->setTrack(gstaff * VOICES); chord->setStemDirection(dir); if (tuplet) { chord->setTuplet(tuplet); tuplet->add(chord); --ntuplet; } TDuration d; d.setVal(ticks); chord->setDurationType(d); Segment* segment = measure->getSegment(chord, tick); voice = 0; for (; voice < VOICES; ++voice) { Element* e = segment->element(gstaff * VOICES + voice); if (e == 0) { chord->setTrack(gstaff * VOICES + voice); segment->add(chord); break; } } if (voice == VOICES) { qDebug("cannot allocate voice"); delete chord; return; } Note* note = new Note(score); note->setPitch(pitch); note->setTpcFromPitch(); note->setTrack(gstaff * VOICES + voice); chord->add(note); QString dynamics; QString an = s.mid(31, 11); for (int i = 0; i < an.size(); ++i) { if (an[i] == '(') openSlur(0, tick, staff, voice); else if (an[i] == ')') closeSlur(0, tick, staff, voice); else if (an[i] == '[') openSlur(1, tick, staff, voice); else if (an[i] == ']') closeSlur(1, tick, staff, voice); else if (an[i] == '{') openSlur(2, tick, staff, voice); else if (an[i] == '}') closeSlur(2, tick, staff, voice); else if (an[i] == 'z') openSlur(3, tick, staff, voice); else if (an[i] == 'x') closeSlur(3, tick, staff, voice); else if (an[i] == '.') { Articulation* atr = new Articulation(score); atr->setArticulationType(Articulation_Staccato); chord->add(atr); } else if (an[i] == '_') { Articulation* atr = new Articulation(score); atr->setArticulationType(Articulation_Tenuto); chord->add(atr); } else if (an[i] == 'v') { Articulation* atr = new Articulation(score); atr->setArticulationType(Articulation_Upbow); chord->add(atr); } else if (an[i] == 'n') { Articulation* atr = new Articulation(score); atr->setArticulationType(Articulation_Downbow); chord->add(atr); } else if (an[i] == 't') { Articulation* atr = new Articulation(score); atr->setArticulationType(Articulation_Trill); chord->add(atr); } else if (an[i] == 'F') { Articulation* atr = new Articulation(score); atr->setUp(true); atr->setArticulationType(Articulation_Fermata); chord->add(atr); } else if (an[i] == 'E') { Articulation* atr = new Articulation(score); atr->setUp(false); atr->setArticulationType(Articulation_Fermata); chord->add(atr); } else if (an[i] == 'O') { // Articulation* atr = new Articulation(score); // atr->setArticulationType(Articulation_Downbow); // chord->add(atr); qDebug("%06d: open string '%c' not implemented", tick, an[i].toLatin1()); } else if (an[i] == '&') { // skip editorial level if (i <= an.size() && an[i+1].isDigit()) ++i; } else if (an[i] == 'p') dynamics += "p"; else if (an[i] == 'm') dynamics += "m"; else if (an[i] == 'f') dynamics += "f"; else if (an[i] == '-') // tie ; else if (an[i] == '*') // start tuplet ; else if (an[i] == '!') // stop tuplet ; else if (an[i] == '+') // cautionary accidental ; else if (an[i] == 'X') // ??? ; else if (an[i] == ' ') ; else { qDebug("%06d: notation '%c' not implemented", tick, an[i].toLatin1()); } } if (!dynamics.isEmpty()) { Dynamic* dyn = new Dynamic(score); dyn->setDynamicType(dynamics); dyn->setTrack(gstaff * VOICES); Segment* s = measure->getSegment(Segment::SegChordRest, tick); s->add(dyn); } QString txt = s.mid(43, 36); if (!txt.isEmpty()) { QStringList sl = txt.split("|"); int no = 0; foreach(QString w, sl) { w = diacritical(w); Lyrics* l = new Lyrics(score); l->setText(w); l->setNo(no++); l->setTrack(gstaff * VOICES); Segment* segment = measure->tick2segment(tick); segment->add(l); }
Element* BarLine::drop(const DropData& data) { Element* e = data.element; int type = e->type(); if (type == BAR_LINE) { BarLine* bl = static_cast<BarLine*>(e); BarLineType st = bl->barLineType(); // if no change in subtype or no change in span, do nothing if (st == barLineType() && bl->spanFrom() == 0 && bl->spanTo() == DEFAULT_BARLINE_TO) { delete e; return 0; } // system left-side bar line if (parent()->type() == SYSTEM) { BarLine* b = static_cast<System*>(parent())->barLine(); score()->undoChangeProperty(b, P_SUBTYPE, int(bl->barLineType())); delete e; return 0; } // check if the new property can apply to this single bar line bool oldRepeat = (barLineType() == START_REPEAT || barLineType() == END_REPEAT || barLineType() == END_START_REPEAT); bool newRepeat = (bl->barLineType() == START_REPEAT || bl->barLineType() == END_REPEAT || bl->barLineType() == END_START_REPEAT); // if repeats are not involved or drop refers to span rather than subtype => // single bar line drop if( (!oldRepeat && !newRepeat) || (bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) ) { // if drop refers to span, update this bar line span if(bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) { // if dropped spanFrom or spanTo are below the middle of standard staff (5 lines) // adjust to the number of syaff lines int bottomSpan = (staff()->lines()-1) * 2; int spanFrom = bl->spanFrom() > 4 ? bottomSpan - (8 - bl->spanFrom()) : bl->spanFrom(); int spanTo = bl->spanTo() > 4 ? bottomSpan - (8 - bl->spanTo()) : bl->spanTo(); score()->undoChangeSingleBarLineSpan(this, 1, spanFrom, spanTo); } // if drop refer to subtype, update this bar line subtype else { score()->undoChangeProperty(this, P_SUBTYPE, int(bl->barLineType())); // setCustomSubtype(true); } delete e; return 0; } // drop applies to all bar lines of the measure Measure* m = static_cast<Segment*>(parent())->measure(); if (st == START_REPEAT) { m = m->nextMeasure(); if (m == 0) { delete e; return 0; } } m->drop(data); } else if (type == ARTICULATION) { Articulation* atr = static_cast<Articulation*>(e); atr->setParent(this); atr->setTrack(track()); score()->undoAddElement(atr); return atr; } return 0; }
void BarLine::layout() { qreal y1, y2; getY(&y1, &y2); qreal _spatium = spatium(); qreal dw = score()->styleS(ST_barWidth).val() * _spatium; qreal dotwidth = symbols[score()->symIdx()][dotSym].width(magS()); switch(subtype()) { case DOUBLE_BAR: dw = (score()->styleS(ST_doubleBarWidth) * 2 + score()->styleS(ST_doubleBarDistance)).val() * _spatium; break; case START_REPEAT: dw += dotwidth + (score()->styleS(ST_endBarWidth) + 2 * score()->styleS(ST_endBarDistance)).val() * _spatium; break; case END_REPEAT: dw += dotwidth + (score()->styleS(ST_endBarWidth) + 2 * score()->styleS(ST_endBarDistance)).val() * _spatium; break; case END_BAR: dw += (score()->styleS(ST_endBarWidth) + score()->styleS(ST_endBarDistance)).val() * _spatium; break; case END_START_REPEAT: dw += 2 * dotwidth + (score()->styleS(ST_barWidth) + score()->styleS(ST_endBarWidth) + 4 * score()->styleS(ST_endBarDistance)).val() * _spatium; break; case BROKEN_BAR: case NORMAL_BAR: break; default: qDebug("illegal bar line type\n"); break; } QRectF r(0.0, y1, dw, y2-y1); if (score()->styleB(ST_repeatBarTips)) { // qreal mags = magS(); switch (subtype()) { case START_REPEAT: //r |= symbols[brackettipsRightUp].bbox(mags).translated(0, y1); //r |= symbols[brackettipsRightDown].bbox(mags).translated(0, y2); break; case END_REPEAT: //r |= symbols[brackettipsLeftUp].bbox(mags).translated(0, y1); //r |= symbols[brackettipsLeftDown].bbox(mags).translated(0, y2); break; default: break; } } foreach(Element* e, _el) { e->layout(); if (e->type() == ARTICULATION) { Articulation* a = static_cast<Articulation*>(e); ArticulationAnchor aa = a->anchor(); qreal distance = 0.5 * _spatium; qreal topY = y1 - distance; qreal botY = y2 + distance; qreal x = width() - (a->width() * .5); if (aa == A_TOP_STAFF) a->setPos(QPointF(x, topY)); else if (aa == A_BOTTOM_STAFF) a->setPos(QPointF(x, botY)); } }
void BarLine::layout() { qreal y1, y2; getY(&y1, &y2); // if bar line does not belong to a system, has a staff and staff is set to hide bar lines, set null bbox if (parent() && parent()->type() != Element::Type::SYSTEM && staff() && !staff()->staffType()->showBarlines()) setbbox(QRectF()); // bar lines not hidden else { qreal dw = layoutWidth(score(), barLineType(), magS()); QRectF r(0.0, y1, dw, y2-y1); if (score()->styleB(StyleIdx::repeatBarTips)) { switch (barLineType()) { case BarLineType::START_REPEAT: r |= symBbox(SymId::bracketTop).translated(0, y1); r |= symBbox(SymId::bracketBottom).translated(0, y2); break; case BarLineType::END_REPEAT: { qreal w1 = symBbox(SymId::reversedBracketTop).width(); r |= symBbox(SymId::reversedBracketTop).translated(dw - w1, y1); r |= symBbox(SymId::reversedBracketBottom).translated(dw - w1, y2); break; } case BarLineType::END_START_REPEAT: { qreal lw = point(score()->styleS(StyleIdx::barWidth)); qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth)); qreal d1 = point(score()->styleS(StyleIdx::endBarDistance)); qreal dotw = symWidth(SymId::repeatDot); qreal x = dotw + 2 * d1 + lw + lw2 * .5; // thick bar qreal w1 = symBbox(SymId::reversedBracketTop).width(); r |= symBbox(SymId::bracketTop).translated(x, y1); r |= symBbox(SymId::bracketBottom).translated(x, y2); r |= symBbox(SymId::reversedBracketTop).translated(x - w1 , y1); r |= symBbox(SymId::reversedBracketBottom).translated(x - w1, y2); } break; default: break; } } setbbox(r); } // in any case, lay out attached elements foreach(Element* e, _el) { e->layout(); if (e->type() == Element::Type::ARTICULATION) { Articulation* a = static_cast<Articulation*>(e); MScore::Direction dir = a->direction(); qreal distance = 0.5 * spatium(); qreal x = width() * .5; if (dir == MScore::Direction::DOWN) { qreal botY = y2 + distance; a->setPos(QPointF(x, botY)); } else { qreal topY = y1 - distance; a->setPos(QPointF(x, topY)); } } }
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 MuseScore::populatePalette() { //----------------------------------- // notes //----------------------------------- Palette* notePalette = new Palette; notePalette->setName(tr("Grace Notes")); notePalette->setGrid(32, 40); notePalette->setDrawGrid(true); static const IconAction gna[] = { { ICON_ACCIACCATURA, "acciaccatura" }, { ICON_APPOGGIATURA, "appoggiatura" }, { ICON_GRACE4, "grace4" }, { ICON_GRACE16, "grace16" }, { ICON_GRACE32, "grace32" }, { -1, "" } }; populateIconPalette(notePalette, gna); paletteBox->addPalette(notePalette); //----------------------------------- // clefs //----------------------------------- Palette* sp = new Palette; sp->setName(tr("Clefs")); sp->setMag(0.8); sp->setGrid(33, 60); sp->setYOffset(1.0); static const ClefType clefs[21] = { CLEF_G, CLEF_G1, CLEF_G2, CLEF_G3, CLEF_G4, CLEF_C1, CLEF_C2, CLEF_C3, CLEF_C4, CLEF_C5, CLEF_F, CLEF_F_8VA, CLEF_F_15MA, CLEF_F8, CLEF_F15, CLEF_F_B, CLEF_F_C, CLEF_PERC, CLEF_TAB, CLEF_TAB2, CLEF_PERC2 }; for (int i = 0; i < 20; ++i) { ClefType j = clefs[i]; Clef* k = new ::Clef(gscore); k->setClefType(ClefTypeList(j, j)); sp->append(k, qApp->translate("clefTable", clefTable[j].name)); } paletteBox->addPalette(sp); //----------------------------------- // key signatures //----------------------------------- sp = newKeySigPalette(); paletteBox->addPalette(sp); //----------------------------------- // Time //----------------------------------- sp = new Palette; sp->setName(tr("Time Signatures")); sp->setMag(.8); sp->setGrid(42, 38); TimeSig* ts; ts = new TimeSig(gscore); ts->setSig(2, 2); sp->append(ts, "2/2"); sp->append(new TimeSig(gscore, 2, 4), "2/4"); sp->append(new TimeSig(gscore, 3, 4), "3/4"); sp->append(new TimeSig(gscore, 4, 4), "4/4"); sp->append(new TimeSig(gscore, 5, 4), "5/4"); sp->append(new TimeSig(gscore, 6, 4), "6/4"); sp->append(new TimeSig(gscore, 3, 8), "3/8"); sp->append(new TimeSig(gscore, 6, 8), "6/8"); sp->append(new TimeSig(gscore, 9, 8), "9/8"); sp->append(new TimeSig(gscore, 12, 8), "12/8"); sp->append(new TimeSig(gscore, TSIG_FOUR_FOUR), tr("4/4 common time")); sp->append(new TimeSig(gscore, TSIG_ALLA_BREVE), tr("2/2 alla breve")); paletteBox->addPalette(sp); //----------------------------------- // Bar Lines //----------------------------------- sp = new Palette; sp->setName(tr("Barlines")); sp->setMag(0.8); sp->setGrid(42, 38); struct { BarLineType type; const char* name; } t[] = { { NORMAL_BAR, QT_TR_NOOP("Normal") }, { BROKEN_BAR, QT_TR_NOOP("Dashed") }, { END_BAR, QT_TR_NOOP("End Bar") }, { DOUBLE_BAR, QT_TR_NOOP("Double Bar") }, { START_REPEAT, QT_TR_NOOP("Start Repeat") }, { END_REPEAT, QT_TR_NOOP("End Repeat") }, { END_START_REPEAT, QT_TR_NOOP("End-Start Repeat") }, }; for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) { BarLine* b = new BarLine(gscore); b->setSubtype(t[i].type); sp->append(b, tr(t[i].name)); } paletteBox->addPalette(sp); //----------------------------------- // Lines //----------------------------------- sp = new Palette; sp->setName(tr("Lines")); sp->setMag(.8); sp->setGrid(82, 23); Slur* slur = new Slur(gscore); slur->setId(0); sp->append(slur, tr("Slur")); Hairpin* gabel0 = new Hairpin(gscore); gabel0->setSubtype(0); sp->append(gabel0, tr("Crescendo")); Hairpin* gabel1 = new Hairpin(gscore); gabel1->setSubtype(1); sp->append(gabel1, tr("Diminuendo")); Volta* volta = new Volta(gscore); volta->setSubtype(VOLTA_CLOSED); volta->setText("1."); QList<int> il; il.append(1); volta->setEndings(il); sp->append(volta, tr("Prima volta")); volta = new Volta(gscore); volta->setSubtype(VOLTA_CLOSED); volta->setText("2."); il.clear(); il.append(2); volta->setEndings(il); sp->append(volta, tr("Seconda volta")); volta = new Volta(gscore); volta->setSubtype(VOLTA_CLOSED); volta->setText("3."); il.clear(); il.append(3); volta->setEndings(il); sp->append(volta, tr("Terza volta")); volta = new Volta(gscore); volta->setSubtype(VOLTA_OPEN); volta->setText("2."); il.clear(); il.append(2); volta->setEndings(il); sp->append(volta, tr("Seconda volta 2")); Ottava* ottava = new Ottava(gscore); ottava->setSubtype(0); sp->append(ottava, tr("8va")); ottava = new Ottava(gscore); ottava->setSubtype(1); sp->append(ottava, tr("15ma")); ottava = new Ottava(gscore); ottava->setSubtype(2); sp->append(ottava, tr("8vb")); ottava = new Ottava(gscore); ottava->setSubtype(3); sp->append(ottava, tr("15mb")); Pedal* pedal = new Pedal(gscore); //pedal->setLen(l); sp->append(pedal, tr("Pedal")); pedal = new Pedal(gscore); //pedal->setLen(l); pedal->setEndHookType(HOOK_45); sp->append(pedal, tr("Pedal")); pedal = new Pedal(gscore); //pedal->setLen(l); pedal->setBeginSymbol(-1); pedal->setBeginHook(true); pedal->setBeginHookType(HOOK_45); pedal->setEndHookType(HOOK_45); sp->append(pedal, tr("Pedal")); pedal = new Pedal(gscore); //pedal->setLen(l); pedal->setBeginSymbol(-1); pedal->setBeginHook(true); pedal->setBeginHookType(HOOK_45); sp->append(pedal, tr("Pedal")); Trill* trill = new Trill(gscore); sp->append(trill, tr("Trill line")); trill = new Trill(gscore); trill->setSubtype("upprall"); sp->append(trill, tr("Upprall line")); trill = new Trill(gscore); trill->setSubtype("downprall"); sp->append(trill, tr("Downprall line")); trill = new Trill(gscore); trill->setSubtype("prallprall"); sp->append(trill, tr("Prallprall line")); TextLine* textLine = new TextLine(gscore); textLine->setBeginText("VII"); textLine->setEndHook(true); sp->append(textLine, tr("Text line")); TextLine* line = new TextLine(gscore); line->setDiagonal(true); sp->append(line, tr("Line")); paletteBox->addPalette(sp); //----------------------------------- // Arpeggio && Glissando //----------------------------------- sp = new Palette(); sp->setName(tr("Arpeggio && Glissando")); sp->setGrid(27, 60); for (int i = 0; i < 4; ++i) { Arpeggio* a = new Arpeggio(gscore); a->setSubtype(ArpeggioType(i)); sp->append(a, tr("Arpeggio")); } for (int i = 0; i < 2; ++i) { Glissando* a = new Glissando(gscore); a->setSubtype(i); sp->append(a, tr("Glissando")); } paletteBox->addPalette(sp); //----------------------------------- // Symbols: Breath //----------------------------------- sp = new Palette(); sp->setName(tr("Breath && Pauses")); sp->setGrid(42, 40); for (int i = 0; i < 4; ++i) { Breath* a = new Breath(gscore); a->setSubtype(i); if (i < 2) sp->append(a, tr("Breath")); else sp->append(a, tr("Caesura")); } paletteBox->addPalette(sp); //----------------------------------- // Brackets //----------------------------------- sp = new Palette; sp->setName(tr("Brackets")); sp->setMag(0.7); sp->setGrid(42, 60); Bracket* b1 = new Bracket(gscore); b1->setSubtype(BRACKET_NORMAL); Bracket* b2 = new Bracket(gscore); b2->setSubtype(BRACKET_AKKOLADE); // b1->setHeight(_spatium * 7); // b2->setHeight(_spatium * 7); sp->append(b1, tr("Square bracket")); sp->append(b2, tr("Curly bracket")); paletteBox->addPalette(sp); //----------------------------------- // Attributes, Ornaments //----------------------------------- sp = new Palette; sp->setName(tr("Articulations && Ornaments")); sp->setGrid(42, 25); for (int i = 0; i < ARTICULATIONS; ++i) { Articulation* s = new Articulation(gscore); s->setSubtype(ArticulationType(i)); sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeUserName()))); } Bend* bend = new Bend(gscore); bend->points().append(PitchValue(0, 0, false)); bend->points().append(PitchValue(15, 100, false)); bend->points().append(PitchValue(60, 100, false)); sp->append(bend, qApp->translate("articulation", "Bend")); TremoloBar* tb = new TremoloBar(gscore); tb->points().append(PitchValue(0, 0, false)); // "Dip" tb->points().append(PitchValue(30, -100, false)); tb->points().append(PitchValue(60, 0, false)); sp->append(tb, qApp->translate("articulation", "Tremolo Bar")); paletteBox->addPalette(sp); //----------------------------------- // Accidentals //----------------------------------- sp = newAccidentalsPalette(); paletteBox->addPalette(sp); //----------------------------------- // Dynamics //----------------------------------- sp = new Palette; sp->setName(tr("Dynamics")); sp->setMag(.8); sp->setGrid(42, 28); static const char* dynS[] = { "ppp", "pp", "p", "mp", "mf", "f", "ff", "fff" }; for (unsigned i = 0; i < sizeof(dynS)/sizeof(*dynS); ++i) { Dynamic* dynamic = new Dynamic(gscore); dynamic->setSubtype(dynS[i]); sp->append(dynamic, dynamic->subtypeName()); } paletteBox->addPalette(sp); //----------------------------------- // Fingering //----------------------------------- sp = new Palette; sp->setName(tr("Fingering")); sp->setMag(1.5); sp->setGrid(28, 30); sp->setDrawGrid(true); const char finger[] = "012345pimac"; for (unsigned i = 0; i < strlen(finger); ++i) { Fingering* f = new Fingering(gscore); f->setText(QString(finger[i])); sp->append(f, tr("Fingering %1").arg(finger[i])); } const char stringnumber[] = "0123456"; for (unsigned i = 0; i < strlen(stringnumber); ++i) { Fingering* f = new Fingering(gscore); f->setTextStyle(TEXT_STYLE_STRING_NUMBER); f->setText(QString(stringnumber[i])); sp->append(f, tr("String number %1").arg(stringnumber[i])); } Symbol* symbol = new Symbol(gscore, thumbSym); sp->append(symbol, tr("Thumb")); paletteBox->addPalette(sp); //----------------------------------- // Noteheads //----------------------------------- sp = new Palette; sp->setName(tr("Note Heads")); sp->setMag(1.3); sp->setGrid(33, 36); sp->setDrawGrid(true); for (int i = 0; i < HEAD_GROUPS; ++i) { int sym = noteHeads[0][i][1]; if (i == HEAD_BREVIS_ALT) sym = noteHeads[0][i][3]; NoteHead* nh = new NoteHead(gscore); nh->setSym(sym); sp->append(nh, qApp->translate("symbol", symbols[0][sym].name())); } paletteBox->addPalette(sp); //----------------------------------- // Tremolo //----------------------------------- sp = new Palette; sp->setName(tr("Tremolo")); sp->setGrid(27, 40); sp->setDrawGrid(true); const char* tremoloName[] = { QT_TR_NOOP("1/8 through stem"), QT_TR_NOOP("1/16 through stem"), QT_TR_NOOP("1/32 through stem"), QT_TR_NOOP("1/64 through stem"), QT_TR_NOOP("1/8 between notes"), QT_TR_NOOP("1/16 between notes"), QT_TR_NOOP("1/32 between notes"), QT_TR_NOOP("1/64 between notes") }; for (int i = TREMOLO_R8; i <= TREMOLO_C64; ++i) { Tremolo* tremolo = new Tremolo(gscore); tremolo->setSubtype(TremoloType(i)); sp->append(tremolo, tr(tremoloName[i - TREMOLO_R8])); } paletteBox->addPalette(sp); //----------------------------------- // Fall, Doit //----------------------------------- sp = new Palette; sp->setName(tr("Fall/Doit")); sp->setGrid(27, 40); sp->setDrawGrid(true); const char* scorelineNames[] = { QT_TR_NOOP("fall"), QT_TR_NOOP("doit"), }; ChordLine* cl = new ChordLine(gscore); cl->setSubtype(1); sp->append(cl, tr(scorelineNames[0])); cl = new ChordLine(gscore); cl->setSubtype(2); sp->append(cl, tr(scorelineNames[1])); paletteBox->addPalette(sp); //----------------------------------- // Repeats //----------------------------------- sp = new Palette; sp->setName(tr("Repeats")); sp->setMag(0.65); sp->setGrid(84, 28); sp->setDrawGrid(true); RepeatMeasure* rm = new RepeatMeasure(gscore); sp->append(rm, tr("Repeat measure sign")); Marker* mk = new Marker(gscore); mk->setMarkerType(MARKER_SEGNO); sp->append(mk, tr("Segno")); mk = new Marker(gscore); mk->setMarkerType(MARKER_VARSEGNO); sp->append(mk, tr("Segno Variation")); mk = new Marker(gscore); mk->setMarkerType(MARKER_CODA); sp->append(mk, tr("Coda")); mk = new Marker(gscore); mk->setMarkerType(MARKER_VARCODA); sp->append(mk, tr("Varied coda")); mk = new Marker(gscore); mk->setMarkerType(MARKER_CODETTA); sp->append(mk, tr("Codetta")); mk = new Marker(gscore); mk->setMarkerType(MARKER_FINE); sp->append(mk, tr("Fine")); Jump* jp = new Jump(gscore); jp->setJumpType(JUMP_DC); sp->append(jp, tr("Da Capo")); jp = new Jump(gscore); jp->setJumpType(JUMP_DC_AL_FINE); sp->append(jp, tr("Da Capo al Fine")); jp = new Jump(gscore); jp->setJumpType(JUMP_DC_AL_CODA); sp->append(jp, tr("Da Capo al Coda")); jp = new Jump(gscore); jp->setJumpType(JUMP_DS_AL_CODA); sp->append(jp, tr("D.S al Coda")); jp = new Jump(gscore); jp->setJumpType(JUMP_DS_AL_FINE); sp->append(jp, tr("D.S al Fine")); jp = new Jump(gscore); jp->setJumpType(JUMP_DS); sp->append(jp, tr("D.S")); mk = new Marker(gscore); mk->setMarkerType(MARKER_TOCODA); sp->append(mk, tr("To Coda")); paletteBox->addPalette(sp); //----------------------------------- // Text //----------------------------------- sp = new Palette; sp->setName(tr("Text")); sp->setMag(0.65); sp->setGrid(84, 28); sp->setDrawGrid(true); StaffText* st = new StaffText(gscore); st->setSystemFlag(false); st->setTextStyle(TEXT_STYLE_STAFF); //TODO st->setSubtype(TEXT_STAFF); st->setText(tr("staff-text")); sp->append(st, tr("Staff Text")); st = new StaffText(gscore); st->setSystemFlag(true); st->setTextStyle(TEXT_STYLE_SYSTEM); // st->setSubtype(TEXT_SYSTEM); st->setText(tr("system-text")); sp->append(st, tr("System Text")); RehearsalMark* rhm = new RehearsalMark(gscore); rhm->setTrack(0); rhm->setText("B1"); sp->append(rhm, tr("RRehearsal Mark")); InstrumentChange* is = new InstrumentChange(gscore); is->setText(tr("Instrument")); sp->append(is, tr("Instrument Change")); Text* text = new Text(gscore); text->setTrack(0); text->setTextStyle(TEXT_STYLE_LYRICS_VERSE_NUMBER); text->setText(tr("1.")); text->setSystemFlag(true); sp->append(text, tr("Lyrics Verse Number")); static const TempoPattern tp[] = { TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd5f)), 80.0/60.0), // 1/4 TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd5e)), 80.0/30.0), // 1/2 TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd60)), 80.0/120.0), // 1/8 TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120.0/60.0), // dotted 1/4 TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/30.0), // dotted 1/2 TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/120.0) // dotted 1/8 }; for (unsigned i = 0; i < sizeof(tp)/sizeof(*tp); ++i) { TempoText* tt = new TempoText(gscore); tt->setFollowText(true); tt->setTrack(0); tt->setTempo(tp[i].f); tt->setText(tp[i].pattern); sp->append(tt, tr("Tempo Text"), QString(), 1.5); } Harmony* harmony = new Harmony(gscore); harmony->setText("c7"); sp->append(harmony, tr("Chord Name")); paletteBox->addPalette(sp); //----------------------------------- // breaks //----------------------------------- qreal _spatium = gscore->spatium(); sp = new Palette; sp->setName(tr("Breaks && Spacer")); sp->setMag(.7); sp->setGrid(42, 36); sp->setDrawGrid(true); LayoutBreak* lb = new LayoutBreak(gscore); lb->setSubtype(LAYOUT_BREAK_LINE); sp->append(lb, tr("Line break")); lb = new LayoutBreak(gscore); lb->setSubtype(LAYOUT_BREAK_PAGE); sp->append(lb, tr("Page break")); lb = new LayoutBreak(gscore); lb->setSubtype(LAYOUT_BREAK_SECTION); sp->append(lb, tr("Section break")); Spacer* spacer = new Spacer(gscore); spacer->setGap(3 * _spatium); spacer->setSubtype(SPACER_DOWN); sp->append(spacer, tr("Staff spacer down")); spacer = new Spacer(gscore); spacer->setGap(3 * _spatium); spacer->setSubtype(SPACER_UP); sp->append(spacer, tr("Staff spacer up")); paletteBox->addPalette(sp); //----------------------------------- // staff state changes //----------------------------------- #if 0 sp = new Palette; sp->setName(tr("Staff Changes")); sp->setMag(.7); sp->setGrid(42, 36); sp->setDrawGrid(true); StaffState* st = new StaffState(gscore); st->setSubtype(STAFF_STATE_VISIBLE); sp->append(st, tr("set visible")); st = new StaffState(gscore); st->setSubtype(STAFF_STATE_INVISIBLE); sp->append(st, tr("set invisible")); st = new StaffState(gscore); st->setSubtype(STAFF_STATE_TYPE); sp->append(st, tr("change staff type")); st = new StaffState(gscore); st->setSubtype(STAFF_STATE_INSTRUMENT); sp->append(st, tr("change instrument")); paletteBox->addPalette(sp); #endif //----------------------------------- // beam properties //----------------------------------- sp = new Palette; sp->setName(tr("Beam Properties")); sp->setGrid(27, 40); sp->setDrawGrid(true); static const IconAction bpa[] = { { ICON_SBEAM, "beam-start" }, { ICON_MBEAM, "beam-mid" }, { ICON_NBEAM, "no-beam" }, { ICON_BEAM32, "beam32" }, { ICON_BEAM64, "beam64" }, { ICON_AUTOBEAM, "auto-beam" }, { ICON_FBEAM1, "fbeam1" }, { ICON_FBEAM2, "fbeam2" }, { -1, ""} }; populateIconPalette(sp, bpa); paletteBox->addPalette(sp); //----------------------------------- // Symbols //----------------------------------- sp = new Palette; sp->setName(tr("Symbols")); sp->setGrid(42, 45); sp->setDrawGrid(true); sp->append(accDiscantSym); sp->append(accDotSym); sp->append(accFreebaseSym); sp->append(accStdbaseSym); sp->append(accBayanbaseSym); sp->append(accOldEESym); sp->append(accpushSym); sp->append(accpullSym); FretDiagram* fret = new FretDiagram(gscore); fret->setDot(5, 1); fret->setDot(2, 2); fret->setDot(1, 3); fret->setMarker(0, 'X'); fret->setMarker(3, 'O'); fret->setMarker(4, 'O'); sp->append(fret, tr("Fret Diagram")); paletteBox->addPalette(sp); }