Skip to content

Commit

Permalink
Fix #22996 - Wrong clef when selecting standard staff type in instrum…
Browse files Browse the repository at this point in the history
…ent wizard.

In the instrument wizard, when a staff is changed to standard type (from a previous different type), the standard clef of the istrument is lost.

Changes:
- Added a member variable to `StaffListItem` storing the default standard clef for the instrument.
- Modified `instruments.xml' to remove <clef> tags from tablature instrument definitions: all these instruments are inited from a standard-staff main entry, recording the default standard clef; this clef is used to init the `StaffListItem::_defaultClef` member variable.

NOTE: Percussion instruments are not covered (an number of percussion instruments seem to have old-style definitions in `instruments.xml`); conversion from percussion to standard staff may yield unexpected results.
  • Loading branch information
mgavioli committed May 23, 2014
1 parent 6e452db commit b8ecd49
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
24 changes: 17 additions & 7 deletions mscore/instrdialog.cpp
Expand Up @@ -61,7 +61,7 @@ StaffListItem::StaffListItem(PartListItem* li)
setPartIdx(0);
staffIdx = 0;
setLinked(false);
setClef(ClefTypeList(ClefType::G, ClefType::G));
setDefaultClef(ClefTypeList(ClefType::G, ClefType::G));
_staffTypeCombo = 0;
initStaffTypeCombo();
}
Expand All @@ -73,7 +73,7 @@ StaffListItem::StaffListItem()
staff = 0;
setPartIdx(0);
staffIdx = 0;
setClef(ClefTypeList(ClefType::G, ClefType::G));
setDefaultClef(ClefTypeList(ClefType::G, ClefType::G));
setLinked(false);
_staffTypeCombo = 0;
}
Expand Down Expand Up @@ -129,6 +129,16 @@ void StaffListItem::setPartIdx(int val)
setText(0, InstrumentsDialog::tr("Staff %1").arg(_partIdx + 1));
}

//---------------------------------------------------------
// setDefaultClef
//---------------------------------------------------------

void StaffListItem::setDefaultClef(const ClefTypeList& val)
{
_defaultClef = val;
setClef(val);
}

//---------------------------------------------------------
// setClef
//---------------------------------------------------------
Expand Down Expand Up @@ -210,10 +220,10 @@ void StaffListItem::staffTypeChanged(int idx)
ClefType clefType;
switch (stfType->group()) {
case STANDARD_STAFF_GROUP:
clefType = ClefType::G3;
clefType = _defaultClef._transposingClef;
break;
case TAB_STAFF_GROUP:
clefType = ClefType::TAB2;
clefType = ClefType::TAB;
break;
case PERCUSSION_STAFF_GROUP:
clefType = ClefType::PERC;
Expand Down Expand Up @@ -548,7 +558,7 @@ void InstrumentsDialog::on_addButton_clicked()
sli->staff = 0;
sli->setPartIdx(i);
sli->staffIdx = -1;
sli->setClef(it->clefTypes[i]);
sli->setDefaultClef(it->clefTypes[i]);
sli->setStaffType(it->staffTypePreset);
}
partiturList->setItemExpanded(pli, true);
Expand Down Expand Up @@ -795,7 +805,7 @@ void InstrumentsDialog::on_belowButton_clicked()
PartListItem* pli = (PartListItem*)sli->QTreeWidgetItem::parent();
StaffListItem* nsli = new StaffListItem();
nsli->staff = staff;
nsli->setClef(sli->clef());
nsli->setDefaultClef(sli->clef());
if (staff)
nsli->op = ITEM_ADD;
pli->insertChild(pli->indexOfChild(sli)+1, nsli);
Expand Down Expand Up @@ -823,7 +833,7 @@ void InstrumentsDialog::on_linkedButton_clicked()
PartListItem* pli = (PartListItem*)sli->QTreeWidgetItem::parent();
StaffListItem* nsli = new StaffListItem();
nsli->staff = staff;
nsli->setClef(sli->clef());
nsli->setDefaultClef(sli->clef());
nsli->setLinked(true);
if (staff)
nsli->op = ITEM_ADD;
Expand Down
2 changes: 2 additions & 0 deletions mscore/instrdialog.h
Expand Up @@ -64,6 +64,7 @@ class PartListItem : public QTreeWidgetItem {
class StaffListItem : public QObject, public QTreeWidgetItem {
Q_OBJECT
ClefTypeList _clef;
ClefTypeList _defaultClef; // the clef to use when the staff type does not mandate a specific clef
int _partIdx;
bool _linked;
QComboBox* _staffTypeCombo;
Expand All @@ -83,6 +84,7 @@ class StaffListItem : public QObject, public QTreeWidgetItem {

void setClef(const ClefTypeList& val);
const ClefTypeList& clef() const { return _clef; }
void setDefaultClef(const ClefTypeList& val);
void setLinked(bool val);
bool linked() const { return _linked; }
void setStaffType(const StaffType*);
Expand Down
8 changes: 4 additions & 4 deletions mscore/newwizard.cpp
Expand Up @@ -207,9 +207,9 @@ void InstrumentWizard::on_addButton_clicked()
sli->setPartIdx(i);
sli->staffIdx = -1;
if (i > MAX_STAVES)
sli->setClef(ClefTypeList(ClefType::G, ClefType::G));
sli->setDefaultClef(ClefTypeList(ClefType::G, ClefType::G));
else
sli->setClef(it->clefTypes[i]);
sli->setDefaultClef(it->clefTypes[i]);
sli->setStaffType(it->staffTypePreset);
}
partiturList->setItemExpanded(pli, true);
Expand Down Expand Up @@ -388,7 +388,7 @@ void InstrumentWizard::on_linkedButton_clicked()
pli->setVisible(true);
StaffListItem* nsli = new StaffListItem();
nsli->staff = staff;
nsli->setClef(sli->clef());
nsli->setDefaultClef(sli->clef());
nsli->setLinked(true);
if (staff)
nsli->op = ITEM_ADD;
Expand Down Expand Up @@ -417,7 +417,7 @@ void InstrumentWizard::on_belowButton_clicked()
PartListItem* pli = (PartListItem*)sli->QTreeWidgetItem::parent();
StaffListItem* nsli = new StaffListItem();
nsli->staff = staff;
nsli->setClef(sli->clef());
nsli->setDefaultClef(sli->clef());
if (staff)
nsli->op = ITEM_ADD;
pli->insertChild(pli->indexOfChild(sli)+1, nsli);
Expand Down
16 changes: 8 additions & 8 deletions share/templates/instruments.xml
Expand Up @@ -7935,7 +7935,7 @@
<description>Acoustic Nylon Strung Guitar (Tablature)</description>
<musicXMLid>pluck.guitar.nylon-string</musicXMLid>
<stafftype staffTypePreset="tab6StrCommon">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>common</genre>
</Instrument>
<Instrument id="guitar-steel">
Expand Down Expand Up @@ -7968,7 +7968,7 @@
<description>Acoustic Steel Strung Guitar (Tablature)</description>
<musicXMLid>pluck.guitar.acoustic</musicXMLid>
<stafftype staffTypePreset="tab6StrCommon">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>common</genre>
</Instrument>
<Instrument id="11-string-alto-guitar">
Expand Down Expand Up @@ -8043,7 +8043,7 @@
<init>electric-guitar</init>
<description>Electric Guitar (Tablature)</description>
<stafftype staffTypePreset="tab6StrCommon">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>common</genre>
</Instrument>
<Instrument id="harp">
Expand Down Expand Up @@ -8108,7 +8108,7 @@
<description>Lute (Tablature)</description>
<musicXMLid>pluck.lute</musicXMLid>
<stafftype staffTypePreset="tab6StrFrench">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>earlymusic</genre>
</Instrument>
<Instrument id="ren.-tenor-lute-5-course">
Expand Down Expand Up @@ -8488,7 +8488,7 @@
<description>Ukulele (4-str. TAB)</description>
<musicXMLid>pluck.ukulele</musicXMLid>
<stafftype staffTypePreset="tabUkulele">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
</Instrument>
<Instrument id="tenor-ukulele">
<longName>Tenor Ukulele</longName>
Expand Down Expand Up @@ -8558,7 +8558,7 @@
<description>Bass Guitar (Tablature)</description>
<musicXMLid>pluck.bass</musicXMLid>
<stafftype staffTypePreset="tab4StrCommon">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>common</genre>
</Instrument>
<Instrument id="acoustic-bass">
Expand Down Expand Up @@ -8604,7 +8604,7 @@
<description>Electric Bass (Tablature)</description>
<musicXMLid>pluck.bass.electric</musicXMLid>
<stafftype staffTypePreset="tab4StrCommon">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>common</genre>
</Instrument>
<Instrument id="fretless-electric-bass">
Expand Down Expand Up @@ -8874,7 +8874,7 @@
<init>viola-da-gamba</init>
<description>Viola da gamba (Tablature)</description>
<stafftype staffTypePreset="tab6StrFrench">tablature</stafftype>
<clef>TAB</clef>
<!-- <clef>TAB</clef> -->
<genre>earlymusic</genre>
</Instrument>
<!-- Viola da Gamba (6 string) removed as a duplication -->
Expand Down

0 comments on commit b8ecd49

Please sign in to comment.