remove stafftype subclasses

This commit is contained in:
ws 2014-04-28 18:38:50 +02:00
parent 8108b0932d
commit f9059a269b
27 changed files with 492 additions and 896 deletions

View file

@ -260,11 +260,11 @@ void Beam::layout1()
Chord* c2 = 0;
// TAB's with stem beside staves have special layout
if (staff()->isTabStaff() && !((StaffTypeTablature*)staff()->staffType())->stemThrough()) {
if (staff()->isTabStaff() && !staff()->staffType()->stemThrough()) {
//TABULATURES: all beams (and related chords) are:
// UP or DOWN according to TAB duration position
// slope 0
_up = !((StaffTypeTablature*)staff()->staffType())->stemsDown();
_up = !staff()->staffType()->stemsDown();
slope = 0.0;
cross = false;
minMove = maxMove = 0; // no cross-beaming in TAB's!
@ -1440,9 +1440,9 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
int n = crl.size();
StaffTypeTablature* tab = 0;
StaffType* tab = 0;
if (staff()->isTabStaff() )
tab = (StaffTypeTablature*)staff()->staffType();
tab = staff()->staffType();
if (tab && !tab->stemThrough() ) {
//
// TAB STAVES with stems beside staves: beam position is fixed depending on TAB parameters and chordrest up/down

View file

@ -70,8 +70,8 @@ Note* Chord::upNote() const
}
}
else if (staff()->isTabStaff()) {
StaffTypeTablature* tab = (StaffTypeTablature*) staff()->staffType();
int line = tab->lines() - 1; // start at bottom line
StaffType* tab = staff()->staffType();
int line = tab->lines() - 1; // start at bottom line
int noteLine;
// scan each note: if TAB strings are not in sequential order,
// visual order of notes might not correspond to pitch order
@ -99,8 +99,8 @@ Note* Chord::downNote() const
}
}
else if (staff()->isTabStaff()) {
StaffTypeTablature* tab = (StaffTypeTablature*) staff()->staffType();
int line = 0; // start at top line
StaffType* tab = staff()->staffType();
int line = 0; // start at top line
int noteLine;
// scan each note: if TAB strings are not in sequential order,
// visual order of notes might not correspond to pitch order
@ -145,8 +145,8 @@ int Chord::upString() const
// if no staff or staff not a TAB, return 0 (=topmost line)
if(!staff() || !staff()->isTabStaff())
return 0;
StaffTypeTablature* tab = (StaffTypeTablature*) staff()->staffType();
int line = tab->lines() - 1; // start at bottom line
StaffType* tab = staff()->staffType();
int line = tab->lines() - 1; // start at bottom line
int noteLine;
// scan each note: if TAB strings are not in sequential order,
// visual order of notes might not correspond to pitch order
@ -161,17 +161,17 @@ int Chord::upString() const
int Chord::downString() const
{
if(!staff()) // if no staff, return 0
if (!staff()) // if no staff, return 0
return 0;
if(!staff()->isTabStaff()) // if staff not a TAB, return bottom line
if (!staff()->isTabStaff()) // if staff not a TAB, return bottom line
return staff()->lines()-1;
StaffTypeTablature* tab = (StaffTypeTablature*) staff()->staffType();
int line = 0; // start at top line
int noteLine;
StaffType* tab = staff()->staffType();
int line = 0; // start at top line
int noteLine;
int n = _notes.size();
for (int i = 0; i < n; ++i) {
noteLine = tab->physStringToVisual(_notes.at(i)->string());
if(noteLine > line)
if (noteLine > line)
line = noteLine;
}
return line;
@ -303,7 +303,7 @@ void Chord::setStem(Stem* s)
qreal Chord::stemPosX() const
{
if (staff() && staff()->isTabStaff())
return static_cast<StaffTypeTablature*>(staff()->staffType())->chordStemPosX(this) * spatium();
return staff()->staffType()->chordStemPosX(this) * spatium();
if (_up) {
qreal nhw = score()->noteHeadWidth();
@ -326,7 +326,7 @@ QPointF Chord::stemPos() const
QPointF p(pagePos());
if (staff() && staff()->isTabStaff())
return (static_cast<StaffTypeTablature*>(staff()->staffType())->chordStemPos(this) * _spatium) + p;
return staff()->staffType()->chordStemPos(this) * _spatium + p;
if (_up) {
qreal nhw = score()->noteHeadWidth();
@ -351,7 +351,7 @@ QPointF Chord::stemPosBeam() const
{
qreal _spatium = spatium();
if (staff() && staff()->isTabStaff())
return (static_cast<StaffTypeTablature*>(staff()->staffType())->chordStemPosBeam(this) * _spatium) + pagePos();
return staff()->staffType()->chordStemPosBeam(this) * _spatium + pagePos();
QPointF p(pagePos());
if (_up) {
qreal nhw = score()->noteHeadWidth();
@ -800,10 +800,10 @@ void Chord::addLedgerLines(int move)
void Chord::computeUp()
{
StaffTypeTablature* tab = 0;
StaffType* tab = 0;
// TAB STAVES
if (staff() && staff()->isTabStaff()) {
tab = (StaffTypeTablature*)staff()->staffType();
tab = staff()->staffType();
// if no stems or stem beside staves
if (tab->slashStyle() || !tab->stemThrough()) {
// if measure has voices, set stem direction according to voice
@ -1112,7 +1112,7 @@ qreal Chord::centerX() const
{
// TAB 'notes' are always centered on the stem
if (staff()->isTabStaff())
return ((StaffTypeTablature*)staff()->staffType())->chordStemPosX(this) * spatium();
return staff()->staffType()->chordStemPosX(this) * spatium();
const Note* note = up() ? upNote() : downNote();
qreal x = note->pos().x();
@ -1288,9 +1288,9 @@ void Chord::layoutStem()
// TAB
//
qreal _spatium = spatium();
StaffTypeTablature* tab = 0;
StaffType* tab = 0;
if (staff() && staff()->isTabStaff()) {
tab = (StaffTypeTablature*)staff()->staffType();
tab = staff()->staffType();
// require stems only if TAB is not stemless and this chord has a stem
if (!tab->slashStyle() && _stem) {
// if stems are beside staff, apply special formatting
@ -1870,7 +1870,7 @@ void Chord::layoutTablature()
qreal rrr = 0.0; // space to leave at right of chord
Note* upnote = upNote();
qreal headWidth = symWidth(SymId::noteheadBlack);
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
StaffType* tab = staff()->staffType();
qreal lineDist = tab->lineDistance().val() *_spatium;
qreal stemX = tab->chordStemPosX(this) *_spatium;
@ -2312,7 +2312,7 @@ QPointF Chord::layoutArticulation(Articulation* a)
pos = stem()->hookPos();
a->layout();
qreal _spatium2 = _spatium * .5;
qreal _spStaff2 = _spStaff * .5;
if (stemSide) { // if artic. is really beyond a stem,

View file

@ -1189,7 +1189,7 @@ void Score::upDown(bool up, UpDownMode mode)
switch(mode) {
case UP_DOWN_OCTAVE: // move same note to next string, if possible
{
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(oNote->staff()->staffType());
StaffType* stt = oNote->staff()->staffType();
string = stt->physStringToVisual(string);
string += (up ? -1 : 1);
if (string < 0 || string >= stringData->strings())

View file

@ -679,7 +679,7 @@ void Score::putNote(const Position& p, bool replace)
MScore::Direction stemDirection = MScore::AUTO;
NoteVal nval;
StringData* stringData = 0;
StaffTypeTablature * tab = 0;
StaffType* tab = 0;
switch(st->staffType()->group()) {
case PERCUSSION_STAFF_GROUP: {
@ -699,7 +699,7 @@ void Score::putNote(const Position& p, bool replace)
if (_is.rest())
return;
stringData = instr->stringData();
tab = (StaffTypeTablature*)st->staffType();
tab = st->staffType();
int string = tab->VisualStringToPhys(line);
if (string < 0 || string >= stringData->strings())
return;

View file

@ -3417,7 +3417,7 @@ void Measure::layoutX(qreal stretch)
qreal distBelow = 0.0;
Staff * staff = _score->staff(staffIdx);
if (staff->isTabStaff()) {
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(staff->staffType());
StaffType* stt = staff->staffType();
if (stt->slashStyle()) // if no stems
distAbove = stt->genDurations() ? -stt->durationBoxY() : 0.0;
else { // if stems

View file

@ -204,7 +204,7 @@ void MScore::init()
}
#endif
initScoreFonts();
StaffTypeTablature::readConfigFile(0); // get TAB font config, before initStaffTypes()
StaffType::readConfigFile(0); // get TAB font config, before initStaffTypes()
initStaffTypes();
initDrumset();
FiguredBass::readConfigFile(0);

View file

@ -447,7 +447,7 @@ qreal Note::headWidth() const
return symWidth(noteHead());
}
qreal Note::tabHeadWidth(StaffTypeTablature* tab) const
qreal Note::tabHeadWidth(StaffType* tab) const
{
qreal val;
if (tab && _fret != FRET_NONE && _string != STRING_NONE) {
@ -476,7 +476,11 @@ qreal Note::headHeight() const
return symHeight(noteHead());
}
qreal Note::tabHeadHeight(StaffTypeTablature *tab) const
//---------------------------------------------------------
// tabHeadHeight
//---------------------------------------------------------
qreal Note::tabHeadHeight(StaffType* tab) const
{
if(tab && _fret != FRET_NONE && _string != STRING_NONE)
return tab->fretBoxH() * magS();
@ -662,7 +666,7 @@ void Note::draw(QPainter* painter) const
// tablature
if (tablature) {
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
StaffType* tab = staff()->staffType();
if (tieBack() && tab->slashStyle())
return;
QString s = tab->fretString(_fret, _ghost);
@ -1112,8 +1116,7 @@ void Note::endDrag()
if (staff->isTabStaff()) {
// on TABLATURE staves, dragging a note keeps same pitch on a different string (if possible)
// determine new string of dragged note (if tablature is upside down, invert _lineOffset)
int nString = _string + (static_cast<StaffTypeTablature*>(staff->staffType())->upsideDown() ?
-_lineOffset : _lineOffset);
int nString = _string + staff->staffType()->upsideDown() ? -_lineOffset : _lineOffset;
_lineOffset = 0;
// get a fret number for same pitch on new string
StringData* strData = staff->part()->instr()->stringData();
@ -1424,7 +1427,7 @@ void Note::setDotY(MScore::Direction pos)
if (staff()->isTabStaff()) {
// with TAB's, dotPosX is not set:
// get dot X from width of fret text and use TAB default spacing
StaffTypeTablature* tab = static_cast<StaffTypeTablature*>(staff()->staffType());
StaffType* tab = staff()->staffType();
if (tab->stemThrough() ) {
// if fret mark on lines, use standard processing
if (tab->onLines())
@ -1486,7 +1489,7 @@ void Note::layout()
{
bool useTablature = staff() && staff()->isTabStaff();
if (useTablature) {
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
StaffType* tab = staff()->staffType();
qreal mags = magS();
qreal w = tabHeadWidth(tab);
bbox().setRect(0.0, tab->fretBoxY() * mags, w, tab->fretBoxH() * mags);
@ -1520,7 +1523,7 @@ void Note::layout2()
x = width();
dd = STAFFTYPE_TAB_DEFAULTDOTDIST_X * spatium();
d = dd * 0.5;
StaffTypeTablature* tab = static_cast<StaffTypeTablature*>( staff()->staffType());
StaffType* tab = staff()->staffType();
if (!tab->stemThrough())
return;
}
@ -1544,7 +1547,7 @@ void Note::layout2()
if (e->type() == SYMBOL && static_cast<Symbol*>(e)->sym() == SymId::noteheadParenthesisRight) {
qreal w = headWidth();
if (staff()->isTabStaff()) {
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
StaffType* tab = staff()->staffType();
w = tabHeadWidth(tab);
}
e->setPos(w, 0.0);

View file

@ -40,7 +40,7 @@ class AccidentalState;
class Accidental;
class NoteDot;
class Spanner;
class StaffTypeTablature;
class StaffType;
enum class SymId;
//---------------------------------------------------------
@ -243,8 +243,8 @@ class Note : public Element {
qreal headWidth() const;
qreal headHeight() const;
qreal tabHeadWidth(StaffTypeTablature* tab = 0) const;
qreal tabHeadHeight(StaffTypeTablature* tab = 0) const;
qreal tabHeadWidth(StaffType* tab = 0) const;
qreal tabHeadHeight(StaffType* tab = 0) const;
QPointF attach() const;
SymId noteHead() const;

View file

@ -47,7 +47,7 @@ void NoteDot::draw(QPainter* p) const
{
if (note() && note()->dotsHidden()) // don't draw dot if note is hidden
return;
if (!staff()->isTabStaff() || ((StaffTypeTablature*)staff()->staffType())->stemThrough()) {
if (!staff()->isTabStaff() || staff()->staffType()->stemThrough()) {
p->setPen(curColor());
drawSymbol(SymId::augmentationDot, p);
}

View file

@ -242,7 +242,7 @@ void Part::read114(XmlReader& e)
if (instr(0)->useDrumset()) {
foreach(Staff* staff, _staves) {
int lines = staff->lines();
staff->setStaffType(score()->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO staff->setStaffType(score()->staffType(PERC_DEFAULT_STAFF_TYPE));
staff->setLines(lines);
}
}

View file

@ -65,8 +65,7 @@ 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()) )
&& (!staff()->staffType()->showRests() || staff()->staffType()->genDurations()))
|| generated())
return;
qreal _spatium = spatium();
@ -320,9 +319,9 @@ void Rest::layout()
rxpos() = 0.0;
if (staff() && staff()->isTabStaff()) {
StaffTypeTablature* tab = (StaffTypeTablature*)staff()->staffType();
StaffType* tab = staff()->staffType();
// if rests are shown and note values are shown as duration symbols
if(tab->showRests() && tab->genDurations()) {
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

View file

@ -291,13 +291,6 @@ void Score::init()
_scoreFont = ScoreFont::fontFactory("emmentaler");
_pageNumberOffset = 0;
if (!parentScore()) {
int numOfPresets = StaffType::numOfPresets();
for (int idx = 0; idx < numOfPresets; idx++) {
StaffType * st = StaffType::preset(idx)->clone();
addStaffType(st);
}
}
_mscVersion = MSCVERSION;
_created = false;
@ -435,11 +428,6 @@ Score::~Score()
delete _tempomap;
delete _sigmap;
delete _repeatList;
for (StaffType** st : staffTypes()) {
if (!(*st)->builtin())
delete *st;
delete st;
}
}
//---------------------------------------------------------
@ -1959,95 +1947,6 @@ Q_INVOKABLE void Score::setMetaTag(const QString& tag, const QString& val)
_metaTags.insert(tag, val);
}
//---------------------------------------------------------
// staffTypes
//---------------------------------------------------------
const QList<StaffType**>& Score::staffTypes() const
{
return rootScore()->_staffTypes;
}
//---------------------------------------------------------
// addStaffType
// ownership of st move to score except if the buildin
// flag is set
//---------------------------------------------------------
void Score::addStaffType(StaffType* st)
{
addStaffType(-1, st);
}
void Score::addStaffType(int idx, StaffType* st)
{
Score* s = rootScore();
// if the modified staff type is NOT replacing an existing type
if (idx < 0 || idx >= s->_staffTypes.size()) {
// store new pointer to pointer to type data
StaffType** stp = new StaffType*;
*stp = st;
s->_staffTypes.append(stp);
}
// if the modified staff type IS replacing an existing type
else {
StaffType* oldStaffType = *(s->_staffTypes[idx]);
// update the type of each root score staff which uses the old type
// as well as the type of each staff linked to each score staff
for (int staffIdx = 0; staffIdx < s->staves().size(); staffIdx++) {
Staff* currStaff = s->staff(staffIdx);
if (currStaff->staffType() == oldStaffType)
currStaff->setStaffType(st);
if (currStaff->linkedStaves())
foreach (Staff* linkStaff, currStaff->linkedStaves()->staves())
if (linkStaff->staffType() == oldStaffType)
linkStaff->setStaffType(st);
}
// store the updated staff type
*(s->_staffTypes[idx]) = st;
// delete old staff type if not built-in
if (!oldStaffType->builtin())
delete oldStaffType;
}
}
//---------------------------------------------------------
// staffTypeIdx
//---------------------------------------------------------
int Score::staffTypeIdx(StaffType* st) const
{
const Score* s = rootScore();
for (int i = 0; i < s->_staffTypes.size(); ++i) {
if ((*s->_staffTypes[i]) == st)
return i;
}
return -1;
}
//---------------------------------------------------------
// staffType
//---------------------------------------------------------
StaffType* Score::staffType(int idx) const
{
const Score* s = rootScore();
if (idx < 0 || idx >= s->_staffTypes.size())
return 0;
return *(s->_staffTypes[idx]);
}
//---------------------------------------------------------
// replaceStaffTypes
//---------------------------------------------------------
void Score::replaceStaffTypes(const QList<StaffType*>& tl)
{
Q_ASSERT(this == rootScore());
for (int idx = 0; idx < tl.size(); idx++)
addStaffType(idx, tl[idx]->clone());
}
//---------------------------------------------------------
// addExcerpt
//---------------------------------------------------------

View file

@ -83,7 +83,6 @@ class Text;
class Omr;
class Audio;
class Parameter;
class StaffType;
class Revisions;
class Spanner;
class MuseScoreView;
@ -294,7 +293,6 @@ class Score : public QObject {
InputState _is;
MStyle _style;
QList<StaffType**> _staffTypes;
QFileInfo info;
bool _created; ///< file is never saved, has generated name
@ -847,13 +845,6 @@ class Score : public QObject {
SynthesizerState& synthesizerState() { return _synthesizerState; }
void setSynthesizerState(const SynthesizerState& s);
const QList<StaffType**>& staffTypes() const;
void replaceStaffTypes(const QList<StaffType*>&);
StaffType* staffType(int idx) const;
int staffTypeIdx(StaffType*) const;
void addStaffType(StaffType*);
void addStaffType(int idx, StaffType*);
void addLayoutFlags(LayoutFlags val) { layoutFlags |= val; }
void updateHairpin(Hairpin*); // add/modify hairpin to pitchOffset list
void removeHairpin(Hairpin*); // remove hairpin from pitchOffset list

View file

@ -125,14 +125,6 @@ void Score::write(Xml& xml, bool selectionOnly)
_style.save(xml, true); // save only differences to buildin style
if (!parentScore()) {
int idx = 0;
foreach(StaffType** st, _staffTypes) {
if ((idx >= STAFF_TYPES) || !(*st)->isEqual(*StaffType::preset(idx)))
(*st)->write(xml, idx);
++idx;
}
}
xml.tag("showInvisible", _showInvisible);
xml.tag("showUnprintable", _showUnprintable);
xml.tag("showFrames", _showFrames);
@ -896,7 +888,7 @@ bool Score::read(XmlReader& e)
ks->read(e);
customKeysigs.append(ks);
}
else if (tag == "StaffType") {
else if (tag == "StaffType") { // obsolete
int idx = e.intAttribute("idx");
QString groupName = e.attribute("group", "pitched");
int group;
@ -907,27 +899,20 @@ bool Score::read(XmlReader& e)
else if (groupName == "tablature")
group = TAB_STAFF_GROUP;
else group = STANDARD_STAFF_GROUP;
#if 0
StaffType* ost = staffType(idx);
StaffType* st;
if (ost && ost->group() == group)
st = ost->clone();
st = new StaffType(*ost);
else {
idx = -1;
switch (group)
{
case PERCUSSION_STAFF_GROUP:
st = new StaffTypePercussion();
break;
case TAB_STAFF_GROUP:
st = new StaffTypeTablature();
break;
default:
st = new StaffTypePitched();
st = new StaffType;
}
}
st->read(e);
st->setBuiltin(false);
addStaffType(idx, st);
#endif
StaffType st;
st.read(e);
// st->setBuiltin(false);
// TODO addStaffType(idx, st);
}
else if (tag == "siglist")
_sigmap->read(e, _fileDivision);

View file

@ -163,7 +163,7 @@ Staff::Staff(Score* s)
_rstaff = 0;
_part = 0;
_keymap[0] = KeySigEvent(0); // default to C major
_staffType = _score->staffType(STANDARD_STAFF_TYPE);
// _staffType = _score->staffType(STANDARD_STAFF_TYPE);
_small = false;
_invisible = false;
_userDist = .0;
@ -182,7 +182,7 @@ Staff::Staff(Score* s, Part* p, int rs)
_rstaff = rs;
_part = p;
_keymap[0] = KeySigEvent(0); // default to C major
_staffType = _score->staffType(STANDARD_STAFF_TYPE);
// _staffType = _score->staffType(STANDARD_STAFF_TYPE);
_small = false;
_invisible = false;
_userDist = .0;
@ -374,7 +374,8 @@ void Staff::write(Xml& xml) const
xml.tag("linkedTo", s->staffIdx(staff) + 1);
}
}
xml.tag("type", score()->staffTypeIdx(_staffType));
_staffType.write(xml);
// xml.tag("type", score()->staffTypeIdx(_staffType));
if (small() && !xml.excerptmode) // switch small staves to normal ones when extracting part
xml.tag("small", small());
if (invisible())
@ -417,17 +418,8 @@ void Staff::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "type") {
StaffType* st = score()->staffType(e.readInt());
if (st) {
_staffType = st;
// set default barLineTo according to staff type (1-line staff bar lines are special)
_barLineFrom = (lines() == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : 0);
_barLineTo = (lines() == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (lines() - 1) * 2);
}
else
qDebug("Staff::read: unknown staff type");
}
if (tag == "type")
_staffType.read(e);
else if (tag == "small")
setSmall(e.readInt());
else if (tag == "invisible")
@ -493,7 +485,7 @@ void Staff::read(XmlReader& e)
qreal Staff::height() const
{
return (lines()-1) * spatium() * _staffType->lineDistance().val();
return (lines()-1) * spatium() * _staffType.lineDistance().val();
}
//---------------------------------------------------------
@ -561,7 +553,7 @@ int Staff::channel(int tick, int voice) const
int Staff::lines() const
{
return _staffType->lines();
return _staffType.lines();
}
//---------------------------------------------------------
@ -572,15 +564,7 @@ void Staff::setLines(int val)
{
if (val == lines())
return;
//
// create new staff type
//
StaffType* st = _staffType->clone();
if(part() && !partName().isEmpty())
st->setName(partName());
st->setLines(val);
setStaffType(st);
score()->addStaffType(st);
_staffType.setLines(val); // TODO: make undoable
}
//---------------------------------------------------------
@ -589,7 +573,7 @@ void Staff::setLines(int val)
qreal Staff::lineDistance() const
{
return _staffType->lineDistance().val();
return _staffType.lineDistance().val();
}
//---------------------------------------------------------
@ -598,7 +582,7 @@ qreal Staff::lineDistance() const
bool Staff::slashStyle() const
{
return _staffType->slashStyle();
return _staffType.slashStyle();
}
//---------------------------------------------------------
@ -607,7 +591,7 @@ bool Staff::slashStyle() const
void Staff::setSlashStyle(bool val)
{
_staffType->setSlashStyle(val);
_staffType.setSlashStyle(val);
}
//---------------------------------------------------------
@ -690,13 +674,14 @@ bool Staff::primaryStaff() const
// setStaffType
//---------------------------------------------------------
void Staff::setStaffType(StaffType* st)
void Staff::setStaffType(const StaffType* st)
{
if (_staffType == st)
return;
//TODO if (_staffType == *st)
// return;
int linesOld = lines();
int linesNew = st->lines();
_staffType = st;
_staffType = *st;
if (linesNew != linesOld) {
int sIdx = score()->staffIdx(this);
if (sIdx < 0) { // staff does not belong to score (yet?)
@ -720,8 +705,8 @@ void Staff::setStaffType(StaffType* st)
ClefType ct = clef(0);
StaffGroup csg = ClefInfo::staffGroup(ct);
if (_staffType->group() != csg) {
switch(_staffType->group()) {
if (_staffType.group() != csg) {
switch(_staffType.group()) {
case TAB_STAFF_GROUP: ct = ClefType(score()->styleI(ST_tabClef)); break;
case STANDARD_STAFF_GROUP: ct = ClefType::G; break; // TODO: use preferred clef for instrument
case PERCUSSION_STAFF_GROUP: ct = ClefType::PERC; break;
@ -758,21 +743,6 @@ void Staff::init(const InstrumentTemplate* t, const StaffType* staffType, int ci
if (!presetStaffType)
presetStaffType = StaffType::getDefaultPreset(t->staffGroup, 0);
// look for a staff type with same structure among staff types already defined in the score
bool found = false;
foreach (StaffType** scoreStaffType, score()->staffTypes()) {
if ( (*scoreStaffType)->isSameStructure(*presetStaffType) ) {
st = *scoreStaffType; // staff type found in score: use for instrument staff
found = true;
break;
}
}
// if staff type not found in score, use from preset (for staff and adding to score staff types)
if (!found) {
st = presetStaffType->clone();
score()->addStaffType(st);
}
// use selected staff type
setStaffType(st);
// if (st->group() == PITCHED_STAFF) // if PITCHED (in other staff groups num of lines is determined by style)
@ -790,22 +760,8 @@ void Staff::initFromStaffType(const StaffType* staffType)
if (!presetStaffType)
presetStaffType = StaffType::getDefaultPreset(STANDARD_STAFF_GROUP, 0);
// look for a staff type with same structure among staff types already defined in the score
StaffType* st = 0;
foreach (StaffType** scoreStaffType, score()->staffTypes()) {
if ( (*scoreStaffType)->isSameStructure(*presetStaffType) ) {
st = *scoreStaffType; // staff type found in score: use for instrument staff
break;
}
}
// if staff type not found in score, use from preset (for staff and adding to score staff types)
if (!st) {
st = presetStaffType->clone();
score()->addStaffType(st);
}
// use selected staff type
setStaffType(st);
setStaffType(staffType);
}
//---------------------------------------------------------
@ -832,16 +788,10 @@ bool Staff::show() const
bool Staff::genKeySig()
{
switch(_staffType->group()) {
case TAB_STAFF_GROUP:
return false;
case STANDARD_STAFF_GROUP:
return static_cast<StaffTypePitched*>(_staffType)->genKeysig();
case PERCUSSION_STAFF_GROUP:
return static_cast<StaffTypePercussion*>(_staffType)->genKeysig();
default:
return true;
}
if (_staffType.group() == TAB_STAFF_GROUP)
return false;
else
return _staffType.genKeysig();
}
//---------------------------------------------------------
@ -850,16 +800,10 @@ bool Staff::genKeySig()
bool Staff::showLedgerLines()
{
switch(_staffType->group()) {
case TAB_STAFF_GROUP:
if (_staffType.group() == TAB_STAFF_GROUP)
return false;
case STANDARD_STAFF_GROUP:
return static_cast<StaffTypePitched*>(_staffType)->showLedgerLines();
case PERCUSSION_STAFF_GROUP:
return static_cast<StaffTypePercussion*>(_staffType)->showLedgerLines();
default:
return true;
}
else
return _staffType.showLedgerLines();
}
//---------------------------------------------------------

View file

@ -35,7 +35,6 @@ class Part;
class Score;
class KeyList;
class StaffType;
class StaffTypeTablature;
class Staff;
class StringData;
class ClefList;
@ -106,7 +105,7 @@ class Staff : public QObject {
qreal _userDist; ///< user edited extra distance
StaffType* _staffType;
StaffType _staffType;
LinkedStaves* _linkedStaves;
@ -186,9 +185,11 @@ class Staff : public QObject {
int channel(int tick, int voice) const;
QMap<int,int>* channelList(int voice) { return &_channelList[voice]; }
StaffType* staffType() const { return _staffType; }
void setStaffType(StaffType* st);
StaffGroup staffGroup() const { return _staffType->group(); }
const StaffType* staffType() const { return &_staffType; }
StaffType* staffType() { return &_staffType; }
void setStaffType(const StaffType* st);
StaffGroup staffGroup() const { return _staffType.group(); }
bool isPitchedStaff() const { return staffGroup() == STANDARD_STAFF_GROUP; }
bool isTabStaff() const { return staffGroup() == TAB_STAFF_GROUP; }
bool isDrumStaff() const { return staffGroup() == PERCUSSION_STAFF_GROUP; }

View file

@ -28,7 +28,6 @@ namespace Ms {
StaffType::StaffType()
{
_builtin = false;
_lines = 5;
_stepOffset = 0;
_lineDistance = Spatium(1);
@ -37,6 +36,25 @@ StaffType::StaffType()
_showBarlines = true;
_slashStyle = false; // do not show stems
_genTimesig = true; // whether time signature is shown or not
_genKeysig = true; // create key signature at beginning of system
_showLedgerLines = true;
}
//---------------------------------------------------------
// groupName
//---------------------------------------------------------
const char* StaffType::groupName() const
{
switch (_group) {
default:
case STANDARD_STAFF_GROUP:
return "pitched";
case PERCUSSION_STAFF_GROUP:
return "percussion";
case TAB_STAFF_GROUP:
return "tablature";
}
}
//---------------------------------------------------------
@ -45,8 +63,30 @@ StaffType::StaffType()
bool StaffType::isEqual(const StaffType& st) const
{
return isSameStructure(st)
&& st._name == _name;
if (_group != TAB_STAFF_GROUP) {
return isSameStructure(st)
&& st._name == _name
&& st._genKeysig == _genKeysig
&& st._showLedgerLines == _showLedgerLines;
}
else {
return st._durationFontIdx == _durationFontIdx
&& st._durationFontSize == _durationFontSize
&& st._durationFontUserY == _durationFontUserY
&& st._fretFontIdx == _fretFontIdx
&& st._fretFontSize == _fretFontSize
&& st._fretFontUserY == _fretFontUserY
&& st._genDurations == _genDurations
&& st._linesThrough == _linesThrough
&& st._minimStyle == _minimStyle
&& st._onLines == _onLines
&& st._showRests == _showRests
&& st._stemsDown == _stemsDown
&& st._stemsThrough == _stemsThrough
&& st._upsideDown == _upsideDown
&& st._useNumbers == _useNumbers
;
}
}
//---------------------------------------------------------
@ -57,15 +97,38 @@ bool StaffType::isEqual(const StaffType& st) const
bool StaffType::isSameStructure(const StaffType& st) const
{
return st.group() == group()
&& st._lines == _lines
&& st._stepOffset == _stepOffset
&& st._lineDistance == _lineDistance
&& st._genClef == _genClef
&& st._showBarlines == _showBarlines
&& st._slashStyle == _slashStyle
&& st._genTimesig == _genTimesig
;
if (_group != TAB_STAFF_GROUP) {
return st.group() == group()
&& st._lines == _lines
&& st._stepOffset == _stepOffset
&& st._lineDistance == _lineDistance
&& st._genClef == _genClef
&& st._showBarlines == _showBarlines
&& st._slashStyle == _slashStyle
&& st._genTimesig == _genTimesig
&& st._genKeysig == _genKeysig
&& st._showLedgerLines == _showLedgerLines
;
}
else {
return st.group() == group()
&& st._lines == _lines
&& st._stepOffset == _stepOffset
&& st._lineDistance == _lineDistance
&& st._genClef == _genClef
&& st._showBarlines == _showBarlines
&& st._slashStyle == _slashStyle
&& st._genDurations == _genDurations
&& st._linesThrough == _linesThrough
&& st._minimStyle == _minimStyle
&& st._onLines == _onLines
&& st._showRests == _showRests
&& st._stemsDown == _stemsDown
&& st._stemsThrough == _stemsThrough
&& st._upsideDown == _upsideDown
&& st._useNumbers == _useNumbers
;
}
}
//---------------------------------------------------------
@ -93,19 +156,9 @@ void StaffType::setLines(int val)
// write
//---------------------------------------------------------
void StaffType::write(Xml& xml, int idx) const
{
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
writeProperties(xml);
xml.etag();
}
//---------------------------------------------------------
// writeProperties
//---------------------------------------------------------
void StaffType::writeProperties(Xml& xml) const
void StaffType::write(Xml& xml) const
{
xml.stag(QString("StaffType group=\"%1\"").arg(groupName()));
xml.tag("name", name());
// uncontionally write properties: staff types are read back over a copy of the built-in types
// and properties may be different across types => each might need to be properly (re-)set
@ -115,6 +168,30 @@ void StaffType::writeProperties(Xml& xml) const
xml.tag("slashStyle", slashStyle());
xml.tag("barlines", showBarlines());
xml.tag("timesig", genTimesig());
if (_group == STANDARD_STAFF_GROUP || _group == PERCUSSION_STAFF_GROUP) {
if (!genKeysig())
xml.tag("keysig", genKeysig());
if (!showLedgerLines())
xml.tag("ledgerlines", showLedgerLines());
}
else {
xml.tag("durations", _genDurations);
xml.tag("durationFontName", _durationFonts[_durationFontIdx].displayName);
xml.tag("durationFontSize", _durationFontSize);
xml.tag("durationFontY", _durationFontUserY);
xml.tag("fretFontName", _fretFonts[_fretFontIdx].displayName);
xml.tag("fretFontSize", _fretFontSize);
xml.tag("fretFontY", _fretFontUserY);
xml.tag("linesThrough", _linesThrough);
xml.tag("minimStyle", _minimStyle);
xml.tag("onLines", _onLines);
xml.tag("showRests", _showRests);
xml.tag("stemsDown", _stemsDown);
xml.tag("stemsThrough", _stemsThrough);
xml.tag("upsideDown", _upsideDown);
xml.tag("useNumbers", _useNumbers);
}
xml.etag();
}
//---------------------------------------------------------
@ -124,37 +201,56 @@ void StaffType::writeProperties(Xml& xml) const
void StaffType::read(XmlReader& e)
{
while (e.readNextStartElement()) {
if (!readProperties(e))
const QStringRef& tag(e.name());
if (tag == "name")
setName(e.readElementText());
else if (tag == "lines")
setLines(e.readInt());
else if (tag == "lineDistance")
setLineDistance(Spatium(e.readDouble()));
else if (tag == "clef")
setGenClef(e.readInt());
else if (tag == "slashStyle")
setSlashStyle(e.readInt());
else if (tag == "barlines")
setShowBarlines(e.readInt());
else if (tag == "timesig")
setGenTimesig(e.readInt());
else if (tag == "durations")
setGenDurations(e.readInt() != 0);
else if (tag == "durationFontName")
setDurationFontName(e.readElementText());
else if (tag == "durationFontSize")
setDurationFontSize(e.readDouble());
else if (tag == "durationFontY")
setDurationFontUserY(e.readDouble());
else if (tag == "fretFontName")
setFretFontName(e.readElementText());
else if (tag == "fretFontSize")
setFretFontSize(e.readDouble());
else if (tag == "fretFontY")
setFretFontUserY(e.readDouble());
else if (tag == "linesThrough")
setLinesThrough(e.readInt() != 0);
else if (tag == "minimStyle")
setMinimStyle( (TablatureMinimStyle) e.readInt() );
else if (tag == "onLines")
setOnLines(e.readInt() != 0);
else if (tag == "showRests")
setShowRests(e.readInt() != 0);
else if (tag == "stemsDown")
setStemsDown(e.readInt() != 0);
else if (tag == "stemsThrough")
setStemsThrough(e.readInt() != 0);
else if (tag == "upsideDown")
setUpsideDown(e.readInt() != 0);
else if (tag == "useNumbers")
setUseNumbers(e.readInt() != 0);
else
e.unknown();
}
}
//---------------------------------------------------------
// readProperties
//---------------------------------------------------------
bool StaffType::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());
if (tag == "name")
setName(e.readElementText());
else if (tag == "lines")
setLines(e.readInt());
else if (tag == "lineDistance")
setLineDistance(Spatium(e.readDouble()));
else if (tag == "clef")
setGenClef(e.readInt());
else if (tag == "slashStyle")
setSlashStyle(e.readInt());
else if (tag == "barlines")
setShowBarlines(e.readInt());
else if (tag == "timesig")
setGenTimesig(e.readInt());
else
return false;
return true;
}
//---------------------------------------------------------
// doty1
// get y dot position of first repeat barline dot
@ -209,156 +305,16 @@ qreal StaffType::doty2() const
return 0.0;
}
//---------------------------------------------------------
// StaffTypePitched
//---------------------------------------------------------
StaffTypePitched::StaffTypePitched()
: StaffType()
{
_genKeysig = true; // create key signature at beginning of system
_showLedgerLines = true;
}
//---------------------------------------------------------
// isEqual
//---------------------------------------------------------
bool StaffTypePitched::isEqual(const StaffType& st) const
{
return StaffType::isEqual(st)
&& static_cast<const StaffTypePitched&>(st)._genKeysig == _genKeysig
&& static_cast<const StaffTypePitched&>(st)._showLedgerLines == _showLedgerLines
;
}
//---------------------------------------------------------
// isSameStructure
//
// same as isEqual(), but ignores name
//---------------------------------------------------------
bool StaffTypePitched::isSameStructure(const StaffType& st) const
{ return StaffType::isSameStructure(st)
&& static_cast<const StaffTypePitched&>(st)._genKeysig == _genKeysig
&& static_cast<const StaffTypePitched&>(st)._showLedgerLines == _showLedgerLines;
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
void StaffTypePitched::write(Xml& xml, int idx) const
{
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
StaffType::writeProperties(xml);
if (!genKeysig())
xml.tag("keysig", genKeysig());
if (!showLedgerLines())
xml.tag("ledgerlines", showLedgerLines());
xml.etag();
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
void StaffTypePitched::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "keysig")
setGenKeysig(e.readInt());
else if (tag == "ledgerlines")
setShowLedgerLines(e.readInt());
else {
if (!StaffType::readProperties(e))
e.unknown();
}
}
}
//---------------------------------------------------------
// StaffTypePercussion
//---------------------------------------------------------
StaffTypePercussion::StaffTypePercussion()
: StaffType()
{
_genKeysig = true; // create key signature at beginning of system
_showLedgerLines = true;
}
//---------------------------------------------------------
// isEqual
//---------------------------------------------------------
bool StaffTypePercussion::isEqual(const StaffType& st) const
{
return StaffType::isEqual(st)
&& static_cast<const StaffTypePercussion&>(st)._genKeysig == _genKeysig
&& static_cast<const StaffTypePercussion&>(st)._showLedgerLines == _showLedgerLines
;
}
//---------------------------------------------------------
// isSameStructure
//
// same as isEqual(), but ignores name
//---------------------------------------------------------
bool StaffTypePercussion::isSameStructure(const StaffType& st) const
{ return StaffType::isSameStructure(st)
&& static_cast<const StaffTypePercussion&>(st)._genKeysig == _genKeysig
&& static_cast<const StaffTypePercussion&>(st)._showLedgerLines == _showLedgerLines;
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
void StaffTypePercussion::write(Xml& xml, int idx) const
{
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
StaffType::writeProperties(xml);
if (!genKeysig())
xml.tag("keysig", genKeysig());
if (!showLedgerLines())
xml.tag("ledgerlines", showLedgerLines());
xml.etag();
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
void StaffTypePercussion::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "keysig")
setGenKeysig(e.readInt());
else if (tag == "ledgerlines")
setShowLedgerLines(e.readInt());
else {
if (!StaffType::readProperties(e))
e.unknown();
}
}
}
//---------------------------------------------------------
// StaffTypeTablature
//---------------------------------------------------------
#define TAB_DEFAULT_DUR_YOFFS (-1.75)
QList<TablatureFretFont> StaffTypeTablature::_fretFonts = QList<TablatureFretFont>();
QList<TablatureDurationFont> StaffTypeTablature::_durationFonts = QList<TablatureDurationFont>();
QList<TablatureFretFont> StaffType::_fretFonts = QList<TablatureFretFont>();
QList<TablatureDurationFont> StaffType::_durationFonts = QList<TablatureDurationFont>();
void StaffTypeTablature::init()
void StaffType::init()
{
// set reasonable defaults for type-specific members */
setDurationFontName(_durationFonts[0].displayName);
@ -384,127 +340,11 @@ void StaffTypeTablature::init()
_durationBoxH = _durationBoxY = _durationYOffset = _fretBoxH = _fretBoxY = _fretYOffset = _refDPI = 0.0;
}
//---------------------------------------------------------
// isEqual
//---------------------------------------------------------
bool StaffTypeTablature::isEqual(const StaffType& st) const
{
return StaffType::isEqual(st)
&& static_cast<const StaffTypeTablature&>(st)._durationFontIdx == _durationFontIdx
&& static_cast<const StaffTypeTablature&>(st)._durationFontSize == _durationFontSize
&& static_cast<const StaffTypeTablature&>(st)._durationFontUserY == _durationFontUserY
&& static_cast<const StaffTypeTablature&>(st)._fretFontIdx == _fretFontIdx
&& static_cast<const StaffTypeTablature&>(st)._fretFontSize == _fretFontSize
&& static_cast<const StaffTypeTablature&>(st)._fretFontUserY == _fretFontUserY
&& static_cast<const StaffTypeTablature&>(st)._genDurations == _genDurations
&& static_cast<const StaffTypeTablature&>(st)._linesThrough == _linesThrough
&& static_cast<const StaffTypeTablature&>(st)._minimStyle == _minimStyle
&& static_cast<const StaffTypeTablature&>(st)._onLines == _onLines
&& static_cast<const StaffTypeTablature&>(st)._showRests == _showRests
&& static_cast<const StaffTypeTablature&>(st)._stemsDown == _stemsDown
&& static_cast<const StaffTypeTablature&>(st)._stemsThrough == _stemsThrough
&& static_cast<const StaffTypeTablature&>(st)._upsideDown == _upsideDown
&& static_cast<const StaffTypeTablature&>(st)._useNumbers == _useNumbers
;
}
//---------------------------------------------------------
// isSameStructure
//
// same as isEqual(), but ignores name and font data
//---------------------------------------------------------
bool StaffTypeTablature::isSameStructure(const StaffType &st) const
{
return StaffType::isSameStructure(st)
&& static_cast<const StaffTypeTablature&>(st)._genDurations == _genDurations
&& static_cast<const StaffTypeTablature&>(st)._linesThrough == _linesThrough
&& static_cast<const StaffTypeTablature&>(st)._minimStyle == _minimStyle
&& static_cast<const StaffTypeTablature&>(st)._onLines == _onLines
&& static_cast<const StaffTypeTablature&>(st)._showRests == _showRests
&& static_cast<const StaffTypeTablature&>(st)._stemsDown == _stemsDown
&& static_cast<const StaffTypeTablature&>(st)._stemsThrough == _stemsThrough
&& static_cast<const StaffTypeTablature&>(st)._upsideDown == _upsideDown
&& static_cast<const StaffTypeTablature&>(st)._useNumbers == _useNumbers;
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
void StaffTypeTablature::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "durations")
setGenDurations(e.readInt() != 0);
else if (tag == "durationFontName")
setDurationFontName(e.readElementText());
else if (tag == "durationFontSize")
setDurationFontSize(e.readDouble());
else if (tag == "durationFontY")
setDurationFontUserY(e.readDouble());
else if (tag == "fretFontName")
setFretFontName(e.readElementText());
else if (tag == "fretFontSize")
setFretFontSize(e.readDouble());
else if (tag == "fretFontY")
setFretFontUserY(e.readDouble());
else if (tag == "linesThrough")
setLinesThrough(e.readInt() != 0);
else if (tag == "minimStyle")
setMinimStyle( (TablatureMinimStyle) e.readInt() );
else if (tag == "onLines")
setOnLines(e.readInt() != 0);
else if (tag == "showRests")
setShowRests(e.readInt() != 0);
else if (tag == "stemsDown")
setStemsDown(e.readInt() != 0);
else if (tag == "stemsThrough")
setStemsThrough(e.readInt() != 0);
else if (tag == "upsideDown")
setUpsideDown(e.readInt() != 0);
else if (tag == "useNumbers")
setUseNumbers(e.readInt() != 0);
else
if (!StaffType::readProperties(e))
e.unknown();
}
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
void StaffTypeTablature::write(Xml& xml, int idx) const
{
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
StaffType::writeProperties(xml);
xml.tag("durations", _genDurations);
xml.tag("durationFontName", _durationFonts[_durationFontIdx].displayName);
xml.tag("durationFontSize", _durationFontSize);
xml.tag("durationFontY", _durationFontUserY);
xml.tag("fretFontName", _fretFonts[_fretFontIdx].displayName);
xml.tag("fretFontSize", _fretFontSize);
xml.tag("fretFontY", _fretFontUserY);
xml.tag("linesThrough", _linesThrough);
xml.tag("minimStyle", _minimStyle);
xml.tag("onLines", _onLines);
xml.tag("showRests", _showRests);
xml.tag("stemsDown", _stemsDown);
xml.tag("stemsThrough", _stemsThrough);
xml.tag("upsideDown", _upsideDown);
xml.tag("useNumbers", _useNumbers);
xml.etag();
}
//---------------------------------------------------------
// setOnLines
//---------------------------------------------------------
void StaffTypeTablature::setOnLines(bool val)
void StaffType::setOnLines(bool val)
{
_onLines = val;
_durationMetricsValid = _fretMetricsValid = false;
@ -515,8 +355,8 @@ void StaffTypeTablature::setOnLines(bool val)
// checks whether the internally computed metrics are is still valid and re-computes them, if not
//---------------------------------------------------------
void StaffTypeTablature::setDurationMetrics()
{
void StaffType::setDurationMetrics()
{
if (_durationMetricsValid && _refDPI == MScore::DPI) // metrics are still valid
return;
@ -535,17 +375,17 @@ void StaffTypeTablature::setDurationMetrics()
// keep track of the conditions under which metrics have been computed
_refDPI = MScore::DPI;
_durationMetricsValid = true;
}
}
void StaffTypeTablature::setFretMetrics()
{
if(_fretMetricsValid && _refDPI == MScore::DPI)
void StaffType::setFretMetrics()
{
if (_fretMetricsValid && _refDPI == MScore::DPI)
return;
QFontMetricsF fm(fretFont());
QRectF bb;
// compute vertical displacement
if(_useNumbers) {
if (_useNumbers) {
// compute total height of used characters
QString txt = QString();
for (int idx = 0; idx < 10; idx++) // use only first 10 digits
@ -566,7 +406,7 @@ void StaffTypeTablature::setFretMetrics()
_fretYOffset = -bx.y() / 2.0;
}
// if on string, we are done; if between strings, raise by half line distance
if(!_onLines)
if (!_onLines)
_fretYOffset -= lineDistance().val()*MScore::DPI*SPATIUM20 / 2.0;
// from _fretYOffset, compute _fretBoxH and _fretBoxY
@ -576,31 +416,33 @@ void StaffTypeTablature::setFretMetrics()
// keep track of the conditions under which metrics have been computed
_refDPI = MScore::DPI;
_fretMetricsValid = true;
}
}
//---------------------------------------------------------
// setDurationFontName / setFretFontName
//---------------------------------------------------------
void StaffTypeTablature::setDurationFontName(QString name)
void StaffType::setDurationFontName(QString name)
{
int idx;
for(idx=0; idx < _durationFonts.size(); idx++)
if(_durationFonts[idx].displayName == name)
int idx;
for (idx = 0; idx < _durationFonts.size(); idx++)
if (_durationFonts[idx].displayName == name)
break;
if(idx >= _durationFonts.size()) idx = 0; // if name not found, use first font
if (idx >= _durationFonts.size())
idx = 0; // if name not found, use first font
_durationFont.setFamily(_durationFonts[idx].family);
_durationFontIdx = idx;
_durationMetricsValid = false;
}
void StaffTypeTablature::setFretFontName(QString name)
void StaffType::setFretFontName(QString name)
{
int idx;
for(idx=0; idx < _fretFonts.size(); idx++)
if(_fretFonts[idx].displayName == name)
int idx;
for (idx = 0; idx < _fretFonts.size(); idx++)
if (_fretFonts[idx].displayName == name)
break;
if(idx >= _fretFonts.size()) idx = 0; // if name not found, use first font
if (idx >= _fretFonts.size())
idx = 0; // if name not found, use first font
_fretFont.setFamily(_fretFonts[idx].family);
_fretFontIdx = idx;
_fretMetricsValid = false;
@ -610,7 +452,7 @@ void StaffTypeTablature::setFretFontName(QString name)
// durationBoxH / durationBoxY
//---------------------------------------------------------
qreal StaffTypeTablature::durationBoxH()
qreal StaffType::durationBoxH()
{
if (!_genDurations && !_slashStyle)
return 0.0;
@ -618,9 +460,9 @@ qreal StaffTypeTablature::durationBoxH()
return _durationBoxH;
}
qreal StaffTypeTablature::durationBoxY()
qreal StaffType::durationBoxY()
{
if(!_genDurations && !_slashStyle)
if (!_genDurations && !_slashStyle)
return 0.0;
setDurationMetrics();
return _durationBoxY + _durationFontUserY * MScore::MScore::DPI * SPATIUM20;
@ -630,14 +472,14 @@ qreal StaffTypeTablature::durationBoxY()
// setDurationFontSize / setFretFontSize
//---------------------------------------------------------
void StaffTypeTablature::setDurationFontSize(qreal val)
void StaffType::setDurationFontSize(qreal val)
{
_durationFontSize = val;
_durationFont.setPixelSize( lrint(val * MScore::DPI / PPI) );
_durationMetricsValid = false;
}
void StaffTypeTablature::setFretFontSize(qreal val)
void StaffType::setFretFontSize(qreal val)
{
_fretFontSize = val;
_fretFont.setPixelSize( lrint(val * MScore::DPI / PPI) );
@ -654,7 +496,7 @@ void StaffTypeTablature::setFretFontSize(qreal val)
// returns the vertical position of stem start point
//---------------------------------------------------------
qreal StaffTypeTablature::chordRestStemPosY(const ChordRest *chordRest) const
qreal StaffType::chordRestStemPosY(const ChordRest *chordRest) const
{
if (stemThrough()) // does not make sense for "stems through staves" setting; just return top line vert. position
return 0.0;
@ -678,10 +520,10 @@ qreal StaffTypeTablature::chordRestStemPosY(const ChordRest *chordRest) const
//---------------------------------------------------------
// chordStemPos
// return position of note at other side of beam
// return position of note at other side of beam
//---------------------------------------------------------
QPointF StaffTypeTablature::chordStemPos(const Chord *chord) const
QPointF StaffType::chordStemPos(const Chord* chord) const
{
qreal y;
if (stemThrough())
@ -699,7 +541,7 @@ QPointF StaffTypeTablature::chordStemPos(const Chord *chord) const
// return position of note at beam side of stem
//---------------------------------------------------------
QPointF StaffTypeTablature::chordStemPosBeam(const Chord *chord) const
QPointF StaffType::chordStemPosBeam(const Chord* chord) const
{
qreal y = ( stemsDown() ? chord->downString() : chord->upString() ) * _lineDistance.val();
@ -711,7 +553,7 @@ QPointF StaffTypeTablature::chordStemPosBeam(const Chord *chord) const
// return length of stem
//---------------------------------------------------------
qreal StaffTypeTablature::chordStemLength(const Chord *chord) const
qreal StaffType::chordStemLength(const Chord* chord) const
{
qreal stemLen;
// if stems are through staff, length should be computed by relevant chord algorithm;
@ -735,7 +577,7 @@ qreal StaffTypeTablature::chordStemLength(const Chord *chord) const
static const QString unknownFret = QString("?");
QString StaffTypeTablature::fretString(int fret, bool ghost) const
QString StaffType::fretString(int fret, bool ghost) const
{
if (fret == FRET_NONE)
return unknownFret;
@ -757,13 +599,13 @@ QString StaffTypeTablature::fretString(int fret, bool ghost) const
}
}
QString StaffTypeTablature::durationString(TDuration::DurationType type, int dots) const
{
QString StaffType::durationString(TDuration::DurationType type, int dots) const
{
QString s = _durationFonts[_durationFontIdx].displayValue[type];
for(int count=0; count < dots; count++)
s.append(_durationFonts[_durationFontIdx].displayDot);
return s;
}
}
//---------------------------------------------------------
// physStringToVisual / VisualStringToPhys
@ -775,21 +617,21 @@ QString StaffTypeTablature::durationString(TDuration::DurationType type, int dot
// introduce more differences)
//---------------------------------------------------------
int StaffTypeTablature::physStringToVisual(int strg) const
{
int StaffType::physStringToVisual(int strg) const
{
if(strg <= STRING_NONE || strg >= _lines) // if no physical string, return topmost visual string
return 0;
// if TAB upside down, reverse string number
return (_upsideDown ? _lines - 1 - strg : strg);
}
}
int StaffTypeTablature::VisualStringToPhys(int strg) const
{
int StaffType::VisualStringToPhys(int strg) const
{
if(strg <= VISUAL_STRING_NONE || strg >= _lines) // if no visual string, return topmost physical string
return 0;
// if TAB upside down, reverse string number
return (_upsideDown ? _lines - 1 - strg : strg);
}
}
//---------------------------------------------------------
// TabDurationSymbol
@ -804,7 +646,7 @@ TabDurationSymbol::TabDurationSymbol(Score* s)
_text = QString();
}
TabDurationSymbol::TabDurationSymbol(Score* s, StaffTypeTablature * tab, TDuration::DurationType type, int dots)
TabDurationSymbol::TabDurationSymbol(Score* s, StaffType* tab, TDuration::DurationType type, int dots)
: Element(s)
{
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
@ -970,11 +812,11 @@ bool TablatureDurationFont::read(XmlReader& e)
// resets everythings and reads the built-in config file if fileName is null or empty
//---------------------------------------------------------
bool StaffTypeTablature::readConfigFile(const QString& fileName)
bool StaffType::readConfigFile(const QString& fileName)
{
QString path;
QString path;
if(fileName == 0 || fileName.isEmpty()) { // defaults to built-in xml
if (fileName == 0 || fileName.isEmpty()) { // defaults to built-in xml
#ifdef Q_OS_IOS
{
extern QString resourcePath();
@ -1035,7 +877,7 @@ qDebug("StaffTypeTablature::readConfigFile failed: <%s>", qPrintable(path));
// the index of a name in the list can be used to retrieve the font data with fontData()
//---------------------------------------------------------
QList<QString> StaffTypeTablature::fontNames(bool bDuration)
QList<QString> StaffType::fontNames(bool bDuration)
{
QList<QString> names;
if(bDuration)
@ -1055,8 +897,8 @@ QList<QString> StaffTypeTablature::fontNames(bool bDuration)
// any of the pointer parameter can be null, if that datum is not needed
//---------------------------------------------------------
bool StaffTypeTablature::fontData(bool bDuration, int nIdx, QString * pFamily, QString * pDisplayName,
qreal * pSize, qreal* pYOff)
bool StaffType::fontData(bool bDuration, int nIdx, QString* pFamily, QString* pDisplayName,
qreal* pSize, qreal* pYOff)
{
if (bDuration) {
if (nIdx >= 0 && nIdx < _durationFonts.size()) {
@ -1089,10 +931,14 @@ bool StaffTypeTablature::fontData(bool bDuration, int nIdx, QString * pFamily, Q
QList<StaffType*> staffTypes;
//---------------------------------------------------------
// StaffTypePreset
//---------------------------------------------------------
struct StaffTypePreset {
QString xmlName; // the name used to reference this preset in intruments.xml
StaffType * staffType; // the actual StaffType settings
};
QString xmlName; // the name used to reference this preset in intruments.xml
StaffType* staffType; // the actual StaffType settings
};
std::array<StaffTypePreset, STAFF_TYPES> _presets;
@ -1121,7 +967,7 @@ const StaffType* StaffType::preset(int idx)
}
const StaffType* StaffType::presetFromXmlName(QString& xmlName, int* idx)
{
{
for (int i = 0; i < (int)_presets.size(); ++i)
if (_presets[i].xmlName == xmlName) {
if (idx)
@ -1129,10 +975,10 @@ const StaffType* StaffType::presetFromXmlName(QString& xmlName, int* idx)
return _presets[i].staffType;
}
return 0;
}
}
const StaffType* StaffType::presetFromName(QString& name, int* idx)
{
{
for (int i = 0; i < (int)_presets.size(); ++i)
if (_presets[i].staffType->name() == name) {
if (idx)
@ -1140,7 +986,7 @@ const StaffType* StaffType::presetFromName(QString& name, int* idx)
return _presets[i].staffType;
}
return 0;
}
}
const QString& StaffType::presetXmlName(int idx)
{
@ -1172,22 +1018,22 @@ void initStaffTypes()
{
// init staff type presets
// human readable name lin dst clef bars stmless time key ledger
_presets[STANDARD_STAFF_TYPE].staffType = new StaffTypePitched (QObject::tr("Standard"), 5, 1, true, true, false, true, true, true);
_presets[PERC_1LINE_STAFF_TYPE].staffType = new StaffTypePercussion(QObject::tr("Perc. 1 line"), 1, 1, true, true, false, true, false, true);
_presets[PERC_3LINE_STAFF_TYPE].staffType = new StaffTypePercussion(QObject::tr("Perc. 3 lines"), 3, 1, true, true, false, true, false, true);
_presets[PERC_5LINE_STAFF_TYPE].staffType = new StaffTypePercussion(QObject::tr("Perc. 5 lines"), 5, 1, true, true, false, true, false, true);
_presets[STANDARD_STAFF_TYPE].staffType = new StaffType(STANDARD_STAFF_GROUP, QObject::tr("Standard"), 5, 1, true, true, false, true, true, true);
_presets[PERC_1LINE_STAFF_TYPE].staffType = new StaffType(PERCUSSION_STAFF_GROUP, QObject::tr("Perc. 1 line"), 1, 1, true, true, false, true, false, true);
_presets[PERC_3LINE_STAFF_TYPE].staffType = new StaffType(PERCUSSION_STAFF_GROUP, QObject::tr("Perc. 3 lines"), 3, 1, true, true, false, true, false, true);
_presets[PERC_5LINE_STAFF_TYPE].staffType = new StaffType(PERCUSSION_STAFF_GROUP, QObject::tr("Perc. 5 lines"), 5, 1, true, true, false, true, false, true);
// human-readable name lin dist clef bars stemless time duration font size off genDur fret font size off thru minim style onLin rests stmDn stmThr upsDn nums
_presets[TAB_6SIMPLE_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 6-str simple"), 6, 1.5, true, true, true, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Sans"), 9, 0, false, TAB_MINIM_NONE, true, false, true, false, false, true);
_presets[TAB_6COMMON_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 6-str common"), 6, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, false, true, false, false, true);
_presets[TAB_6FULL_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 6-str full"), 6, 1.5, true, true, false, true, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SLASHED,true, true, true, true, false, true);
_presets[TAB_4SIMPLE_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 4-str simple"), 4, 1.5, true, true, true, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Sans"), 9, 0, false, TAB_MINIM_NONE, true, false, true, false, false, true);
_presets[TAB_4COMMON_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 4-str common"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, false, true, false, false, true);
_presets[TAB_4FULL_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 4-str full"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SLASHED,true, true, true, true, false, true);
_presets[TAB_UKULELE_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. ukulele"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, true, true, false, false, true);
_presets[TAB_BALALAJKA_STAFF_TYPE].staffType= new StaffTypeTablature(QObject::tr("Tab. balalajka"), 3, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, true, true, false, false, true);
_presets[TAB_6SIMPLE_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 6-str simple"), 6, 1.5, true, true, true, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Sans"), 9, 0, false, TAB_MINIM_NONE, true, false, true, false, false, true);
_presets[TAB_6COMMON_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 6-str common"), 6, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, false, true, false, false, true);
_presets[TAB_6FULL_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 6-str full"), 6, 1.5, true, true, false, true, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SLASHED,true, true, true, true, false, true);
_presets[TAB_4SIMPLE_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 4-str simple"), 4, 1.5, true, true, true, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Sans"), 9, 0, false, TAB_MINIM_NONE, true, false, true, false, false, true);
_presets[TAB_4COMMON_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 4-str common"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, false, true, false, false, true);
_presets[TAB_4FULL_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 4-str full"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SLASHED,true, true, true, true, false, true);
_presets[TAB_UKULELE_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. ukulele"), 4, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, true, true, false, false, true);
_presets[TAB_BALALAJKA_STAFF_TYPE].staffType= new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. balalajka"), 3, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 9, 0, false, TAB_MINIM_SHORTER,true, true, true, false, false, true);
// (QObject::tr("Tab. bandurria"), 6, 1.5, true, true, false, false, QString("MuseScore Tab Modern"), 15, 0, false, QString("MuseScore Tab Serif"), 10, 0, false, TAB_MINIM_SLASHED,true, true, true, true, false, true);
_presets[TAB_ITALIAN_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 6-str Italian"),6, 1.5, false, true, true, true, QString("MuseScore Tab Italian"),15, 0, true, QString("MuseScore Tab Renaiss"), 10, 0, true, TAB_MINIM_NONE, true, true, false, false, true, true);
_presets[TAB_FRENCH_STAFF_TYPE].staffType = new StaffTypeTablature(QObject::tr("Tab. 6-str French"), 6, 1.5, false, true, true, true, QString("MuseScore Tab French"), 15, 0, true, QString("MuseScore Tab Renaiss"), 10, 0, true, TAB_MINIM_NONE, false, false, false, false, false, false);
_presets[TAB_ITALIAN_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 6-str Italian"),6, 1.5, false, true, true, true, QString("MuseScore Tab Italian"),15, 0, true, QString("MuseScore Tab Renaiss"), 10, 0, true, TAB_MINIM_NONE, true, true, false, false, true, true);
_presets[TAB_FRENCH_STAFF_TYPE].staffType = new StaffType(TAB_STAFF_GROUP, QObject::tr("Tab. 6-str French"), 6, 1.5, false, true, true, true, QString("MuseScore Tab French"), 15, 0, true, QString("MuseScore Tab Renaiss"), 10, 0, true, TAB_MINIM_NONE, false, false, false, false, false, false);
_presets[STANDARD_STAFF_TYPE].xmlName = QString("stdNormal");
_presets[PERC_1LINE_STAFF_TYPE].xmlName = QString("perc1Line");

View file

@ -60,152 +60,6 @@ class ChordRest;
class Staff;
class Xml;
//---------------------------------------------------------
// StaffType
//---------------------------------------------------------
class StaffType {
bool _builtin; // used for memory management: do not delete if true
protected:
QString _name;
int _lines;
int _stepOffset;
Spatium _lineDistance;
bool _genClef; // create clef at beginning of system
bool _showBarlines;
bool _slashStyle; // do not show stems
bool _genTimesig; // whether time signature is shown or not
public:
StaffType();
StaffType(const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimeSig) :
_name(name), _lineDistance(Spatium(lineDist)), _genClef(genClef),_showBarlines(showBarLines),
_slashStyle(stemless), _genTimesig(genTimeSig)
{
_builtin = false;
setLines(lines);
}
virtual ~StaffType() {}
QString name() const { return _name; }
void setName(const QString& val) { _name = val; }
virtual StaffGroup group() const = 0;
virtual StaffType* clone() const = 0;
virtual const char* groupName() const = 0;
virtual bool isEqual(const StaffType&) const;
virtual bool isSameStructure(const StaffType&) const;
virtual void setLines(int val);
int lines() const { return _lines; }
void setStepOffset(int v) { _stepOffset = v; }
int stepOffset() const { return _stepOffset; }
void setLineDistance(const Spatium& val) { _lineDistance = val; }
Spatium lineDistance() const { return _lineDistance; }
void setGenClef(bool val) { _genClef = val; }
bool genClef() const { return _genClef; }
void setShowBarlines(bool val) { _showBarlines = val; }
bool showBarlines() const { return _showBarlines; }
virtual void write(Xml& xml, int) const;
void writeProperties(Xml& xml) const;
virtual void read(XmlReader&);
bool readProperties(XmlReader& e);
void setSlashStyle(bool val) { _slashStyle = val; }
bool slashStyle() const { return _slashStyle; }
bool genTimesig() const { return _genTimesig; }
void setGenTimesig(bool val) { _genTimesig = val; }
qreal doty1() const;
qreal doty2() const;
bool builtin() { return _builtin; }
void setBuiltin(bool val) { _builtin = val; }
// static function to deal with presets
static const StaffType* getDefaultPreset(StaffGroup grp, int* idx);
static size_t numOfPresets();
static const StaffType* preset(int idx);
static const StaffType* presetFromName(QString& name, int* idx);
static const StaffType* presetFromXmlName(QString& xmlName, int* idx);
static const QString& presetXmlName(int idx);
static const QString& presetName(int idx);
};
// ready-made staff types:
enum {
STANDARD_STAFF_TYPE,
PERC_1LINE_STAFF_TYPE, PERC_3LINE_STAFF_TYPE, PERC_5LINE_STAFF_TYPE,
TAB_6SIMPLE_STAFF_TYPE, TAB_6COMMON_STAFF_TYPE, TAB_6FULL_STAFF_TYPE,
TAB_4SIMPLE_STAFF_TYPE, TAB_4COMMON_STAFF_TYPE, TAB_4FULL_STAFF_TYPE,
TAB_UKULELE_STAFF_TYPE, TAB_BALALAJKA_STAFF_TYPE, TAB_ITALIAN_STAFF_TYPE, TAB_FRENCH_STAFF_TYPE,
STAFF_TYPES,
// some usefull shorthands:
PERC_DEFAULT_STAFF_TYPE = PERC_5LINE_STAFF_TYPE,
TAB_DEFAULT_STAFF_TYPE = TAB_6COMMON_STAFF_TYPE
};
//---------------------------------------------------------
// StaffTypePitched
//---------------------------------------------------------
class StaffTypePitched : public StaffType {
bool _genKeysig; // create key signature at beginning of system
bool _showLedgerLines;
public:
StaffTypePitched();
StaffTypePitched(const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimeSig, bool genKeySig, bool showLedgerLines) :
StaffType(name, lines, lineDist, genClef, showBarLines, stemless, genTimeSig),
_genKeysig(genKeySig), _showLedgerLines(showLedgerLines)
{
}
virtual StaffGroup group() const { return STANDARD_STAFF_GROUP; }
virtual StaffTypePitched* clone() const { return new StaffTypePitched(*this); }
virtual const char* groupName() const { return "pitched"; }
virtual bool isEqual(const StaffType&) const;
virtual bool isSameStructure(const StaffType& st) const;
virtual void read(XmlReader&);
virtual void write(Xml& xml, int) const;
void setGenKeysig(bool val) { _genKeysig = val; }
bool genKeysig() const { return _genKeysig; }
void setShowLedgerLines(bool val) { _showLedgerLines = val; }
bool showLedgerLines() const { return _showLedgerLines; }
};
//---------------------------------------------------------
// StaffTypePercussion
//---------------------------------------------------------
class StaffTypePercussion : public StaffType {
bool _genKeysig; // create key signature at beginning of system
bool _showLedgerLines;
public:
StaffTypePercussion();
StaffTypePercussion(const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimeSig, bool genKeySig, bool showLedgerLines) :
StaffType(name, lines, lineDist, genClef, showBarLines, stemless, genTimeSig),
_genKeysig(genKeySig), _showLedgerLines(showLedgerLines)
{
}
virtual StaffGroup group() const { return PERCUSSION_STAFF_GROUP; }
virtual StaffTypePercussion* clone() const { return new StaffTypePercussion(*this); }
virtual const char* groupName() const { return "percussion"; }
virtual bool isEqual(const StaffType&) const;
virtual bool isSameStructure(const StaffType& st) const;
virtual void read(XmlReader&);
virtual void write(Xml& xml, int) const;
void setGenKeysig(bool val) { _genKeysig = val; }
bool genKeysig() const { return _genKeysig; }
void setShowLedgerLines(bool val) { _showLedgerLines = val; }
bool showLedgerLines() const { return _showLedgerLines; }
};
//---------------------------------------------------------
// TablatureFont
//---------------------------------------------------------
@ -259,12 +113,25 @@ struct TablatureDurationFont {
};
//---------------------------------------------------------
// StaffTypeTablature
// StaffType
//---------------------------------------------------------
class StaffTypeTablature : public StaffType {
class StaffType {
StaffGroup _group;
QString _name;
int _lines;
int _stepOffset;
Spatium _lineDistance;
bool _genClef; // create clef at beginning of system
bool _showBarlines;
bool _slashStyle; // do not show stems
bool _genTimesig; // whether time signature is shown or not
bool _genKeysig; // create key signature at beginning of system
bool _showLedgerLines;
protected:
// configurable properties
qreal _durationFontSize; // the size (in points) for the duration symbol font
qreal _durationFontUserY; // the vertical offset (spatium units) for the duration symb. font
@ -306,17 +173,24 @@ class StaffTypeTablature : public StaffType {
static QList<TablatureFretFont> _fretFonts;
static QList<TablatureDurationFont> _durationFonts;
void init(); // init to reasonable defaults
public:
StaffTypeTablature() : StaffType() { init(); }
StaffTypeTablature(const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimesig,
const QString& durFontName, qreal durFontSize, qreal durFontUserY, qreal genDur,
const QString& fretFontName, qreal fretFontSize, qreal fretFontUserY,
bool linesThrough, TablatureMinimStyle minimStyle, bool onLines, bool showRests,
bool stemsDown, bool stemThrough, bool upsideDown, bool useNumbers)
StaffType();
StaffType(StaffGroup sg, const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimeSig, bool genKeySig, bool showLedgerLines) :
_group(sg), _name(name), _lineDistance(Spatium(lineDist)), _genClef(genClef),_showBarlines(showBarLines),
_slashStyle(stemless), _genTimesig(genTimeSig),
_genKeysig(genKeySig), _showLedgerLines(showLedgerLines)
{
setLines(lines);
}
StaffType(StaffGroup sg, const QString& name, int lines, qreal lineDist, bool genClef,
bool showBarLines, bool stemless, bool genTimesig,
const QString& durFontName, qreal durFontSize, qreal durFontUserY, qreal genDur,
const QString& fretFontName, qreal fretFontSize, qreal fretFontUserY,
bool linesThrough, TablatureMinimStyle minimStyle, bool onLines, bool showRests,
bool stemsDown, bool stemThrough, bool upsideDown, bool useNumbers)
{
_group = sg;
setName(name);
setLines(lines);
setLineDistance(Spatium(lineDist));
@ -341,14 +215,49 @@ class StaffTypeTablature : public StaffType {
setUseNumbers(useNumbers);
}
// re-implemented virtual functions
virtual StaffGroup group() const { return TAB_STAFF_GROUP; }
virtual StaffTypeTablature* clone() const { return new StaffTypeTablature(*this); }
virtual const char* groupName() const { return "tablature"; }
virtual void read(XmlReader& e);
virtual void write(Xml& xml, int) const;
virtual bool isEqual(const StaffType&) const;
virtual bool isSameStructure(const StaffType& st) const;
virtual ~StaffType() {}
void init();
StaffGroup group() const { return _group; }
QString name() const { return _name; }
void setName(const QString& val) { _name = val; }
const char* groupName() const;
bool isEqual(const StaffType&) const;
bool isSameStructure(const StaffType&) const;
void setLines(int val);
int lines() const { return _lines; }
void setStepOffset(int v) { _stepOffset = v; }
int stepOffset() const { return _stepOffset; }
void setLineDistance(const Spatium& val) { _lineDistance = val; }
Spatium lineDistance() const { return _lineDistance; }
void setGenClef(bool val) { _genClef = val; }
bool genClef() const { return _genClef; }
void setShowBarlines(bool val) { _showBarlines = val; }
bool showBarlines() const { return _showBarlines; }
void write(Xml& xml) const;
void read(XmlReader&);
void setSlashStyle(bool val) { _slashStyle = val; }
bool slashStyle() const { return _slashStyle; }
bool genTimesig() const { return _genTimesig; }
void setGenTimesig(bool val) { _genTimesig = val; }
qreal doty1() const;
qreal doty2() const;
// static function to deal with presets
static const StaffType* getDefaultPreset(StaffGroup grp, int* idx);
static size_t numOfPresets();
static const StaffType* preset(int idx);
static const StaffType* presetFromName(QString& name, int* idx);
static const StaffType* presetFromXmlName(QString& xmlName, int* idx);
static const QString& presetXmlName(int idx);
static const QString& presetName(int idx);
void setGenKeysig(bool val) { _genKeysig = val; }
bool genKeysig() const { return _genKeysig; }
void setShowLedgerLines(bool val) { _showLedgerLines = val; }
bool showLedgerLines() const { return _showLedgerLines; }
QString fretString(int fret, bool ghost) const; // returns a string with the text for fret
QString durationString(TDuration::DurationType type, int dots) const;
@ -384,6 +293,7 @@ class StaffTypeTablature : public StaffType {
bool stemThrough() const { return _stemsThrough; }
bool upsideDown() const { return _upsideDown; }
bool useNumbers() const { return _useNumbers; }
// properties setters (setting some props invalidates metrics)
void setDurationFontName(QString name);
void setDurationFontSize(qreal val);
@ -392,7 +302,7 @@ class StaffTypeTablature : public StaffType {
void setFretFontSize(qreal val);
void setFretFontUserY(qreal val) { _fretFontUserY = val; }
void setGenDurations(bool val) { _genDurations = val; }
virtual void setLines(int val) { _lines = val; _stepOffset = (val / 2 - 2) * 2; }
// virtual void setLines(int val) { _lines = val; _stepOffset = (val / 2 - 2) * 2; }
void setLinesThrough(bool val) { _linesThrough = val; }
void setMinimStyle(TablatureMinimStyle val) { _minimStyle = val; }
void setOnLines(bool val);
@ -420,9 +330,22 @@ class StaffTypeTablature : public StaffType {
void setFretMetrics();
};
// ready-made staff types:
enum {
STANDARD_STAFF_TYPE,
PERC_1LINE_STAFF_TYPE, PERC_3LINE_STAFF_TYPE, PERC_5LINE_STAFF_TYPE,
TAB_6SIMPLE_STAFF_TYPE, TAB_6COMMON_STAFF_TYPE, TAB_6FULL_STAFF_TYPE,
TAB_4SIMPLE_STAFF_TYPE, TAB_4COMMON_STAFF_TYPE, TAB_4FULL_STAFF_TYPE,
TAB_UKULELE_STAFF_TYPE, TAB_BALALAJKA_STAFF_TYPE, TAB_ITALIAN_STAFF_TYPE, TAB_FRENCH_STAFF_TYPE,
STAFF_TYPES,
// some usefull shorthands:
PERC_DEFAULT_STAFF_TYPE = PERC_5LINE_STAFF_TYPE,
TAB_DEFAULT_STAFF_TYPE = TAB_6COMMON_STAFF_TYPE
};
extern void initStaffTypes();
//extern QList<StaffType*> staffTypes;
//---------------------------------------------------------
// TabDurationSymbol
@ -430,12 +353,12 @@ extern void initStaffTypes();
//---------------------------------------------------------
class TabDurationSymbol : public Element {
StaffTypeTablature* _tab;
QString _text;
StaffType* _tab;
QString _text;
public:
TabDurationSymbol(Score* s);
TabDurationSymbol(Score* s, StaffTypeTablature * tab, TDuration::DurationType type, int dots);
TabDurationSymbol(Score* s, StaffType* tab, TDuration::DurationType type, int dots);
TabDurationSymbol(const TabDurationSymbol&);
virtual TabDurationSymbol* clone() const { return new TabDurationSymbol(*this); }
virtual void draw(QPainter*) const;
@ -443,7 +366,7 @@ class TabDurationSymbol : public Element {
virtual void layout();
virtual ElementType type() const { return TAB_DURATION_SYMBOL; }
void setDuration(TDuration::DurationType type, int dots, StaffTypeTablature* tab)
void setDuration(TDuration::DurationType type, int dots, StaffType* tab)
{ _tab = tab;
_text = tab->durationString(type, dots);
}

View file

@ -80,12 +80,12 @@ void Stem::layout()
Staff* st = staff();
if (chord() && st ) {
if (st->isTabStaff() ) { // TAB staves
if ( ((StaffTypeTablature*)st->staffType())->stemThrough()) {
if (st->staffType()->stemThrough()) {
// if stems through staves, gets Y pos. of stem-side note relative to chord other side
qreal lineDist = st->lineDistance() * spatium();
y1 = (chord()->downString() - chord()->upString() ) * _up * lineDist;
// if fret marks above lines, raise stem beginning by 1/2 line distance
if ( !((StaffTypeTablature*)st->staffType())->onLines() )
if (!st->staffType()->onLines())
y1 -= lineDist * 0.5;
// shorten stem by 1/2 lineDist to clear the note and a little more to keep 'air' betwen stem and note
lineDist *= 0.7 * mag();
@ -152,7 +152,7 @@ void Stem::draw(QPainter* painter) const
return;
// TODO: adjust bounding rectangle in layout() for dots and for slash
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType());
StaffType* stt = st->staffType();
qreal sp = spatium();
bool _up = up();

View file

@ -82,6 +82,7 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)
void EditStaff::fillStaffTypeCombo()
{
#if 0 // TODO-ST
Score* score = staff->score();
int curIdx = -1;
// can this instrument accept tabs or drum set?
@ -102,6 +103,7 @@ void EditStaff::fillStaffTypeCombo()
if (curIdx == -1)
qDebug("EditStaff::fillStaffTypeCombo: staff type not found");
staffType->setCurrentIndex(curIdx == -1 ? 0 : curIdx);
#endif
}
//---------------------------------------------------------
@ -203,6 +205,7 @@ void EditStaff::bboxClicked(QAbstractButton* button)
void EditStaff::apply()
{
#if 0 // TODO-ST
Score* score = staff->score();
Part* part = staff->part();
@ -255,6 +258,7 @@ void EditStaff::apply()
score->setLayoutAll(true);
score->update();
#endif
}
//---------------------------------------------------------

View file

@ -41,12 +41,10 @@ EditStaffType::EditStaffType(QWidget* parent, Staff* st)
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
staff = st;
Score* score = staff->score();
// Score* score = staff->score();
// copy types from score and set as non-built-in
foreach(StaffType** const st, score->staffTypes())
staffTypes.append((*st)->clone());
foreach(StaffType* const st, staffTypes)
st->setBuiltin(false);
// foreach(StaffType** const st, score->staffTypes())
// staffTypes.append((*st)->clone());
int idx = 0;
QListWidgetItem* ci = 0;
foreach(StaffType* st, staffTypes) {
@ -78,11 +76,11 @@ EditStaffType::EditStaffType(QWidget* parent, Staff* st)
// tab page configuration
// tabDetails->hide(); // start tabulature page in simple mode
QList<QString> fontNames = StaffTypeTablature::fontNames(false);
QList<QString> fontNames = StaffType::fontNames(false);
foreach(const QString& name, fontNames) // fill fret font name combo
fretFontName->addItem(name);
fretFontName->setCurrentIndex(0);
fontNames = StaffTypeTablature::fontNames(true);
fontNames = StaffType::fontNames(true);
foreach(const QString& name, fontNames) // fill duration font name combo
durFontName->addItem(name);
durFontName->setCurrentIndex(0);
@ -179,7 +177,7 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
switch(st->group()) {
case STANDARD_STAFF_GROUP:
{
StaffTypePitched* sp = static_cast<StaffTypePitched*>(st);
StaffType* sp = static_cast<StaffType*>(st);
if (sp->genKeysig() != genKeysigPitched->isChecked()
|| sp->showLedgerLines() != showLedgerLinesPitched->isChecked()
|| st->slashStyle() != stemlessPitched->isChecked()
@ -191,7 +189,7 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
case TAB_STAFF_GROUP:
{
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
StaffType* stt = static_cast<StaffType*>(st);
TablatureMinimStyle minimStyle = minimNoneRadio->isChecked() ? TAB_MINIM_NONE :
(minimShortRadio->isChecked() ? TAB_MINIM_SHORTER : TAB_MINIM_SLASHED);
if (stt->durationFontName() != durFontName->currentText()
@ -221,7 +219,7 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
case PERCUSSION_STAFF_GROUP:
{
StaffTypePercussion* sp = static_cast<StaffTypePercussion*>(st);
StaffType* sp = static_cast<StaffType*>(st);
if (sp->genKeysig() != genKeysigPercussion->isChecked()
|| sp->showLedgerLines() != showLedgerLinesPercussion->isChecked()
|| st->slashStyle() != stemlessPercussion->isChecked()
@ -243,7 +241,7 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
switch(st->group()) {
case STANDARD_STAFF_GROUP:
{
StaffTypePitched* stp = static_cast<StaffTypePitched*>(st);
StaffType* stp = static_cast<StaffType*>(st);
stp->setName(name->text());
stp->setLines(lines->value());
stp->setLineDistance(Spatium(lineDistance->value()));
@ -257,13 +255,13 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
break;
case TAB_STAFF_GROUP:
{
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
StaffType* stt = static_cast<StaffType*>(st);
setTabFromDlg(stt);
}
break;
case PERCUSSION_STAFF_GROUP:
{
StaffTypePercussion* stp = static_cast<StaffTypePercussion*>(st);
StaffType* stp = static_cast<StaffType*>(st);
setPercFromDlg(stp);
}
break;
@ -291,7 +289,7 @@ void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
switch(st->group()) {
case STANDARD_STAFF_GROUP:
{
StaffTypePitched* ps = static_cast<StaffTypePitched*>(st);
StaffType* ps = static_cast<StaffType*>(st);
stack->setCurrentIndex(0);
name->setText(st->name());
lines->setValue(st->lines());
@ -307,7 +305,7 @@ void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
case TAB_STAFF_GROUP:
{
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
StaffType* stt = static_cast<StaffType*>(st);
blockTabPreviewSignals(true);
setDlgFromTab(stt);
name->setText(stt->name()); // setDlgFromTab() does not copy the name and it shouldn't
@ -318,7 +316,7 @@ void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
case PERCUSSION_STAFF_GROUP:
{
StaffTypePercussion* ps = static_cast<StaffTypePercussion*>(st);
StaffType* ps = static_cast<StaffType*>(st);
blockPercPreviewSignals(true);
setDlgFromPerc(ps);
name->setText(ps->name()); // setDlgFromPerc() does not copy the name and it shouldn't
@ -339,7 +337,7 @@ void EditStaffType::createNewType()
// initialize new StaffType with current selected one
//
int idx = staffTypeList->currentItem()->data(Qt::UserRole).toInt();
StaffType* ns = staffTypes[idx]->clone();
StaffType* ns = new StaffType(*staffTypes[idx]);
ns->setName(createUniqueStaffTypeName(ns->group()));
@ -383,7 +381,7 @@ void EditStaffType::presetPercChanged(int idx)
int presetIdx = presetPercCombo->itemData(idx).toInt();
if(presetIdx >= 0) { // ignore setting to "Custom"
blockPercPreviewSignals(true); // do not redraw preview for every value we change!
const StaffTypePercussion* st = static_cast<const StaffTypePercussion*>(StaffType::preset(presetIdx));
const StaffType* st = static_cast<const StaffType*>(StaffType::preset(presetIdx));
setDlgFromPerc(st);
blockPercPreviewSignals(false);
}
@ -395,7 +393,7 @@ void EditStaffType::presetPercChanged(int idx)
// initializes dlg controls from a StaffTypePercussion
//---------------------------------------------------------
void EditStaffType::setDlgFromPerc(const StaffTypePercussion * st)
void EditStaffType::setDlgFromPerc(const StaffType* st)
{
// name->setText(st->name()); // keep existing name: presets should not overwrite type name
lines->setValue(st->lines());
@ -415,7 +413,7 @@ void EditStaffType::setDlgFromPerc(const StaffTypePercussion * st)
// initializes a StaffTypePercussion from dlg controls
//---------------------------------------------------------
void EditStaffType::setPercFromDlg(StaffTypePercussion * st)
void EditStaffType::setPercFromDlg(StaffType* st)
{
st->setName(name->text());
st->setLines(lines->value());
@ -439,7 +437,7 @@ void EditStaffType::updatePercPreview()
if(staffTypes[staffTypeList->currentItem()->data(Qt::UserRole).toInt()]->group() != PERCUSSION_STAFF_GROUP)
return;
// create a new staff type from dlg settings
StaffTypePercussion* st = new StaffTypePercussion();
StaffType* st = new StaffType();
setPercFromDlg(st);
// set preset combo: check stt has the same structure as one of the presets
// if none matches, set as custom
@ -500,7 +498,7 @@ void EditStaffType::presetTablatureChanged(int idx)
int presetIdx = presetTablatureCombo->itemData(idx).toInt();
if(presetIdx >= 0) { // ignore setting to "Custom"
blockTabPreviewSignals(true); // do not redraw preview for every value we change!
const StaffTypeTablature* st = static_cast<const StaffTypeTablature*>(StaffType::preset(presetIdx));
const StaffType* st = static_cast<const StaffType*>(StaffType::preset(presetIdx));
setDlgFromTab(st);
blockTabPreviewSignals(false);
}
@ -515,7 +513,7 @@ void EditStaffType::presetTablatureChanged(int idx)
void EditStaffType::durFontNameChanged(int idx)
{
qreal size, yOff;
if (StaffTypeTablature::fontData(true, idx, 0, 0, &size, &yOff)) {
if (StaffType::fontData(true, idx, 0, 0, &size, &yOff)) {
durFontSize->setValue(size);
durY->setValue(yOff);
}
@ -525,7 +523,7 @@ void EditStaffType::durFontNameChanged(int idx)
void EditStaffType::fretFontNameChanged(int idx)
{
qreal size, yOff;
if (StaffTypeTablature::fontData(false, idx, 0, 0, &size, &yOff)) {
if (StaffType::fontData(false, idx, 0, 0, &size, &yOff)) {
fretFontSize->setValue(size);
fretY->setValue(yOff);
}
@ -572,7 +570,7 @@ void EditStaffType::tabStemThroughToggled(bool checked)
// initializes dlg controls from a StaffTypeTablature
//---------------------------------------------------------
void EditStaffType::setDlgFromTab(const StaffTypeTablature * stt)
void EditStaffType::setDlgFromTab(const StaffType* stt)
{
// name->setText(stt->name()); // keep existing name: presets should not overwrite type name
lines->setValue(stt->lines());
@ -639,7 +637,7 @@ void EditStaffType::setDlgFromTab(const StaffTypeTablature * stt)
// initializes a StaffTypeTablature from dlg controls
//---------------------------------------------------------
void EditStaffType::setTabFromDlg(StaffTypeTablature * stt)
void EditStaffType::setTabFromDlg(StaffType* stt)
{
stt->setName(name->text());
stt->setLines(lines->value());
@ -775,9 +773,9 @@ void EditStaffType::updateTabPreview()
staffTypes[staffTypeList->currentItem()->data(Qt::UserRole).toInt()]->group() != TAB_STAFF_GROUP)
return;
// create a new staff type from dlg settings and set it into the preview score
StaffTypeTablature* stt = new StaffTypeTablature();
StaffType* stt = new StaffType();
setTabFromDlg(stt);
tabPreview->score()->addStaffType(TAB_6COMMON_STAFF_TYPE, stt);
//TODO-ST tabPreview->score()->addStaffType(TAB_6COMMON_STAFF_TYPE, stt);
tabPreview->score()->doLayout();
#ifdef _USE_NAVIGATOR_PREVIEW_

View file

@ -32,8 +32,6 @@ namespace Ms {
class Navigator;
class ScoreView;
class StaffType;
class StaffTypePercussion;
class StaffTypeTablature;
class Staff;
//---------------------------------------------------------
@ -55,10 +53,10 @@ class EditStaffType : public QDialog, private Ui::EditStaffType {
void blockPercPreviewSignals(bool block);
void blockTabPreviewSignals(bool block);
void saveCurrent(QListWidgetItem*);
void setDlgFromPerc(const StaffTypePercussion *st);
void setPercFromDlg(StaffTypePercussion* st);
void setDlgFromTab(const StaffTypeTablature* stt);
void setTabFromDlg(StaffTypeTablature* stt);
void setDlgFromPerc(const StaffType* st);
void setPercFromDlg(StaffType* st);
void setDlgFromTab(const StaffType* stt);
void setTabFromDlg(StaffType* stt);
void tabStemsCompatibility(bool checked);
void tabMinimShortCompatibility(bool checked);
void tabStemThroughCompatibility(bool checked);

View file

@ -871,7 +871,7 @@ qDebug("BeginRepeat=============================================");
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO-ST staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = ClefType::G3;
@ -1458,7 +1458,7 @@ void GuitarPro3::read(QFile* fp)
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO-ST staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = ClefType::G3;
@ -2165,7 +2165,7 @@ void GuitarPro4::read(QFile* fp)
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO-ST staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = ClefType::G3;
@ -3028,7 +3028,7 @@ void GuitarPro5::readTracks()
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO-TS staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = ClefType::G3;
@ -3316,9 +3316,9 @@ Score::FileError importGTP(Score* score, const QString& name)
s->setUpdateKeymap(true);
StaffType* st = staff->staffType();
s->setStaffType(st);
int idx = pscore->staffTypeIdx(st);
if (idx == -1)
pscore->addStaffType(st);
// int idx = pscore->staffTypeIdx(st);
// if (idx == -1)
// pscore->addStaffType(st);
s->linkTo(staff);
p->staves()->append(s);
pscore->staves().append(s);
@ -3329,9 +3329,10 @@ Score::FileError importGTP(Score* score, const QString& name)
p->setStaves(2);
Staff* s1 = p->staff(1);
s1->setUpdateKeymap(true);
StaffTypeTablature* st = static_cast<StaffTypeTablature*>(pscore->staffType(TAB_DEFAULT_STAFF_TYPE));
st->setSlashStyle(true);
s1->setStaffType(st);
//TODO-ST StaffType* st = static_cast<StaffTypeTablature*>(pscore->staffType(TAB_DEFAULT_STAFF_TYPE));
// st->setSlashStyle(true);
// s1->setStaffType(st);
s1->linkTo(s);
cloneStaff(s,s1);
p->staves()->front()->addBracket(BracketItem(BRACKET_NORMAL, 2));
@ -3344,10 +3345,10 @@ Score::FileError importGTP(Score* score, const QString& name)
excerpt->parts().append(part);
score->excerpts().append(excerpt);
if (part->staves()->front()->staffType()->group() == STANDARD_STAFF_GROUP) {
Staff* staff2 = pscore->staff(1);
staff2->setStaffType(pscore->staffType(TAB_DEFAULT_STAFF_TYPE));
}
//TODO-ST if (part->staves()->front()->staffType()->group() == STANDARD_STAFF_GROUP) {
// Staff* staff2 = pscore->staff(1);
// staff2->setStaffType(pscore->staffType(TAB_DEFAULT_STAFF_TYPE));
// }
//
// create excerpt title

View file

@ -1723,9 +1723,9 @@ void MusicXml::xmlPart(QDomElement e, QString id)
lastMeasureLen = 0;
multiMeasureRestCount = -1;
startMultiMeasureRest = false;
KeySigEvent ev;
KeySig currKeySig;
currKeySig.setKeySigEvent(ev);
KeySigEvent ev;
KeySig currKeySig;
currKeySig.setKeySigEvent(ev);
// initVoiceMapperAndMapVoices(e);
voicelist = pass1.getVoiceList(id);
@ -1794,8 +1794,8 @@ void MusicXml::xmlPart(QDomElement e, QString id)
// Note: part has been read, staff type already set based on clef type and staff-details
// but may be incorrect for a percussion staff that does not use a percussion clef
for (int j = 0; j < part->nstaves(); ++j)
if (part->staff(j)->lines() == 5 && !part->staff(j)->isDrumStaff())
part->staff(j)->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
//TODO-ST if (part->staff(j)->lines() == 5 && !part->staff(j)->isDrumStaff())
// part->staff(j)->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
// set drumset for instrument
part->instr()->setUseDrumset(true);
part->instr()->setDrumset(drumset);
@ -2049,7 +2049,7 @@ Measure* MusicXml::xmlMeasure(Part* part, QDomElement e, int number, Fraction me
QList<Chord*> graceNotes;
for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
if (e.tagName() == "attributes")
xmlAttributes(measure, staff, e.firstChildElement(), currKeySig);
xmlAttributes(measure, staff, e.firstChildElement(), currKeySig);
else if (e.tagName() == "note") {
note = xmlNote(measure, staff, part->id(), beam, cv, e, graceNotes, alt);
if(note) {
@ -3192,7 +3192,7 @@ static void xmlStaffDetails(Score* score, int staff, StringData* t, QDomElement
// staves must be read first, as it determines how many key and time signatures
// must be inserted.
void MusicXml::xmlAttributes(Measure* measure, int staff, QDomElement e, KeySig* currKeySig)
void MusicXml::xmlAttributes(Measure* measure, int staff, QDomElement e, KeySig* currKeySig)
{
QString beats = "";
QString beatType = "";
@ -3251,7 +3251,7 @@ void MusicXml::xmlAttributes(Measure* measure, int staff, QDomElement e, KeySig*
keysig->setVisible(printObject == "yes");
Segment* s = measure->getSegment(keysig, tick);
s->add(keysig);
currKeySig->setKeySigEvent(key);
currKeySig->setKeySigEvent(key);
}
}
}
@ -3268,7 +3268,7 @@ void MusicXml::xmlAttributes(Measure* measure, int staff, QDomElement e, KeySig*
keysig->setVisible(printObject == "yes");
Segment* s = measure->getSegment(keysig, tick);
s->add(keysig);
currKeySig->setKeySigEvent(key);
currKeySig->setKeySigEvent(key);
}
}
}
@ -3294,8 +3294,8 @@ void MusicXml::xmlAttributes(Measure* measure, int staff, QDomElement e, KeySig*
staffIdx += number - 1;
// qDebug("xmlAttributes clef score->staff(0) %p staffIdx %d score->staff(%d) %p",
// score->staff(0), staffIdx, staffIdx, score->staff(staffIdx));
if (st != STANDARD_STAFF_TYPE)
score->staff(staffIdx)->setStaffType(score->staffType(st));
//TODO-ST if (st != STANDARD_STAFF_TYPE)
// score->staff(staffIdx)->setStaffType(score->staffType(st));
}
else if (e.tagName() == "staves")
; // ignore, already handled
@ -4629,7 +4629,7 @@ static void setDuration(ChordRest* cr, bool rest, bool wholeMeasure, TDuration d
\a Staff is the number of first staff of the part this note belongs to.
*/
Note* MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*& beam,
Note* MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*& beam,
QString& currentVoice, QDomElement e, QList<Chord*>& graceNotes, int& alt)
{
int ticks = 0;

View file

@ -232,6 +232,7 @@ Score * StaffListItem::_score = 0;
void StaffListItem::populateStaffTypes(Score *score)
{
#if 0 // TODO-ST
STAFF_LIST_STAFF_TYPE staffTypeData;
int idx;
@ -265,6 +266,7 @@ void StaffListItem::populateStaffTypes(Score *score)
}
}
}
#endif
}
const StaffType* StaffListItem::getListedStaffType(int idx)
@ -499,8 +501,8 @@ void InstrumentsDialog::genPartList()
}
}
sli->setLinked(bLinked);
int staffTypeIdx = cs->staffTypeIdx(s->staffType());
sli->setStaffType(staffTypeIdx);
//TODO-ST int staffTypeIdx = cs->staffTypeIdx(s->staffType());
// sli->setStaffType(staffTypeIdx);
}
partiturList->setItemExpanded(pli, true);
}
@ -1108,6 +1110,7 @@ void MuseScore::editInstrList()
// look for a staff type with same structure among staff types already defined in the score
StaffType* st;
bool found = false;
#if 0 //TODO-ST
foreach (StaffType** scoreStaffType, rootScore->staffTypes()) {
if ( (*scoreStaffType)->isSameStructure(*stfType) ) {
st = *scoreStaffType; // staff type found in score: use for instrument staff
@ -1126,6 +1129,7 @@ void MuseScore::editInstrList()
rootScore->undo(new ChangeStaff(staff, staff->small(), staff->invisible(), staff->userDist(), staff->color(), st));
if (updateNeeded)
rootScore->cmdUpdateNotes();
#endif
}
else {
++staffIdx;

View file

@ -4281,15 +4281,15 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
else if (cmd == "staff-types") {
Staff* staff = cs->staff(0);
EditStaffType* est = new EditStaffType(this, staff);
if (est->exec() && est->isModified()) {
Score* score = cs->rootScore();
score->startCmd();
score->deselectAll();
QList<StaffType*> tl = est->getStaffTypes();
score->replaceStaffTypes(tl);
score->setLayoutAll(true);
score->endCmd();
}
// if (est->exec() && est->isModified()) {
// Score* score = cs->rootScore();
// score->startCmd();
// score->deselectAll();
// QList<StaffType*> tl = est->getStaffTypes();
//TODO-ST score->replaceStaffTypes(tl);
// score->setLayoutAll(true);
// score->endCmd();
// }
delete est;
}
else if (cmd == "lock") {

View file

@ -3078,7 +3078,7 @@ void ScoreView::startNoteEntry()
// set InputState::_string to note visual string
if (el->type() == Element::NOTE) {
strg = (static_cast<Note*>(el))->string();
strg = (static_cast<StaffTypeTablature*>(staff->staffType()))->physStringToVisual(strg);
strg = staff->staffType()->physStringToVisual(strg);
}
is.setString(strg);
break;