From aedbca82befd7f10fcf925550be4c7dc922b05ed Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 24 Jun 2013 17:41:15 -0700 Subject: [PATCH] Mixer: Avoid unecessary redraws (hidden widgets, when mixer strips are added). Also, draw fonts of inactive widgets in dimmed color. --- FL/Fl_DialX.C | 18 +++++++++++++---- FL/Fl_SliderX.C | 45 ++++++++++++++++++++++++++--------------- mixer/src/Mixer.C | 44 ++++++++++++++++++++++++---------------- mixer/src/Mixer_Strip.C | 2 ++ mixer/src/Module.C | 3 +++ 5 files changed, 75 insertions(+), 37 deletions(-) diff --git a/FL/Fl_DialX.C b/FL/Fl_DialX.C index a925d53..e9b96df 100644 --- a/FL/Fl_DialX.C +++ b/FL/Fl_DialX.C @@ -25,6 +25,7 @@ void Fl_DialX::draw ( void ) { int X,Y,S; + int act = active_r(); { int ox, oy, ww, hh, side; @@ -68,17 +69,26 @@ Fl_DialX::draw ( void ) fl_line_style( FL_SOLID, S / 12 ); /* background arc */ - fl_color( fl_darker( color() ) ); + + Fl_Color c = fl_darker( color() ); + if ( !act ) + c = fl_inactive( c ); + + fl_color( c ); fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() ); /* foreground arc */ - fl_color( selection_color() ); - fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle ); + c = selection_color(); + if ( !act ) + c = fl_inactive( c ); + + fl_color(c); + fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle ); fl_line_style( FL_SOLID, 0 ); - if ( active_r() ) + if ( act ) { int W = OS; int H = OS; diff --git a/FL/Fl_SliderX.C b/FL/Fl_SliderX.C index 2c0c5e6..54dc6e4 100644 --- a/FL/Fl_SliderX.C +++ b/FL/Fl_SliderX.C @@ -24,6 +24,8 @@ void Fl_SliderX::draw ( int X, int Y, int W, int H) { + int act = active_r(); + if (damage()&FL_DAMAGE_ALL) draw_box(); double val; @@ -70,21 +72,29 @@ Fl_SliderX::draw ( int X, int Y, int W, int H) fl_push_clip(X, Y, W, H); draw_box(); fl_pop_clip(); - - Fl_Color black = active_r() ? FL_BLACK : FL_INACTIVE_COLOR; } //draw_bg(X, Y, W, H); fl_line_style( FL_SOLID, hh/6 ); - fl_color( fl_darker(color()) ); + Fl_Color c = fl_darker(color()); + + if ( !act ) + c = fl_inactive(c); + + fl_color(c); if ( horizontal() ) fl_line ( X + S/2, Y + hh/2, X + W - S/2, Y + hh/2 ); else fl_line ( X + hh/2, Y + S/2, X + hh/2, Y + H - S/2 ); - fl_color( selection_color() ); + c = selection_color(); + + if ( !act ) + c = fl_inactive(c); + + fl_color( c ); if ( horizontal() ) fl_line ( X + S/2, ysl, xsl + S/2, ysl ); @@ -93,18 +103,21 @@ Fl_SliderX::draw ( int X, int Y, int W, int H) fl_line_style( FL_SOLID, 0 ); - fl_push_matrix(); - if ( horizontal() ) - fl_translate( xsl + (hh/2), ysl); - else - fl_translate( xsl, ysl + (hh/2) ); - - fl_color( fl_color_add_alpha( FL_WHITE, 127 )); - fl_begin_polygon(); fl_circle(0.0,0.0, hh/3); fl_end_polygon(); - fl_color( FL_WHITE ); - fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon(); - - fl_pop_matrix(); + if ( act ) + { + fl_push_matrix(); + if ( horizontal() ) + fl_translate( xsl + (hh/2), ysl); + else + fl_translate( xsl, ysl + (hh/2) ); + + fl_color( fl_color_add_alpha( FL_WHITE, 127 )); + fl_begin_polygon(); fl_circle(0.0,0.0, hh/3); fl_end_polygon(); + fl_color( FL_WHITE ); + fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon(); + + fl_pop_matrix(); + } draw_label(xsl, ysl, wsl, hsl); diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index 5577b34..456d2bc 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -459,7 +459,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(); @@ -481,6 +481,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : // fl_tooltip_docked = 1; _rows = 1; + _strip_height = 0; box( FL_FLAT_BOX ); labelsize( 96 ); { Fl_Group *o = new Fl_Group( X, Y, W, 24 ); @@ -540,6 +541,7 @@ 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*2 + 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 ); @@ -731,6 +733,8 @@ Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before ) { // mixer_strips->remove( ms ); mixer_strips->insert( *ms, before ); + +// scroll->redraw(); } void Mixer::insert ( Mixer_Strip *ms, int i ) @@ -747,6 +751,9 @@ Mixer::move_left ( Mixer_Strip *ms ) if ( i > 0 ) insert( ms, i - 1 ); + + /* FIXME: do better */ + mixer_strips->redraw(); } void @@ -756,6 +763,9 @@ Mixer::move_right ( Mixer_Strip *ms ) if ( i < mixer_strips->children() - 1 ) insert( ms, i + 2 ); + + /* FIXME: do better */ + mixer_strips->redraw(); } void Mixer::remove ( Mixer_Strip *ms ) @@ -793,27 +803,29 @@ Mixer::rows ( int ideal_rows ) int actual_rows = 1; - 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); + sh = (scroll->h() - 18); + mixer_strips->flow( false ); + + actual_rows = 1; } int tw = 0; @@ -1049,8 +1061,6 @@ Mixer::command_load ( const char *path, const char *display_name ) if ( display_name ) Project::name( display_name ); - load_project_settings(); - load_translations(); update_menu(); diff --git a/mixer/src/Mixer_Strip.C b/mixer/src/Mixer_Strip.C index 4d46158..7a78f95 100644 --- a/mixer/src/Mixer_Strip.C +++ b/mixer/src/Mixer_Strip.C @@ -745,6 +745,8 @@ Mixer_Strip::handle ( int m ) if ( dragging == this && ! Fl::event_is_click() ) { mixer->insert( this, mixer->event_inside() ); + /* FIXME: do better! */ + mixer->redraw(); dragging = NULL; return 1; } diff --git a/mixer/src/Module.C b/mixer/src/Module.C index f2d6feb..34bcd5b 100644 --- a/mixer/src/Module.C +++ b/mixer/src/Module.C @@ -616,6 +616,9 @@ Module::draw_box ( int tx, int ty, int tw, int th ) c = active() && ! bypass() ? c : FL_GRAY; + if ( ! active_r() ) + c = fl_inactive( c ); + int spacing = w() / instances(); for ( int i = instances(); i--; ) {