From: Mathias L. <lun...@us...> - 2005-03-25 14:25:48
|
Update of /cvsroot/lmuse/muse/muse/ctrl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6947/muse/ctrl Modified Files: ctrledit.cpp ctrledit.h Log Message: more updates (was asleep in the morning it seems) Index: ctrledit.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/ctrl/ctrledit.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ctrledit.h 25 Mar 2005 11:55:15 -0000 1.12 --- ctrledit.h 25 Mar 2005 14:25:34 -0000 1.13 *************** *** 30,33 **** --- 30,34 ---- int _controller; MidiTrack* track; + bool velocity_change; Q_OBJECT *************** *** 42,45 **** --- 43,50 ---- void controllerChanged(int); void velocityChange(unsigned time, float val); + void velocityChangeStart(unsigned time, float val); + void velocityChangeStop(); + void controllerManipulation(unsigned time, CVal c); + void songChanged(int flags); signals: *************** *** 47,51 **** void destroyedCtrl(CtrlEdit*); void enterCanvas(); - void yposChanged(int); public: --- 52,55 ---- Index: ctrledit.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/ctrl/ctrledit.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ctrledit.cpp 25 Mar 2005 11:55:15 -0000 1.13 --- ctrledit.cpp 25 Mar 2005 14:25:34 -0000 1.14 *************** *** 17,20 **** --- 17,21 ---- #include "arranger/cswidget.h" #include "midictrl.h" + #include "debug.h" static Ctrl veloList(CTRL_VELOCITY, "velocity", Ctrl::DISCRETE, 0.0, 127.0); // dummy *************** *** 38,41 **** --- 39,43 ---- _ctrl = &veloList; // _controller = &veloCtrl; + velocity_change = false; track = (MidiTrack*)(e->parts()->find(0)->track()); *************** *** 63,69 **** connect(canvas, SIGNAL(cursorPos(unsigned)), SIGNAL(timeChanged(unsigned))); connect(track, SIGNAL(controllerChanged(int)), canvas, SLOT(controllerChanged(int))); ! connect(canvas, SIGNAL(velocityChange(unsigned, float)), SLOT(velocityChange(unsigned, float))); ! // connect(canvas, SIGNAL(yposChanged(int)), SIGNAL(yposChanged(int))); connect(song, SIGNAL(posChanged(int,unsigned,bool)), this, SLOT(setPos(int,unsigned))); connect(track, SIGNAL(controllerChanged(int)), canvas, SLOT(controllerChanged(int))); connect(panel, SIGNAL(controllerChanged(int)), this, SLOT(controllerChanged(int))); --- 65,76 ---- connect(canvas, SIGNAL(cursorPos(unsigned)), SIGNAL(timeChanged(unsigned))); connect(track, SIGNAL(controllerChanged(int)), canvas, SLOT(controllerChanged(int))); ! ! // Velocity: ! connect(canvas, SIGNAL(velocityChangeStart(unsigned, float)), SLOT(velocityChangeStart(unsigned, float))); ! connect(canvas, SIGNAL(velocityChangeStop(void)), SLOT(velocityChangeStop(void))); ! connect(canvas, SIGNAL(yposChanged(unsigned, CVal)), SLOT(controllerManipulation(unsigned, CVal))); ! connect(song, SIGNAL(posChanged(int,unsigned,bool)), this, SLOT(setPos(int,unsigned))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); connect(track, SIGNAL(controllerChanged(int)), canvas, SLOT(controllerChanged(int))); connect(panel, SIGNAL(controllerChanged(int)), this, SLOT(controllerChanged(int))); *************** *** 174,185 **** } ! // If part and event is found, change to new velocity ! if (theEvent) { Event clone = theEvent->clone(); clone.setB((unsigned)val); - song->startUndo(); song->changeEvent(*theEvent, clone, part); ! song->endUndo(SC_EVENT_MODIFIED); ! // Update the canvas (something like the partChange signal should be used instead of this) canvas->update(); } --- 181,190 ---- } ! // If part and event is found, change to new velocity if different ! if (theEvent && (unsigned)val != theEvent->dataB()) { Event clone = theEvent->clone(); clone.setB((unsigned)val); song->changeEvent(*theEvent, clone, part); ! song->undoOp(UndoOp::ModifyEvent, clone, *theEvent, part); canvas->update(); } *************** *** 188,189 **** --- 193,243 ---- } + //--------------------------------------------------------- + /*! + \fn CtrlEdit::velocityChangeStart + \brief Triggered when cswidget receives a mousedown if it's set to use velocity + */ + //--------------------------------------------------------- + void CtrlEdit::velocityChangeStart(unsigned time, float val) + { + velocity_change = true; + song->startUndo(); + velocityChange(time, val); + } + + //--------------------------------------------------------- + /*! + \fn CtrlEdit::velocityChangeStop + \brief Triggered when cswidget receives a mouserelease + if it's set to use velocity. This way generates quite + a bit of undo-elements, hmmm.... + */ + //--------------------------------------------------------- + void CtrlEdit::velocityChangeStop() + { + velocity_change = false; + song->endUndo(SC_EVENT_MODIFIED); + } + + //--------------------------------------------------------- + /*! + \fn CtrlEdit::controllerManipulation + \brief Slot that catches manipulations of controller + (used for velocity) in cswidget + */ + //--------------------------------------------------------- + void CtrlEdit::controllerManipulation(unsigned time, CVal c) + { + if (!velocity_change) + return; + velocityChange(time, c.f); + } + + + void CtrlEdit::songChanged(int flags) + { + if (flags & SC_EVENT_MODIFIED) { + canvas->update(); + } + } + |