Skip to content

Commit

Permalink
Merge pull request #3031 from lasconic/MarkusLutz63-176511-tablature-…
Browse files Browse the repository at this point in the history
…fingering

fix #176511: Allow fingerings in tablature staves
  • Loading branch information
lasconic committed Mar 1, 2017
2 parents b60cdb5 + a13b5a9 commit c231be2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 24 deletions.
9 changes: 6 additions & 3 deletions libmscore/note.cpp
Expand Up @@ -590,8 +590,9 @@ Note::Note(const Note& n, bool link)
add(new Accidental(*(n._accidental)));

// types in _el: SYMBOL, IMAGE, FINGERING, TEXT, BEND
bool tabFingering = staff()->staffType(tick())->showTabFingering();
for (Element* e : n._el) {
if (e->isFingering() && staff()->isTabStaff(tick())) // tablature has no fingering
if (e->isFingering() && staff()->isTabStaff(tick()) && !tabFingering) // tablature has no fingering
continue;
Element* ce = e->clone();
add(ce);
Expand Down Expand Up @@ -1547,11 +1548,12 @@ bool Note::acceptDrop(const DropData& data) const
return true;
}
bool isTablature = staff()->isTabStaff(tick());
bool tabFingering = staff()->staffType(tick())->showTabFingering();
return (type == ElementType::ARTICULATION
|| type == ElementType::CHORDLINE
|| type == ElementType::TEXT
|| type == ElementType::REHEARSAL_MARK
|| (type == ElementType::FINGERING && !isTablature)
|| (type == ElementType::FINGERING && (!isTablature || tabFingering))
|| type == ElementType::ACCIDENTAL
|| type == ElementType::BREATH
|| type == ElementType::ARPEGGIO
Expand Down Expand Up @@ -1606,6 +1608,7 @@ Element* Note::drop(const DropData& data)
Element* e = data.element;

bool isTablature = staff()->isTabStaff(tick());
bool tabFingering = staff()->staffType(tick())->showTabFingering();
Chord* ch = chord();

switch(e->type()) {
Expand All @@ -1619,7 +1622,7 @@ Element* Note::drop(const DropData& data)
return e;

case ElementType::FINGERING:
if (!isTablature) {
if (!isTablature || tabFingering) {
e->setParent(this);
score()->undoAddElement(e);
return e;
Expand Down
35 changes: 20 additions & 15 deletions libmscore/stafftype.cpp
Expand Up @@ -74,7 +74,7 @@ StaffType::StaffType(StaffGroup sg, const QString& xml, const QString& name, int
const QString& durFontName, qreal durFontSize, qreal durFontUserY, qreal genDur,
const QString& fretFontName, qreal fretFontSize, qreal fretFontUserY,
TablatureSymbolRepeat symRepeat, bool linesThrough, TablatureMinimStyle minimStyle, bool onLines,
bool showRests, bool stemsDown, bool stemThrough, bool upsideDown, bool useNumbers, bool showBackTied)
bool showRests, bool stemsDown, bool stemThrough, bool upsideDown, bool showTabFingering, bool useNumbers, bool showBackTied)
{
_group = sg;
_xmlName = xml;
Expand All @@ -101,6 +101,7 @@ StaffType::StaffType(StaffGroup sg, const QString& xml, const QString& name, int
setStemsDown(stemsDown);
setStemsThrough(stemThrough);
setUpsideDown(upsideDown);
setShowTabFingering(showTabFingering);
setUseNumbers(useNumbers);
setShowBackTied(showBackTied);
}
Expand Down Expand Up @@ -180,6 +181,7 @@ bool StaffType::isSameStructure(const StaffType& st) const
&& st._stemsDown == _stemsDown
&& st._stemsThrough == _stemsThrough
&& st._upsideDown == _upsideDown
&& st._showTabFingering == _showTabFingering
&& st._useNumbers == _useNumbers
;
}
Expand Down Expand Up @@ -240,6 +242,7 @@ void StaffType::write(XmlWriter& xml) const
xml.tag("stemsDown", _stemsDown);
xml.tag("stemsThrough", _stemsThrough);
xml.tag("upsideDown", _upsideDown);
xml.tag("showTabFingering", _showTabFingering);
xml.tag("useNumbers", _useNumbers);
// only output "showBackTied" if different from !"slashStyle"
// to match the behaviour in 2.0.2 scores (or older)
Expand Down Expand Up @@ -328,6 +331,8 @@ void StaffType::read(XmlReader& e)
setStemsThrough(e.readBool());
else if (tag == "upsideDown")
setUpsideDown(e.readBool());
else if (tag == "showTabFingering")
setShowTabFingering(e.readBool());
else if (tag == "useNumbers")
setUseNumbers(e.readBool());
else if (tag == "showBackTied") // must be after reading "slashStyle" prop, as in older
Expand Down Expand Up @@ -1384,20 +1389,20 @@ void StaffType::initStaffTypes()
StaffType(StaffGroup::PERCUSSION, "perc1Line", QObject::tr("Perc. 1 line"), 1, -4, 1, true, true, false, true, false, true),
StaffType(StaffGroup::PERCUSSION, "perc3Line", QObject::tr("Perc. 3 lines"), 3, 0, 2, true, true, false, true, false, true),
StaffType(StaffGroup::PERCUSSION, "perc5Line", QObject::tr("Perc. 5 lines"), 5, 0, 1, true, true, false, true, false, true),
// group xml-name, human-readable-name lin dist clef bars stemless time duration font size off genDur fret font size off duration symbol repeat thru minim style onLin rests stmDn stmThr upsDn nums bkTied
StaffType(StaffGroup::TAB, "tab6StrSimple", QObject::tr("Tab. 6-str. simple"), 6, 2, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, true, false),
StaffType(StaffGroup::TAB, "tab6StrCommon", QObject::tr("Tab. 6-str. common"), 6, 2, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab6StrFull", QObject::tr("Tab. 6-str. full"), 6, 2, 1.5, true, true, false, true, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, true, true),
StaffType(StaffGroup::TAB, "tab4StrSimple", QObject::tr("Tab. 4-str. simple"), 4, 0, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, true, false),
StaffType(StaffGroup::TAB, "tab4StrCommon", QObject::tr("Tab. 4-str. common"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab4StrFull", QObject::tr("Tab. 4-str. full"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, true, true),
StaffType(StaffGroup::TAB, "tab5StrSimple", QObject::tr("Tab. 5-str. simple"), 5, 0, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, true, false),
StaffType(StaffGroup::TAB, "tab5StrCommon", QObject::tr("Tab. 5-str. common"), 5, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab5StrFull", QObject::tr("Tab. 5-str. full"), 5, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, true, true),
StaffType(StaffGroup::TAB, "tabUkulele", QObject::tr("Tab. ukulele"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, true, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tabBalajka", QObject::tr("Tab. balalaika"), 3, -2, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, true, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab6StrItalian",QObject::tr("Tab. 6-str. Italian"),6, 2, 1.5, false, true, true, true, "MuseScore Tab Italian",15, 0, true, "MuseScore Tab Renaiss",10, 0, TablatureSymbolRepeat::NEVER, true, TablatureMinimStyle::NONE, true, true, false, false, true, true, false),
StaffType(StaffGroup::TAB, "tab6StrFrench", QObject::tr("Tab. 6-str. French"), 6, 2, 1.5, false, true, true, true, "MuseScore Tab French", 15, 0, true, "MuseScore Tab Renaiss",10, 0, TablatureSymbolRepeat::NEVER, true, TablatureMinimStyle::NONE, false, false, false, false, false, false,false)
// group xml-name, human-readable-name lin dist clef bars stemless time duration font size off genDur fret font size off duration symbol repeat thru minim style onLin rests stmDn stmThr upsDn sTFing nums bkTied
StaffType(StaffGroup::TAB, "tab6StrSimple", QObject::tr("Tab. 6-str. simple"), 6, 2, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, false, true, false),
StaffType(StaffGroup::TAB, "tab6StrCommon", QObject::tr("Tab. 6-str. common"), 6, 2, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, false, true, true),
StaffType(StaffGroup::TAB, "tab6StrFull", QObject::tr("Tab. 6-str. full"), 6, 2, 1.5, true, true, false, true, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab4StrSimple", QObject::tr("Tab. 4-str. simple"), 4, 0, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, false, true, false),
StaffType(StaffGroup::TAB, "tab4StrCommon", QObject::tr("Tab. 4-str. common"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, false, true, true),
StaffType(StaffGroup::TAB, "tab4StrFull", QObject::tr("Tab. 4-str. full"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tab5StrSimple", QObject::tr("Tab. 5-str. simple"), 5, 0, 1.5, true, true, true, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Sans", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::NONE, true, false, true, false, false, false, true, false),
StaffType(StaffGroup::TAB, "tab5StrCommon", QObject::tr("Tab. 5-str. common"), 5, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, false, true, false, false, false, true, true),
StaffType(StaffGroup::TAB, "tab5StrFull", QObject::tr("Tab. 5-str. full"), 5, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SLASHED,true, true, true, true, false, false, true, true),
StaffType(StaffGroup::TAB, "tabUkulele", QObject::tr("Tab. ukulele"), 4, 0, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, true, true, false, false, false, true, true),
StaffType(StaffGroup::TAB, "tabBalajka", QObject::tr("Tab. balalaika"), 3, -2, 1.5, true, true, false, false, "MuseScore Tab Modern", 15, 0, false, "MuseScore Tab Serif", 9, 0, TablatureSymbolRepeat::NEVER, false, TablatureMinimStyle::SHORTER,true, true, true, false, false, false, true, true),
StaffType(StaffGroup::TAB, "tab6StrItalian",QObject::tr("Tab. 6-str. Italian"),6, 2, 1.5, false, true, true, true, "MuseScore Tab Italian",15, 0, true, "MuseScore Tab Renaiss",10, 0, TablatureSymbolRepeat::NEVER, true, TablatureMinimStyle::NONE, true, true, false, false, true, false, true, false),
StaffType(StaffGroup::TAB, "tab6StrFrench", QObject::tr("Tab. 6-str. French"), 6, 2, 1.5, false, true, true, true, "MuseScore Tab French", 15, 0, true, "MuseScore Tab Renaiss",10, 0, TablatureSymbolRepeat::NEVER, true, TablatureMinimStyle::NONE, false, false, false, false, false, false, false,false)
};
}

Expand Down
5 changes: 4 additions & 1 deletion libmscore/stafftype.h
Expand Up @@ -209,6 +209,7 @@ class StaffType {
bool _stemsDown = true; // stems are drawn downward (stem-and-beam durations only)
bool _stemsThrough = true; // stems are drawn through the staff rather than beside it (stem-and-beam durations only)
bool _upsideDown = false; // whether lines are drawn with highest string at top (false) or at bottom (true)
bool _showTabFingering = false; // Allow fingering in tablature staff (true) or not (false)
bool _useNumbers = true; // true: use numbers ('0' - ...) for frets | false: use letters ('a' - ...)
bool _showBackTied = true; // whether back-tied notes are shown or not

Expand Down Expand Up @@ -261,7 +262,7 @@ class StaffType {
const QString& durFontName, qreal durFontSize, qreal durFontUserY, qreal genDur,
const QString& fretFontName, qreal fretFontSize, qreal fretFontUserY, TablatureSymbolRepeat symRepeat,
bool linesThrough, TablatureMinimStyle minimStyle, bool onLines, bool showRests,
bool stemsDown, bool stemThrough, bool upsideDown, bool useNumbers, bool showBackTied);
bool stemsDown, bool stemThrough, bool upsideDown, bool showTabFingering, bool useNumbers, bool showBackTied);

virtual ~StaffType() {}
bool operator==(const StaffType&) const;
Expand Down Expand Up @@ -357,6 +358,7 @@ class StaffType {
bool stemsDown() const { return _stemsDown; }
bool stemThrough() const { return _stemsThrough; }
bool upsideDown() const { return _upsideDown; }
bool showTabFingering() const { return _showTabFingering; }
bool useNumbers() const { return _useNumbers; }
bool showBackTied() const { return _showBackTied; }

Expand All @@ -376,6 +378,7 @@ class StaffType {
void setStemsDown(bool val) { _stemsDown = val; }
void setStemsThrough(bool val) { _stemsThrough = val; }
void setUpsideDown(bool val) { _upsideDown = val; }
void setShowTabFingering (bool val) { _showTabFingering = val; }
void setUseNumbers(bool val) { _useNumbers = val; _fretMetricsValid = false; }
void setShowBackTied(bool val) { _showBackTied = val; }

Expand Down
10 changes: 5 additions & 5 deletions libmscore/undo.cpp
Expand Up @@ -1121,6 +1121,7 @@ void Score::undoAddElement(Element* element)
if (e == parent)
ne = element;
else {
bool tabFingering = e->staff()->staffType(e->tick())->showTabFingering();
if (element->isGlissando()) { // and other spanners with Anchor::NOTE
Note* newEnd = Spanner::endElementFromSpanner(static_cast<Glissando*>(element), e);
if (newEnd) {
Expand All @@ -1130,8 +1131,8 @@ void Score::undoAddElement(Element* element)
else //couldn't find suitable start note
continue;
}
else if (element->isFingering() && e->staff()->isTabStaff(e->tick()))
continue; // tablature has no fingering
else if (element->isFingering() && e->staff()->isTabStaff(e->tick()) && !tabFingering)
continue;
else
ne = element->linkedClone();
}
Expand Down Expand Up @@ -2955,8 +2956,8 @@ void InsertRemoveMeasures::removeMeasures()
}
score->measures()->remove(fm, lm);

// if (score->firstMeasure()) // any measures left?
score->fixTicks();
// if (score->firstMeasure()) // any measures left?
score->fixTicks();
if (fm->isMeasure()) {
score->setPlaylistDirty();

Expand All @@ -2974,7 +2975,6 @@ void InsertRemoveMeasures::removeMeasures()
}
}
}

if (score->firstMeasure())
score->insertTime(tick1, -(tick2 - tick1));
for (Spanner* sp : score->unmanagedSpanners()) {
Expand Down
4 changes: 4 additions & 0 deletions mscore/editstafftype.cpp
Expand Up @@ -146,6 +146,7 @@ EditStaffType::EditStaffType(QWidget* parent, Staff* st)

connect(linesThroughRadio, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(onLinesRadio, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(showTabFingering, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(upsideDown, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(numbersRadio, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(showBackTied, SIGNAL(toggled(bool)), SLOT(updatePreview()));
Expand Down Expand Up @@ -211,6 +212,7 @@ void EditStaffType::setValues()
case StaffGroup::TAB:
{
upsideDown->setChecked(staffType.upsideDown());
showTabFingering->setChecked(staffType.showTabFingering());
int idx = fretFontName->findText(staffType.fretFontName(), Qt::MatchFixedString);
if (idx == -1)
idx = 0; // if name not found, use first name
Expand Down Expand Up @@ -402,6 +404,7 @@ void EditStaffType::setFromDlg()
staffType.setOnLines(onLinesRadio->isChecked());
staffType.setShowRests(showRests->isChecked());
staffType.setUpsideDown(upsideDown->isChecked());
staffType.setShowTabFingering(showTabFingering->isChecked());
staffType.setUseNumbers(numbersRadio->isChecked());
//note values
staffType.setStemsDown(stemBelowRadio->isChecked());
Expand Down Expand Up @@ -444,6 +447,7 @@ void EditStaffType::blockSignals(bool block)
showBackTied->blockSignals(block);

upsideDown->blockSignals(block);
showTabFingering->blockSignals(block);
valuesRepeatNever->blockSignals(block);
valuesRepeatSystem->blockSignals(block);
valuesRepeatMeasure->blockSignals(block);
Expand Down
7 changes: 7 additions & 0 deletions mscore/editstafftype.ui
Expand Up @@ -682,6 +682,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showTabFingering">
<property name="text">
<string>Show fingering in tablature</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
Expand Down

0 comments on commit c231be2

Please sign in to comment.