diff --git a/lib/ntk b/lib/ntk index 81f41f5..415422b 160000 --- a/lib/ntk +++ b/lib/ntk @@ -1 +1 @@ -Subproject commit 81f41f5fed153f7f9aa5f7b845d7171f74919750 +Subproject commit 415422bd1b35cdbac5c751dcf8f4fb9cbe696927 diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index ff726b1..221b223 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -318,19 +318,6 @@ void Mixer::cb_menu(Fl_Widget* o) { { Fl::paste(*this); } - else if ( !strcmp( picked, "&Mixer/Spatialization Console" ) ) - { - if ( ! spatialization_console ) - { - Spatialization_Console *o = new Spatialization_Console(); - spatialization_console = o; - } - - if ( spatialization_console->shown() ) - spatialization_console->hide(); - else - spatialization_console->show(); - } else if (! strcmp( picked, "&Project/Se&ttings/&Rows/One") ) { rows( 1 ); @@ -343,6 +330,19 @@ void Mixer::cb_menu(Fl_Widget* o) { { rows( 3 ); } + else if (! strcmp( picked, "&Mixer/&Spatialization Console") ) + { + if ( ! spatialization_console ) + { + Spatialization_Console *o = new Spatialization_Console(); + spatialization_console = o; + } + + if ( ! menu->mvalue()->value() ) + spatialization_console->hide(); + else + spatialization_console->show(); + } else if (! strcmp( picked, "&Project/Se&ttings/Make Default") ) { save_default_project_settings(); @@ -517,7 +517,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : o->add( "&Mixer/Add &N Strips" ); o->add( "&Mixer/&Import Strip" ); o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 ); - o->add( "&Mixer/Spatialization Console", FL_F + 8, 0, 0 ); + o->add( "&Mixer/&Spatialization Console", FL_F + 8, 0, 0, FL_MENU_TOGGLE ); o->add( "&Remote Control/Start Learning", FL_F + 9, 0, 0 ); o->add( "&Remote Control/Stop Learning", FL_F + 10, 0, 0 ); o->add( "&Remote Control/Send State" ); @@ -933,6 +933,9 @@ Mixer::handle_dirty ( int d, void *v ) void Mixer::snapshot ( void ) { + if ( spatialization_console ) + spatialization_console->log_create(); + for ( int i = 0; i < mixer_strips->children(); ++i ) ((Mixer_Strip*)mixer_strips->child( i ))->log_children(); } @@ -981,6 +984,9 @@ void Mixer::update_menu ( void ) { project_name->label( Project::name() ); + + const_cast(menubar->find_item( "&Mixer/&Spatialization Console" )) + ->flags = FL_MENU_TOGGLE | ( ( spatialization_console && spatialization_console->shown() ) ? FL_MENU_VALUE : 0 ); } void diff --git a/mixer/src/Mixer.H b/mixer/src/Mixer.H index ef7bcb2..9343347 100644 --- a/mixer/src/Mixer.H +++ b/mixer/src/Mixer.H @@ -73,7 +73,6 @@ private: void load_options ( void ); void save_options ( void ); - void update_menu ( void ); void save_translations ( void ); void load_translations ( void ); @@ -91,6 +90,8 @@ private: public: + void update_menu ( void ); + static Spatialization_Console *spatialization_console; int nstrips ( void ) const; diff --git a/mixer/src/Panner.C b/mixer/src/Panner.C index 9985de1..6d44aca 100644 --- a/mixer/src/Panner.C +++ b/mixer/src/Panner.C @@ -66,6 +66,33 @@ Panner::Panner ( int X, int Y, int W, int H, const char *L ) : } end(); + + _bg_image[0] = _bg_image[1] = 0; +} + +Panner::~Panner ( ) +{ + if ( _bg_image[0] ) + ((Fl_Shared_Image*)_bg_image[0])->release(); + if ( _bg_image[1] ) + ((Fl_Shared_Image*)_bg_image[1])->release(); +} + +static int find_numeric_menu_item( const Fl_Menu_Item *menu, int n ) +{ + for ( unsigned int i = 0; menu[i].text; i++ ) + { + if ( atoi( menu[i].text ) == n ) + return i; + } +} + +void +Panner::range ( float v ) +{ + int i = find_numeric_menu_item( _range_choice->menu(), v ); + + _range_choice->value( i ); } /** set X, Y, W, and H to the bounding box of point /p/ in screen coords */ @@ -136,8 +163,10 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th ) Fl_Image *i = 0; - if ( projection() == POLAR ) + if ( ! ( _bg_image[0] && _bg_image[1] )) { + Fl_Image *i; + switch ( tw ) { case 802: @@ -150,9 +179,9 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th ) i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" ); break; } - } - else - { + + _bg_image[0] = i; + switch ( tw ) { case 802: @@ -165,56 +194,18 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th ) i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" ); break; } + + _bg_image[1] = i; } + if ( projection() == POLAR ) + i = _bg_image[0]; + else + i = _bg_image[1]; if ( i ) i->draw( tx, ty ); } -void -Panner::draw_grid ( int tx, int ty, int tw, int th ) -{ - - fl_push_matrix(); - fl_translate(tx,ty); - fl_scale(tw,th); - - fl_color( fl_color_add_alpha( FL_WHITE, 25 ) ); - - for ( float x = 0.0f; x <= 1.0f; x += 0.05f ) - { - fl_begin_line(); - for ( float y = 0.0f; y <= 1.0f; y += 0.5f ) - { - fl_vertex( x, y ); - } - fl_end_line(); - } - - for ( float y = 0.0f; y <= 1.0f; y += 0.05f ) - { - fl_begin_line(); - for ( float x = 0.0f; x <= 1.0f; x += 0.5f ) - { - fl_vertex( x, y ); - } - fl_end_line(); - } - - for ( float x = 0.0f; x < 1.0f; x += 0.05f ) - { - fl_begin_points(); - for ( float y = 0.0f; y < 1.0f; y += 0.05f ) - { - fl_vertex( x, y ); - } - fl_end_points(); - } - - fl_pop_matrix(); - -} - /** translate angle /a/ into x/y coords and place the result in /X/ and /Y/ */ void Panner::project_polar ( const Point *p, float *X, float *Y, float *S ) const diff --git a/mixer/src/Panner.H b/mixer/src/Panner.H index 809dc7b..32933f3 100644 --- a/mixer/src/Panner.H +++ b/mixer/src/Panner.H @@ -24,7 +24,7 @@ #include #include #include - +#include #include using namespace std; @@ -33,6 +33,7 @@ class Panner : public Fl_Group Fl_Choice *_range_choice; Fl_Choice *_projection_choice; + Fl_Image *_bg_image[2]; void draw_grid( int,int,int,int); void draw_the_box( int, int, int, int ); @@ -177,14 +178,14 @@ protected: public: enum { POLAR, ORTHO }; - - float projection ( void ) const { return _projection_choice->value(); } + + int projection ( void ) const { return _projection_choice->value(); } void projection ( int v ) { _projection_choice->value(v); } Panner ( int X, int Y, int W, int H, const char *L = 0 ); float range ( void ) const { return *((int*)_range_choice->mvalue()->user_data()); } - /* void range ( float v ) { _range = v; } */ + void range ( float v ); void clear_points ( void ) { _points.clear(); } @@ -193,7 +194,7 @@ public: _points.push_back( p ); } - virtual ~Panner ( ) { } + virtual ~Panner ( ); Panner::Point *point ( int i ); diff --git a/mixer/src/Spatialization_Console.C b/mixer/src/Spatialization_Console.C index 3466894..3d7b0a0 100644 --- a/mixer/src/Spatialization_Console.C +++ b/mixer/src/Spatialization_Console.C @@ -53,18 +53,68 @@ Spatialization_Console::Spatialization_Console ( void ) : Fl_Double_Window( 850, panner->callback( cb_panner_value_handle, this ); panner->when( FL_WHEN_CHANGED ); + callback( cb_window, this ); end(); make_controls(); + + mixer->spatialization_console = this; } Spatialization_Console::~Spatialization_Console ( ) { // controls_by_port.clear(); + mixer->spatialization_console = NULL; + +} + + +void +Spatialization_Console::get ( Log_Entry &e ) const +{ + e.add( ":range", panner->range() ); + e.add( ":projection", panner->projection() ); + e.add( ":shown", ((const Fl_Double_Window*)this)->shown() ); +} + +void +Spatialization_Console::set ( Log_Entry &e ) +{ + for ( int i = 0; i < e.size(); ++i ) + { + const char *s, *v; + + e.get( i, &s, &v ); + + if ( ! ( strcmp( s, ":range" ) ) ) + panner->range( atoi( v ) ); + if ( ! ( strcmp( s, ":projection" ) ) ) + panner->projection( atoi( v ) ); + else if ( ! ( strcmp( s, ":shown" ) ) ) + { + if ( atoi( v ) ) + show(); + else + hide(); + } + } } +void +Spatialization_Console::cb_window ( Fl_Widget *w, void *v ) +{ + ((Spatialization_Console*)v)->cb_window(w); +} + +void +Spatialization_Console::cb_window ( Fl_Widget *w ) +{ + w->hide(); + mixer->update_menu(); +} + void diff --git a/mixer/src/Spatialization_Console.H b/mixer/src/Spatialization_Console.H index c1c0792..792df91 100644 --- a/mixer/src/Spatialization_Console.H +++ b/mixer/src/Spatialization_Console.H @@ -21,7 +21,7 @@ #include #include - +#include "Loggable.H" class Fl_Pack; class Fl_Flowpack; @@ -31,13 +31,16 @@ class Panner; class Controller_Module; #include -class Spatialization_Console : public Fl_Double_Window +class Spatialization_Console : public Loggable, public Fl_Double_Window { Panner *panner; static void cb_panner_value_handle ( Fl_Widget *w, void *v ); void make_controls ( void ); + static void cb_window ( Fl_Widget *w, void *v ); + static void cb_window ( Fl_Widget *w ); + bool _resized; int _min_width; @@ -46,8 +49,15 @@ class Spatialization_Console : public Fl_Double_Window std::vector controls_by_port; +protected: + + virtual void get ( Log_Entry &e ) const; + virtual void set ( Log_Entry &e ); + public: + LOG_CREATE_FUNC( Spatialization_Console ); + void handle_control_changed ( Controller_Module *m ); void update ( void ); diff --git a/mixer/src/main.C b/mixer/src/main.C index e3ae71f..d7614b1 100644 --- a/mixer/src/main.C +++ b/mixer/src/main.C @@ -54,6 +54,7 @@ #include "Mixer_Strip.H" #include "AUX_Module.H" #include "NSM.H" +#include "Spatialization_Console.H" #include #include @@ -159,6 +160,7 @@ main ( int argc, char **argv ) LOG_REGISTER_CREATE( Meter_Indicator_Module ); LOG_REGISTER_CREATE( Controller_Module ); LOG_REGISTER_CREATE( AUX_Module ); + LOG_REGISTER_CREATE( Spatialization_Console ); signal( SIGPIPE, SIG_IGN );