From bc78302220266b80ccdad28b6961cc7ade6e27c0 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 24 Jun 2013 17:17:15 -0700 Subject: [PATCH] Mixer: Avoid unecessary redraws (hidden widgets, when mixer strips are added). Also, draw fonts of inactive widgets in dimmed color. Conflicts: mixer/src/Mixer.C --- FL/Fl_Sometimes_Input.H | 6 +++- mixer/src/Controller_Module.C | 3 +- mixer/src/DPM.H | 2 +- mixer/src/Meter.H | 3 +- mixer/src/Mixer.C | 65 ++++++++++++++++++----------------- mixer/src/Mixer.H | 1 + mixer/src/Mixer_Strip.C | 11 ++---- mixer/src/Mixer_Strip.H | 2 +- mixer/src/Module.C | 4 ++- 9 files changed, 52 insertions(+), 45 deletions(-) diff --git a/FL/Fl_Sometimes_Input.H b/FL/Fl_Sometimes_Input.H index bb58c5e..ef5be75 100644 --- a/FL/Fl_Sometimes_Input.H +++ b/FL/Fl_Sometimes_Input.H @@ -52,7 +52,11 @@ public: else { fl_draw_box( up_box(), x(), y(), w(), h(), color() ); - fl_color( fl_contrast( textcolor(), color() ) ); + + Fl_Color c = fl_contrast( textcolor(), color() ); + + fl_color( active_r() ? c : fl_inactive( c ) ); + fl_font( textfont(), textsize() ); fl_draw( value(), x(), y(), w(), h(), (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_CLIP) ); } diff --git a/mixer/src/Controller_Module.C b/mixer/src/Controller_Module.C index cfb7418..f3b79a4 100644 --- a/mixer/src/Controller_Module.C +++ b/mixer/src/Controller_Module.C @@ -566,7 +566,8 @@ Controller_Module::handle_control_changed ( Port *p ) pan->point( 0 )->azimuth( control_output[0].control_value() ); pan->point( 0 )->elevation( control_output[1].control_value() ); - pan->redraw(); + if ( visible_r() ) + pan->redraw(); } else { diff --git a/mixer/src/DPM.H b/mixer/src/DPM.H index c061140..fa94e0b 100644 --- a/mixer/src/DPM.H +++ b/mixer/src/DPM.H @@ -84,7 +84,7 @@ public: void pixels_per_segment ( int v ) { _pixels_per_segment = v; } float dim ( void ) const { return _dim; } - void dim ( float v ) { _dim = v; redraw(); } + void dim ( float v ) { _dim = v; if ( visible_r() ) redraw(); } static void diff --git a/mixer/src/Meter.H b/mixer/src/Meter.H index c94ca34..180f927 100644 --- a/mixer/src/Meter.H +++ b/mixer/src/Meter.H @@ -83,7 +83,8 @@ public: virtual void value ( float v ) { - damage( FL_DAMAGE_USER1 ); + if ( visible_r() ) + damage( FL_DAMAGE_USER1 ); _value = v; diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index 6ef59ca..bb57f0b 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -422,7 +422,7 @@ Mixer::load_project_settings ( void ) { reset_project_settings(); - if ( Project::open() ) +// if ( Project::open() ) ((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), "options" ); update_menu(); @@ -491,9 +491,10 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : Fl_Flowpack *o = mixer_strips = new Fl_Flowpack( X, Y + 24, W, H - 18 - 24 ); // label( "Non-Mixer" ); align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) ); + o->flow( false ); o->box( FL_FLAT_BOX ); o->type( Fl_Pack::HORIZONTAL ); - o->hspacing( 2 ); + o->hspacing( 2 ); o->vspacing( 2 ); o->end(); Fl_Group::current()->resizable( o ); @@ -563,13 +564,12 @@ void Mixer::add ( Mixer_Strip *ms ) mixer_strips->add( ms ); - ms->take_focus(); - - rows( _rows ); - -// scroll->redraw(); + ms->size( ms->w(), _strip_height ); + ms->redraw(); + ms->take_focus(); } + void Mixer::quit ( void ) { @@ -582,10 +582,10 @@ Mixer::quit ( void ) void Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before ) { - mixer_strips->remove( ms ); +// mixer_strips->remove( ms ); mixer_strips->insert( *ms, before ); - scroll->redraw(); +// scroll->redraw(); } void Mixer::insert ( Mixer_Strip *ms, int i ) @@ -646,31 +646,26 @@ Mixer::rows ( int ideal_rows ) { int sh; - int actual_rows = 1; + int actual_rows; - if ( ideal_rows > 1 ) + /* calculate how many rows will actually fit */ + int can_fit = scroll->h() / ( Mixer_Strip::min_h() ); + + actual_rows = can_fit > 0 ? can_fit : 1; + + if ( actual_rows > ideal_rows ) + actual_rows = ideal_rows; + + /* calculate strip height */ + if ( actual_rows > 1 ) { - sh = (scroll->h() / ideal_rows ) - (mixer_strips->vspacing() * (ideal_rows - 1)); - mixer_strips->flow( true ); - - if ( sh < Mixer_Strip::min_h() ) - { - int can_fit = ( scroll->h() - 18 ) / Mixer_Strip::min_h(); - - actual_rows = can_fit > 0 ? can_fit : 1; - } - else - actual_rows = ideal_rows; + sh = ( scroll->h() / (float)actual_rows ) - ( mixer_strips->vspacing() * ( actual_rows - 2 )); + mixer_strips->flow(true); } else - actual_rows = 1; - - if ( 1 == actual_rows ) { - sh = (scroll->h() - 18); - mixer_strips->flow( false ); - - actual_rows = 1; + sh = (scroll->h() - 18); + mixer_strips->flow(false); } int tw = 0; @@ -690,8 +685,12 @@ Mixer::rows ( int ideal_rows ) mixer_strips->size( tw, mixer_strips->h() ); _rows = ideal_rows; - - scroll->redraw(); + + if ( _strip_height != sh ); + { + scroll->redraw(); + _strip_height = sh; + } } /** retrun a pointer to the track named /name/, or NULL if no track is named /name/ */ @@ -851,6 +850,10 @@ Mixer::command_load ( const char *path, const char *display_name ) { mixer->deactivate(); + chdir( path ); + + load_project_settings(); + if ( Project::open( path ) ) { // fl_alert( "Error opening project specified on commandline: %s", Project::errstr( err ) ); diff --git a/mixer/src/Mixer.H b/mixer/src/Mixer.H index 9e06374..e111fbb 100644 --- a/mixer/src/Mixer.H +++ b/mixer/src/Mixer.H @@ -47,6 +47,7 @@ private: float _update_interval; int _rows; + int _strip_height; Fl_Color system_colors[3]; diff --git a/mixer/src/Mixer_Strip.C b/mixer/src/Mixer_Strip.C index 278692a..1128a6c 100644 --- a/mixer/src/Mixer_Strip.C +++ b/mixer/src/Mixer_Strip.C @@ -518,7 +518,7 @@ Mixer_Strip::init ( ) size( 96, h() ); - redraw(); +// redraw(); // _chain->configure_ports(); } @@ -526,15 +526,10 @@ Mixer_Strip::init ( ) void Mixer_Strip::draw ( void ) { - if ( !fl_not_clipped( x(), y(), w(), h() ) ) - return; - /* don't bother drawing anything else, all we're doing is drawing the focus. */ - if ( damage() & FL_DAMAGE_ALL || - damage() & FL_DAMAGE_CHILD ) + if ( damage() & ~FL_DAMAGE_USER1 ) Fl_Group::draw(); - - + fl_color( Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK ); fl_rect( x(), y(), w(), h() ); } diff --git a/mixer/src/Mixer_Strip.H b/mixer/src/Mixer_Strip.H index c040c4b..704cb20 100644 --- a/mixer/src/Mixer_Strip.H +++ b/mixer/src/Mixer_Strip.H @@ -53,7 +53,7 @@ class Mixer_Strip : public Fl_Group, public Loggable { public: - static int min_h ( void ) { return 336; } + static int min_h ( void ) { return 333; } Mixer_Strip( const char *strip_name ); Mixer_Strip(); /* for log create */ diff --git a/mixer/src/Module.C b/mixer/src/Module.C index 24ceac4..02545e7 100644 --- a/mixer/src/Module.C +++ b/mixer/src/Module.C @@ -577,7 +577,9 @@ Module::draw_label ( int tx, int ty, int tw, int th ) const char *lp = label(); - fl_color( fl_contrast( FL_FOREGROUND_COLOR, bypass() ? FL_BLACK : color() ) ); + Fl_Color c = fl_contrast( FL_FOREGROUND_COLOR, bypass() ? FL_BLACK : color() ); + + fl_color( active_r() ? c : fl_inactive(c) ); fl_font( FL_HELVETICA, 12 );