From 1121c068ca8ed8645e754cf59871e8afc7236919 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Thu, 25 Jul 2013 01:47:19 +0100 Subject: [PATCH] -Updated UI to send LOOPER_PLAY event on click --- src/avtk/avtk_clip_selector.h | 6 +++-- src/gclipselectoraction.hxx | 47 +++++++++++++++++++++++++++++++++++ src/gmastertrack.hxx | 1 + src/gtrack.hxx | 22 ---------------- src/gui.cxx | 2 +- src/gui.hxx | 2 -- src/main.cxx | 4 +-- 7 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 src/gclipselectoraction.hxx diff --git a/src/avtk/avtk_clip_selector.h b/src/avtk/avtk_clip_selector.h index 1a089cf..f0a0aaa 100644 --- a/src/avtk/avtk_clip_selector.h +++ b/src/avtk/avtk_clip_selector.h @@ -27,6 +27,8 @@ #include +#include "../gclipselectoraction.hxx" + namespace Avtk { @@ -51,7 +53,7 @@ class ClipState state = CLIP_EMPTY; name = n; } - + State state; std::string name; }; @@ -249,7 +251,7 @@ class ClipSelector : public Fl_Button } else if ( strcmp(m->label(), "Load") == 0 ) { - fl_choice("Loading...", "OK", NULL, NULL); + clipSelectorLoad( 0 ); clips[clipNum].state = ClipState::CLIP_LOADED; } else if ( strcmp(m->label(), "Duration") == 0 ) diff --git a/src/gclipselectoraction.hxx b/src/gclipselectoraction.hxx new file mode 100644 index 0000000..268022a --- /dev/null +++ b/src/gclipselectoraction.hxx @@ -0,0 +1,47 @@ + +#ifndef LUPPP_G_CLIP_SELECTOR_ACTION_H +#define LUPPP_G_CLIP_SELECTOR_ACTION_H + +#include "config.hxx" +#include "worker.hxx" +#include "audiobuffer.hxx" +#include "eventhandler.hxx" + + +static string choose_file() +{ + string path; + Fl_Native_File_Chooser fnfc; + fnfc.title("Pick a file"); + fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); + //fnfc.filter("Wav\t*.wav"); + fnfc.directory( getenv("HOME") ); // default directory to use + // Show native chooser + switch ( fnfc.show() ) { + case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR + case 1: printf("CANCEL\n"); break; // CANCEL + default: printf("Loading directory: %s\n", fnfc.filename()); + + // update path and load it + path = fnfc.filename(); + + break; // FILE CHOSEN + } + return path; +} + +static void clipSelectorLoad(int track) +{ + AudioBuffer* ab = Worker::loadSample( choose_file() ); + EventLooperLoad e = EventLooperLoad( track, 0, ab ); + writeToDspRingbuffer( &e ); +} + +static void clipSelectorPlay(int track, int scene) +{ + EventLooperPlay e = EventLooperPlay( track, scene ); + writeToDspRingbuffer( &e ); +} + +#endif // LUPPP_G_CLIP_SELECTOR_ACTION_H + diff --git a/src/gmastertrack.hxx b/src/gmastertrack.hxx index 41704ff..92a4f3e 100644 --- a/src/gmastertrack.hxx +++ b/src/gmastertrack.hxx @@ -12,6 +12,7 @@ #include "avtk/avtk_dial.h" #include "avtk/avtk_button.h" #include "avtk/avtk_background.h" +#include "avtk/avtk_light_button.h" #include "avtk/avtk_clip_selector.h" diff --git a/src/gtrack.hxx b/src/gtrack.hxx index aaa34d6..a84d3e9 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -24,28 +24,6 @@ using namespace std; -static string choose_file() -{ - string path; - Fl_Native_File_Chooser fnfc; - fnfc.title("Pick a file"); - fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); - //fnfc.filter("Wav\t*.wav"); - fnfc.directory( getenv("HOME") ); // default directory to use - // Show native chooser - switch ( fnfc.show() ) { - case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR - case 1: printf("CANCEL\n"); break; // CANCEL - default: printf("Loading directory: %s\n", fnfc.filename()); - - // update path and load it - path = fnfc.filename(); - - break; // FILE CHOSEN - } - return path; -} - extern void gtrack_button_callback(Fl_Widget *w, void *data); class GTrack : public Fl_Group diff --git a/src/gui.cxx b/src/gui.cxx index 6680f5a..afd15e9 100644 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -56,7 +56,7 @@ Gui::Gui() : Avtk::Image* headerImage = new Avtk::Image(0,0,1272,36,"header.png"); headerImage->setPixbuf( header.pixel_data, 4 ); - Gui::tooltipLabel = new Fl_Box(100, 20, 200, 20, "tooltips go here"); + tooltipLabel = new Fl_Box(100, 20, 200, 20, "tooltips go here"); //window.resizable( headerImage ); diff --git a/src/gui.hxx b/src/gui.hxx index e82daa4..19b68b5 100644 --- a/src/gui.hxx +++ b/src/gui.hxx @@ -6,8 +6,6 @@ #include #include -#include "avtk/avtk_light_button.h" - #include "config.hxx" #include "gtrack.hxx" #include "gunittrack.hxx" diff --git a/src/main.cxx b/src/main.cxx index 5ca1c43..635452f 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -36,8 +36,8 @@ int main() rbToGui = jack_ringbuffer_create( 5000 * sizeof(EventBase)); - //jack = new Jack(); - //jack->activate(); + jack = new Jack(); + jack->activate(); gui = new Gui(); gui->show();