int Clef::GetClefLocOffset() const { if (this->HasSameasLink() && this->GetSameasLink()->Is(CLEF)) { Clef *sameas = dynamic_cast<Clef *>(this->GetSameasLink()); assert(sameas); return sameas->GetClefLocOffset(); } int offset = 0; if (GetShape() == CLEFSHAPE_G) offset = -4; else if (GetShape() == CLEFSHAPE_F) offset = 4; offset += (GetLine() - 1) * 2; int disPlace = 0; if (GetDisPlace() == STAFFREL_basic_above) disPlace = -1; else if (GetDisPlace() == STAFFREL_basic_below) disPlace = 1; if ((disPlace != 0) && (GetDis() != OCTAVE_DIS_NONE)) offset += (disPlace * (GetDis() - 1)); return offset; }
void InspectorClef::setElement() { otherClef = nullptr; // no 'other clef' yet InspectorElementBase::setElement(); // try to locate the 'other clef' of a courtesy / main pair Clef* clef = toClef(inspector->element()); // if not in a clef-segment-measure hierarchy, do nothing if (!clef->parent() || clef->parent()->type() != ElementType::SEGMENT) return; Segment* segm = toSegment(clef->parent()); int segmTick = segm->tick(); if (!segm->parent() || segm->parent()->type() != ElementType::MEASURE) return; Measure* meas = toMeasure(segm->parent()); Measure* otherMeas = nullptr; Segment* otherSegm = nullptr; if (segmTick == meas->tick()) // if clef segm is measure-initial otherMeas = meas->prevMeasure(); // look for a previous measure else if (segmTick == meas->tick()+meas->ticks()) // if clef segm is measure-final otherMeas = meas->nextMeasure(); // look for a next measure // look for a clef segment in the 'other' measure at the same tick of this clef segment if (otherMeas) otherSegm = otherMeas->findSegment(SegmentType::Clef, segmTick); // if any 'other' segment found, look for a clef in the same track as this if (otherSegm) otherClef = toClef(otherSegm->element(clef->track())); }
Element* Clef::drop(const DropData& data) { Element* e = data.element; Clef* c = 0; if (e->isClef()) { Clef* clef = toClef(e); ClefType stype = clef->clefType(); if (clefType() != stype) { score()->undoChangeClef(staff(), segment(), stype); c = this; } } else if (e->isAmbitus()) { /*if (!generated())*/ { Measure* meas = measure(); Segment* segm = meas->getSegment(Segment::Type::Ambitus, meas->tick()); if (segm->element(track())) score()->undoRemoveElement(segm->element(track())); Ambitus* r = new Ambitus(score()); r->setParent(segm); r->setTrack(track()); score()->undoAddElement(r); } } delete e; return c; }
void InspectorClef::setElement(Element* e) { Clef* clef = static_cast<Clef*>(e); Segment* segment = clef->segment(); iElement->setElement(clef); iSegment->setElement(segment); }
void InspectorClef::apply() { Clef* clef = static_cast<Clef*>(inspector->element()); Score* score = clef->score(); score->startCmd(); iElement->apply(); iSegment->apply(); score->setLayoutAll(true); score->endCmd(); mscore->endCmd(); }
SetClefCommand::SetClefCommand(MusicShape* shape, Bar* bar, Staff* staff, Clef::ClefShape clefShape, int line, int octaveChange) : m_shape(shape), m_bar(bar), m_clef(new Clef(staff, 0, clefShape, line, octaveChange)), m_oldClef(NULL) { setText(i18nc("(qtundo-format)", "Change clef")); for (int i = 0; i < bar->staffElementCount(staff); i++) { Clef* c = dynamic_cast<Clef*>(bar->staffElement(staff, i)); if (c && c->startTime() == 0) { m_oldClef = c; break; } } }
void NoteEntryAction::mousePress(Staff* staff, int bar, const QPointF& pos) { Clef* clef = staff->lastClefChange(bar); Voice* voice = staff->part()->voice(m_tool->voice()); VoiceBar* vb = voice->bar(bar); // find element before which to insert the chord int before = 0; for (int i = 0; i < vb->elementCount(); i++) { VoiceElement* e = vb->element(i); if (e->x() >= pos.x()) break; before++; } int line = staff->line(pos.y()); int pitch = 0, accidentals = 0; if (clef && !m_isRest) { pitch = clef->lineToPitch(line); // get correct accidentals for note KeySignature* ks = staff->lastKeySignatureChange(bar); if (ks) accidentals = ks->accidentals(pitch); for (int i = 0; i < before; i++) { Chord* c = dynamic_cast<Chord*>(vb->element(i)); if (!c) continue; for (int n = 0; n < c->noteCount(); n++) { if (c->note(n)->pitch() == pitch) { accidentals = c->note(n)->accidentals(); } } } } Chord* join = NULL; if (before > 0) join = dynamic_cast<Chord*>(vb->element(before-1)); if (join && join->x() + join->width() >= pos.x()) { if (clef && !m_isRest) { m_tool->addCommand(new AddNoteCommand(m_tool->shape(), join, staff, m_duration, pitch, accidentals)); } else { m_tool->addCommand(new MakeRestCommand(m_tool->shape(), join)); } } else { if (clef && !m_isRest) { m_tool->addCommand(new CreateChordCommand(m_tool->shape(), vb, staff, m_duration, before, pitch, accidentals)); } else { m_tool->addCommand(new CreateChordCommand(m_tool->shape(), vb, staff, m_duration, before)); } } }
bool MusicXMLImportHelper::insertClef(const Clef &clef, int number) { if (number > 0) { QString staff; staff.setNum(number); setStaff(staff); m_segments[m_staff+"/"+m_voice]->insert(clef.getAsEvent(m_curTime)); } else { for (TrackMap::iterator i = m_tracks.begin(); i != m_tracks.end(); ++i) { m_segments[(*i).first+"/"+m_mainVoice[m_staff]]->insert(clef.getAsEvent(m_curTime)); } } return true; }
Clef *ScoreOrStaffDefAttrInterface::GetClefCopy() const { // we should not call it without having checked if a clef is set if (!m_clef) return NULL; Clef *copy = NULL; Clef *current_clef = dynamic_cast<Clef*>(m_clef); if (current_clef) { copy = new Clef(*current_clef); } else { ClefAttr *current_attr = dynamic_cast<ClefAttr*>(m_clef); copy = new Clef(current_attr); } assert(copy); copy->SetScoreOrStaffDefAttr(true); return copy; }
void MuseScore::clefMenu() { if (clefPalette == 0) { Palette* sp = new Palette; sp->setGrid(60, 80); sp->resize(360, 400); clefPalette = new PaletteScrollArea(sp); clefPalette->setRestrictHeight(false); clefPalette->setWindowTitle(tr("MuseScore: Clefs")); for (int i = 0; i < CLEF_MAX; ++i) { Clef* k = new ::Clef(gscore); k->setClefType(ClefType(i)); sp->append(k, qApp->translate("clefTable", clefTable[i].name)); } } clefPalette->show(); clefPalette->raise(); }
Palette* MuseScore::newClefsPalette() { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "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)); } return sp; }
Palette* MuseScore::newClefsPalette() { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Clefs")); sp->setMag(0.8); sp->setGrid(33, 60); sp->setYOffset(1.0); // Up to ClefType::MAX-1, because ClefType::PERC2 is no longer supported static const ClefType clefs[int(ClefType::MAX)-1] = { ClefType::G, ClefType::G1, ClefType::G2, ClefType::G3, ClefType::G4, ClefType::C1, ClefType::C2, ClefType::C3, ClefType::C4, ClefType::C5, ClefType::F, ClefType::F_8VA, ClefType::F_15MA, ClefType::F8, ClefType::F15, ClefType::F_B, ClefType::F_C, ClefType::PERC, ClefType::TAB, ClefType::TAB2 }; for (int i = 0; i < int(ClefType::MAX)-1; ++i) { ClefType j = clefs[i]; Clef* k = new Ms::Clef(gscore); k->setClefType(ClefTypeList(j, j)); sp->append(k, qApp->translate("clefTable", ClefInfo::name(j))); } return sp; }
void NoteEntryAction::keyPress(QKeyEvent* event, const MusicCursor& cursor) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { Staff* staff = cursor.staff(); //Part* part = staff->part(); //Sheet* sheet = part->sheet(); //Bar* bar = sheet->bar(cursor.bar()); Clef* clef = staff->lastClefChange(cursor.bar()); int line = cursor.line(); int pitch = 0, accidentals = 0; VoiceBar* vb = cursor.voiceBar(); if (clef) { pitch = clef->lineToPitch(line); // get correct accidentals for note KeySignature* ks = staff->lastKeySignatureChange(cursor.bar()); if (ks) accidentals = ks->accidentals(pitch); for (int i = 0; i < cursor.element(); i++) { Chord* c = dynamic_cast<Chord*>(vb->element(i)); if (!c) continue; for (int n = 0; n < c->noteCount(); n++) { if (c->note(n)->pitch() == pitch) { accidentals = c->note(n)->accidentals(); } } } } Chord* join = 0; if (cursor.element() < vb->elementCount()) join = dynamic_cast<Chord*>(vb->element(cursor.element())); if (event->modifiers() & Qt::ShiftModifier || !join) { m_tool->addCommand(new CreateChordCommand(m_tool->shape(), vb, staff, m_duration, cursor.element(), pitch, accidentals)); } else { m_tool->addCommand(new AddNoteCommand(m_tool->shape(), join, staff, join->duration(), pitch, accidentals)); } event->accept(); } }
Palette* MuseScore::newClefsPalette(bool basic) { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Clefs")); sp->setMag(0.8); sp->setGrid(33, 60); sp->setYOffset(1.0); // Up to ClefType::MAX-1, because ClefType::PERC2 is no longer supported static std::vector<ClefType> clefs1 { ClefType::G, ClefType::F, ClefType::C3, ClefType::C4 }; static std::vector<ClefType> clefs2 { ClefType::G, ClefType::G1, ClefType::G2, ClefType::G3, ClefType::G5, ClefType::G4, ClefType::C1, ClefType::C2, ClefType::C3, ClefType::C4, ClefType::C5, ClefType::F, ClefType::F_8VA, ClefType::F_15MA, ClefType::F8, ClefType::F15, ClefType::F_B, ClefType::F_C, ClefType::PERC, ClefType::TAB, ClefType::TAB2 }; for (ClefType j : basic ? clefs1 : clefs2) { Clef* k = new Ms::Clef(gscore); k->setClefType(ClefTypeList(j, j)); sp->append(k, qApp->translate("clefTable", ClefInfo::name(j))); } return sp; }
void TestClefCourtesy::clef_courtesy02() { Score* score = readScore(DIR + "clef_courtesy02.mscx"); score->doLayout(); // 'go' to 4th measure Measure* m1 = score->firstMeasure(); for (int i=0; i < 3; i++) m1 = m1->nextMeasure(); // make a clef-drop object and drop it to the measure Clef* clef = new Clef(score); // create a new element, as Measure::drop() will eventually delete it clef->setClefType(ClefType::G1); DropData dropData; dropData.pos = m1->pagePos(); dropData.element = clef; m1->drop(dropData); // 'go' to 7th measure Measure* m2 = m1; for (int i=0; i < 3; i++) m2 = m2->nextMeasure(); // make a clef-drop object and drop it to the measure clef = new Clef(score); // create a new element, as Measure::drop() will eventually delete it clef->setClefType(ClefType::G); dropData.pos = m2->pagePos(); dropData.element = clef; m2->drop(dropData); score->doLayout(); // check both clef elements are there, but none is shown Clef* clefCourt = nullptr; Measure* m = m1->prevMeasure(); Segment* seg = m->findSegment(SegmentType::Clef, m1->tick()); QVERIFY2(seg != nullptr, "No SegClef in measure 3."); clefCourt = static_cast<Clef*>(seg->element(0)); QVERIFY2(clefCourt != nullptr, "No courtesy clef element in measure 3."); QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden."); clefCourt = nullptr; m = m2->prevMeasure(); seg = m->findSegment(SegmentType::Clef, m2->tick()); QVERIFY2(seg != nullptr, "No SegClef in measure 6."); clefCourt = static_cast<Clef*>(seg->element(0)); QVERIFY2(clefCourt != nullptr, "No courtesy clef element in measure 6."); QVERIFY2(clefCourt->bbox().width() == 0, "Courtesy clef in measure 3 is NOT hidden."); QVERIFY(saveCompareScore(score, "clef_courtesy02.mscx", DIR + "clef_courtesy02-ref.mscx")); delete score; }
void GuitarPro5::readTracks() { for (int i = 0; i < staves; ++i) { int tuning[GP_MAX_STRING_NUMBER]; Staff* staff = score->staff(i); Part* part = staff->part(); uchar c = readUChar(); // simulations bitmask if (c & 0x2) { // 12 stringed guitar } if (c & 0x4) { // banjo track } if (i == 0 || version == 500) skip(1); QString name = readPascalString(40); int strings = readInt(); if (strings <= 0 || strings > GP_MAX_STRING_NUMBER) throw GuitarProError::GP_BAD_NUMBER_OF_STRINGS ; for (int j = 0; j < strings; ++j) { tuning[j] = readInt(); } for (int j = strings; j < GP_MAX_STRING_NUMBER; ++j) readInt(); /*int midiPort =*/ readInt(); // -1 int midiChannel = readInt() - 1; /*int midiChannel2 =*/ readInt(); // -1 int frets = readInt(); int capo = readInt(); /*int color =*/ readInt(); skip(version > 500 ? 49 : 44); if (version > 500) { // british stack clean / amp tone readDelphiString(); readDelphiString(); } int tuning2[strings]; for (int k = 0; k < strings; ++k) tuning2[strings-k-1] = tuning[k]; StringData stringData(frets, strings, tuning2); Instrument* instr = part->instr(); instr->setStringData(stringData); part->setPartName(name); part->setLongName(name); instr->setTranspose(Interval(capo)); // // determine clef // int patch = channelDefaults[midiChannel].patch; ClefType clefId = ClefType::G; if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) { clefId = ClefType::PERC; // instr->setUseDrumset(DrumsetKind::GUITAR_PRO); instr->setDrumset(gpDrumset); staff->setStaffType(StaffType::preset(StaffTypes::PERC_DEFAULT)); } else if (patch >= 24 && patch < 32) clefId = ClefType::G3; else if (patch >= 32 && patch < 40) clefId = ClefType::F8; Measure* measure = score->firstMeasure(); Clef* clef = new Clef(score); clef->setClefType(clefId); clef->setTrack(i * VOICES); Segment* segment = measure->getSegment(Segment::Type::Clef, 0); segment->add(clef); Channel& ch = instr->channel(0); if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) { ch.program = 0; ch.bank = 128; } else { ch.program = patch; ch.bank = 0; } ch.volume = channelDefaults[midiChannel].volume; ch.pan = channelDefaults[midiChannel].pan; ch.chorus = channelDefaults[midiChannel].chorus; ch.reverb = channelDefaults[midiChannel].reverb; //qDebug("default2: %d", channelDefaults[i].reverb); // missing: phase, tremolo ch.updateInitList(); } skip(version == 500 ? 2 : 1); }
bool MuseScore::importPdf(Score* score, const QString& path) { Omr* omr = new Omr(path, score); if (!omr->readPdf()) { delete omr; return false; } score->setOmr(omr); qreal sp = omr->spatiumMM(); if (sp == 0.0) sp = 1.5; score->setSpatium(sp * DPMM); score->style()->set(StyleVal(ST_pageFillLimit, 1.0)); score->style()->set(StyleVal(ST_lastSystemFillLimit, 0.0)); score->style()->set(StyleVal(ST_staffLowerBorder, 0.0)); score->style()->set(StyleVal(ST_measureSpacing, 1.0)); PageFormat pF(*score->pageFormat()); pF.setEvenLeftMargin(5.0 * DPMM / DPI); pF.setEvenTopMargin(0); pF.setEvenBottomMargin(0); pF.setOddLeftMargin(5.0 * DPMM / DPI); pF.setOddTopMargin(0); pF.setOddBottomMargin(0); score->setPageFormat(pF); score->style()->set(StyleVal(ST_systemDistance, Spatium(omr->systemDistance()))); score->style()->set(StyleVal(ST_akkoladeDistance, Spatium(omr->staffDistance()))); Part* part = new Part(score); Staff* staff = new Staff(score, part, 0); part->staves()->push_back(staff); score->staves().insert(0, staff); staff = new Staff(score, part, 1); part->staves()->push_back(staff); score->staves().insert(1, staff); part->staves()->front()->setBarLineSpan(part->nstaves()); score->insertPart(part, 0); TDuration d(TDuration::V_MEASURE); Measure* measure = 0; int tick = 0; foreach(const OmrPage* omrPage, omr->pages()) { int nsystems = omrPage->systems().size(); int n = nsystems == 0 ? 1 : nsystems; for (int k = 0; k < n; ++k) { int numMeasures = 1; if (k < nsystems) { const OmrSystem& omrSystem = omrPage->systems().at(k); numMeasures = omrSystem.barLines.size() - 1; if (numMeasures < 1) numMeasures = 1; else if (numMeasures > 50) // sanity check numMeasures = 50; } for (int i = 0; i < numMeasures; ++i) { measure = new Measure(score); measure->setTick(tick); Rest* rest = new Rest(score, d); rest->setDuration(Fraction(4,4)); rest->setTrack(0); Segment* s = measure->getSegment(SegChordRest, tick); s->add(rest); rest = new Rest(score, d); rest->setDuration(Fraction(4,4)); rest->setTrack(4); s->add(rest); score->measures()->add(measure); tick += MScore::division * 4; } if (k < (nsystems-1)) { LayoutBreak* b = new LayoutBreak(score); b->setSubtype(LAYOUT_BREAK_LINE); measure->add(b); } } if (measure) { LayoutBreak* b = new LayoutBreak(score); b->setSubtype(LAYOUT_BREAK_PAGE); measure->add(b); } } //---create bracket score->staff(0)->setBracket(0, BRACKET_AKKOLADE); score->staff(0)->setBracketSpan(0, 2); //---create clefs measure = score->firstMeasure(); if (measure) { Clef* clef = new Clef(score); clef->setClefType(CLEF_G); clef->setTrack(0); Segment* segment = measure->getSegment(SegClef, 0); segment->add(clef); clef = new Clef(score); clef->setClefType(CLEF_F); clef->setTrack(4); segment->add(clef); } score->setShowOmr(true); omr->page(0)->readHeader(score); score->rebuildMidiMapping(); return true; }
int Layer::GetClefLocOffset(LayerElement *test) { Clef *clef = GetClef(test); if (!clef) return 0; return clef->GetClefLocOffset(); }
void MTrack::convertTrack(const Fraction &lastTick) { Score* score = staff->score(); int key = 0; // TODO-LIB findKey(mtrack, score->sigmap()); int track = staff->idx() * VOICES; int voices = VOICES; for (int voice = 0; voice < voices; ++voice) { // startChordTick is onTime value of all simultaneous notes // chords here are consist of notes with equal durations // several chords may have the same onTime value Fraction startChordTick; QList<MidiChord> midiChords; for (auto it = chords.begin(); it != chords.end();) { const Fraction &nextChordTick = it->first; const MidiChord& midiChord = it->second; if (midiChord.voice != voice) { ++it; continue; } processPendingNotes(midiChords, voice, startChordTick, nextChordTick); // now 'midiChords' list is empty // so - fill it: // collect all midiChords on current tick position startChordTick = nextChordTick; // debug for (;it != chords.end(); ++it) { const MidiChord& midiChord = it->second; if (it->first != startChordTick) break; if (midiChord.voice != voice) continue; midiChords.append(midiChord); } if (midiChords.isEmpty()) break; } // process last chords at the end of the score processPendingNotes(midiChords, voice, startChordTick, lastTick); } createTuplets(track, score); KeyList* km = staff->keymap(); if (!hasKey && !mtrack->drumTrack()) { KeySigEvent ks; ks.setAccidentalType(key); (*km)[0] = ks; } for (auto it = km->begin(); it != km->end(); ++it) { int tick = it->first; KeySigEvent key = it->second; KeySig* ks = new KeySig(score); ks->setTrack(track); ks->setGenerated(false); ks->setKeySigEvent(key); ks->setMag(staff->mag()); Measure* m = score->tick2measure(tick); Segment* seg = m->getSegment(ks, tick); seg->add(ks); } #if 0 // TODO ClefList* cl = staff->clefList(); for (ciClefEvent i = cl->begin(); i != cl->end(); ++i) { int tick = i.key(); Clef* clef = new Clef(score); clef->setClefType(i.value()); clef->setTrack(track); clef->setGenerated(false); clef->setMag(staff->mag()); Measure* m = score->tick2measure(tick); Segment* seg = m->getSegment(clef, tick); seg->add(clef); } #endif }
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 ContinuousPanel::draw(QPainter& painter, const QList<Element*>& el) { painter.save(); painter.setRenderHint(QPainter::Antialiasing, preferences.antialiasedDrawing); painter.setRenderHint(QPainter::TextAntialiasing, true); // Draw colored rectangle painter.setClipping(false); QPointF pos(_offsetPanel, 0); painter.translate(pos); QPen pen; pen.setWidthF(0.0); pen.setStyle(Qt::NoPen); painter.setPen(pen); painter.setBrush(preferences.fgColor); QRectF bg(_rect); bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding); QPixmap* fgPixmap = _sv->fgPixmap(); if (fgPixmap == 0 || fgPixmap->isNull()) painter.fillRect(bg, preferences.fgColor); else { painter.setMatrixEnabled(false); painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft() - QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy()))); painter.setMatrixEnabled(true); } painter.setClipRect(_rect); painter.setClipping(true); QColor color(MScore::layoutBreakColor); // Draw measure text number QString text = _mmRestCount ? QString("#%1-%2").arg(_currentMeasureNo+1).arg(_currentMeasureNo+_mmRestCount) : QString("#%1").arg(_currentMeasureNo+1); Text* newElement = new Text(_score); newElement->setTextStyleType(TextStyleType::DEFAULT); newElement->setFlag(ElementFlag::MOVABLE, false); newElement->setXmlText(text); newElement->textStyle().setFamily("FreeSans"); newElement->textStyle().setSizeIsSpatiumDependent(true); newElement->setColor(color); newElement->sameLayout(); pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height()); painter.translate(pos); newElement->draw(&painter); pos += QPointF(_offsetPanel, 0); painter.translate(-pos); delete newElement; // This second pass draws the elements spaced evently using the width of the largest element for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible()) { if (_score->printing() || !_score->showInvisible()) continue; } if (e->type() == Element::Type::STAFF_LINES) { Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segmentMM(_currentMeasureTick); pos = QPointF (_offsetPanel, e->pagePos().y()); painter.translate(pos); // Draw staff lines StaffLines* newStaffLines = static_cast<StaffLines*>(e->clone()); newStaffLines->setWidth(bg.width()); newStaffLines->setParent(parent); newStaffLines->setTrack(e->track()); newStaffLines->layout(); newStaffLines->setColor(color); newStaffLines->draw(&painter); delete newStaffLines; // Draw barline BarLine* newBarLine = new BarLine(_score); newBarLine->setBarLineType(BarLineType::NORMAL); newBarLine->setParent(parent); newBarLine->setTrack(e->track()); newBarLine->setSpan(currentStaff->barLineSpan()); newBarLine->setSpanFrom(currentStaff->barLineFrom()); newBarLine->setSpanTo(currentStaff->barLineTo()); newBarLine->layout(); newBarLine->setColor(color); newBarLine->draw(&painter); delete newBarLine; // Draw the current staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->setColor(color); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); if (currentStaff->part()->staff(0) == currentStaff) { double _spatium = _score->spatium(); pos = QPointF (_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, 0 - _spatium * 2); painter.translate(pos); newName->draw(&painter); painter.translate(-pos); } delete newName; // Draw the current Clef Clef* newClef = new Clef(_score); ClefType currentClef = currentStaff->clef(_currentMeasureTick); newClef->setClefType(currentClef); newClef->setParent(parent); newClef->setTrack(e->track()); newClef->setColor(color); newClef->layout(); pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin), 0); painter.translate(pos); newClef->draw(&painter); pos = QPointF(_widthClef,0); painter.translate(pos); delete newClef; // Draw the current KeySignature KeySig* newKs = new KeySig(_score); KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(_currentMeasureTick); newKs->setKeySigEvent(currentKeySigEvent); // The Parent and the track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs->setParent(parent); newKs->setTrack(e->track()); newKs->setColor(color); newKs->setHideNaturals(true); pos = QPointF(_score->styleP(StyleIdx::keysigLeftMargin),0); painter.translate(pos); newKs->layout(); newKs->draw(&painter); delete newKs; pos = QPointF(_widthKeySig + _xPosTimeSig, 0); painter.translate(pos); // Draw the current TimeSignature TimeSig* newTs = new TimeSig(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(_currentMeasureTick); if (currentTimeSig) { newTs->setFrom(currentTimeSig); newTs->setParent(parent); newTs->setTrack(e->track()); newTs->setColor(color); newTs->layout(); pos = QPointF(_score->styleP(StyleIdx::timesigLeftMargin),0); painter.translate(pos); newTs->draw(&painter); delete newTs; } pos = QPointF(_offsetPanel + _widthClef + _widthKeySig + _xPosTimeSig + _leftMarginTotal, e->pagePos().y()); painter.translate(-pos); } } painter.restore(); }
void MsScWriter::beginMeasure(const Bww::MeasureBeginFlags mbf) { qDebug() << "MsScWriter::beginMeasure()"; ++measureNumber; // create a new measure currentMeasure = new Measure(score); currentMeasure->setTick(tick); currentMeasure->setTimesig(Fraction(beats, beat)); currentMeasure->setNo(measureNumber); score->measures()->add(currentMeasure); if (mbf.repeatBegin) currentMeasure->setRepeatFlags(RepeatStart); if (mbf.irregular) currentMeasure->setIrregular(true); if (mbf.endingFirst || mbf.endingSecond) { Volta* volta = new Volta(score); volta->setTrack(0); volta->endings().clear(); if (mbf.endingFirst) { volta->setText("1"); volta->endings().append(1); ending = 1; } else { volta->setText("2"); volta->endings().append(2); ending = 2; } volta->setStartElement(currentMeasure); currentMeasure->add(volta); lastVolta = volta; } // set clef, key and time signature in the first measure if (measureNumber == 1) { // clef Clef* clef = new Clef(score); clef->setClefType(CLEF_G); clef->setTrack(0); Segment* s = currentMeasure->getSegment(clef, tick); s->add(clef); // keysig KeySigEvent key; key.setAccidentalType(2); KeySig* keysig = new KeySig(score); keysig->setKeySigEvent(key); keysig->setTrack(0); s = currentMeasure->getSegment(keysig, tick); s->add(keysig); // timesig TimeSig* timesig = new TimeSig(score); timesig->setSig(Fraction(beats, beat)); timesig->setTrack(0); s = currentMeasure->getSegment(timesig, tick); s->add(timesig); } }
void ContinuousPanel::paint(const QRect&, QPainter& painter) { qreal _offsetPanel = 0; qreal _y = 0; qreal _oldWidth = 0; // The last final panel width qreal _newWidth = 0; // New panel width qreal _height = 0; qreal _leftMarginTotal = 0; // Sum of all elments left margin qreal _panelRightPadding = 5; // Extra space for the panel after last element Measure* measure = _score->firstMeasure(); if (!_active || !measure) { _visible = false; return; } if (measure->mmRest()) { measure = measure->mmRest(); } System* system = measure->system(); if (system == 0) { _visible = false; return; } Segment* s = measure->first(); double _spatium = _score->spatium(); if (_width <= 0) _width = s->x(); // // Set panel height for whole system // _height = 6 * _spatium; _y = system->staffYpage(0) + system->page()->pos().y(); double y2 = 0.0; for (int i = 0; i < _score->nstaves(); ++i) { SysStaff* ss = system->staff(i); if (!ss->show() || !_score->staff(i)->show()) continue; y2 = ss->y() + ss->bbox().height(); } _height += y2 + 6*_spatium; _y -= 6 * _spatium; // // Check elements at current panel position // _offsetPanel = -(_sv->xoffset()) / _sv->mag(); _rect = QRect(_offsetPanel + _width, _y, 1, _height); Page* page = _score->pages().front(); QList<Element*> el = page->items(_rect); if (el.empty()) { _visible = false; return; } qStableSort(el.begin(), el.end(), elementLessThan); const Measure*_currentMeasure = 0; for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible() && !_score->showInvisible()) continue; if (e->isMeasure()) { _currentMeasure = toMeasure(e); break; } } if (!_currentMeasure) return; // Don't show panel if staff names are visible if (_currentMeasure == _score->firstMeasure() && _sv->toPhysical(_currentMeasure->canvasPos()).x() > 0) { _visible = false; return; } qreal _xPosMeasure = _currentMeasure->canvasX(); qreal _measureWidth = _currentMeasure->width(); int tick = _currentMeasure->tick(); Fraction _currentTimeSig = _currentMeasure->timesig(); //qDebug() << "_sv->xoffset()=" <<_sv->xoffset() << " _sv->mag()="<< _sv->mag() <<" s->x=" << s->x() << " width=" << _width << " currentMeasure=" << _currentMeasure->x() << " _xPosMeasure=" << _xPosMeasure; //--------------------------------------------------------- // findElementWidths // determines the max width for each element types //--------------------------------------------------------- // The first pass serves to get the maximum width for each elements qreal lineWidthName = 0; qreal _widthClef = 0; qreal _widthKeySig = 0; qreal _widthTimeSig = 0; qreal _xPosTimeSig = 0; for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible() && !_score->showInvisible()) continue; if (e->isRest() && toRest(e)->isGap()) continue; if (e->isStaffLines()) { Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segment(tick); // Find maximum width for the staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); // Find maximum width for the current Clef Clef* newClef = new Clef(_score); ClefType currentClef = currentStaff->clef(tick); newClef->setClefType(currentClef); newClef->setParent(parent); newClef->setTrack(e->track()); newClef->layout(); if (newClef->width() > _widthClef) _widthClef = newClef->width(); // Find maximum width for the current KeySignature KeySig* newKs = new KeySig(_score); KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(tick); newKs->setKeySigEvent(currentKeySigEvent); // The Parent and the Track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs->setParent(parent); newKs->setTrack(e->track()); newKs->setHideNaturals(true); newKs->layout(); if (newKs->width() > _widthKeySig) _widthKeySig = newKs->width(); // Find maximum width for the current TimeSignature TimeSig* newTs = new TimeSig(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(tick); if (currentTimeSig) newTs->setFrom(currentTimeSig); else newTs->setSig(Fraction(_currentTimeSig.numerator(), _currentTimeSig.denominator()), TimeSigType::NORMAL); newTs->setParent(parent); newTs->setTrack(e->track()); newTs->layout(); if ((newName->width() > lineWidthName) && (newName->xmlText() != "")) lineWidthName = newName->width(); if (newTs->width() > _widthTimeSig) _widthTimeSig = newTs->width(); delete newClef; delete newName; delete newKs; delete newTs; } } _leftMarginTotal = _score->styleP(StyleIdx::clefLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::keysigLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::timesigLeftMargin); _newWidth = _widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding; _xPosMeasure -= _offsetPanel; lineWidthName += _score->spatium() + _score->styleP(StyleIdx::clefLeftMargin) + _widthClef; if (_newWidth < lineWidthName) { _newWidth = lineWidthName; _oldWidth = 0; } if (_oldWidth == 0) { _oldWidth = _newWidth; _width = _newWidth; } else if (_newWidth > 0) { if (_newWidth == _width) { _oldWidth = _width; _width = _newWidth; } else if (((_xPosMeasure <= _newWidth) && (_xPosMeasure >= _oldWidth)) || ((_xPosMeasure >= _newWidth) && (_xPosMeasure <= _oldWidth))) _width = _xPosMeasure; else if (((_xPosMeasure+_measureWidth <= _newWidth) && (_xPosMeasure+_measureWidth >= _oldWidth)) || ((_xPosMeasure+_measureWidth >= _newWidth) && (_xPosMeasure+_measureWidth <= _oldWidth))) _width = _xPosMeasure+_measureWidth; else { _oldWidth = _width; _width = _newWidth; } } _rect = QRect(0, _y, _width, _height); //==================== painter.save(); // Draw colored rectangle painter.setClipping(false); QPointF pos(_offsetPanel, 0); painter.translate(pos); QPen pen; pen.setWidthF(0.0); pen.setStyle(Qt::NoPen); painter.setPen(pen); painter.setBrush(preferences.fgColor); QRectF bg(_rect); bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding); QPixmap* fgPixmap = _sv->fgPixmap(); if (fgPixmap == 0 || fgPixmap->isNull()) painter.fillRect(bg, preferences.fgColor); else { painter.setMatrixEnabled(false); painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft() - QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy()))); painter.setMatrixEnabled(true); } painter.setClipRect(_rect); painter.setClipping(true); QColor color(MScore::layoutBreakColor); // Draw measure text number QString text = QString("#%1").arg(_currentMeasure->no()+1); Text* newElement = new Text(_score); newElement->setTextStyleType(TextStyleType::DEFAULT); newElement->setFlag(ElementFlag::MOVABLE, false); newElement->setXmlText(text); newElement->textStyle().setFamily("FreeSans"); newElement->textStyle().setSizeIsSpatiumDependent(true); newElement->setColor(color); newElement->sameLayout(); pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height()); painter.translate(pos); newElement->draw(&painter); pos += QPointF(_offsetPanel, 0); painter.translate(-pos); delete newElement; // This second pass draws the elements spaced evently using the width of the largest element for (const Element* e : el) { if (!e->visible() && !_score->showInvisible()) continue; if (e->isRest() && toRest(e)->isGap()) continue; if (e->isStaffLines()) { painter.save(); Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segmentMM(tick); pos = QPointF (_offsetPanel, e->pagePos().y()); painter.translate(pos); // Draw staff lines StaffLines newStaffLines(*toStaffLines(e)); newStaffLines.setParent(parent); newStaffLines.setTrack(e->track()); newStaffLines.layout(); newStaffLines.setColor(color); newStaffLines.setWidth(bg.width()); newStaffLines.draw(&painter); // Draw barline BarLine barLine(_score); barLine.setBarLineType(BarLineType::NORMAL); barLine.setParent(parent); barLine.setTrack(e->track()); barLine.setSpan(currentStaff->barLineSpan()); barLine.setSpanFrom(currentStaff->barLineFrom()); barLine.setSpanTo(currentStaff->barLineTo()); barLine.layout(); barLine.setColor(color); barLine.draw(&painter); // Draw the current staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->setColor(color); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); if (currentStaff->part()->staff(0) == currentStaff) { double _spatium = _score->spatium(); pos = QPointF (_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, -_spatium * 2); painter.translate(pos); newName->draw(&painter); painter.translate(-pos); } delete newName; qreal posX = 0.0; // Draw the current Clef Clef clef(_score); clef.setClefType(currentStaff->clef(tick)); clef.setParent(parent); clef.setTrack(e->track()); clef.setColor(color); clef.layout(); posX += _score->styleP(StyleIdx::clefLeftMargin); clef.drawAt(&painter, QPointF(posX, clef.pos().y())); posX += _widthClef; // Draw the current KeySignature KeySig newKs(_score); newKs.setKeySigEvent(currentStaff->keySigEvent(tick)); // The Parent and the track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs.setParent(parent); newKs.setTrack(e->track()); newKs.setColor(color); newKs.setHideNaturals(true); newKs.layout(); posX += _score->styleP(StyleIdx::keysigLeftMargin); newKs.drawAt(&painter, QPointF(posX, 0.0)); posX += _widthKeySig + _xPosTimeSig; // Draw the current TimeSignature TimeSig newTs(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(tick); if (currentTimeSig) { newTs.setFrom(currentTimeSig); newTs.setParent(parent); newTs.setTrack(e->track()); newTs.setColor(color); newTs.layout(); posX += _score->styleP(StyleIdx::timesigLeftMargin); newTs.drawAt(&painter, QPointF(posX, 0.0)); } painter.restore(); } } painter.restore(); _visible = true; }
void AbstractNoteMusicAction::mousePress(Staff* staff, int barIdx, const QPointF& pos) { Part* part = staff->part(); Sheet* sheet = part->sheet(); Bar* bar = sheet->bar(barIdx); Clef* clef = staff->lastClefChange(barIdx, 0); // loop over all noteheads qreal closestDist = 1e9; Note* closestNote = 0; Chord* chord = 0; // outer loop, loop over all voices for (int v = 0; v < part->voiceCount(); v++) { Voice* voice = part->voice(v); VoiceBar* vb = voice->bar(bar); // next loop over all chords for (int e = 0; e < vb->elementCount(); e++) { Chord* c = dynamic_cast<Chord*>(vb->element(e)); if (!c) continue; qreal centerX = c->x() + (c->width() / 2); // check if it is a rest if (c->noteCount() == 0) { qreal centerY = c->y() + (c->height() / 2); qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y())); if (dist < closestDist) { closestDist = dist; closestNote = NULL; chord = c; } } // lastly loop over all noteheads for (int n = 0; n < c->noteCount(); n++) { Note* note = c->note(n); if (note->staff() != staff) continue; int line = clef->pitchToLine(note->pitch()); qreal centerY = line * staff->lineSpacing() / 2; qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y())); if (dist < closestDist) { closestDist = dist; closestNote = note; chord = c; } } } } StaffElement* se = 0; for (int e = 0; e < bar->staffElementCount(staff); e++) { StaffElement* elem = bar->staffElement(staff, e); qreal centerX = elem->x() + (elem->width() / 2); qreal centerY = elem->y() + (elem->height() / 2); qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y())); if (dist < closestDist) { se = elem; closestDist = dist; } } if (se) { mousePress(se, closestDist, pos); } else { mousePress(chord, closestNote, closestDist, pos); } }
Staff* CScribeToNeoScribeXML::Scribe2MEIXMLStaff(const CScribeReaderVisitable& scribe_data, const scribe_part& partit, StaffGrp* staffgrp, const int i) { std::string staffnum("s"); staffnum += std::to_string(i); //autogenerate staff ids //finish score definitions //add staff definition for current part //NB. look to alternatively embedding these in staffs StaffDef* staffdef = new StaffDef; //define staff from data staffgrp->addChild(staffdef); staffdef->addAttribute("id", staffnum); staffdef->addAttribute("lines", std::to_string(partit.initial_staff_data.staff_lines)); staffdef->addAttribute("label", CScribeCodes::voice_labels[partit.voice_type].c_str()); //define clef from data Clef* clef = new Clef; staffdef->addChild(clef); scribe_clef loc_clef; loc_clef.clef_line = partit.initial_staff_data.clef_line; loc_clef.clef = partit.initial_staff_data.clef; //convert scribe-based clef position to mei //int mei_clef_line = ((loc_clef.clef_line + 1)/2) - 1; = incorrect int mei_clef_line = 1 + (loc_clef.clef_line-3)/2; //4-line staves are numbered 3, 5, 7, 9 in scribe //if (partit->staff_lines<=4) mei_clef_line -= (5 - partit->staff_lines); clef->addAttribute("line", std::to_string(mei_clef_line)); //these need to be set for each staff/part clef->addAttribute("shape", std::string(&(partit.initial_staff_data.clef),1).c_str()); //the first event in stored memory should be the initial clef Staff* staff = new Staff; staff->addAttribute("id", staffnum); staff->addAttribute("source", partit.abbrev_ms); //folio on which part appears Pb* pb = new Pb; //new ELEMENT? staff->addChild(pb); pb->addAttribute("n", partit.folios); //first staff on which part appears Sb* sb = new Sb; sb->addAttribute("n", "0"); //set to "0" since this isn't encoded in scribe; data will need to be enhanced later staff->addChild(sb); coloration_type current_color = coloration_type::full_black; // this needs to be better handled with a default coloration in a part for (std::vector<scribe_row>::const_iterator rowit = partit.rows.begin(); rowit!=partit.rows.end(); rowit++) { if (rowit->is_comment) { //check it this is the correct way to handle a comment MeiCommentNode* comment = new MeiCommentNode; comment->setValue(rowit->comment); staff->addChild(comment); //NB. syl can have a type (eg. initial) attribute and also encode color as <rend> child element } else { //syllable container (holds syllables, notes, neumes, and ligatures) Syllable* syllable = new Syllable; //neumes.h staff->addChild(syllable); //add actual syllable if present if (!rowit->syllable.empty()) { Syl* syl = new Syl; syl->setValue(rowit->syllable); syllable->addChild(syl); } //extract events - notes, rests ligatures, uneumes and/or ligatures for (std::vector<scribe_event>::const_iterator eventit = rowit->events.begin(); eventit!=rowit->events.end(); eventit++ ) { current_color = eventit->local_coloration; //use temp TiXML pointer which is either syllable, uneume/ineume or ligature - add notes to this, but make sure that uneume/inueme/ligature pointer is preinserted into syllable //handle events for each row code_t event_type = scribe_data.GetCodes()->get_code_type(eventit->code);//codes->get_code_type(eventit->code); //foster parent will change roles according to child elements that need to be added MeiElement* foster = syllable; switch (event_type) { case code_t::ineume: { #ifdef IGNOREGAPS Ineume* ineume = new Ineume; //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ineume); foster = ineume; #else //this needs work, hence excluded if (!eventit->preceding_gap || foster->getChildren().empty()) { Ineume* ineume = new Ineume; //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ineume); foster = ineume; } else { MeiElement* lastNeume = foster->getChildren().back(); if (lastNeume->getName() == "ineume") { Ineume* newNeume = new Ineume(*dynamic_cast<Ineume*>(lastNeume)); /*for (std::vector<MeiElement*>::const_iterator child = lastNeume->getChildren().begin(); child!=lastNeume->getChildren().end(); child++ ) { MeiElement* clone = new MeiElement(**child); newNeume->addChild(clone); }*/ foster->removeChild(lastNeume); foster->addChild(newNeume); //delete lastNeume; foster = newNeume; } else foster = lastNeume; } #endif goto do_note; break; } case code_t::uneume: { Uneume* uneume = new Uneume; uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(uneume); foster = uneume; goto do_note; break; } case code_t::ligature: { Ligature* ligature = new Ligature; //mensural.h ligature->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ligature); foster = ligature; if (current_color!=coloration_type::full_black) { switch (current_color) { case full_red: ligature->addAttribute("color", "red"); break; case void_red: ligature->addAttribute("color", "red"); ligature->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description break; case void_black: ligature->addAttribute("void", "true"); //** break; case full_blue: ligature->addAttribute("color", "blue"); break; default: break; } } //goto do_note; //break; } case code_t::note: do_note: { for (auto i = eventit->pitch_num.begin(); i!=eventit->pitch_num.end(); i++) { int note_count = 1; MeiElement* temp_foster = foster; //handle note attributes according to type if ( foster->getName()=="ineume" ) { Uneume* temp_uneume = new Uneume; //handle ineumes //find uneume names temp_uneume->addAttribute("name", CScribeReaderVisitable::get_ineume_part(eventit->code, i - eventit->pitch_num.begin(), note_count)); foster->addChild(temp_uneume); temp_foster = temp_uneume; //allow notes to be children of uneume } else if ((eventit->code=="B" || eventit->code=="V" || eventit->code=="L") && eventit->pitch_num.size()>1 && scribe_data.GetType()==chant && i!=eventit->pitch_num.begin()) //codes like virga and punctum may be followed by several pitch numbers, indicating a sequence of simple neumes { Uneume* temp_uneume = new Uneume; temp_uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->getParent()->addChild(temp_uneume); //link to syllable element, not uneume! temp_foster = temp_uneume; } //also handle ligatures auto j = 0; //insert note or notes for unneumes in ineumes for (; j < note_count ; j++) { //convert note location to pitch name // need to handle dots as element rather than attribute? char pitch_name = loc_clef.get_pitch_name(*i); int octave = loc_clef.get_octave(*i); Note* note = new Note; if (foster->getName()=="syllable") { note->addAttribute("dur", scribe_data.GetCodes()->code_to_name(eventit->code)); } else if (foster->getName()=="ligature") { note->addAttribute("dur", scribe_data.get_ligature_part(eventit->code, j)); } note->addAttribute("pname", std::string(&pitch_name,1)); note->addAttribute("oct", std::to_string(octave)); int note_loc = *i - 3; //3 is bottom line in Scribe, 0 in MEI note->addAttribute("loc", std::to_string( note_loc )); if (current_color!=coloration_type::full_black) { switch (current_color) { case full_red: note->addAttribute("color", "red"); break; case void_red: note->addAttribute("color", "red"); note->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description break; case void_black: note->addAttribute("void", "true"); //** break; case full_blue: note->addAttribute("color", "blue"); break; default: break; } } temp_foster->addChild(note); } i+=j-1; } } break; //dot needs to be handled as a unique element in our extended definition /*Stinson, 7 July 2013: Further notes on DOT The code has two arguments: the first is the substantive position on the staff; the second refines that position up or down and is capable of five variants: 0 = exactly on the line or exactly in the middle of the space between the lines; -1 = 0.1 of the space between the lines below (or for +, above) the space or line; -2= 0.2 of the space below the normal position for that line or space; -3 = 0.3 below the normal position; -4 = 0.4 below the normal position. Only values between 0 and 4 are permitted as the second argument as 5 would be the equivalent of having the dot on the next numbered line or space, e.g. '7 -5', if it were permitted, would be the same as '6 0'.*/ case code_t::dot: { Dot* dot = new Dot; char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]); int octave = loc_clef.get_octave(eventit->pitch_num[0]); dot->addAttribute("ploc", std::string(&pitch_name,1)); dot->addAttribute("oloc", std::to_string(octave)); /*vo: records the vertical adjustment of a feature's programmatically-determined location in terms of staff interline distance; that is, in units of 1/2 the distance between adjacent staff lines. (MEI2013)*/ //only set for non-defult positions if (eventit->pitch_num[1]!=0) { float v_pos = eventit->pitch_num[1]/10.0*2; dot->addAttribute("vo", to_string_with_precision(v_pos,1)); } foster->addChild(dot); } break; case code_t::rest: { Rest* rest = new Rest; foster->addChild(rest); switch (*(eventit->code.c_str())) { //rests of type 'R' has two associated pitch numbers from which we might infer the type case generic_rest: { int end = eventit->pitch_num[0]; int start = eventit->pitch_num[1]; int rest_type = start-end; switch (rest_type) { case minim_rest: rest->addAttribute("type", "minima"); break; case semibreve_rest: rest->addAttribute("type", "semibrevis"); break; case breve_rest: rest->addAttribute("type", "brevis"); break; case long_rest: rest->addAttribute("type", "longa imperfecta"); break; case perf_long_rest: rest->addAttribute("type", "long perfecta"); break; default: break; } char ploc = loc_clef.get_pitch_name(start); rest->addAttribute("ploc", std::string(&ploc,1)); rest->addAttribute("oloc", std::to_string(loc_clef.get_octave(start))); break; //also process 'RSM', semiminim rest } //case semiminim_rest: //rest->SetAttribute("type", "semiminim"); // break; default: rest->addAttribute("type", scribe_data.GetCodes()->code_to_name(eventit->code)); if (!eventit->pitch_num.empty()) { char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]); int octave = loc_clef.get_octave(eventit->pitch_num[0]); rest->addAttribute("ploc", std::string(&pitch_name,1)); rest->addAttribute("oloc", std::to_string(octave)); } break; } } break; // non-standard mensuration signs case code_t::mensuration: { Mensur* mensuration_sign = new Mensur; foster->addChild(mensuration_sign); if (eventit->code == "MO" || eventit->code == "MC" || eventit->code == "MO." || eventit->code == "MC.") { char the_sign = eventit->code[1]; mensuration_sign->addAttribute("sign", std::string(&the_sign,1)); if (eventit->code.size()==3 && eventit->code[2]=='.') { mensuration_sign->addAttribute("dot", "true"); } //also able to set attribute 'orient' to reversed for reversed signs; and slash attribute for cut signs } if (eventit->code == ".D." || eventit->code == ".Q." || eventit->code == ".SI." || eventit->code == ".P." || eventit->code == ".N." || eventit->code == ".O." || eventit->code == ".I.") //also .SG.? { //these are wholly new to the MEI schema; the whole dot-letter-dot sign is encoded mensuration_sign->addAttribute("sign", eventit->code); } break; } case code_t::barline: { BarLine* barline = new BarLine; foster->addChild(barline); if (eventit->code == "QBAR") { barline->addAttribute("rend", "quarter"); //non-standard data type for rend. } if (eventit->code == "HBAR") { barline->addAttribute("rend", "half"); } if (eventit->code == "WBAR") { barline->addAttribute("rend", "single"); } if (eventit->code == "DBAR") { barline->addAttribute("rend", "dbl"); } //modern bar editorial - ignore? if (eventit->code == "MBAR") { barline->addAttribute("barplace", "takt"); barline->addAttribute("taktplace", std::string(9,1)); } //also able to see rend attribute break; } case code_t::clef: { //NB. old clefchange element superceded; clefGrp used for simultaneous clefs loc_clef.clef_line = *(eventit->pitch_num.begin()); loc_clef.clef = *(eventit->code.c_str()); Clef* clef = new Clef; clef->addAttribute("line", std::to_string( ((loc_clef.clef_line + 1)/2) - 1)); clef->addAttribute("shape", std::string(&(loc_clef.clef),1).c_str()); foster->addChild(clef); break; } //The MEI accidental names are not used: diesis, b-rotundum and b-quadratum are. Other variants may be added. All ms accidentials in Scribe (as they should be in NeoScribe) are independent elements case code_t::accidental: { Accid* accid = new Accid; accid->addAttribute("accidental", scribe_data.GetCodes()->code_to_name(eventit->code)); if (!eventit->pitch_num.empty()) { char ploc = loc_clef.get_pitch_name(eventit->pitch_num[0]); int oloc = loc_clef.get_octave(eventit->pitch_num[0]); accid->addAttribute("ploc", std::string(&ploc,1)); accid->addAttribute("oloc", std::to_string(oloc)); } foster->addChild(accid); break; } case code_t::other: //lucunae default: break; } } } } return staff; }
void PaeInput::parsePlainAndEasy(std::istream &infile) { // buffers char c_clef[1024] = {0}; char c_key[1024] = {0}; char c_keysig[1024] = {0}; char c_timesig[1024] = {0}; char c_alttimesig[1024] = {0}; char incipit[10001] = {0}; int in_beam = 0; std::string s_key; MeasureObject current_measure; NoteObject current_note; Clef *staffDefClef = NULL; std::vector<MeasureObject> staff; // read values while (!infile.eof()) { infile.getline(data_line, 10000); if (infile.eof()) { LogDebug("Truncated file or ending tag missing"); //exit(1); } getAtRecordKeyValue(data_key, data_value, data_line); if (strcmp(data_key,"end")==0) { break; } else if (strcmp(data_key,"clef")==0) { strcpy( c_clef, data_value ); } else if (strcmp(data_key,"key")==0) { strcpy( c_key, data_value ); } else if (strcmp(data_key,"keysig")==0) { strcpy( c_keysig, data_value ); } else if (strcmp(data_key,"timesig")==0) { strcpy( c_timesig, data_value ); } else if (strcmp(data_key,"alttimesig")==0) { strcpy( c_alttimesig, data_value ); } else if (strcmp(data_key,"data")==0) { strcpy( incipit, data_value ); } } if (strlen(c_clef)) { Clef *c = new Clef; getClefInfo(c_clef, c ); // do we need to put a default clef? if (!staffDefClef) staffDefClef = c; else current_measure.clef = c; } if (strlen(c_keysig)) { KeySig *k = new KeySig(); getKeyInfo( c_keysig, k); current_measure.key = k; } if (strlen(c_timesig)) { MeterSig *meter = new MeterSig; getTimeInfo( c_timesig, meter); // What about previous values? Potential memory leak? LP current_measure.meter = meter; } // read the incipit string size_t length = strlen(incipit); int i = 0; while(i < length) { // eat the input... if (incipit[i] == ' ') { // just skip i++; } // octaves if ((incipit[i] == '\'') || (incipit[i] == ',')) { i += getOctave( incipit, ¤t_note.octave, i ); } // rhythmic values else if (isdigit(incipit[i]) != 0) { i += getDurations( incipit, ¤t_measure, i ); } //accidentals (1 = n; 2 = x; 3 = xx; 4 = b; 5 = bb) else if (incipit[i] == 'n' || incipit[i] == 'x' || incipit[i] == 'b') { i += getAccidental( incipit, ¤t_note.accidental, i ); } // // beaming starts else if (incipit[i] == '{') { //current_note.beam = 1; current_note.beam = BEAM_INITIAL; in_beam++; } // beaming ends else if (incipit[i] == '}' && in_beam > 0) { current_measure.notes[current_measure.notes.size() - 1].beam = BEAM_TERMINAL; current_note.beam = 0; in_beam--; } // slurs are read when adding the note else if (incipit[i] == '+') { } // beginning tuplets & fermatas else if (incipit[i] == '(') { i += getTupletFermata( incipit, ¤t_note, i ); } // end of tuplets else if ((incipit[i] == ';') || (incipit[i] == ')')) { i += getTupletFermataEnd( incipit, ¤t_note, i ); } // trills are read when adding the note else if (incipit[i] == 't') { } //grace notes else if ((incipit[i] == 'g') || (incipit[i] == 'q')) { i += getGraceNote( incipit, ¤t_note, i ); } // end of appogiatura else if (incipit[i] == 'r') { current_note.appoggiatura = 0; // should not have to be done, but just in case } //note and rest // getNote also creates a new note object else if (((incipit[i]-'A'>=0) && (incipit[i]-'A'<7)) || (incipit[i]=='-')) { i += getNote( incipit, ¤t_note, ¤t_measure, i ); } // whole rest else if (incipit[i] == '=') { i += getWholeRest( incipit, ¤t_measure.wholerest, i ); } // abbreviation else if (incipit[i] == '!') { i += getAbbreviation( incipit, ¤t_measure, i ); } // measure repetition else if ((incipit[i] == 'i') && staff.size() > 0) { MeasureObject last_measure = staff[staff.size() - 1]; current_measure.notes = last_measure.notes; current_measure.wholerest = last_measure.wholerest; // if old measure does not end with a tie // force the first note of the newly copied measure to be without tie // this is to prevent copying tie closes which are invalid if (last_measure.notes.size() > 0 && last_measure.notes[last_measure.notes.capacity() - 1].tie == 0) current_measure.notes[0].tie = 0; } //barLine else if ((incipit[i] == ':') || (incipit[i] == '/')) { i += getBarline(incipit, ¤t_measure.barLine, i); current_measure.abbreviation_offset = 0; // just in case... staff.push_back( current_measure ); current_measure.reset(); } //clef change else if ((incipit[i] == '%') && (i+1 < length)) { Clef *c = new Clef; i += getClefInfo(incipit, c, i + 1); // if (!staffDefClef) { staffDefClef = c; } // If there are no notes yet in the measure // attach this clef change to the measure else if (current_measure.notes.size() == 0) { // If a clef was already assigned, remove it if (current_measure.clef) delete current_measure.clef; current_measure.clef = c; } else { // as above if (current_note.clef) delete current_note.clef; current_note.clef = c; } } //time signature change else if ((incipit[i] == '@') && (i+1 < length)) { MeterSig *meter = new MeterSig; i += getTimeInfo( incipit, meter, i + 1); if (current_measure.notes.size() == 0) { if (current_measure.meter) { delete current_measure.meter; } // When will this be deleted? Potential memory leak? LP current_measure.meter = meter; } else { if (current_note.meter) { delete current_note.meter; } current_note.meter = meter; } } //key signature change else if ((incipit[i] == '$') && (i+1 < length)) { KeySig *k = new KeySig; i += getKeyInfo( incipit, k, i + 1); if (current_measure.notes.size() == 0) { if (current_measure.key) delete current_measure.key; current_measure.key = k; } else { if (current_note.key) delete current_note.key; current_note.key = k; } } i++; } // we need to add the last measure if it has no barLine at the end if (current_measure.notes.size() != 0) { //current_measure.barLine = "=-"; staff.push_back( current_measure ); current_measure.notes.clear(); } m_doc->Reset( Raw ); Page *page = new Page(); System *system = new System(); int measure_count = 1; std::vector<MeasureObject>::iterator it; for ( it = staff.begin() ; it < staff.end(); it++ ) { m_staff = new Staff( 1 ); m_measure = new Measure( true, measure_count ); m_layer = new Layer( ); m_layer->SetN( 1 ); m_staff->AddLayer(m_layer); m_measure->AddStaff( m_staff ); system->AddMeasure( m_measure ); MeasureObject obj = *it; convertMeasure( &obj ); measure_count++; } // add miniaml scoreDef StaffGrp *staffGrp = new StaffGrp(); StaffDef *staffDef = new StaffDef(); staffDef->SetN( 1 ); staffDef->SetLines(5); if (staffDefClef) { staffDef->SetClefShape(staffDefClef->GetShape()); staffDef->SetClefLine(staffDefClef->GetLine()); staffDef->SetClefDis(staffDefClef->GetDis()); staffDef->SetClefDisPlace(staffDefClef->GetDisPlace()); delete staffDefClef; } staffGrp->AddStaffDef( staffDef ); m_doc->m_scoreDef.AddStaffGrp( staffGrp ); page->AddSystem( system ); m_doc->AddPage( page ); }
void ContinuousPanel::findElementWidths(const QList<Element*>& el) { // The first pass serves to get the maximum width for each elements qreal lineWidthName = 0; _widthClef = 0; _widthKeySig = 0; _widthTimeSig = 0; _xPosTimeSig = 0; for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible()) { if (_score->printing() || !_score->showInvisible()) continue; } if (e->type() == Element::Type::STAFF_LINES) { Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segment(_currentMeasureTick); // Find maximum width for the staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); // Find maximum width for the current Clef Clef* newClef = new Clef(_score); ClefType currentClef = currentStaff->clef(_currentMeasureTick); newClef->setClefType(currentClef); newClef->setParent(parent); newClef->setTrack(e->track()); newClef->layout(); // Find maximum width for the current KeySignature KeySig* newKs = new KeySig(_score); KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(_currentMeasureTick); newKs->setKeySigEvent(currentKeySigEvent); // The Parent and the Track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs->setParent(parent); newKs->setTrack(e->track()); newKs->setHideNaturals(true); newKs->layout(); // Find maximum width for the current TimeSignature TimeSig* newTs = new TimeSig(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(_currentMeasureTick); if (currentTimeSig) newTs->setFrom(currentTimeSig); else newTs->setSig(_currentTimeSig.numerator(), _currentTimeSig.denominator(), TimeSigType::NORMAL); newTs->setParent(parent); newTs->setTrack(e->track()); newTs->layout(); if ((newName->width() > lineWidthName) && (newName->xmlText() != "")) lineWidthName = newName->width(); if (newClef->width() > _widthClef) _widthClef = newClef->width(); if (newKs->width() > _widthKeySig) _widthKeySig = newKs->width(); if (newTs->width() > _widthTimeSig) _widthTimeSig = newTs->width(); delete newClef; delete newName; delete newKs; delete newTs; } } _leftMarginTotal = _score->styleP(StyleIdx::clefLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::keysigLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::timesigLeftMargin); _newWidth = _widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding; _xPosMeasure -= _offsetPanel; lineWidthName += _score->spatium() + _score->styleP(StyleIdx::clefLeftMargin) + _widthClef; if (_newWidth < lineWidthName) { _newWidth = lineWidthName; _oldWidth = 0; } if (_oldWidth == 0) { _oldWidth = _newWidth; _width = _newWidth; } else if (_newWidth > 0) { if (_newWidth == _width) { _oldWidth = _width; _width = _newWidth; } else if (((_xPosMeasure <= _newWidth) && (_xPosMeasure >= _oldWidth)) || ((_xPosMeasure >= _newWidth) && (_xPosMeasure <= _oldWidth))) _width = _xPosMeasure; else if (((_xPosMeasure+_measureWidth <= _newWidth) && (_xPosMeasure+_measureWidth >= _oldWidth)) || ((_xPosMeasure+_measureWidth >= _newWidth) && (_xPosMeasure+_measureWidth <= _oldWidth))) _width = _xPosMeasure+_measureWidth; else { _oldWidth = _width; _width = _newWidth; } } _rect = QRect(0, _y, _width, _height); }
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); }