From a99daa5aa86c4cf4cd5aff8652b3ececdccfb685 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Wed, 24 Jul 2013 19:09:35 +0100 Subject: [PATCH 1/2] -UI tooltip & updated --- src/gmastertrack.hxx | 10 +++++----- src/gtrack.hxx | 27 +++++++++++++++------------ src/gui.cxx | 14 +++++++++++++- src/gui.hxx | 6 ++++++ src/main.cxx | 4 ++-- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/gmastertrack.hxx b/src/gmastertrack.hxx index 99262b9..054ec67 100644 --- a/src/gmastertrack.hxx +++ b/src/gmastertrack.hxx @@ -59,10 +59,10 @@ class GMasterTrack : public Fl_Group title( strdup(l) ), bg( x, y , w, h, title ), - clipSel(x + 5, y + 26, 140, 294,"Testing"), + clipSel(x + 5, y + 26 + 26, 140, 294,"Testing"), - tapTempo(x + 25 + 22, y + 475, 44, 44,"Tap"), + tapTempo(x + 25 + 22, y + 475 + 26, 44, 44,"Tap"), /* button2(x + 5, y + 44, 100, 18,"Play"), button3(x + 5, y + 64, 100, 18,"Stop"), @@ -70,14 +70,14 @@ class GMasterTrack : public Fl_Group button5(x +57, y + 84, 48, 18,"+"), button6(x + 5, y +104, 18, 18,"6"), */ - metronomeButton(x + 5,y + 424,140,30,"Metro"), + metronomeButton(x + 5,y + 424 + 26,140,30,"Metro"), - dial1(x+25-22, y +475, 44, 44, "BPM"), + dial1(x+25-22, y +475 + 26, 44, 44, "BPM"), /* dial2(x+45, y +155, 24, 24, "B"), dial3(x+75, y +155, 24, 24, "C") */ - volume(x+108, y +495, 36, 150, "Vol") + volume(x+108, y +495 + 26, 36, 150, "Vol") { ID = privateID++; diff --git a/src/gtrack.hxx b/src/gtrack.hxx index 384d47d..a74ef6b 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -17,6 +17,7 @@ #include "avtk/avtk_clip_selector.h" +#include "config.hxx" #include "worker.hxx" #include "audiobuffer.hxx" #include "eventhandler.hxx" @@ -55,11 +56,13 @@ static void gtrack_button_callback(Fl_Widget *w, void *data) { { EventLooperState e = EventLooperState(track,Looper::STATE_RECORD_QUEUED); writeToDspRingbuffer( &e ); + w->tooltip( "Rec Clicked" ); } else if ( strcmp( w->label() , "Play" ) == 0 ) { EventLooperState e = EventLooperState(track,Looper::STATE_PLAY_QUEUED); writeToDspRingbuffer( &e ); + w->tooltip( "Play clicked" ); } else if ( strcmp( w->label() , "Stop" ) == 0 ) { @@ -102,23 +105,23 @@ class GTrack : public Fl_Group title( strdup(l) ), bg( x, y , w, h, title ), - clipSel(x + 5, y + 26, 100, 294,"Clip"), + clipSel(x + 5, y + 26 + 26, 100, 294,""), - button1(x + 5, y + 324, 100, 18,"Rec"), - button2(x + 5, y + 344, 100, 18,"Play"), - button3(x + 5, y + 364, 100, 18,"Stop"), - button4(x + 5, y + 384, 48, 18,"-"), - button5(x +57, y + 384, 48, 18,"+"), + button1(x + 5, y + 324 + 26, 100, 18,"Rec"), + button2(x + 5, y + 344 + 26, 100, 18,"Play"), + button3(x + 5, y + 364 + 26, 100, 18,"Stop"), + button4(x + 5, y + 384 + 26, 48, 18,"-"), + button5(x +57, y + 384 + 26, 48, 18,"+"), - button6(x + 5, y + 404, 100, 18,"Load"), + button6(x + 5, y + 404 + 26, 100, 18,"Load"), - volume(x+68, y +495, 36, 150, "Vol"), + volume(x+68, y +495 + 26, 36, 150, "Vol"), - dial1(x+15, y +452, 24, 24, "REV"), - dial2(x+45, y +452, 24, 24, "SC"), - dial3(x+75, y +452, 24, 24, "POST"), + dial1(x+15, y +452 + 26, 24, 24, "REV"), + dial2(x+45, y +452 + 26, 24, 24, "SC"), + dial3(x+75, y +452 + 26, 24, 24, "POST"), - progress(x+5, y+428, 100, 18, "") + progress(x+5, y+428 + 26, 100, 18, "") { ID = privateID++; diff --git a/src/gui.cxx b/src/gui.cxx index b8925fc..4832a55 100644 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -4,6 +4,8 @@ #include +#include + #include "audiobuffer.hxx" // include the header.c file in the planning dir: @@ -11,12 +13,14 @@ #include "../planning/header.c" // Hack, move to gtrack.cpp +Fl_Box* Gui::tooltipLabel = 0; int GTrack::privateID = 0; int GMasterTrack::privateID = 0; int AudioBuffer::privateID = 0; using namespace std; + void close_cb(Fl_Widget*o, void*) { if ((Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) && Fl::event_key() == FL_Escape) @@ -34,15 +38,18 @@ static void gui_static_read_rb(void* inst) Gui::Gui() : window(1272,750) { + fl_show_tooltip = &Gui::show_tooltip; + window.color(FL_BLACK); window.label("Luppp 5"); //window.callback( close_cb, 0 ); - 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"); + //window.resizable( headerImage ); int i = 0; @@ -80,3 +87,8 @@ int Gui::show() return Fl::run(); } + +void Gui::show_tooltip( const char* c ) +{ + tooltipLabel->label( c ); +} diff --git a/src/gui.hxx b/src/gui.hxx index 4cbd83d..d69406d 100644 --- a/src/gui.hxx +++ b/src/gui.hxx @@ -14,6 +14,7 @@ #include "gmastertrack.hxx" #include +#include using namespace std; @@ -23,6 +24,9 @@ class Gui Gui(); int show(); GTrack* getTrack(int id); + + // for pushing strings to tooltip area + static void show_tooltip( const char* ); private: Fl_Double_Window window; @@ -32,6 +36,8 @@ class Gui GUnitTrack* unit; vector tracks; + + static Fl_Box* tooltipLabel; }; #endif // LUPPP_GUI diff --git a/src/main.cxx b/src/main.cxx index 635452f..5ca1c43 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(); From 0b67eed2830983b78f2d2a759826f3739054bf27 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Wed, 24 Jul 2013 23:23:30 +0100 Subject: [PATCH 2/2] -Tooltips working --- src/gtrack.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/gtrack.hxx | 51 +------------------------------------------ src/gui.cxx | 29 +++++++++++-------------- src/gui.hxx | 5 +++-- wscript | 1 + 5 files changed, 77 insertions(+), 68 deletions(-) create mode 100644 src/gtrack.cxx diff --git a/src/gtrack.cxx b/src/gtrack.cxx new file mode 100644 index 0000000..0a0c66c --- /dev/null +++ b/src/gtrack.cxx @@ -0,0 +1,59 @@ + +#include "gtrack.hxx" +#include "gui.hxx" + +extern Gui* gui; + +void gtrack_button_callback(Fl_Widget *w, void *data) +{ + int track = 0; + if ( data ) + track = *(int*)data; + //cout << "Button " << *(int*)data << " " << w->label() << " clicked" << endl; + + if ( strcmp( w->label() , "Rec" ) == 0 ) + { + EventLooperState e = EventLooperState(track,Looper::STATE_RECORD_QUEUED); + writeToDspRingbuffer( &e ); + //w->tooltip( "Rec Clicked" ); + gui->setTooltip("Rec clicked"); + } + else if ( strcmp( w->label() , "Play" ) == 0 ) + { + EventLooperState e = EventLooperState(track,Looper::STATE_PLAY_QUEUED); + writeToDspRingbuffer( &e ); + //w->tooltip( "Play clicked" ); + gui->setTooltip("Play clicked"); + } + else if ( strcmp( w->label() , "Stop" ) == 0 ) + { + EventLooperState e = EventLooperState(track,Looper::STATE_STOP_QUEUED); + writeToDspRingbuffer( &e ); + } + else if ( strcmp( w->label() , "+" ) == 0 ) + { + EventLooperLoopLength e = EventLooperLoopLength(track, 2); + writeToDspRingbuffer( &e ); + } + else if ( strcmp( w->label() , "-" ) == 0 ) + { + EventLooperLoopLength e = EventLooperLoopLength(track, 0.5); + writeToDspRingbuffer( &e ); + } + else if ( strcmp( w->label() , "Load" ) == 0 ) + { + AudioBuffer* ab = Worker::loadSample( choose_file() ); + EventLooperLoad e = EventLooperLoad( track, 0 , ab ); + cout << "writing event ab ptr = " << ab << endl; + writeToDspRingbuffer( &e ); + cout << "writing event done" << endl; + } + else if ( strcmp( w->label() , "Vol" ) == 0 ) + { + + } + else + { + cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl; + } +} diff --git a/src/gtrack.hxx b/src/gtrack.hxx index a74ef6b..b46b5ae 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -46,56 +46,7 @@ static string choose_file() return path; } -static void gtrack_button_callback(Fl_Widget *w, void *data) { - int track = 0; - if ( data ) - track = *(int*)data; - //cout << "Button " << *(int*)data << " " << w->label() << " clicked" << endl; - - if ( strcmp( w->label() , "Rec" ) == 0 ) - { - EventLooperState e = EventLooperState(track,Looper::STATE_RECORD_QUEUED); - writeToDspRingbuffer( &e ); - w->tooltip( "Rec Clicked" ); - } - else if ( strcmp( w->label() , "Play" ) == 0 ) - { - EventLooperState e = EventLooperState(track,Looper::STATE_PLAY_QUEUED); - writeToDspRingbuffer( &e ); - w->tooltip( "Play clicked" ); - } - else if ( strcmp( w->label() , "Stop" ) == 0 ) - { - EventLooperState e = EventLooperState(track,Looper::STATE_STOP_QUEUED); - writeToDspRingbuffer( &e ); - } - else if ( strcmp( w->label() , "+" ) == 0 ) - { - EventLooperLoopLength e = EventLooperLoopLength(track, 2); - writeToDspRingbuffer( &e ); - } - else if ( strcmp( w->label() , "-" ) == 0 ) - { - EventLooperLoopLength e = EventLooperLoopLength(track, 0.5); - writeToDspRingbuffer( &e ); - } - else if ( strcmp( w->label() , "Load" ) == 0 ) - { - AudioBuffer* ab = Worker::loadSample( choose_file() ); - EventLooperLoad e = EventLooperLoad( track, 0 , ab ); - cout << "writing event ab ptr = " << ab << endl; - writeToDspRingbuffer( &e ); - cout << "writing event done" << endl; - } - else if ( strcmp( w->label() , "Vol" ) == 0 ) - { - - } - else - { - cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl; - } -} +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 4832a55..6680f5a 100644 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -4,8 +4,6 @@ #include -#include - #include "audiobuffer.hxx" // include the header.c file in the planning dir: @@ -13,13 +11,25 @@ #include "../planning/header.c" // Hack, move to gtrack.cpp -Fl_Box* Gui::tooltipLabel = 0; int GTrack::privateID = 0; int GMasterTrack::privateID = 0; int AudioBuffer::privateID = 0; using namespace std; +extern Gui* gui; + + +static void luppp_tooltip(std::string s) +{ + gui->setTooltip(s); +} + +void Gui::setTooltip( std::string s ) +{ + tooltip = s; + tooltipLabel->label( tooltip.c_str() ); +} void close_cb(Fl_Widget*o, void*) { if ((Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) @@ -38,8 +48,6 @@ static void gui_static_read_rb(void* inst) Gui::Gui() : window(1272,750) { - fl_show_tooltip = &Gui::show_tooltip; - window.color(FL_BLACK); window.label("Luppp 5"); //window.callback( close_cb, 0 ); @@ -64,13 +72,6 @@ Gui::Gui() : unit = new GUnitTrack(9 + i * 118 + 158, 40, 150, 700, "Units"); - - /* - box = new Fl_Box(655, 5, 200, 60, "BPM = 120"); - box->box(FL_UP_BOX); - box->labelsize(36); - box->labeltype(FL_SHADOW_LABEL); - */ window.end(); } @@ -88,7 +89,3 @@ int Gui::show() return Fl::run(); } -void Gui::show_tooltip( const char* c ) -{ - tooltipLabel->label( c ); -} diff --git a/src/gui.hxx b/src/gui.hxx index d69406d..e82daa4 100644 --- a/src/gui.hxx +++ b/src/gui.hxx @@ -26,7 +26,7 @@ class Gui GTrack* getTrack(int id); // for pushing strings to tooltip area - static void show_tooltip( const char* ); + void setTooltip( std::string s ); private: Fl_Double_Window window; @@ -37,7 +37,8 @@ class Gui vector tracks; - static Fl_Box* tooltipLabel; + std::string tooltip; + Fl_Box* tooltipLabel; }; #endif // LUPPP_GUI diff --git a/wscript b/wscript index 47bfc6a..c56bc15 100644 --- a/wscript +++ b/wscript @@ -22,6 +22,7 @@ def build(bld): sources = ['src/gui.cxx', 'src/main.cxx', 'src/jack.cxx', + 'src/gtrack.cxx', 'src/looper.cxx', 'src/controller/apc.cxx', 'src/eventhandlergui.cxx',