bool Rest::acceptDrop(MuseScoreView*, const QPointF&, Element* e) const { ElementType type = e->type(); if ( (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::SBEAM) || (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::MBEAM) || (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::NBEAM) || (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::BEAM32) || (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::BEAM64) || (type == ElementType::ICON && static_cast<Icon*>(e)->iconType() == IconType::AUTOBEAM) || (type == ElementType::ARTICULATION && static_cast<Articulation*>(e)->articulationType() == ArticulationType::Fermata) || (type == ElementType::CLEF) || (type == ElementType::STAFF_TEXT) || (type == ElementType::BAR_LINE) || (type == ElementType::BREATH) || (type == ElementType::CHORD) || (type == ElementType::STAFF_STATE) || (type == ElementType::INSTRUMENT_CHANGE) || (type == ElementType::DYNAMIC) || (type == ElementType::HARMONY) || (type == ElementType::TEMPO_TEXT) || (type == ElementType::STAFF_TEXT) || (type == ElementType::REHEARSAL_MARK) || (type == ElementType::FRET_DIAGRAM) || (type == ElementType::SYMBOL) ) { return true; } if(type == ElementType::REPEAT_MEASURE && durationType().type() == TDuration::DurationType::V_MEASURE) return true; return false; }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && ( !((StaffTypeTablature*)staff()->staffType())->showRests() || ((StaffTypeTablature*)staff()->staffType())->genDurations()) ) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->multiMeasure()) { Measure* m = measure(); int n = m->multiMeasure(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = _spatium; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); QFont font(fontId2font(0)); painter->setFont(font); QFontMetricsF fm(font); y = -_spatium * .5 - fm.ascent(); painter->drawText(QRectF(center(x1, x2), y, .0, .0), Qt::AlignHCenter|Qt::TextDontClip, QString("%1").arg(n)); } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y)); } } } }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && (!staff()->staffType()->showRests() || staff()->staffType()->genDurations())) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->isMMRest()) { //only on voice 1 if ((track() % VOICES) != 0) return; Measure* m = measure(); int n = m->mmRestCount(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = 0.0; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); painter->setFont(score()->scoreFont()->font()); QFontMetricsF fm(score()->scoreFont()->font()); QString s = toTimeSigString(QString("%1").arg(n)); y = -_spatium * 1.5 - staff()->height() *.5; qreal x = center(x1, x2); x -= symBbox(s).width() * .5; drawSymbols(s, painter, QPointF(x, y)); } else { drawSymbol(_sym, painter); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symWidth(_sym) + point(score()->styleS(StyleIdx::dotNoteDistance)) * i; drawSymbol(SymId::augmentationDot, painter, QPointF(x, y)); } } } }
QString ChordRest::durationUserName() { QString duration = tr("Duration"); QString tupletType = ""; if(tuplet()) { switch (tuplet()->ratio().numerator()) { case 2: tupletType += " " + tr("Duplet"); break; case 3: tupletType += " " + tr("Triplet"); break; case 4: tupletType += " " + tr("Quadruplet"); break; case 5: tupletType += " " + tr("Quintuplet"); break; case 6: tupletType += " " + tr("Sextuplet"); break; case 7: tupletType += " " + tr("Septuplet"); break; case 8: tupletType += " " + tr("Octuplet"); break; case 9: tupletType += " " + tr("Nonuplet"); break; default: tupletType += " " + tr("Custom Tuplet"); } } QString dotString = ""; switch (dots()) { case 1: dotString += " " + tr("Dotted"); break; case 2: dotString += " " + tr("Double dotted"); break; case 3: dotString += " " + tr("Triple dotted"); break; } return QString("%1:%2%3 %4").arg(duration).arg(tupletType).arg(dotString).arg(durationType().durationTypeUserName()); }
Element* Rest::drop(const DropData& data) { Element* e = data.element; switch (e->type()) { case ElementType::ARTICULATION: { Articulation* a = static_cast<Articulation*>(e); if (a->articulationType() != ArticulationType::Fermata || !score()->addArticulation(this, a)) { delete e; e = 0; } } return e; case ElementType::CHORD: { Chord* c = static_cast<Chord*>(e); Note* n = c->upNote(); Direction dir = c->stemDirection(); // score()->select(0, SelectType::SINGLE, 0); NoteVal nval; nval.pitch = n->pitch(); nval.headGroup = n->headGroup(); Fraction d = score()->inputState().duration().fraction(); if (!d.isZero()) { Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir); if (seg) { ChordRest* cr = static_cast<ChordRest*>(seg->element(track())); if (cr) score()->nextInputPos(cr, true); } } delete e; } break; case ElementType::REPEAT_MEASURE: delete e; if (durationType().type() == TDuration::DurationType::V_MEASURE) { measure()->cmdInsertRepeatMeasure(staffIdx()); } break; default: return ChordRest::drop(data); } return 0; }
void Rest::draw(Painter* painter) const { if (staff()->useTablature() || generated()) return; qreal _spatium = spatium(); Measure* m = measure(); if (m && m->multiMeasure()) { int n = m->multiMeasure(); qreal pw = _spatium * .7; painter->setLineWidth(pw); qreal w = _mmWidth; qreal y = _spatium; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(x1 + pw, y, x2 - pw, y); // draw vertical lines: painter->setLineWidth(_spatium * .2); painter->drawLine(x1, y-_spatium, x1, y+_spatium); painter->drawLine(x2, y-_spatium, x2, y+_spatium); QFont font = symbols[score()->symIdx()][allabreveSym].font(); painter->setFont(font); QFontMetricsF fm(font); y = -_spatium * .5 - fm.ascent(); painter->drawTextHCentered(center(x1, x2), y, QString("%1").arg(n)); } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, x, y); } } } }
void MsScWriter::note(const QString pitch, const QVector<Bww::BeamType> beamList, const QString type, const int dots, bool tieStart, bool /*TODO tieStop */, StartStop triplet, bool grace) { qDebug() << "MsScWriter::note()" << "type:" << type << "dots:" << dots << "grace" << grace ; if (!stepAlterOctMap.contains(pitch) || !typeMap.contains(type)) { // TODO: error message return; } StepAlterOct sao = stepAlterOctMap.value(pitch); int ticks = 4 * Ms::MScore::division / type.toInt(); if (dots) ticks = 3 * ticks / 2; qDebug() << "ticks:" << ticks; Ms::TDuration durationType(Ms::TDuration::DurationType::V_INVALID); durationType.setVal(ticks); qDebug() << "duration:" << durationType.name(); if (triplet != ST_NONE) ticks = 2 * ticks / 3; Ms::Beam::Mode bm = (beamList.at(0) == Bww::BM_BEGIN) ? Ms::Beam::Mode::BEGIN : Ms::Beam::Mode::AUTO; Ms::Direction sd = Ms::Direction::AUTO; // create chord Ms::Chord* cr = new Ms::Chord(score); //ws cr->setTick(tick); cr->setBeamMode(bm); cr->setTrack(0); if (grace) { cr->setNoteType(Ms::NoteType::GRACE32); cr->setDurationType(Ms::TDuration::DurationType::V_32ND); sd = Ms::Direction::UP; } else { if (durationType.type() == Ms::TDuration::DurationType::V_INVALID) durationType.setType(Ms::TDuration::DurationType::V_QUARTER); cr->setDurationType(durationType); sd = Ms::Direction::DOWN; } cr->setDuration(durationType.fraction()); cr->setDots(dots); cr->setStemDirection(sd); // add note to chord Ms::Note* note = new Ms::Note(score); note->setTrack(0); xmlSetPitch(note, sao.s.toLatin1(), sao.a, sao.o); if (tieStart) { Ms::Tie* tie = new Ms::Tie(score); note->setTieFor(tie); tie->setStartNote(note); tie->setTrack(0); } cr->add(note); // add chord to measure if (!grace) { Ms::Segment* s = currentMeasure->getSegment(cr, tick); s->add(cr); if (!currentGraceNotes.isEmpty()) { for (int i = currentGraceNotes.size() - 1; i >=0; i--) cr->add(currentGraceNotes.at(i)); currentGraceNotes.clear(); } doTriplet(cr, triplet); int tickBefore = tick; tick += ticks; Ms::Fraction nl(Ms::Fraction::fromTicks(tick - currentMeasure->tick())); currentMeasure->setLen(nl); qDebug() << "MsScWriter::note()" << "tickBefore:" << tickBefore << "tick:" << tick << "nl:" << nl.print() ; } else { currentGraceNotes.append(cr); } }
void Rest::layout() { int lines = staff()->lines(); switch(durationType().type()) { case Duration::V_64TH: case Duration::V_32ND: dotline = -3; break; case Duration::V_256TH: case Duration::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); int lineOffset = 0; if (measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case Duration::V_LONG: lineOffset = up ? -3 : 5; break; case Duration::V_BREVE: lineOffset = up ? -3 : 5; break; case Duration::V_MEASURE: case Duration::V_WHOLE: lineOffset = up ? -4 : 6; break; case Duration::V_HALF: lineOffset = up ? -4 : 4; break; case Duration::V_QUARTER: lineOffset = up ? -4 : 4; break; case Duration::V_EIGHT: lineOffset = up ? -4 : 4; break; case Duration::V_16TH: lineOffset = up ? -6 : 4; break; case Duration::V_32ND: lineOffset = up ? -6 : 6; break; case Duration::V_64TH: lineOffset = up ? -8 : 6; break; case Duration::V_128TH: lineOffset = up ? -8 : 8; break; case Duration::V_256TH: // not available lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case Duration::V_LONG: case Duration::V_BREVE: case Duration::V_MEASURE: case Duration::V_WHOLE: if (lines == 1) lineOffset = -2; break; case Duration::V_HALF: case Duration::V_QUARTER: case Duration::V_EIGHT: case Duration::V_16TH: case Duration::V_32ND: case Duration::V_64TH: case Duration::V_128TH: case Duration::V_256TH: // not available if (lines == 1) lineOffset = -4; break; default: break; } } int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); setYoff(qreal(yo) + qreal(lineOffset) * .5); layoutArticulations(); setPos(0.0, yoff() * _spatium); Spatium rs; if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } Segment* s = segment(); if (s && s->measure() && s->measure()->multiMeasure()) { qreal _spatium = spatium(); qreal h = _spatium * 6.5; qreal w = point(score()->styleS(ST_minMMRestWidth)); setbbox(QRectF(-w * .5, -h + 2 * _spatium, w, h)); } else { if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } setbbox(symbols[score()->symIdx()][_sym].bbox(magS())); } _space.setLw(point(_extraLeadingSpace)); _space.setRw(width() + point(_extraTrailingSpace + rs)); // adjustReadPos(); }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && ( !((StaffTypeTablature*)staff()->staffType())->showRests() || ((StaffTypeTablature*)staff()->staffType())->genDurations()) ) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->multiMeasure()) { Measure* m = measure(); int n = m->multiMeasure(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = 0.0; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); #ifdef USE_GLYPHS QRawFont rfont = fontId2RawFont(0); rfont.setPixelSize(20.0 * spatium()/(PPI * SPATIUM20)); QGlyphRun glyphs; QVector<quint32> idx = rfont.glyphIndexesForString(QString("%1").arg(n)); glyphs.setGlyphIndexes(idx); QVector<QPointF> adv = rfont.advancesForGlyphIndexes(idx); adv.insert(0, QPointF()); glyphs.setPositions(adv); glyphs.setRawFont(rfont); QRectF r = glyphs.boundingRect(); y = -_spatium * .5; painter->drawGlyphRun(QPointF((x2 - x1) * .5 + x1 - r.width() * .5, y), glyphs); #else QFont font = fontId2font(0); font.setPixelSize(lrint(20.0 * spatium()/(PPI * SPATIUM20))); painter->setFont(font); QFontMetricsF fm(font); // y = -_spatium * .5 - (staff()->height()*.5) - fm.ascent(); y = -_spatium * .5 - fm.ascent(); painter->drawText(QRectF(center(x1, x2), y, .0, .0), Qt::AlignHCenter|Qt::TextDontClip, QString("%1").arg(n)); #endif } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y)); } } } }
void Rest::layout() { _space.setLw(0.0); if (parent() && measure() && measure()->multiMeasure()) { _space.setRw(point(score()->styleS(ST_minMMRestWidth))); return; } rxpos() = 0.0; if (staff() && staff()->isTabStaff()) { StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType(); // if rests are shown and note values are shown as duration symbols if(tab->showRests() &&tab->genDurations()) { // symbol needed; if not exist, create, if exists, update duration if (!_tabDur) _tabDur = new TabDurationSymbol(score(), tab, durationType().type(), dots()); else _tabDur->setDuration(durationType().type(), dots(), tab); _tabDur->setParent(this); // needed? _tabDur->setTrack(track()); _tabDur->layout(); setbbox(_tabDur->bbox()); setPos(0.0, 0.0); // no rest is drawn: reset any position might be set for it _space.setLw(0.0); _space.setRw(width()); return; } // if no rests or no duration symbols, delete any dur. symbol and chain into standard staff mngmt // this is to ensure horiz space is reserved for rest, even if they are not diplayed // Rest::draw() will skip their drawing, if not needed if(_tabDur) { delete _tabDur; _tabDur = 0; } } switch(durationType().type()) { case TDuration::V_64TH: case TDuration::V_32ND: dotline = -3; break; case TDuration::V_256TH: case TDuration::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int stepOffset = 0; if (staff()) stepOffset = staff()->staffType()->stepOffset(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); qreal lineDist = staff() ? staff()->staffType()->lineDistance().val() : 1.0; int lineOffset = 0; int lines = staff() ? staff()->lines() : 5; if (segment() && measure() && measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case TDuration::V_LONG: lineOffset = up ? -3 : 5; break; case TDuration::V_BREVE: lineOffset = up ? -3 : 5; break; case TDuration::V_MEASURE: if (duration() >= Fraction(2, 1)) // breve symbol lineOffset = up ? -3 : 5; // fall through case TDuration::V_WHOLE: lineOffset = up ? -4 : 6; break; case TDuration::V_HALF: lineOffset = up ? -4 : 4; break; case TDuration::V_QUARTER: lineOffset = up ? -4 : 4; break; case TDuration::V_EIGHT: lineOffset = up ? -4 : 4; break; case TDuration::V_16TH: lineOffset = up ? -6 : 4; break; case TDuration::V_32ND: lineOffset = up ? -6 : 6; break; case TDuration::V_64TH: lineOffset = up ? -8 : 6; break; case TDuration::V_128TH: lineOffset = up ? -8 : 8; break; case TDuration::V_256TH: // not available lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case TDuration::V_LONG: case TDuration::V_BREVE: case TDuration::V_MEASURE: case TDuration::V_WHOLE: if (lines == 1) lineOffset = -2; break; case TDuration::V_HALF: case TDuration::V_QUARTER: case TDuration::V_EIGHT: case TDuration::V_16TH: case TDuration::V_32ND: case TDuration::V_64TH: case TDuration::V_128TH: case TDuration::V_256TH: // not available if (lines == 1) lineOffset = -4; break; default: break; } } int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); layoutArticulations(); rypos() = (qreal(yo) + qreal(lineOffset + stepOffset) * .5) * lineDist * _spatium; Spatium rs; if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } setbbox(symbols[score()->symIdx()][_sym].bbox(magS())); _space.setRw(width() + point(rs)); }
void MsScWriter::note(const QString pitch, const QVector<Bww::BeamType> beamList, const QString type, const int dots, bool tieStart, bool /*TODO tieStop */, StartStop triplet, bool grace) { qDebug() << "MsScWriter::note()" << "type:" << type << "dots:" << dots << "grace" << grace ; if (!stepAlterOctMap.contains(pitch) || !typeMap.contains(type)) { // TODO: error message return; } StepAlterOct sao = stepAlterOctMap.value(pitch); int ticks = 4 * MScore::division / type.toInt(); if (dots) ticks = 3 * ticks / 2; qDebug() << "ticks:" << ticks; TDuration durationType(TDuration::V_INVALID); durationType.setVal(ticks); qDebug() << "duration:" << durationType.name(); if (triplet != ST_NONE) ticks = 2 * ticks / 3; BeamMode bm = (beamList.at(0) == Bww::BM_BEGIN) ? BEAM_BEGIN : BEAM_AUTO; Direction sd = AUTO; // create chord Chord* cr = new Chord(score); //ws cr->setTick(tick); cr->setBeamMode(bm); cr->setTrack(0); if (grace) { cr->setNoteType(NOTE_GRACE32); cr->setDurationType(TDuration::V_32ND); sd = UP; } else { if (durationType.type() == TDuration::V_INVALID) durationType.setType(TDuration::V_QUARTER); cr->setDurationType(durationType); sd = DOWN; } cr->setDuration(durationType.fraction()); cr->setDots(dots); cr->setStemDirection(sd); // add note to chord Note* note = new Note(score); note->setTrack(0); xmlSetPitch(note, sao.s.toAscii(), sao.a, sao.o); if (tieStart) { Tie* tie = new Tie(score); note->setTieFor(tie); tie->setStartNote(note); tie->setTrack(0); } cr->add(note); // add chord to measure Segment* s = currentMeasure->getSegment(cr, tick); s->add(cr); if (!grace) { doTriplet(cr, triplet); int tickBefore = tick; tick += ticks; Fraction nl(Fraction::fromTicks(tick - currentMeasure->tick())); currentMeasure->setLen(nl); qDebug() << "MsScWriter::note()" << "tickBefore:" << tickBefore << "tick:" << tick << "nl:" << nl.print() ; } }
int Rest::computeLineOffset() { int lineOffset = 0; int lines = staff() ? staff()->lines() : 5; if (segment() && measure() && measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case TDuration::DurationType::V_LONG: lineOffset = up ? -3 : 5; break; case TDuration::DurationType::V_BREVE: lineOffset = up ? -3 : 5; break; case TDuration::DurationType::V_MEASURE: if (duration() >= Fraction(2, 1)) // breve symbol lineOffset = up ? -3 : 5; // fall through case TDuration::DurationType::V_WHOLE: lineOffset = up ? -4 : 6; break; case TDuration::DurationType::V_HALF: lineOffset = up ? -4 : 4; break; case TDuration::DurationType::V_QUARTER: lineOffset = up ? -4 : 4; break; case TDuration::DurationType::V_EIGHT: lineOffset = up ? -4 : 4; break; case TDuration::DurationType::V_16TH: lineOffset = up ? -6 : 4; break; case TDuration::DurationType::V_32ND: lineOffset = up ? -6 : 6; break; case TDuration::DurationType::V_64TH: lineOffset = up ? -8 : 6; break; case TDuration::DurationType::V_128TH: lineOffset = up ? -8 : 8; break; case TDuration::DurationType::V_1024TH: case TDuration::DurationType::V_512TH: case TDuration::DurationType::V_256TH: lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case TDuration::DurationType::V_LONG: case TDuration::DurationType::V_BREVE: case TDuration::DurationType::V_MEASURE: case TDuration::DurationType::V_WHOLE: if (lines == 1) lineOffset = -2; break; case TDuration::DurationType::V_HALF: case TDuration::DurationType::V_QUARTER: case TDuration::DurationType::V_EIGHT: case TDuration::DurationType::V_16TH: case TDuration::DurationType::V_32ND: case TDuration::DurationType::V_64TH: case TDuration::DurationType::V_128TH: case TDuration::DurationType::V_256TH: case TDuration::DurationType::V_512TH: case TDuration::DurationType::V_1024TH: if (lines == 1) lineOffset = -4; break; default: break; } } return lineOffset; }
void Rest::layout() { _space.setLw(0.0); if (parent() && measure() && measure()->isMMRest()) { _space.setRw(point(score()->styleS(StyleIdx::minMMRestWidth))); static const qreal verticalLineWidth = .2; qreal _spatium = spatium(); qreal h = _spatium * (2 + verticalLineWidth); qreal w = _mmWidth + _spatium * verticalLineWidth*.5; bbox().setRect(-_spatium * verticalLineWidth*.5, -h * .5, w, h); // text qreal y = -_spatium * 2.5 - staff()->height() *.5; addbbox(QRectF(0, y, w, _spatium * 2)); // approximation return; } rxpos() = 0.0; if (staff() && staff()->isTabStaff()) { StaffType* tab = staff()->staffType(); // if rests are shown and note values are shown as duration symbols if (tab->showRests() && tab->genDurations()) { TDuration::DurationType type = durationType().type(); int dots = durationType().dots(); // if rest is whole measure, convert into actual type and dot values if (type == TDuration::DurationType::V_MEASURE) { int ticks = measure()->ticks(); TDuration dur = TDuration(Fraction::fromTicks(ticks)).type(); type = dur.type(); dots = dur.dots(); } // symbol needed; if not exist, create, if exists, update duration if (!_tabDur) _tabDur = new TabDurationSymbol(score(), tab, type, dots); else _tabDur->setDuration(type, dots, tab); _tabDur->setParent(this); // needed? _tabDur->setTrack(track()); _tabDur->layout(); setbbox(_tabDur->bbox()); setPos(0.0, 0.0); // no rest is drawn: reset any position might be set for it _space.setLw(0.0); _space.setRw(width()); return; } // if no rests or no duration symbols, delete any dur. symbol and chain into standard staff mngmt // this is to ensure horiz space is reserved for rest, even if they are not diplayed // Rest::draw() will skip their drawing, if not needed if(_tabDur) { delete _tabDur; _tabDur = 0; } } switch(durationType().type()) { case TDuration::DurationType::V_64TH: case TDuration::DurationType::V_32ND: dotline = -3; break; case TDuration::DurationType::V_1024TH: case TDuration::DurationType::V_512TH: case TDuration::DurationType::V_256TH: case TDuration::DurationType::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int stepOffset = 0; if (staff()) stepOffset = staff()->staffType()->stepOffset(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); qreal lineDist = staff() ? staff()->staffType()->lineDistance().val() : 1.0; int lines = staff() ? staff()->lines() : 5; int lineOffset = computeLineOffset(); int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); layoutArticulations(); rypos() = (qreal(yo) + qreal(lineOffset + stepOffset) * .5) * lineDist * _spatium; Spatium rs; if (dots()) { rs = Spatium(score()->styleS(StyleIdx::dotNoteDistance) + dots() * score()->styleS(StyleIdx::dotDotDistance)); } if (dots()) { rs = Spatium(score()->styleS(StyleIdx::dotNoteDistance) + dots() * score()->styleS(StyleIdx::dotDotDistance)); } setbbox(symBbox(_sym)); _space.setRw(width() + point(rs)); }