void TestBarline::barline02() { char msg[256]; Score* score = readScore(DIR + "barline02.mscx"); QVERIFY(score); Measure* msr = score->firstMeasure()->nextMeasure(); TimeSig* ts = new TimeSig(score); ts->setSig(Fraction(3, 4), TimeSigType::NORMAL); score->cmdAddTimeSig(msr, 0, ts, false); score->doLayout(); msr = score->firstMeasure(); int msrNo = 1; while ((msr = msr->nextMeasure())) { ++msrNo; Segment* seg = msr->findSegment(SegmentType::EndBarLine, msr->tick()+msr->ticks()); sprintf(msg, "No SegEndBarLine in measure %d.", msrNo); QVERIFY2(seg != nullptr, msg); BarLine* bar = static_cast<BarLine*>(seg->element(0)); sprintf(msg, "No barline in measure %d.", msrNo); QVERIFY2(bar != nullptr, msg); // bar line should be generated if NORMAL, except the END one at the end sprintf(msg, "Barline in measure %d changed into 'non-generated'.", msrNo); // ws: end barline is also generated // bool test = (bar->barLineType() == BarLineType::NORMAL) ? bar->generated() : !bar->generated(); bool test = bar->generated(); QVERIFY2(test, msg); } // QVERIFY(saveCompareScore(score, "barline02.mscx", DIR + "barline02-ref.mscx")); delete score; }
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords) { MCursor c; c.setTimeSig(_sig); c.createScore("score8"); c.addPart("voice"); c.move(0, 0); c.addKeySig(0); TimeSig* nts = c.addTimeSig(_sig); GroupNode node {0, 0}; Groups ng; ng.push_back(node); nts->setGroups(ng); for (int i = 0; i < n; ++i) { Chord* chord = c.addChord(67, t); int tick = chord->rtick(); chord->setBeamMode(_groups.beamMode(tick, t)); chords->push_back(chord); } c.score()->parts().front()->setLongName(""); c.score()->style()->set(ST_linearStretch, 1.1); return c.score(); }
void InspectorTimeSig::setElement() { InspectorElementBase::setElement(); TimeSig* ts = toTimeSig(inspector->element()); if (ts->generated()) t.showCourtesy->setEnabled(false); }
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords) { MCursor c; c.setTimeSig(_sig); c.createScore("score8"); c.addPart("voice"); c.move(0, 0); c.addKeySig(Key::C); TimeSig* nts = c.addTimeSig(_sig); GroupNode node {0, 0}; Groups ng; ng.push_back(node); nts->setGroups(ng); for (int i = 0; i < n; ++i) { Chord* chord = c.addChord(67, t); int tick = chord->rtick(); chord->setBeamMode(_groups.beamMode(tick, t)); chords->push_back(chord); } c.score()->pageFormat()->setEvenLeftMargin(0.0); c.score()->pageFormat()->setOddLeftMargin(0.0); c.score()->parts().front()->setLongName(""); c.score()->style().set(StyleIdx::linearStretch, 1.3); c.score()->style().set(StyleIdx::MusicalSymbolFont, QString("Bravura")); c.score()->style().set(StyleIdx::MusicalTextFont, QString("Bravura Text")); return c.score(); }
bool TimeSig::operator==(const TimeSig& ts) const { return (timeSigType() == ts.timeSigType()) && (sig().identical(ts.sig())) && (stretch() == ts.stretch()) && (groups() == ts.groups()) && (_numeratorString == ts._numeratorString) && (_denominatorString == ts._denominatorString) ; }
bool TimeSig::operator==(const TimeSig& ts) const { return (timeSigType() == ts.timeSigType()) && (sig().identical(ts.sig())) && (stretch() == ts.stretch()) && (groups() == ts.groups()) && (customText == ts.customText) && (!customText || (_numeratorString == ts._numeratorString && _denominatorString == ts._denominatorString)) ; }
void TestTimesig::timesig03() { Score* score = readScore(DIR + "timesig-03.mscx"); QVERIFY(score); Measure* m = score->firstMeasure()->nextMeasure(); TimeSig* ts = new TimeSig(score); ts->setSig(Fraction(3, 4), TimeSigType::NORMAL); score->cmdAddTimeSig(m, 0, ts, false); score->doLayout(); QVERIFY(saveCompareScore(score, "timesig-03.mscx", DIR + "timesig-03-ref.mscx")); delete score; }
void TestClef::clef2() { Score* score = readScore(DIR + "clef-2.mscx"); Measure* m = score->firstMeasure(); m = m->nextMeasure(); m = m->nextMeasure(); TimeSig* ts = new TimeSig(score); ts->setSig(2, 4); qDebug("tick %d", m->tick()); score->cmdAddTimeSig(m, 0, ts, false); score->doLayout(); QVERIFY(saveCompareScore(score, "clef-2.mscx", DIR + "clef-2-ref.mscx")); delete score; }
TimeSig* MCursor::addTimeSig(const Fraction& f) { createMeasures(); Measure* measure = _score->tick2measure(_tick); Segment* segment = measure->getSegment(Segment::Type::TimeSig, _tick); TimeSig* ts = 0; for (int i = 0; i < _score->nstaves(); ++i) { ts = new TimeSig(_score); ts->setSig(f, TimeSigType::NORMAL); ts->setTrack(i * VOICES); segment->add(ts); } _score->sigmap()->add(_tick, SigEvent(f)); return ts; }
void TimeDialog::addClicked() { TimeSig* ts = new TimeSig(gscore); ts->setSig(Fraction(zNominal->value(), denominator())); ts->setGroups(groups->groups()); // check for special text if ((QString("%1").arg(zNominal->value()) != zText->text()) || (QString("%1").arg(denominator()) != nText->text())) { ts->setNumeratorString(zText->text()); ts->setDenominatorString(nText->text()); } // extend palette: sp->append(ts, ""); _dirty = true; sp->updateGeometry(); _timePalette->adjustSize(); }
void TimeDialog::paletteChanged(int idx) { TimeSig* e = static_cast<TimeSig*>(sp->element(idx)); if (!e || e->type() != Element::TIMESIG) { zNominal->setEnabled(false); nNominal->setEnabled(false); zText->setEnabled(false); nText->setEnabled(false); groups->setEnabled(false); addButton->setEnabled(false); return; } zNominal->setEnabled(true); nNominal->setEnabled(true); zText->setEnabled(true); nText->setEnabled(true); groups->setEnabled(true); addButton->setEnabled(true); Fraction sig(e->sig()); Groups g = e->groups(); if (g.empty()) g = Groups::endings(sig); groups->setSig(sig, g); zNominal->setValue(sig.numerator()); nNominal->setCurrentIndex(denominator2Idx(sig.denominator())); zText->setText(e->numeratorString()); nText->setText(e->denominatorString()); }
Palette* MuseScore::newTimePalette() { struct TS { int numerator; int denominator; TimeSigType type; QString name; }; TS tsList[] = { { 2, 4, TimeSigType::NORMAL, "2/4" }, { 3, 4, TimeSigType::NORMAL, "3/4" }, { 4, 4, TimeSigType::NORMAL, "4/4" }, { 5, 4, TimeSigType::NORMAL, "5/4" }, { 6, 4, TimeSigType::NORMAL, "6/4" }, { 3, 8, TimeSigType::NORMAL, "3/8" }, { 6, 8, TimeSigType::NORMAL, "6/8" }, { 9, 8, TimeSigType::NORMAL, "9/8" }, { 12, 8, TimeSigType::NORMAL, "12/8" }, { 4, 4, TimeSigType::FOUR_FOUR, tr("4/4 common time") }, { 2, 2, TimeSigType::ALLA_BREVE, tr("2/2 alla breve") } }; Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Time Signatures")); sp->setMag(.8); sp->setGrid(42, 38); for (unsigned i = 0; i < sizeof(tsList)/sizeof(*tsList); ++i) { TimeSig* ts; ts = new TimeSig(gscore); ts->setSig(Fraction(tsList[i].numerator, tsList[i].denominator), tsList[i].type); sp->append(ts, tsList[i].name); } return sp; }
TimeSig* TimeSig::clone() const { TimeSig* ts = new TimeSig(*this); ts->setNeedLayout(true); // relayout of the ts is needed in parts #24571 return ts; }
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 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); }
tick_t MidiTime::ticksPerBeat( const TimeSig &sig ) const { // (number of ticks per bar) divided by (number of beats per bar) return ticksPerTact(sig) / sig.numerator(); }
tick_t MidiTime::ticksPerTact( const TimeSig &sig ) { return DefaultTicksPerTact * sig.numerator() / sig.denominator(); }
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 ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) { if (e->type() == Element::BAR_LINE) { genPropertyMenu1(e, popup); } else if (e->type() == Element::ARTICULATION) { genPropertyMenu1(e, popup); popup->addAction(tr("Articulation Properties..."))->setData("a-props"); } else if (e->type() == Element::BEAM) { popup->addAction(getAction("flip")); } else if (e->type() == Element::STEM) { popup->addAction(getAction("flip")); } else if (e->type() == Element::HOOK) { popup->addAction(getAction("flip")); } else if (e->type() == Element::BEND) { genPropertyMenu1(e, popup); popup->addAction(tr("Bend Properties..."))->setData("b-props"); } else if (e->type() == Element::TREMOLOBAR) { genPropertyMenu1(e, popup); popup->addAction(tr("TremoloBar Properties..."))->setData("tr-props"); } else if (e->type() == Element::HBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == Element::VBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("title-text")); textMenu->addAction(getAction("subtitle-text")); textMenu->addAction(getAction("composer-text")); textMenu->addAction(getAction("poet-text")); textMenu->addAction(getAction("insert-hbox")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == Element::TBOX) { popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == Element::VOLTA_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Volta Properties..."))->setData("v-props"); } else if (e->type() == Element::TIMESIG) { genPropertyMenu1(e, popup); TimeSig* ts = static_cast<TimeSig*>(e); int _track = ts->track(); // if the time sig. is not generated (= not courtesy) and is in track 0 // add the specific menu item QAction* a; if (!ts->generated() && !_track) { a = popup->addAction(ts->showCourtesySig() ? QT_TRANSLATE_NOOP("TimeSig", "Hide Courtesy Time Signature") : QT_TRANSLATE_NOOP("TimeSig", "Show Courtesy Time Signature") ); a->setData("ts-courtesy"); } popup->addSeparator(); popup->addAction(tr("Time Signature Properties..."))->setData("ts-props"); } else if (e->type() == Element::ACCIDENTAL) { Accidental* acc = static_cast<Accidental*>(e); genPropertyMenu1(e, popup); QAction* a = popup->addAction(QT_TRANSLATE_NOOP("Properties", "small")); a->setCheckable(true); a->setChecked(acc->small()); a->setData("smallAcc"); } else if (e->type() == Element::CLEF) { genPropertyMenu1(e, popup); // if the clef is not generated (= not courtesy) add the specific menu item if (!e->generated()) { QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy() ? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef") : QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") ); a->setData("clef-courtesy"); } } else if (e->type() == Element::DYNAMIC) { popup->addSeparator(); if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("MIDI Properties..."))->setData("d-dynamics"); popup->addAction(tr("Text Properties..."))->setData("d-props"); } else if (e->type() == Element::TEXTLINE_SEGMENT || e->type() == Element::OTTAVA_SEGMENT || e->type() == Element::VOLTA_SEGMENT || e->type() == Element::PEDAL_SEGMENT) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Line Properties..."))->setData("l-props"); } else if (e->type() == Element::STAFF_TEXT) { genPropertyMenuText(e, popup); popup->addAction(tr("Staff Text Properties..."))->setData("st-props"); } else if (e->type() == Element::TEXT || e->type() == Element::FINGERING || e->type() == Element::LYRICS || e->type() == Element::FIGURED_BASS) { genPropertyMenuText(e, popup); } else if (e->type() == Element::TEMPO_TEXT) { genPropertyMenu1(e, popup); popup->addAction(tr("Tempo Properties..."))->setData("tempo-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == Element::KEYSIG) { genPropertyMenu1(e, popup); KeySig* ks = static_cast<KeySig*>(e); if (!e->generated()) { QAction* a = popup->addAction(ks->showCourtesy() ? QT_TRANSLATE_NOOP("KeySig", "Hide Courtesy Key Signature") : QT_TRANSLATE_NOOP("KeySig", "Show Courtesy Key Signature") ); a->setData("key-courtesy"); a = popup->addAction(ks->showNaturals() ? QT_TRANSLATE_NOOP("KeySig", "Hide Naturals") : QT_TRANSLATE_NOOP("KeySig", "Show Naturals") ); a->setData("key-naturals"); } } else if (e->type() == Element::STAFF_STATE && static_cast<StaffState*>(e)->staffStateType() == STAFF_STATE_INSTRUMENT) { popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props"); } else if (e->type() == Element::SLUR_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Edit Mode"))->setData("edit"); popup->addAction(tr("Slur Properties..."))->setData("slur-props"); } else if (e->type() == Element::REST) { genPropertyMenu1(e, popup); } else if (e->type() == Element::NOTE) { QAction* b = popup->actions()[0]; QAction* a = popup->insertSeparator(b); a->setText(tr("Staff")); a = new QAction(tr("Staff Properties..."), 0); a->setData("staff-props"); popup->insertAction(b, a); a = popup->insertSeparator(b); a->setText(tr("Measure")); a = new QAction(tr("Measure Properties..."), 0); a->setData("measure-props"); popup->insertAction(b, a); genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Style..."))->setData("style"); popup->addAction(tr("Chord Articulation..."))->setData("articulation"); } else if (e->type() == Element::LAYOUT_BREAK && static_cast<LayoutBreak*>(e)->layoutBreakType() == LAYOUT_BREAK_SECTION) { popup->addAction(tr("Section Break Properties..."))->setData("break-props"); } else if (e->type() == Element::INSTRUMENT_CHANGE) { genPropertyMenu1(e, popup); popup->addAction(tr("Change Instrument..."))->setData("ch-instr"); } else if (e->type() == Element::FRET_DIAGRAM) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Color..."))->setData("color"); popup->addAction(tr("Fret Diagram Properties..."))->setData("fret-props"); } else if (e->type() == Element::GLISSANDO) { genPropertyMenu1(e, popup); popup->addAction(tr("Glissando Properties..."))->setData("gliss-props"); } else if (e->type() == Element::HAIRPIN_SEGMENT) { QAction* a = popup->addSeparator(); a->setText(tr("Dynamics")); if (e->visible()) a = popup->addAction(tr("Set Invisible")); else a = popup->addAction(tr("Set Visible")); a->setData("invisible"); popup->addAction(tr("Hairpin Properties..."))->setData("hp-props"); } else if (e->type() == Element::HARMONY) { genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Harmony Properties..."))->setData("ha-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == Element::INSTRUMENT_NAME) { popup->addAction(tr("Staff Properties..."))->setData("staff-props"); } else genPropertyMenu1(e, popup); }
void ScoreView::elementPropertyAction(const QString& cmd, Element* e) { if (cmd == "a-props") { ArticulationProperties rp(static_cast<Articulation*>(e)); rp.exec(); } else if (cmd == "b-props") { Bend* bend = static_cast<Bend*>(e); BendProperties bp(bend, 0); if (bp.exec()) score()->undo(new ChangeBend(bend, bp.points())); } else if (cmd == "f-props") { BoxProperties vp(static_cast<Box*>(e), 0); vp.exec(); } else if (cmd == "measure-props") { MeasureProperties vp(static_cast<Note*>(e)->chord()->segment()->measure()); vp.exec(); } else if (cmd == "frame-text") { Text* s = new Text(score()); // s->setSubtype(TEXT_FRAME); s->setTextStyleType(TEXT_STYLE_FRAME); s->setParent(e); score()->undoAddElement(s); score()->select(s, SELECT_SINGLE, 0); startEdit(s); score()->setLayoutAll(true); } else if (cmd == "picture") { mscore->addImage(score(), static_cast<HBox*>(e)); } else if (cmd == "frame-text") { Text* t = new Text(score()); t->setTextStyleType(TEXT_STYLE_FRAME); t->setParent(e); score()->undoAddElement(t); score()->select(t, SELECT_SINGLE, 0); startEdit(t); } else if (cmd == "title-text") { Text* t = new Text(score()); t->setTextStyleType(TEXT_STYLE_TITLE); t->setParent(e); score()->undoAddElement(t); score()->select(t, SELECT_SINGLE, 0); startEdit(t); } else if (cmd == "subtitle-text") { Text* t = new Text(score()); t->setTextStyleType(TEXT_STYLE_SUBTITLE); t->setParent(e); score()->undoAddElement(t); score()->select(t, SELECT_SINGLE, 0); startEdit(t); } else if (cmd == "composer-text") { Text* t = new Text(score()); t->setTextStyleType(TEXT_STYLE_COMPOSER); t->setParent(e); score()->undoAddElement(t); score()->select(t, SELECT_SINGLE, 0); startEdit(t); } else if (cmd == "poet-text") { Text* t = new Text(score()); t->setTextStyleType(TEXT_STYLE_POET); t->setParent(e); score()->undoAddElement(t); score()->select(t, SELECT_SINGLE, 0); startEdit(t); } else if (cmd == "insert-hbox") { HBox* s = new HBox(score()); double w = width() - s->leftMargin() * MScore::DPMM - s->rightMargin() * MScore::DPMM; s->setBoxWidth(Spatium(w / s->spatium())); s->setParent(e); score()->undoAddElement(s); score()->select(s, SELECT_SINGLE, 0); startEdit(s); } else if (cmd == "picture") mscore->addImage(score(), e); else if (cmd == "v-props") { VoltaSegment* vs = static_cast<VoltaSegment*>(e); VoltaProperties vp; vp.setText(vs->volta()->text()); vp.setEndings(vs->volta()->endings()); int rv = vp.exec(); if (rv) { QString txt = vp.getText(); QList<int> l = vp.getEndings(); if (txt != vs->volta()->text()) score()->undoChangeVoltaText(vs->volta(), txt); if (l != vs->volta()->endings()) score()->undoChangeVoltaEnding(vs->volta(), l); } } else if (cmd == "l-props") { TextLineSegment* vs = static_cast<TextLineSegment*>(e); TextLine* nTl = vs->textLine()->clone(); LineProperties lp(nTl); if (lp.exec()) { score()->undoChangeElement(vs->textLine(), nTl); // force new text foreach(SpannerSegment* l, nTl->spannerSegments()) static_cast<TextLineSegment*>(l)->clearText(); } else delete nTl; } else if (cmd == "tr-props") { TremoloBar* tb = static_cast<TremoloBar*>(e); TremoloBarProperties bp(tb, 0); if (bp.exec()) score()->undo(new ChangeTremoloBar(tb, bp.points())); } if (cmd == "ts-courtesy") { TimeSig* ts = static_cast<TimeSig*>(e); score()->undo(new ChangeTimesig(static_cast<TimeSig*>(e), !ts->showCourtesySig(), ts->sig(), ts->stretch(), ts->numeratorString(), ts->denominatorString(), ts->timeSigType())); } else if (cmd == "ts-props") { TimeSig* ts = static_cast<TimeSig*>(e); TimeSig r(*ts); TimeSigProperties vp(&r); int rv = vp.exec(); if (rv) { bool stretchChanged = r.stretch() != ts->stretch(); if (r.numeratorString() != ts->numeratorString() || r.denominatorString() != ts->denominatorString() || r.sig() != ts->sig() || stretchChanged || r.timeSigType() != ts->timeSigType()) { score()->undo(new ChangeTimesig(ts, r.showCourtesySig(), r.sig(), r.stretch(), r.numeratorString(), r.denominatorString(), r.timeSigType())); if (stretchChanged) score()->timesigStretchChanged(ts, ts->measure(), ts->staffIdx()); } } } else if (cmd == "smallAcc") score()->undoChangeProperty(e, P_SMALL, !static_cast<Accidental*>(e)->small()); else if (cmd == "smallNote") score()->undoChangeProperty(e, P_SMALL, !static_cast<Note*>(e)->small()); else if (cmd == "clef-courtesy") { bool show = !static_cast<Clef*>(e)->showCourtesy(); score()->undoChangeProperty(e, P_SHOW_COURTESY, show); } else if (cmd == "d-props") { Dynamic* dynamic = static_cast<Dynamic*>(e); Dynamic* nText = new Dynamic(*dynamic); TextProperties tp(nText, 0); int rv = tp.exec(); if (rv) score()->undoChangeElement(dynamic, nText); else delete nText; } else if (cmd == "st-props") { StaffTextProperties rp(static_cast<StaffText*>(e)); rp.exec(); } else if (cmd == "d-dynamics") { Dynamic* dynamic = static_cast<Dynamic*>(e); int oldVelo = dynamic->velocity(); Element::DynamicRange ot = dynamic->dynRange(); DynamicProperties dp(dynamic); int rv = dp.exec(); if (rv) { int newVelo = dynamic->velocity(); Element::DynamicRange nt = dynamic->dynRange(); dynamic->setVelocity(oldVelo); dynamic->setDynRange(ot); if (newVelo != oldVelo) score()->undoChangeProperty(dynamic, P_VELOCITY, newVelo); if (nt != ot) score()->undoChangeProperty(dynamic, P_DYNAMIC_RANGE, nt); } } else if (cmd == "text-props") { Text* ot = static_cast<Text*>(e); Text* nText = static_cast<Text*>(ot->clone()); TextProperties tp(nText); int rv = tp.exec(); if (rv) { QList<Element*> sl = score()->selection().elements(); QList<Element*> selectedElements; foreach(Element* e, sl) { if (e->type() != ot->type()) continue; Text* t = static_cast<Text*>(e); Text* tt = t->clone(); if (nText->styled() != ot->styled() || nText->styled()) { if (nText->styled()) tt->setTextStyleType(nText->textStyleType()); else tt->setUnstyled(); tt->setModified(true); } if (!nText->styled() && (nText->textStyle() != ot->textStyle())) { tt->setTextStyle(nText->textStyle()); tt->styleChanged(); tt->setModified(true); } if (t->selected()) selectedElements.append(tt); score()->undoChangeElement(t, tt); } score()->select(0, SELECT_SINGLE, 0); foreach(Element* e, selectedElements) score()->select(e, SELECT_ADD, 0); } delete nText; }
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); }