summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/midiedit/dlist.cpp113
-rw-r--r--muse2/muse/midiedit/dlist.h23
2 files changed, 110 insertions, 26 deletions
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index 7640b38e..ab2ed230 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -23,10 +23,6 @@
#include "song.h"
#include "scrollscale.h"
-// enum DCols { COL_MUTE=0, COL_NAME, COL_QNT, COL_ENOTE, COL_LEN,
-// COL_ANOTE, COL_CHANNEL, COL_PORT,
-// COL_LV1, COL_LV2, COL_LV3, COL_LV4, COL_NONE=-1};
-
//---------------------------------------------------------
// draw
//---------------------------------------------------------
@@ -308,7 +304,6 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
if(val != dm->anote)
{
audio->msgIdle(true);
- //audio->msgRemapPortDrumCtlEvents(pitch, val, -1, -1);
song->remapPortDrumCtrlEvents(pitch, val, -1, -1);
audio->msgIdle(false);
dm->anote = val;
@@ -387,24 +382,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
case COL_NAME:
emit keyPressed(pitch, 100); //Mapping done on other side, send index
break;
-#if 0
- case COL_CHANNEL:
- {
- int channel = t->channel();
- if (button == Qt::RightButton) {
- if (channel < 15)
- ++channel;
- }
- else if (button == Qt::MidButton) {
- if (channel > 0)
- --channel;
- }
- if (channel != t->channel()) {
- t->setChannel(channel);
- emit channelChanged();
- }
- }
-#endif
+
default:
break;
}
@@ -430,6 +408,8 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev)
{
lineEdit(pitch, section);
}
+ else if ((section == COL_ANOTE || section == COL_ENOTE) && (ev->button() == Qt::LeftButton))
+ pitchEdit(pitch, section);
else
viewMousePressEvent(ev);
}
@@ -505,6 +485,40 @@ void DList::lineEdit(int line, int section)
}
+//---------------------------------------------------------
+// pitchEdit
+//---------------------------------------------------------
+void DList::pitchEdit(int line, int section)
+ {
+ DrumMap* dm = &drumMap[line];
+ editEntry = dm;
+ if (pitch_editor == 0) {
+ pitch_editor = new DPitchEdit(this);
+ connect(pitch_editor, SIGNAL(editingFinished()),
+ SLOT(pitchEdited()));
+ pitch_editor->setFrame(true);
+ }
+ int colx = mapx(header->sectionPosition(section));
+ int colw = rmapx(header->sectionSize(section));
+ int coly = mapy(line * TH);
+ int colh = rmapy(TH);
+ selectedColumn = section; //Store selected column to have an idea of which one was selected when return is pressed
+ switch (section) {
+ case COL_ENOTE:
+ pitch_editor->setValue(dm->enote);
+ break;
+
+ case COL_ANOTE:
+ pitch_editor->setValue(dm->anote);
+ break;
+ }
+
+ pitch_editor->setGeometry(colx, coly, colw, colh);
+ pitch_editor->show();
+ pitch_editor->setFocus();
+
+ }
+
//---------------------------------------------------------
// x2col
@@ -642,6 +656,52 @@ void DList::returnPressed()
}
//---------------------------------------------------------
+// pitchValueChanged
+//---------------------------------------------------------
+
+void DList::pitchEdited()
+{
+ int val=pitch_editor->value();
+ int pitch=(editEntry-drumMap);
+
+ switch(selectedColumn) {
+ case COL_ANOTE:
+ if(val != editEntry->anote)
+ {
+ audio->msgIdle(true);
+ song->remapPortDrumCtrlEvents(pitch, val, -1, -1);
+ audio->msgIdle(false);
+ editEntry->anote = val;
+ song->update(SC_DRUMMAP);
+ }
+ break;
+
+ case COL_ENOTE:
+ //Check if there is any other drumMap with the same inmap value (there should be one (and only one):-)
+ //If so, switch the inmap between the instruments
+ for (int i=0; i<DRUM_MAPSIZE; i++) {
+ if (drumMap[i].enote == val && &drumMap[i] != editEntry) {
+ drumInmap[int(editEntry->enote)] = i;
+ drumMap[i].enote = editEntry->enote;
+ break;
+ }
+ }
+ //TODO: Set all the notes on the track with pitch=dm->enote to pitch=val
+ editEntry->enote = val;
+ drumInmap[val] = pitch;
+ break;
+ default:
+ printf("Value changed in unknown column\n");
+ break;
+ }
+ selectedColumn = -1;
+ pitch_editor->hide();
+ editEntry = 0;
+ setFocus();
+ redraw();
+ }
+
+//---------------------------------------------------------
// moved
//---------------------------------------------------------
@@ -688,6 +748,7 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag)
setFocusPolicy(Qt::StrongFocus);
drag = NORMAL;
editor = 0;
+ pitch_editor = 0;
editEntry = 0;
// always select a drum instrument
currentlySelected = &drumMap[0];
@@ -745,9 +806,9 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev)
emit mapChanged(sPitch, dPitch); //Track pitch change done in canvas
}
drag = NORMAL;
-//?? redraw();
- if (editEntry)
- editor->setFocus();
+//?? redraw(); //commented out NOT by flo93; was already commented out
+// if (editEntry) //removed by flo93; seems to work without it
+// editor->setFocus(); //and causes segfaults after adding the pitchedits
int x = ev->x();
int y = ev->y();
bool shift = ev->modifiers() & Qt::ShiftModifier;
diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h
index f57b7501..03437e64 100644
--- a/muse2/muse/midiedit/dlist.h
+++ b/muse2/muse/midiedit/dlist.h
@@ -11,6 +11,7 @@
#include <QKeyEvent>
#include <QLineEdit>
+#include "awl/pitchedit.h"
#include "view.h"
#define TH 18 // normal Track-hight
@@ -46,6 +47,25 @@ class DLineEdit: public QLineEdit
};
//---------------------------------------------------------
+// DPitchEdit
+//---------------------------------------------------------
+class DPitchEdit: public Awl::PitchEdit
+{
+ public:
+ DPitchEdit(QWidget* parent) : PitchEdit(parent) {}
+ virtual ~DPitchEdit() {};
+
+ virtual void keyPressEvent(QKeyEvent* keyItem) {
+ if ((keyItem->key() == Qt::Key_Escape) || (keyItem->key() == Qt::Key_Return)) {
+ parentWidget()->setFocus();
+ hide();
+ }
+ else
+ PitchEdit::keyPressEvent(keyItem);
+ }
+};
+
+//---------------------------------------------------------
// DList
//---------------------------------------------------------
@@ -53,6 +73,7 @@ class DList : public View {
QHeaderView* header;
ScrollScale* scroll;
QLineEdit* editor;
+ DPitchEdit* pitch_editor;
DrumMap* editEntry;
DrumMap* currentlySelected;
int selectedColumn;
@@ -77,6 +98,7 @@ class DList : public View {
private slots:
void sizeChange(int, int, int);
void returnPressed();
+ void pitchEdited();
void moved(int, int, int);
signals:
@@ -91,6 +113,7 @@ class DList : public View {
void songChanged(int);
public:
void lineEdit(int line, int section);
+ void pitchEdit(int line, int section);
void setCurDrumInstrument(int n);
DList(QHeaderView*, QWidget* parent, int ymag);
~DList();