From 9fba8a8577b7a3e4c845c098162eb31f02392f7e Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 2 Sep 2013 12:11:10 -0700 Subject: [PATCH] Mixer: Make spatializer view options song global. --- mixer/src/Panner.C | 27 +++++++++++++++++++++++++-- mixer/src/Panner.H | 14 +++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/mixer/src/Panner.C b/mixer/src/Panner.C index ac29e07..86287eb 100644 --- a/mixer/src/Panner.C +++ b/mixer/src/Panner.C @@ -32,6 +32,8 @@ /* 2D Panner widget. Supports various multichannel configurations. */ Panner::Point *Panner::drag; +int Panner::_range_mode = 1; +int Panner::_projection_mode = 0; Panner::Panner ( int X, int Y, int W, int H, const char *L ) : Fl_Group( X, Y, W, H, L ) @@ -51,7 +53,8 @@ Panner::Panner ( int X, int Y, int W, int H, const char *L ) : o->add("5 Meters",0,0,&ranges[1]); o->add("10 Meters",0,0,&ranges[2]); o->add("15 Meters",0,0,&ranges[3]); - o->value(1); + o->value(_range_mode); + o->callback( cb_mode, this ); } { Fl_Choice *o = _projection_choice = new Fl_Choice(X + W - 75,Y + H - 18,75,18,"Projection:"); @@ -62,7 +65,8 @@ Panner::Panner ( int X, int Y, int W, int H, const char *L ) : o->align(FL_ALIGN_LEFT); o->add("Spherical"); o->add("Planar"); - o->value(0); + o->value(_projection_mode); + o->callback( cb_mode, this ); } end(); @@ -89,12 +93,29 @@ static int find_numeric_menu_item( const Fl_Menu_Item *menu, int n ) return -1; } +void +Panner::cb_mode ( Fl_Widget *w, void *v ) +{ + ((Panner*)v)->cb_mode( w ); +} + +void +Panner::cb_mode ( Fl_Widget *w ) +{ + if ( w == _range_choice ) + _range_mode = _range_choice->value(); + else if ( w == _projection_choice ) + _projection_mode = _projection_choice->value(); +} + void Panner::range ( float v ) { int i = find_numeric_menu_item( _range_choice->menu(), v ); _range_choice->value( i ); + + _range_mode = i; } /** set X, Y, W, and H to the bounding box of point /p/ in screen coords */ @@ -435,6 +456,8 @@ Panner::handle ( int m ) { case FL_ENTER: case FL_LEAVE: + _projection_choice->value(_projection_mode); + _range_choice->value(_range_mode); redraw(); return 1; case FL_PUSH: diff --git a/mixer/src/Panner.H b/mixer/src/Panner.H index 32933f3..829b296 100644 --- a/mixer/src/Panner.H +++ b/mixer/src/Panner.H @@ -36,6 +36,9 @@ class Panner : public Fl_Group Fl_Image *_bg_image[2]; void draw_grid( int,int,int,int); void draw_the_box( int, int, int, int ); + + static int _range_mode; + static int _projection_mode; public: @@ -168,8 +171,9 @@ private: void project_polar ( const Point *p, float *X, float *Y, float *S ) const; void project_ortho ( const Point *p, float *X, float *Y, float *S ) const; - int _projection; - + static void cb_mode ( Fl_Widget *w, void *v ); + void cb_mode ( Fl_Widget *w ); + protected: virtual void draw ( void ); @@ -179,12 +183,12 @@ public: enum { POLAR, ORTHO }; - int projection ( void ) const { return _projection_choice->value(); } - void projection ( int v ) { _projection_choice->value(v); } + int projection ( void ) const { return _projection_mode; } + void projection ( int v ) { _projection_choice->value(v); _projection_mode = 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()); } + float range ( void ) const { return *((int*)_range_choice->menu()[_range_mode].user_data()); } void range ( float v ); void clear_points ( void ) { _points.clear(); }