Skip to content

Commit

Permalink
Merge pull request #348 from mgavioli/remove_guitar_as_default_tablature
Browse files Browse the repository at this point in the history
Remove guitar as default string set
  • Loading branch information
mgavioli committed May 13, 2013
2 parents 5ebc8d5 + 537501f commit 1b72684
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 62 deletions.
2 changes: 1 addition & 1 deletion libmscore/instrument.cpp
Expand Up @@ -133,7 +133,7 @@ InstrumentData::~InstrumentData()

Tablature* InstrumentData::tablature() const
{
return _tablature ? _tablature : &guitarTablature;
return _tablature ? _tablature : &emptyStringData;
}

//---------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions libmscore/tablature.cpp
Expand Up @@ -16,16 +16,22 @@
#include "score.h"
#include "undo.h"

static int guitarStrings[6] = { 40, 45, 50, 55, 59, 64 };
//static int guitarStrings[6] = { 40, 45, 50, 55, 59, 64 };

Tablature guitarTablature(23, 6, guitarStrings);
Tablature emptyStringData(0, 0, 0);

//---------------------------------------------------------
// Tablature
//---------------------------------------------------------

bool Tablature::bFretting = false;

Tablature::Tablature()
{
_frets = 0;
stringTable = QList<int>();
}

Tablature::Tablature(int numFrets, int numStrings, int strings[])
{
_frets = numFrets;
Expand Down
4 changes: 2 additions & 2 deletions libmscore/tablature.h
Expand Up @@ -28,7 +28,7 @@ class Tablature {
static bool bFretting;

public:
Tablature() {}
Tablature();
Tablature(int numFrets, int numStrings, int strings[]);
Tablature(int numFrets, QList<int>& strings);
bool convertPitch(int pitch, int* string, int* fret) const;
Expand All @@ -46,6 +46,6 @@ class Tablature {
void writeMusicXML(Xml& xml) const;
};

extern Tablature guitarTablature;
extern Tablature emptyStringData;
#endif

41 changes: 29 additions & 12 deletions mscore/editstaff.cpp
Expand Up @@ -49,20 +49,9 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)

Part* part = staff->part();
instrument = *part->instr();

Score* score = part->score();
int curIdx = 0;
int n = score->staffTypes().size();
printf("staff types %d\n", n);
for (int idx = 0; idx < n; ++idx) {
StaffType* st = score->staffType(idx);
printf(" %d <%s>\n", idx, qPrintable(st->name()));
staffType->addItem(st->name(), idx);
if (st == s->staffType())
curIdx = idx;
}
staffType->setCurrentIndex(curIdx);

fillStaffTypeCombo();
small->setChecked(staff->small());
invisible->setChecked(staff->invisible());
spinExtraDistance->setValue(s->userDist() / score->spatium());
Expand All @@ -81,6 +70,29 @@ printf(" %d <%s>\n", idx, qPrintable(st->name()));
connect(editStringData, SIGNAL(clicked()), SLOT(editStringDataClicked()));
}

//---------------------------------------------------------
// fillStaffTypecombo
//---------------------------------------------------------

void EditStaff::fillStaffTypeCombo()
{
Score* score = staff->score();
int curIdx = 0;
int n = score->staffTypes().size();
// can this instrument accept tabs?
bool acceptTab = instrument.tablature() && instrument.tablature()->strings() != 0;
staffType->clear();
for (int idx = 0; idx < n; ++idx) {
StaffType* st = score->staffType(idx);
if (acceptTab || st->group() != TAB_STAFF) {
staffType->addItem(st->name(), idx);
if (st == staff->staffType())
curIdx = idx;
}
}
staffType->setCurrentIndex(curIdx);
}

