mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Added "special" selection from GUI
This commit is contained in:
parent
59c46e3dfd
commit
04fc086a5d
14 changed files with 106 additions and 15 deletions
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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){}
|
||||
|
|
|
@ -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<Event::SEND_TYPE>(send), a );
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) ) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue