diff --git a/src/avtk/clipselector.cxx b/src/avtk/clipselector.cxx index 22db7ff..d95360b 100644 --- a/src/avtk/clipselector.cxx +++ b/src/avtk/clipselector.cxx @@ -39,6 +39,8 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h, w = _w; h = _h; + special = -1; + label = _label; _master = master; @@ -85,6 +87,18 @@ void ClipSelector::clipName(int clip, std::string name) clips[clip].setName( name ); } +void ClipSelector::setSpecial(int scene) +{ + if ( special == -1 && scene == -1 ) + { + // no change + return; + } + + special = scene; + redraw(); +} + void ClipSelector::draw() { if (damage() & FL_DAMAGE_ALL) @@ -105,12 +119,13 @@ void ClipSelector::draw() int clipWidth = w - 2; int clipHeight = (h / numClips); + // text height adjustment based on clip size // small 22, 13 // start 29, 17 + //printf("clipHeight %i\n", clipHeight); int textHeight = 13 + ((clipHeight - 22) * 0.66 ); - printf("clipHeight %i\n", clipHeight); int xOff = x+clipHeight/2; @@ -203,7 +218,16 @@ void ClipSelector::draw() cairo_set_font_size( cr, 11 ); cairo_show_text( cr, clips[i].getName().c_str() ); + // special indicator? + if ( i == special ) + { + cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 ); + cairo_set_source_rgba(cr, 1.0, 0.408, 0.0, alpha); + cairo_stroke( cr ); + } + drawY += clipHeight; + } cairo_restore( cr ); @@ -315,14 +339,9 @@ int ClipSelector::handle(int event) } else if ( strcmp(m->label(), "Special select") == 0 ) { - printf("special selected %i, %i\n", ID, clipNum ); - // turn on special selection, send note event, turn off selection: - EventGridSelectClipEnable e1(true); - writeToDspRingbuffer( &e1 ); - EventGridEvent e2(ID, clipNum, true); - writeToDspRingbuffer( &e2 ); - EventGridSelectClipEnable e3(false); - writeToDspRingbuffer( &e3 ); + //printf("special selected %i, %i\n", ID, clipNum ); + EventGridSelectNewChosen e( ID, clipNum); + writeToDspRingbuffer( &e ); } else if ( strcmp(m->label(), "Rename") == 0 ) { diff --git a/src/avtk/clipselector.hxx b/src/avtk/clipselector.hxx index b89792d..3146a39 100644 --- a/src/avtk/clipselector.hxx +++ b/src/avtk/clipselector.hxx @@ -84,6 +84,10 @@ class ClipSelector : public Fl_Button static const int numClips = 10; ClipState clips[numClips]; + /// indicates if a clip is the "special" clip + void setSpecial(int scene); + int special; + bool _master; bool mouseOver; bool highlight; diff --git a/src/controller/controller.hxx b/src/controller/controller.hxx index 1efe89a..f7be40c 100644 --- a/src/controller/controller.hxx +++ b/src/controller/controller.hxx @@ -54,6 +54,9 @@ class Controller virtual void bpm(int bpm){} virtual void tapTempo(bool b){} + /// Special + virtual void specialScene(int t, int scene){} + /// track functionality virtual void mute(int t, bool b){} virtual void volume(int t, float f){} diff --git a/src/controller/guicontroller.cxx b/src/controller/guicontroller.cxx index dc16165..ecbbcb1 100644 --- a/src/controller/guicontroller.cxx +++ b/src/controller/guicontroller.cxx @@ -66,6 +66,13 @@ void LupppGUI::trackSend(int t, int send, float r) writeToGuiRingbuffer( &e ); } +void LupppGUI::specialScene(int t, int s) +{ + printf("special cene writing event\n"); + EventGridSelectNewChosen e( t, s ); + writeToGuiRingbuffer( &e ); +} + void LupppGUI::trackSendActive(int t, int send, bool a) { EventTrackSendActive e( t, static_cast(send), a ); diff --git a/src/controller/guicontroller.hxx b/src/controller/guicontroller.hxx index d07b297..fd9a3dd 100644 --- a/src/controller/guicontroller.hxx +++ b/src/controller/guicontroller.hxx @@ -28,6 +28,8 @@ class LupppGUI : public Controller void bpm(int bpm); void tapTempo( bool b ); + void specialScene(int t, int scene); + void mute(int t, bool b); void volume(int t, float f); void progress(int t, int s, float p); diff --git a/src/controllerupdater.cxx b/src/controllerupdater.cxx index 23914d3..36ee5a1 100644 --- a/src/controllerupdater.cxx +++ b/src/controllerupdater.cxx @@ -95,6 +95,15 @@ void ControllerUpdater::setTrackSend(int t, int send, float v) c.at(i)->trackSend(t, send, v); } +void ControllerUpdater::specialScene(int t, int scene) +{ + for(unsigned int i = 0; i < c.size(); i++) + { + printf("calling on c %i\n", i); + c.at(i)->specialScene(t, scene); + } +} + void ControllerUpdater::masterInputToActive(int to, bool v) { for(unsigned int i = 0; i < c.size(); i++) diff --git a/src/controllerupdater.hxx b/src/controllerupdater.hxx index fc72d63..660cebe 100644 --- a/src/controllerupdater.hxx +++ b/src/controllerupdater.hxx @@ -51,6 +51,8 @@ class ControllerUpdater void setTrackSendActive(int t, int send, bool v); void setTrackSend(int t, int send, float v); + void specialScene(int t, int scene); + void launchScene( int scene ); void setSceneState(int t, int clip, GridLogic::State s); diff --git a/src/event.hxx b/src/event.hxx index 4ec8bdb..8872b25 100644 --- a/src/event.hxx +++ b/src/event.hxx @@ -63,6 +63,7 @@ namespace Event GRID_LAUNCH_SCENE, // launches a scene GRID_SELECT_CLIP_ENABLE, // enable selecting a clip from the grid GRID_SELECT_CLIP_EVENT, // a press / release on the selected clip + GRID_SELECT_NEW_CHOSEN, // a different clip is now "special" /// Track TRACK_SEND, @@ -180,6 +181,16 @@ class EventGridSelectClipEnable : public EventBase EventGridSelectClipEnable(bool e=false):enable(e){} }; +class EventGridSelectNewChosen : public EventBase +{ + public: + int type() { return int(GRID_SELECT_NEW_CHOSEN); } + uint32_t size() { return sizeof(EventGridSelectNewChosen); } + int track; + int scene; + EventGridSelectNewChosen(int t = -1, int s = -1):track(t),scene(s){} +}; + class EventQuit : public EventBase { public: diff --git a/src/eventhandlerdsp.cxx b/src/eventhandlerdsp.cxx index 51acbfe..6884905 100644 --- a/src/eventhandlerdsp.cxx +++ b/src/eventhandlerdsp.cxx @@ -159,6 +159,13 @@ void handleDspEvents() jack->getGridLogic()->selectedTrackSceneEvent( ev.pressed ); break; } + case Event::GRID_SELECT_NEW_CHOSEN: { + EventGridSelectNewChosen ev; + jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridSelectNewChosen) ); + jack->getGridLogic()->specialScene( ev.track, ev.scene ); + break; } + + case Event::LOOPER_LOAD: { if ( availableRead >= sizeof(EventLooperLoad) ) { EventLooperLoad ev; diff --git a/src/eventhandlergui.cxx b/src/eventhandlergui.cxx index 40b41c6..a31a4b4 100644 --- a/src/eventhandlergui.cxx +++ b/src/eventhandlergui.cxx @@ -197,6 +197,21 @@ void handleGuiEvents() gui->getMasterTrack()->getClipSelector()->setState( i, GridLogic::STATE_EMPTY ); gui->getMasterTrack()->getClipSelector()->setState( ev.scene, GridLogic::STATE_PLAYING ); } break; } + + case Event::GRID_SELECT_NEW_CHOSEN: { + if ( availableRead >= sizeof(EventGridSelectNewChosen) ) { + EventGridSelectNewChosen ev; + jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventGridSelectNewChosen) ); + + LUPPP_NOTE("New special, %i, %i", ev.track, ev.scene); + + + for(int i = 0; i < NTRACKS; i++) + { + gui->getTrack(i)->getClipSelector()->setSpecial( i == ev.track ? ev.scene : -1 ); + } + } break; } + case Event::TRACK_SEND: { if ( availableRead >= sizeof(EventTrackSend) ) { diff --git a/src/gridlogic.cxx b/src/gridlogic.cxx index e1f4743..b0cd49c 100644 --- a/src/gridlogic.cxx +++ b/src/gridlogic.cxx @@ -107,14 +107,20 @@ void GridLogic::launchScene( int scene ) jack->getControllerUpdater()->launchScene( scene ); } +void GridLogic::specialScene(int t, int s) +{ + selectedTrack = t; + selectedScene = s; + + // update UI's + jack->getControllerUpdater()->specialScene( t, s ); +} + void GridLogic::pressed( int track, int scene ) { if ( sampleTrackScene ) { - selectedTrack = track; - selectedScene = scene; - - //sampleTrackScene = false; + specialScene( track, scene ); // don't act on grid press! return; diff --git a/src/gridlogic.hxx b/src/gridlogic.hxx index 1e281cd..3fb0cc9 100644 --- a/src/gridlogic.hxx +++ b/src/gridlogic.hxx @@ -60,6 +60,8 @@ class GridLogic : public TimeObserver void selectedTrackSceneEvent(bool pressed); + void specialScene(int t, int s); + /// GUI load event void load(int track, int scene, AudioBuffer* ab); diff --git a/src/gui.cxx b/src/gui.cxx index 4576131..505fb37 100644 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -400,6 +400,9 @@ Gui::Gui(std::string argZero) : window.end(); + tracks.at(0)->getClipSelector()->setSpecial( 0 ); + + optionWindow = new OptionsWindow(); // Create AudioEditor after window.end() has been called diff --git a/src/main.cxx b/src/main.cxx index ed41119..fbe3fa4 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -72,6 +72,7 @@ int main(int argc, char** argv) #ifdef BUILD_TESTS + LUPPP_NOTE("Built with BUILD_TESTS enabled"); if ( runTests ) { // counts failures @@ -100,8 +101,8 @@ int main(int argc, char** argv) #endif - // setup the "real" JACK / Gui: Jack first, then GUI - gui = new Gui(argv[0]); + // Create a GUI, check for NSM integration + gui = new Gui( argv[0] ); if ( gui->getNsm() ) {