diff options
author | Florian Jung <flo@windfisch.org> | 2011-10-16 19:22:35 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-10-16 19:22:35 +0000 |
commit | f6fd0c7b4979612ed34a222c02d43e81ebaddf7e (patch) | |
tree | acd6ca648f8c15371f50935c4627c29fecc88aef /muse2 | |
parent | 5c191a7c5b525cfc833ed4d3be171101058e9779 (diff) |
ctrlcanvas stuff. not ready yet
BUGGY! problem is: while changing entries, ourDrumMap may be reallocated
which causes abort()s and/or bugs.
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/ctrl/ctrlcanvas.cpp | 71 | ||||
-rw-r--r-- | muse2/muse/ctrl/ctrlcanvas.h | 6 | ||||
-rw-r--r-- | muse2/muse/ctrl/ctrledit.cpp | 6 | ||||
-rw-r--r-- | muse2/muse/ctrl/ctrlpanel.cpp | 132 | ||||
-rw-r--r-- | muse2/muse/ctrl/ctrlpanel.h | 4 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 43 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 24 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.h | 3 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 1 |
9 files changed, 202 insertions, 88 deletions
diff --git a/muse2/muse/ctrl/ctrlcanvas.cpp b/muse2/muse/ctrl/ctrlcanvas.cpp index 9c5d636f..6e09e337 100644 --- a/muse2/muse/ctrl/ctrlcanvas.cpp +++ b/muse2/muse/ctrl/ctrlcanvas.cpp @@ -39,6 +39,7 @@ #include "gconfig.h" #include "ctrlpanel.h" #include "midiedit/drummap.h" +#include "drumedit.h" static MusECore::MidiCtrlValList veloList(MusECore::CTRL_VELOCITY); // dummy @@ -211,6 +212,11 @@ CtrlCanvas::CtrlCanvas(MidiEditor* e, QWidget* parent, int xmag, noEvents=false; //_isFirstMove = true; //_lastDelta = QPoint(0, 0); + + if (dynamic_cast<DrumEdit*>(editor) && dynamic_cast<DrumEdit*>(editor)->old_style_drummap_mode()==false) + filterTrack=true; + else + filterTrack=false; ctrl = &veloList; _controller = &MusECore::veloCtrl; @@ -231,10 +237,10 @@ CtrlCanvas::CtrlCanvas(MidiEditor* e, QWidget* parent, int xmag, connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(configChanged())); - curDrumInstrument = editor->curDrumInstrument(); - //printf("CtrlCanvas::CtrlCanvas curDrumInstrument:%d\n", curDrumInstrument); + setCurDrumPitch(editor->curDrumInstrument()); + //printf("CtrlCanvas::CtrlCanvas curDrumPitch:%d\n", curDrumPitch); - connect(editor, SIGNAL(curDrumInstrumentChanged(int)), SLOT(setCurDrumInstrument(int))); + connect(editor, SIGNAL(curDrumInstrumentChanged(int)), SLOT(setCurDrumPitch(int))); updateItems(); } @@ -537,15 +543,21 @@ void CtrlCanvas::partControllers(const MusECore::MidiPart* part, int num, int* d int di; int n; - if((mt->type() != MusECore::Track::DRUM) && curDrumInstrument != -1) //FINDMICHJETZT was ist das? + if(!mt->isDrumTrack() && curDrumPitch != -1) printf("keyfilter != -1 in non drum track?\n"); - if((mt->type() == MusECore::Track::DRUM) && (curDrumInstrument != -1) && ((num & 0xff) == 0xff)) //FINDMICHJETZT was ist das? + if((mt->type() == MusECore::Track::DRUM) && (curDrumPitch != -1) && ((num & 0xff) == 0xff)) + { + di = (num & ~0xff) | curDrumPitch; + n = (num & ~0xff) | MusEGlobal::drumMap[curDrumPitch].anote; // construct real controller number + //num = (num & ~0xff) | curDrumPitch); // construct real controller number + mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[curDrumPitch].port]; + } + else if ((mt->type() == MusECore::Track::NEW_DRUM) && (curDrumPitch != -1) && ((num & 0xff) == 0xff)) //FINDMICHJETZT does this work? { - di = (num & ~0xff) | curDrumInstrument; - n = (num & ~0xff) | MusEGlobal::drumMap[curDrumInstrument].anote; // construct real controller number - //num = (num & ~0xff) | curDrumInstrument); // construct real controller number - mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[curDrumInstrument].port]; + di = (num & ~0xff) | curDrumPitch; + n = (num & ~0xff) | curDrumPitch; + mp = &MusEGlobal::midiPorts[mt->outPort()]; } else { @@ -601,6 +613,10 @@ void CtrlCanvas::updateItems() CEvent* lastce = 0; MusECore::MidiPart* part = (MusECore::MidiPart*)(p->second); + + if (filterTrack && part->track() != curTrack) + continue; + MusECore::EventList* el = part->events(); //MusECore::MidiController* mc; MusECore::MidiCtrlValList* mcvl; @@ -617,15 +633,15 @@ void CtrlCanvas::updateItems() if(_cnum == MusECore::CTRL_VELOCITY && e.type() == MusECore::Note) { - //printf("CtrlCanvas::updateItems MusECore::CTRL_VELOCITY curDrumInstrument:%d\n", curDrumInstrument); + //printf("CtrlCanvas::updateItems MusECore::CTRL_VELOCITY curDrumPitch:%d\n", curDrumPitch); newev = 0; - if(curDrumInstrument == -1) + if(curDrumPitch == -1) { // This is interesting - it would allow ALL drum note velocities to be shown. // But currently the drum list ALWAYS has a selected item so this is not supposed to happen. items.add(newev = new CEvent(e, part, e.velo())); } - else if (e.dataA() == curDrumInstrument) //same note + else if (e.dataA() == curDrumPitch) //same note items.add(newev = new CEvent(e, part, e.velo())); if(newev && e.selected()) selection.push_back(newev); @@ -795,7 +811,7 @@ void CtrlCanvas::viewMouseMoveEvent(QMouseEvent* event) if (!moving) break; drag = DRAG_LASSO; - // weiter mit DRAG_LASSO: + // fallthrough case DRAG_LASSO: lasso.setRect(start.x(), start.y(), dist.x(), dist.y()); redraw(); @@ -857,7 +873,7 @@ void CtrlCanvas::viewMouseReleaseEvent(QMouseEvent* event) case DRAG_LASSO_START: lasso.setRect(-1, -1, -1, -1); - + //fallthrough case DRAG_LASSO: if(_controller) // p4.0.27 { @@ -1690,8 +1706,8 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi MusECore::MidiTrack* mt = part->track(); MusECore::MidiPort* mp; - if((mt->type() == MusECore::Track::DRUM) && (curDrumInstrument != -1) && ((_cnum & 0xff) == 0xff)) //FINDMICHJETZT was ist das? - mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[curDrumInstrument].port]; + if((mt->type() == MusECore::Track::DRUM) && (curDrumPitch != -1) && ((_cnum & 0xff) == 0xff)) + mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[curDrumPitch].port]; else mp = &MusEGlobal::midiPorts[mt->outPort()]; @@ -1857,7 +1873,7 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect) { MusECore::MidiPart* part = (MusECore::MidiPart*)(ip->second); //if((velo && part == curPart) || (!velo && part != curPart)) - if(part == curPart) + if(part == curPart || (filterTrack && part->track() != curTrack)) continue; // Draw items for all parts - other than current part pdrawItems(p, rect, part, velo, !velo); @@ -1978,13 +1994,24 @@ void CtrlCanvas::draw(QPainter& p, const QRect& rect) } //--------------------------------------------------------- -// setCurDrumInstrument +// setCurDrumPitch //--------------------------------------------------------- -void CtrlCanvas::setCurDrumInstrument(int di) +void CtrlCanvas::setCurDrumPitch(int instrument) +{ + DrumEdit* drumedit = dynamic_cast<DrumEdit*>(editor); + if (drumedit == NULL || drumedit->old_style_drummap_mode()) + curDrumPitch = instrument; + else // new style drummap mode { - curDrumInstrument = di; - //printf("CtrlCanvas::setCurDrumInstrument curDrumInstrument:%d\n", curDrumInstrument); + if (drumedit->get_instrument_map()[instrument].tracks.contains(curTrack)) + curDrumPitch = drumedit->get_instrument_map()[instrument].pitch; + else + curDrumPitch = -1; + } + + + //printf("CtrlCanvas::setCurDrumPitch curDrumPitch:%d\n", curDrumPitch); // // check if current controller is only valid for @@ -2000,6 +2027,6 @@ void CtrlCanvas::setCurDrumInstrument(int di) // } // Removed by T356 //songChanged(-1); - } +} } // namespace MusEGui diff --git a/muse2/muse/ctrl/ctrlcanvas.h b/muse2/muse/ctrl/ctrlcanvas.h index 815898ac..79910b94 100644 --- a/muse2/muse/ctrl/ctrlcanvas.h +++ b/muse2/muse/ctrl/ctrlcanvas.h @@ -121,6 +121,7 @@ class CtrlCanvas : public MusEGui::View { int line2y; bool drawLineMode; bool noEvents; + bool filterTrack; void viewMousePressEvent(QMouseEvent* event); void viewMouseMoveEvent(QMouseEvent*); @@ -161,7 +162,7 @@ class CtrlCanvas : public MusEGui::View { QPoint start; MusEGui::Tool tool; unsigned pos[3]; - int curDrumInstrument; //Used by the drum-editor to view velocity of only one key (one drum) + int curDrumPitch; //Used by the drum-editor to view velocity of only one key (one drum) void leaveEvent(QEvent*e); QPoint raster(const QPoint&) const; @@ -179,7 +180,7 @@ class CtrlCanvas : public MusEGui::View { private slots: void songChanged(int type); void configChanged(); - void setCurDrumInstrument(int); + void setCurDrumPitch(int); public slots: void setTool(int t); @@ -199,6 +200,7 @@ class CtrlCanvas : public MusEGui::View { MusECore::MidiCtrlValList* ctrlValList() { return ctrl; } MusECore::MidiController* controller() { return _controller; } MusECore::MidiTrack* track() const { return curTrack; } + int getCurDrumPitch() const { return curDrumPitch; } }; } // namespace MusEGui diff --git a/muse2/muse/ctrl/ctrledit.cpp b/muse2/muse/ctrl/ctrledit.cpp index 7c960dd8..5ce6a7bb 100644 --- a/muse2/muse/ctrl/ctrledit.cpp +++ b/muse2/muse/ctrl/ctrledit.cpp @@ -55,8 +55,10 @@ CtrlEdit::CtrlEdit(QWidget* parent, MidiEditor* e, int xmag, setObjectName(name); setAttribute(Qt::WA_DeleteOnClose); QHBoxLayout* hbox = new QHBoxLayout; - panel = new CtrlPanel(0, e, "panel"); - canvas = new CtrlCanvas(e, 0, xmag, "ctrlcanvas", panel); + canvas = new CtrlCanvas(e, 0, xmag, "ctrlcanvas"); + panel = new CtrlPanel(0, e, canvas, "panel"); + canvas->setPanel(panel); + QWidget* vscale = new MusEGui::VScale; hbox->setContentsMargins(0, 0, 0, 0); diff --git a/muse2/muse/ctrl/ctrlpanel.cpp b/muse2/muse/ctrl/ctrlpanel.cpp index 5e07e5f3..ed83bab8 100644 --- a/muse2/muse/ctrl/ctrlpanel.cpp +++ b/muse2/muse/ctrl/ctrlpanel.cpp @@ -64,7 +64,7 @@ namespace MusEGui { // CtrlPanel //--------------------------------------------------------- -CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, const char* name) +CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, CtrlCanvas* c, const char* name) : QWidget(parent) { setObjectName(name); @@ -72,6 +72,7 @@ CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, const char* name) //ctrlMainPop = 0; //ctrlSubPop = 0; editor = e; + ctrlcanvas = c; setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QVBoxLayout* vbox = new QVBoxLayout; QHBoxLayout* bbox = new QHBoxLayout; @@ -170,11 +171,11 @@ void CtrlPanel::heartBeat() { int outport; int chan; - int cdi = editor->curDrumInstrument(); - if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1) + int cdp = ctrlcanvas->getCurDrumPitch(); + if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdp != -1) { - outport = MusEGlobal::drumMap[cdi].port; - chan = MusEGlobal::drumMap[cdi].channel; + outport = MusEGlobal::drumMap[cdp].port; + chan = MusEGlobal::drumMap[cdp].channel; } else { @@ -248,11 +249,11 @@ void CtrlPanel::labelDoubleClicked() int outport; int chan; - int cdi = editor->curDrumInstrument(); - if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1) + int cdp = ctrlcanvas->getCurDrumPitch(); + if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdp != -1) { - outport = MusEGlobal::drumMap[cdi].port; - chan = MusEGlobal::drumMap[cdi].channel; + outport = MusEGlobal::drumMap[cdp].port; + chan = MusEGlobal::drumMap[cdp].channel; } else { @@ -352,11 +353,11 @@ void CtrlPanel::ctrlChanged(double val) int outport; int chan; - int cdi = editor->curDrumInstrument(); - if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1) + int cdp = ctrlcanvas->getCurDrumPitch(); + if(_track->type() == MusECore::Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdp != -1) { - outport = MusEGlobal::drumMap[cdi].port; - chan = MusEGlobal::drumMap[cdi].channel; + outport = MusEGlobal::drumMap[cdp].port; + chan = MusEGlobal::drumMap[cdp].channel; } else { @@ -421,13 +422,19 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController MusECore::MidiPort* mp; int ch; - int cdi = editor->curDrumInstrument(); + int cdp = ctrlcanvas->getCurDrumPitch(); _dnum = _ctrl->num(); - if(_track->type() == MusECore::Track::DRUM && ((_dnum & 0xff) == 0xff) && cdi != -1) + if(_track->type() == MusECore::Track::DRUM && ((_dnum & 0xff) == 0xff) && cdp != -1) { - _dnum = (_dnum & ~0xff) | MusEGlobal::drumMap[cdi].anote; - mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[cdi].port]; - ch = MusEGlobal::drumMap[cdi].channel; + _dnum = (_dnum & ~0xff) | MusEGlobal::drumMap[cdp].anote; + mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[cdp].port]; + ch = MusEGlobal::drumMap[cdp].channel; + } + else if(_track->type() == MusECore::Track::NEW_DRUM && ((_dnum & 0xff) == 0xff) && cdp != -1) + { + _dnum = (_dnum & ~0xff) | cdp; //FINDMICHJETZT does that work? + mp = &MusEGlobal::midiPorts[_track->outPort()]; + ch = _track->outChannel(); } else { @@ -576,8 +583,9 @@ void CtrlPanel::ctrlPopup() MusECore::MidiTrack* track = (MusECore::MidiTrack*)(part->track()); int channel = track->outChannel(); MusECore::MidiPort* port = &MusEGlobal::midiPorts[track->outPort()]; - int curDrumInstrument = editor->curDrumInstrument(); + int curDrumPitch = ctrlcanvas->getCurDrumPitch(); bool isDrum = track->type() == MusECore::Track::DRUM; + bool isNewDrum = track->type() == MusECore::Track::NEW_DRUM; QMenu* pop = new QMenu; //pop->clear(); @@ -595,12 +603,20 @@ void CtrlPanel::ctrlPopup() MusECore::MidiController* c = port->midiController(cl->num()); // dont show drum specific controller if not a drum track if ((c->num() & 0xff) == 0xff) { - if (!isDrum) - continue; - // only show controller for curDrumInstrument: - if ((cl->num() & 0xff) != MusEGlobal::drumMap[curDrumInstrument].anote) { - continue; - } + if (isDrum) + { + // only show controller for curDrumPitch: + if ((curDrumPitch == -1) || ((cl->num() & 0xff) != MusEGlobal::drumMap[curDrumPitch].anote)) + continue; + } + else if (isNewDrum) + { + // only show controller for curDrumPitch: FINDMICH does this work? + if ((curDrumPitch == -1) || ((cl->num() & 0xff) != curDrumPitch)) + continue; + } + else + continue; } isList i = sList.begin(); for (; i != sList.end(); ++i) { @@ -663,8 +679,10 @@ void CtrlPanel::ctrlPopup() for (iMusECore::MidiController ci = mcl->begin(); ci != mcl->end(); ++ci) { int num = ci->second->num(); - if (isDrum && ((num & 0xff) == 0xff)) - num = (num & ~0xff) + MusEGlobal::drumMap[curDrumInstrument].anote; + if (isDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + MusEGlobal::drumMap[curDrumPitch].anote; + if (isNewDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) //FINDMICHJETZT does this work? + num = (num & ~0xff) + curDrumPitch; if(cll->find(channel, num) == cll->end()) pop1->addAction(ci->second->name()); @@ -677,8 +695,10 @@ void CtrlPanel::ctrlPopup() c = ci->second; if (c->name() == s) { int num = c->num(); - if (isDrum && ((num & 0xff) == 0xff)) - num = (num & ~0xff) + MusEGlobal::drumMap[curDrumInstrument].anote; + if (isDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + MusEGlobal::drumMap[curDrumPitch].anote; + if (isNewDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) //FINDMICHJETZT does this work? + num = (num & ~0xff) + curDrumPitch; if(cll->find(channel, num) == cll->end()) { @@ -734,8 +754,9 @@ void CtrlPanel::ctrlPopup() MusECore::MidiTrack* track = (MusECore::MidiTrack*)(part->track()); int channel = track->outChannel(); MusECore::MidiPort* port = &MusEGlobal::midiPorts[track->outPort()]; - int curDrumInstrument = editor->curDrumInstrument(); - bool isDrum = track->type() == MusECore::Track::DRUM; //FINDMICHJETZT ist das wichtig? + int curDrumPitch = ctrlcanvas->getCurDrumPitch(); + bool isDrum = track->type() == MusECore::Track::DRUM; + bool isNewDrum = track->type() == MusECore::Track::NEW_DRUM; MusECore::MidiInstrument* instr = port->instrument(); MusECore::MidiControllerList* mcl = instr->controller(); @@ -751,12 +772,20 @@ void CtrlPanel::ctrlPopup() MusECore::MidiController* c = port->midiController(cl->num()); // dont show drum specific controller if not a drum track if ((c->num() & 0xff) == 0xff) { - if (!isDrum) - continue; - // only show controller for curDrumInstrument: - if ((cl->num() & 0xff) != MusEGlobal::drumMap[curDrumInstrument].anote) { - continue; - } + if (isDrum) + { + // only show controller for curDrumPitch: + if ((curDrumPitch == -1) || ((cl->num() & 0xff) != MusEGlobal::drumMap[curDrumPitch].anote)) + continue; + } + else if (isNewDrum) + { + // only show controller for curDrumPitch: FINDMICH does this work? + if ((curDrumPitch == -1) || ((cl->num() & 0xff) != curDrumPitch)) + continue; + } + else + continue; } isList i = sList.begin(); for (; i != sList.end(); ++i) { @@ -866,10 +895,12 @@ void CtrlPanel::ctrlPopup() int num = ci->second->num(); if((num & 0xff) == 0xff) { - // dont show drum specific controller if not a drum track - if(!isDrum) + if (isDrum && curDrumPitch!=-1) + num = (num & ~0xff) + MusEGlobal::drumMap[curDrumPitch].anote; + else if (isNewDrum && curDrumPitch!=-1) + num = (num & ~0xff) + curDrumPitch; //FINDMICH does this work? + else // dont show drum specific controller if not a drum track continue; - num = (num & ~0xff) + MusEGlobal::drumMap[curDrumInstrument].anote; } if(cll->find(channel, num) == cll->end()) @@ -896,8 +927,10 @@ void CtrlPanel::ctrlPopup() { c = ci->second; int num = c->num(); - if (isDrum && ((num & 0xff) == 0xff)) - num = (num & ~0xff) + MusEGlobal::drumMap[curDrumInstrument].anote; + if (isDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + MusEGlobal::drumMap[curDrumPitch].anote; + else if (isNewDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + curDrumPitch; //FINDMICHJETZT does this work? if(num != rv2) continue; @@ -933,8 +966,11 @@ void CtrlPanel::ctrlPopup() if (act2) { int rv2 = act2->data().toInt(); int num = rv2; - if (isDrum && ((num & 0xff) == 0xff)) - num = (num & ~0xff) + MusEGlobal::drumMap[curDrumInstrument].anote; + if (isDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + MusEGlobal::drumMap[curDrumPitch].anote; + if (isNewDrum && ((num & 0xff) == 0xff) && curDrumPitch!=-1) + num = (num & ~0xff) + curDrumPitch; //FINDMICHJETZT does this work? + if(cll->find(channel, num) == cll->end()) { MusECore::MidiCtrlValList* vl = new MusECore::MidiCtrlValList(num); @@ -981,11 +1017,11 @@ void CtrlPanel::ctrlRightClicked(const QPoint& p, int /*id*/) if(!editor->curCanvasPart() || !_ctrl) return; - int cdi = editor->curDrumInstrument(); + int cdp = ctrlcanvas->getCurDrumPitch(); int ctlnum = _ctrl->num(); - if(_track->type() == MusECore::Track::DRUM && ((ctlnum & 0xff) == 0xff) && cdi != -1) - //ctlnum = (ctlnum & ~0xff) | MusEGlobal::drumMap[cdi].enote; - ctlnum = (ctlnum & ~0xff) | cdi; + if(_track->type() == MusECore::Track::DRUM && ((ctlnum & 0xff) == 0xff) && cdp != -1) + //ctlnum = (ctlnum & ~0xff) | MusEGlobal::drumMap[cdp].enote; + ctlnum = (ctlnum & ~0xff) | cdp; MusECore::MidiPart* part = dynamic_cast<MusECore::MidiPart*>(editor->curCanvasPart()); MusEGlobal::song->execMidiAutomationCtlPopup(0, part, p, ctlnum); diff --git a/muse2/muse/ctrl/ctrlpanel.h b/muse2/muse/ctrl/ctrlpanel.h index c28708cb..ab6c1777 100644 --- a/muse2/muse/ctrl/ctrlpanel.h +++ b/muse2/muse/ctrl/ctrlpanel.h @@ -37,6 +37,7 @@ namespace MusEGui { class DoubleLabel; class Knob; class MidiEditor; +class CtrlCanvas; //--------------------------------------------------------- // CtrlPanel @@ -48,6 +49,7 @@ class CtrlPanel: public QWidget { //QMenu* pop; QPushButton* selCtrl; MidiEditor* editor; + CtrlCanvas* ctrlcanvas; MusECore::MidiTrack* _track; MusECore::MidiController* _ctrl; @@ -77,7 +79,7 @@ class CtrlPanel: public QWidget { void ctrlPopup(); public: - CtrlPanel(QWidget*, MidiEditor*, const char* name = 0); + CtrlPanel(QWidget*, MidiEditor*, CtrlCanvas*, const char* name = 0); void setHWController(MusECore::MidiTrack* t, MusECore::MidiController* ctrl); }; diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index ec17b655..d024422c 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -304,7 +304,9 @@ bool DrumCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& MusECore::MidiPart* dest_part = part; int nheight = y2pitch(pos.y()); - + if (nheight<0) nheight=0; + if (nheight>=getOurDrumMapSize()) nheight=getOurDrumMapSize()-1; + if (!instrument_map[nheight].tracks.contains(dest_part->track())) { if (debugMsg) @@ -361,6 +363,9 @@ bool DrumCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& CItem* DrumCanvas::newItem(const QPoint& p, int state) { int instr = y2pitch(p.y()); //MusEGlobal::drumInmap[y2pitch(p.y())]; + if ((instr<0) || (instr>=getOurDrumMapSize())) + return NULL; + int velo = ourDrumMap[instr].lv4; if (state == Qt::ShiftModifier) velo = ourDrumMap[instr].lv3; @@ -378,6 +383,9 @@ CItem* DrumCanvas::newItem(const QPoint& p, int state) CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) { + if ((instrument<0) || (instrument>=getOurDrumMapSize())) + return NULL; + if (!old_style_drummap_mode && !instrument_map[instrument].tracks.contains(curPart->track())) { if (debugMsg) @@ -634,6 +642,8 @@ int DrumCanvas::y2pitch(int y) const int pitch = y/TH; if (pitch >= instrument_map.size()) pitch = instrument_map.size()-1; + else if (pitch<0) + pitch = 0; return pitch; } @@ -849,6 +859,9 @@ void DrumCanvas::keyPressed(int index, int velocity) { using MusECore::MidiTrack; + if ((index<0) || (index>=getOurDrumMapSize())) + return; + // called from DList - play event int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outPort(); int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outChannel(); @@ -884,6 +897,9 @@ void DrumCanvas::keyReleased(int index, bool) { using MusECore::MidiTrack; + if ((index<0) || (index>=getOurDrumMapSize())) + return; + // called from DList - silence playing event int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outPort(); int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outChannel(); @@ -1006,15 +1022,24 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) } // the instrument represented by instrument_map[dpitch] is always the instrument - // which will be immediately AFTER our dragged instrument - for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end(); it++) - if (instrument_map[dpitch].pitch==it->second && instrument_map[dpitch].tracks.contains(it->first)) - { - while (!order_temp.empty()) - it=global_drum_ordering.insert(it, order_temp.takeLast()); + // which will be immediately AFTER our dragged instrument. or it's invalid + if (dpitch < getOurDrumMapSize()) + { + for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end(); it++) + if (instrument_map[dpitch].pitch==it->second && instrument_map[dpitch].tracks.contains(it->first)) + { + while (!order_temp.empty()) + it=global_drum_ordering.insert(it, order_temp.takeLast()); - break; - } + break; + } + } + else + { + global_drum_ordering_t::iterator it=global_drum_ordering.end(); + while (!order_temp.empty()) + it=global_drum_ordering.insert(it, order_temp.takeLast()); + } diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 2d4561e0..bcdbad79 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -296,7 +296,9 @@ void DList::viewMousePressEvent(QMouseEvent* ev) int x = ev->x(); int y = ev->y(); int button = ev->button(); - unsigned instrument = y / TH; + int instrument = y / TH; + if (instrument >= ourDrumMapSize) instrument=ourDrumMapSize-1; + if (instrument < 0) instrument=0; MusECore::DrumMap* dm = &ourDrumMap[instrument]; MusECore::DrumMap dm_old = *dm; @@ -551,7 +553,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) } if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode? - dcanvas->propagate_drummap_change(dm-ourDrumMap, (dm_old.enote != dm->enote)); + dcanvas->propagate_drummap_change(instrument, (dm_old.enote != dm->enote)); MusEGlobal::song->update(SC_DRUMMAP); //redraw(); //this is done by the songChanged slot @@ -588,6 +590,9 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) //--------------------------------------------------------- void DList::lineEdit(int line, int section) { + if (line >= ourDrumMapSize) line=ourDrumMapSize-1; + if (line < 0) line=0; + MusECore::DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (editor == 0) { @@ -656,6 +661,9 @@ void DList::lineEdit(int line, int section) //--------------------------------------------------------- void DList::pitchEdit(int line, int section) { + if (line >= ourDrumMapSize) line=ourDrumMapSize-1; + if (line < 0) line=0; + MusECore::DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (pitch_editor == 0) { @@ -710,7 +718,7 @@ int DList::x2col(int x) const void DList::setCurDrumInstrument(int instr) { - if (instr < 0 || instr >= ourDrumMapSize -1) + if (instr < 0 || instr >= ourDrumMapSize) return; // illegal instrument MusECore::DrumMap* dm = &ourDrumMap[instr]; if (currentlySelected != dm) { @@ -1022,7 +1030,14 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev) dInstrument = (y+TH/2) / TH; if (dInstrument < 0) dInstrument=0; - if (dInstrument >= ourDrumMapSize) dInstrument=ourDrumMapSize-1; + if (old_style_drummap_mode) + { + if (dInstrument >= ourDrumMapSize) dInstrument=ourDrumMapSize-1; + } + else + { + if (dInstrument > ourDrumMapSize) dInstrument=ourDrumMapSize; // allow moving something below the last element + } int cur_sel = (!old_style_drummap_mode && dInstrument>sInstrument) ? dInstrument-1 : dInstrument; @@ -1077,6 +1092,7 @@ void DList::ourDrumMapChanged(bool instrMapChanged) editEntry=NULL; if (selIdx >= ourDrumMapSize) selIdx=ourDrumMapSize-1; + if (selIdx < 0) selIdx=0; currentlySelected = &ourDrumMap[selIdx]; redraw(); diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index b860da80..08f485e7 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -33,6 +33,7 @@ #include "header.h" #include "shortcuts.h" #include "event.h" +#include "dcanvas.h" //FINDMICH UGLY. remove! class QCloseEvent; class QLabel; @@ -182,6 +183,8 @@ class DrumEdit : public MidiEditor { bool old_style_drummap_mode(); group_mode_t group_mode() { return _group_mode; } bool ignore_hide() { return _ignore_hide; } + + QVector<instrument_number_mapping_t>& get_instrument_map() { return static_cast<DrumCanvas*>(canvas)->get_instrument_map(); } //FINDMICH UGLY }; } // namespace MusEGui diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 9fd0b3ed..2d24fa54 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4597,6 +4597,7 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo * o drum controllers * update ctrlcanvas/panel * test! + * o don't mix DRUM and NEW_DRUM in drumeditor! * o my record flag handling * o option for disabling old-style / new-style drum tracks? * |