//---------------------------------------------------------
// updateInstrument
//---------------------------------------------------------
Expand Down Expand Up @@ -333,9 +345,14 @@ void EditStaff::editStringDataClicked()
EditStringData* esd = new EditStringData(this, &stringList, &frets);
if (esd->exec()) {
Tablature * tab = new Tablature(frets, stringList);
// detect number of strings going from 0 to !0 or vice versa
bool redoStaffTypeCombo =
(stringList.size() != 0) != (instrument.tablature()->strings() != 0);
instrument.setTablature(tab);
int numStr = tab ? tab->strings() : 0;
numOfStrings->setText(QString::number(numStr));
if (redoStaffTypeCombo)
fillStaffTypeCombo();
}
}

Expand Down
1 change: 1 addition & 0 deletions mscore/editstaff.h
Expand Up @@ -41,6 +41,7 @@ class EditStaff : public QDialog, private Ui::EditStaffBase {
int _minPitchA, _maxPitchA, _minPitchP, _maxPitchP;

void apply();
void fillStaffTypeCombo();
void setInterval(const Interval&);
void updateInstrument();

Expand Down
35 changes: 1 addition & 34 deletions mscore/editstringdata.cpp
Expand Up @@ -35,17 +35,6 @@ EditStringData::EditStringData(QWidget *parent, QList<int> * strings, int * fret
// if any string, insert into string list control and select the first one
if(_strings->size()) {
int i, j;
// insert into local working copy sorting by decreasing MIDI code value
/* foreach(i, *_strings) {
for(j=_stringsLoc.size()-1; j >= 0 && i > _stringsLoc[j]; j--)
;
_stringsLoc.insert(j+1, i);
}
// add to string list dlg control
foreach(i, _stringsLoc)
stringList->addItem(midiCodeToStr(i));
stringList->setCurrentRow(0);
*/
// insert into local working copy and into string list dlg control
// IN REVERSED ORDER
for(i=_strings->size()-1; i >= 0; i--) {
Expand Down Expand Up @@ -73,21 +62,8 @@ EditStringData::EditStringData(QWidget *parent, QList<int> * strings, int * fret

EditStringData::~EditStringData()
{
// delete ui;
}
/*
void EditStringData::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
retranslateUi(this);
break;
default:
break;
}
}
*/

//---------------------------------------------------------
// deleteStringClicked
//---------------------------------------------------------
Expand Down Expand Up @@ -136,15 +112,6 @@ void EditStringData::newStringClicked()

EditPitch* ep = new EditPitch(this);
if ( (newCode=ep->exec()) != -1) {
// find sorted postion for new string tuning value
/* for(i=_stringsLoc.size()-1; i >= 0 && newCode > _stringsLoc[i]; i--)
;
// insert in local string list and in dlg list control
_stringsLoc.insert(i+1, newCode);
stringList->insertItem(i+1, midiCodeToStr(newCode));
// select last added item and ensure buttons are active
stringList->setCurrentRow(i+1);
*/
// add below selected string o at the end if no selected string
i = stringList->currentRow();
if(i < 0)
Expand Down
11 changes: 1 addition & 10 deletions mscore/editstringdata.h
Expand Up @@ -21,13 +21,8 @@
#ifndef EDITSTRINGDATA_H
#define EDITSTRINGDATA_H

//#include <QDialog>
#include "ui_editstringdata.h"
/*
namespace Ui {
class EditStringData;
}
*/

class EditStringData : public QDialog, private Ui::EditStringDataBase {
Q_OBJECT

Expand All @@ -41,12 +36,8 @@ class EditStringData : public QDialog, private Ui::EditStringDataBase {
~EditStringData();

protected:
// void changeEvent(QEvent *e);
QString midiCodeToStr(int midiCode);

//private:
// Ui::EditStringData *ui;

private slots:
void accept();
void deleteStringClicked();
Expand Down
5 changes: 4 additions & 1 deletion mscore/editstringdata.ui
Expand Up @@ -118,7 +118,10 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
<number>0</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
Expand Down

0 comments on commit 1b72684

Please sign in to comment.