From 19b19edf0efdc5da3d2424c936d7d2d93426be84 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 8 Sep 2013 20:00:40 -0700 Subject: [PATCH] Mixer: Make panner widget scalable again. --- FL/Fl_Labelpad_Group.H | 3 +- mixer/src/Module_Parameter_Editor.C | 1 + mixer/src/Panner.C | 115 +++++++++++++++------------- mixer/src/Panner.H | 4 +- 4 files changed, 69 insertions(+), 54 deletions(-) diff --git a/FL/Fl_Labelpad_Group.H b/FL/Fl_Labelpad_Group.H index 57f99b8..f55aea8 100644 --- a/FL/Fl_Labelpad_Group.H +++ b/FL/Fl_Labelpad_Group.H @@ -67,7 +67,8 @@ public: { /* TODO: other alignments */ } - + + init_sizes(); } virtual ~Fl_Labelpad_Group ( ) diff --git a/mixer/src/Module_Parameter_Editor.C b/mixer/src/Module_Parameter_Editor.C index 652abb2..2e6b27f 100644 --- a/mixer/src/Module_Parameter_Editor.C +++ b/mixer/src/Module_Parameter_Editor.C @@ -377,6 +377,7 @@ Module_Parameter_Editor::make_controls ( void ) Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o ); + flg->resizable(o); control_pack->add( flg ); controls_by_port[azimuth_port_number] = o; diff --git a/mixer/src/Panner.C b/mixer/src/Panner.C index 86287eb..8d4159f 100644 --- a/mixer/src/Panner.C +++ b/mixer/src/Panner.C @@ -38,6 +38,8 @@ 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 ) { + _bg_image = 0; + _bg_image_scaled = 0; _range = 15.0f; // _projection = POLAR; _points.push_back( Point( 1, 0 ) ); @@ -70,16 +72,17 @@ 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(); + if ( _bg_image ) + { + if ( _bg_image_scaled ) + delete _bg_image; + else + ((Fl_Shared_Image*)_bg_image)->release(); + } } static int find_numeric_menu_item( const Fl_Menu_Item *menu, int n ) @@ -131,7 +134,7 @@ Panner::point_bbox ( const Point *p, int *X, int *Y, int *W, int *H ) const if ( projection() == POLAR ) { - project_polar( p, &px, &py, &s ); + project_polar( p, &px, &py, &s ); } else { @@ -186,49 +189,53 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th ) Fl_Image *i = 0; - if ( ! ( _bg_image[0] && _bg_image[1] )) + if ( _bg_image && _bg_image->h() != th ) { - Fl_Image *i = NULL; - - switch ( tw ) - { - case 802: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-802x802.png" ); - break; - case 92: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-92x92.png" ); - break; - case 502: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" ); - break; - } - - _bg_image[0] = i; + if ( _bg_image_scaled ) + delete _bg_image; + else + ((Fl_Shared_Image*)_bg_image)->release(); - i = NULL; - - switch ( tw ) - { - case 802: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-802x802.png" ); - break; - case 92: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-92x92.png" ); - break; - case 502: - i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" ); - break; - } - - _bg_image[1] = i; + _bg_image = 0; } - if ( projection() == POLAR ) - i = _bg_image[0]; - else - i = _bg_image[1]; - if ( i ) - i->draw( tx, ty ); + if ( ! _bg_image ) + { + if ( projection() == POLAR ) + { + if ( th <= 92 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-92x92.png" ); + else if ( th <= 502 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" ); + else if ( th <= 802 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-802x802.png" ); + } + else + { + if ( th <= 92 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-92x92.png" ); + else if ( th <= 502 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" ); + else if ( th <= 802 ) + i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-802x802.png" ); + } + + if ( i && i->h() != th ) + { + Fl_Image *scaled = i->copy( th, th ); + + _bg_image = scaled; + _bg_image_scaled = true; + } + else + { + _bg_image = i; + _bg_image_scaled = false; + } + } + + if ( _bg_image ) + _bg_image->draw( tx, ty ); } /** translate angle /a/ into x/y coords and place the result in /X/ and /Y/ */ @@ -392,10 +399,10 @@ Panner::draw ( void ) if ( projection() == POLAR ) { - fl_color( fl_color_average( fl_rgb_color( 127,127,127 ), p->color, 0.50 ) ); - fl_begin_loop(); - fl_circle( tx + tw/2, ty + th/2, tw/2.0f * ( ( p->radius() / range() ))); - fl_end_loop(); + fl_color( fl_color_average( fl_rgb_color( 127,127,127 ), p->color, 0.50 ) ); + fl_begin_loop(); + fl_circle( tx + tw/2, ty + th/2, tw/2.0f * ( ( p->radius() / range() ))); + fl_end_loop(); } } @@ -517,8 +524,12 @@ Panner::handle ( int m ) { if ( POLAR == projection() ) set_polar( drag,X,Y ); - else - set_ortho( drag, X,Y ); + else + { + if ( fabsf( X ) < 0.5f && + fabsf( Y ) < 0.5f ) + set_ortho( drag, X,Y ); + } } else set_polar_radius( drag,X,Y ); diff --git a/mixer/src/Panner.H b/mixer/src/Panner.H index 829b296..6f2daa9 100644 --- a/mixer/src/Panner.H +++ b/mixer/src/Panner.H @@ -33,7 +33,9 @@ class Panner : public Fl_Group Fl_Choice *_range_choice; Fl_Choice *_projection_choice; - Fl_Image *_bg_image[2]; + Fl_Image *_bg_image; + bool _bg_image_scaled; + void draw_grid( int,int,int,int); void draw_the_box( int, int, int, int );