Piano-roll: scale & arpeggio combobox + micro refactoring of ChordCreator::Chord

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
NoiseByNorthwest
2012-02-01 15:09:49 +01:00
committed by Tobias Doerffel
parent 1a09828ad4
commit a6ae31a08e
6 changed files with 421 additions and 176 deletions

View File

@@ -36,12 +36,17 @@ class InstrumentTrack;
class notePlayHandle;
const int MAX_CHORD_POLYPHONY = 10;
class ChordCreator : public Model, public JournallingObject
{
Q_OBJECT
public:
static const int MAX_CHORD_POLYPHONY = 10;
private:
typedef Sint8 ChordSemiTones [MAX_CHORD_POLYPHONY];
public:
ChordCreator( Model * _parent );
virtual ~ChordCreator();
@@ -58,22 +63,84 @@ public:
}
static struct Chord
struct Chord
{
const QString name;
Sint8 interval[MAX_CHORD_POLYPHONY];
} s_chordTable[];
private:
QString m_name;
ChordSemiTones m_semiTones;
int m_size;
public:
Chord() : m_size( 0 ) {}
static inline int getChordSize( Chord & _c )
{
int idx = 0;
while( _c.interval[idx] != -1 )
Chord( const char * n, const ChordSemiTones & semi_tones );
int size() const
{
++idx;
return m_size;
}
return idx;
}
bool isScale() const
{
return size() > 6;
}
bool isEmpty() const
{
return size() == 0;
}
bool hasSemiTone( Sint8 semi_tone ) const;
Sint8 last() const
{
return m_semiTones[size() - 1];
}
const QString & getName() const
{
return m_name;
}
Sint8 operator [] ( int n ) const
{
return m_semiTones[n];
}
};
struct ChordTable : public QVector<Chord>
{
private:
ChordTable();
struct Init
{
const char * m_name;
ChordSemiTones m_semiTones;
};
static Init s_initTable[];
public:
static const ChordTable & getInstance()
{
static ChordTable inst;
return inst;
}
const Chord & getByName( const QString & name, bool is_scale = false ) const;
const Chord & getScaleByName( const QString & name ) const
{
return getByName( name, true );
}
const Chord & getChordByName( const QString & name ) const
{
return getByName( name, false );
}
};
private:

View File

@@ -139,9 +139,16 @@ protected slots:
void zoomingChanged();
void quantizeChanged();
void updateSemiToneMarkerMenu();
void changeNoteEditMode( int i );
void markTone( int i );
void markSemiTone( int i );
signals:
void semiToneMarkerMenuScaleSetEnabled(bool);
void semiToneMarkerMenuChordSetEnabled(bool);
private:
@@ -171,12 +178,12 @@ private:
NoteEditCount // make sure this one is always last
};
enum toneMarkerAction
enum semiToneMarkerAction
{
tmmeUnmarkAll,
tmmeMarkCurrent,
tmmeMarkMinorScale,
tmmeMarkMajorScale,
stmaUnmarkAll,
stmaMarkCurrentSemiTone,
stmaMarkCurrentScale,
stmaMarkCurrentChord,
};
enum pianoRollKeyTypes
@@ -189,8 +196,8 @@ private:
QVector<QString> m_nemStr; // gui names of each edit mode
QMenu * m_noteEditMenu; // when you right click below the key area
QList<int> m_markedTones;
QMenu * m_toneMarkerMenu; // when you right click on the key area
QList<int> m_markedSemiTones;
QMenu * m_semiToneMarkerMenu; // when you right click on the key area
pianoRoll();
pianoRoll( const pianoRoll & );
@@ -251,10 +258,14 @@ private:
comboBox * m_zoomingComboBox;
comboBox * m_quantizeComboBox;
comboBox * m_noteLenComboBox;
comboBox * m_scaleComboBox;
comboBox * m_chordComboBox;
ComboBoxModel m_zoomingModel;
ComboBoxModel m_quantizeModel;
ComboBoxModel m_noteLenModel;
ComboBoxModel m_scaleModel;
ComboBoxModel m_chordModel;