void Stem::draw(QPainter* painter) const { Staff* st = staff(); bool useTab = st && st->isTabStaff(); if (useTab && st->staffType()->slashStyle()) return; qreal lw = lineWidth(); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); if (!useTab) return; // TODO: adjust bounding rectangle in layout() for dots and for slash StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType()); qreal sp = spatium(); // slashed half note stem if (chord() && chord()->durationType().type() == TDuration::V_HALF && stt->minimStyle() == TAB_MINIM_SLASHED) { qreal wdt = sp * STAFFTYPE_TAB_SLASH_WIDTH; qreal sln = sp * STAFFTYPE_TAB_SLASH_SLANTY; qreal thk = sp * STAFFTYPE_TAB_SLASH_THICK; qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL; QPainterPath path; qreal y = stt->stemsDown() ? _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp : -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp; for (int i = 0; i < 2; ++i) { path.moveTo( wdt*0.5-lw, y); // top-right corner path.lineTo( wdt*0.5-lw, y+thk); // bottom-right corner path.lineTo(-wdt*0.5, y+thk+sln);// bottom-left corner path.lineTo(-wdt*0.5, y+sln); // top-left corner path.closeSubpath(); y += displ; } // setbbox(path.boundingRect()); painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); } // dots // NOT THE BEST PLACE FOR THIS? // with tablatures, dots are not drawn near 'notes', but near stems int nDots = chord()->dots(); if (nDots > 0) { qreal y = stemLen() - (stt->stemsDown() ? (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 ); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } }
void Stem::draw(QPainter* painter) const { // hide if second chord of a cross-measure pair if (chord() && chord()->crossMeasure() == CROSSMEASURE_SECOND) return; Staff* st = staff(); bool useTab = st && st->isTabStaff(); if (useTab && st->staffType()->slashStyle()) return; qreal lw = lineWidth(); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); if (!useTab || !chord()) return; // TODO: adjust bounding rectangle in layout() for dots and for slash StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType()); qreal sp = spatium(); bool _up = up(); // slashed half note stem if (chord()->durationType().type() == TDuration::V_HALF && stt->minimStyle() == TAB_MINIM_SLASHED) { // position slashes onto stem qreal y = _up ? -(_len+_userLen) + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp : (_len+_userLen) - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp; // if stems through, try to align slashes within or across lines if (stt->stemThrough()) { qreal halfLineDist = stt->lineDistance().val() * sp * 0.5; qreal halfSlashHgt = STAFFTYPE_TAB_SLASH_2TOTHEIGHT * sp * 0.5; y = lrint( (y + halfSlashHgt) / halfLineDist) * halfLineDist - halfSlashHgt; } // draw slashes qreal hlfWdt= sp * STAFFTYPE_TAB_SLASH_WIDTH * 0.5; qreal sln = sp * STAFFTYPE_TAB_SLASH_SLANTY; qreal thk = sp * STAFFTYPE_TAB_SLASH_THICK; qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL; QPainterPath path; for (int i = 0; i < 2; ++i) { path.moveTo( hlfWdt, y); // top-right corner path.lineTo( hlfWdt, y+thk); // bottom-right corner path.lineTo(-hlfWdt, y+thk+sln); // bottom-left corner path.lineTo(-hlfWdt, y+sln); // top-left corner path.closeSubpath(); y += displ; } // setbbox(path.boundingRect()); painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); } // dots // NOT THE BEST PLACE FOR THIS? // with tablatures and stems beside staves, dots are not drawn near 'notes', but near stems int nDots = chord()->dots(); if (nDots > 0 && !stt->stemThrough()) { qreal y = ( (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN * 0.2) * sp) * (_up ? -1.0 : 1.0); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } }
void EditStaffType::saveCurrent(QListWidgetItem* o) { bool modif = false; // assume no modifications int idx = o->data(Qt::UserRole).toInt(); StaffType* st = staffTypes[idx]; // if any of the common properties is modified if (name->text() != st->name() || st->lines() != lines->value() || st->lineDistance().val()!= lineDistance->value() || st->genClef() != genClef->isChecked() || st->showBarlines() != showBarlines->isChecked() || st->genTimesig() != genTimesig->isChecked() ) { modif = true; } // or if any of the props specific to each group is modified switch(st->group()) { case STANDARD_STAFF_GROUP: { StaffTypePitched* sp = static_cast<StaffTypePitched*>(st); if (sp->genKeysig() != genKeysigPitched->isChecked() || sp->showLedgerLines() != showLedgerLinesPitched->isChecked() || st->slashStyle() != stemlessPitched->isChecked() ) { modif = true; } } break; case TAB_STAFF_GROUP: { StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st); TablatureMinimStyle minimStyle = minimNoneRadio->isChecked() ? TAB_MINIM_NONE : (minimShortRadio->isChecked() ? TAB_MINIM_SHORTER : TAB_MINIM_SLASHED); if (stt->durationFontName() != durFontName->currentText() || stt->durationFontSize() != durFontSize->value() || stt->durationFontUserY()!= durY->value() || stt->fretFontName() != fretFontName->currentText() || stt->fretFontSize() != fretFontSize->value() || stt->fretFontUserY() != fretY->value() || stt->linesThrough() != linesThroughRadio->isChecked() || stt->onLines() != onLinesRadio->isChecked() || stt->upsideDown() != upsideDown->isChecked() || stt->useNumbers() != numbersRadio->isChecked() || ( noteValuesNone->isChecked() && (!stt->slashStyle() || stt->genDurations()) ) || ( noteValuesSymb->isChecked() && (!stt->slashStyle() || !stt->genDurations()) ) // if stems, there are more values to take into account || ( noteValuesStems->isChecked()&& ( stt->slashStyle() || stt->genDurations() || stt->stemsDown() != stemBelowRadio->isChecked() || stt->stemThrough() != stemThroughRadio->isChecked() || stt->minimStyle() != minimStyle) ) || stt->showRests() != showRests->isChecked() ) { modif = true; } } break; case PERCUSSION_STAFF_GROUP: { StaffTypePercussion* sp = static_cast<StaffTypePercussion*>(st); if (sp->genKeysig() != genKeysigPercussion->isChecked() || sp->showLedgerLines() != showLedgerLinesPercussion->isChecked() || st->slashStyle() != stemlessPercussion->isChecked() ) { modif = true; } } break; } if (modif) { // save common properties // save-group specific properties if(name->text().isEmpty()) { QString n = createUniqueStaffTypeName(st->group()); name->setText(n); o->setText(n); } switch(st->group()) { case STANDARD_STAFF_GROUP: { StaffTypePitched* stp = static_cast<StaffTypePitched*>(st); stp->setName(name->text()); stp->setLines(lines->value()); stp->setLineDistance(Spatium(lineDistance->value())); stp->setShowBarlines(showBarlines->isChecked()); stp->setGenClef(genClef->isChecked()); stp->setGenTimesig(genTimesig->isChecked()); stp->setGenKeysig(genKeysigPitched->isChecked()); stp->setShowLedgerLines(showLedgerLinesPitched->isChecked()); stp->setSlashStyle(stemlessPitched->isChecked()); } break; case TAB_STAFF_GROUP: { StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st); setTabFromDlg(stt); } break; case PERCUSSION_STAFF_GROUP: { StaffTypePercussion* stp = static_cast<StaffTypePercussion*>(st); setPercFromDlg(stp); } break; } modified = true; } }