Mixer: Avoid unecessary redraws (hidden widgets, when mixer strips are added). Also, draw fonts of inactive widgets in dimmed color.

This commit is contained in:
Jonathan Moore Liles 2013-06-24 17:41:15 -07:00
parent fd64b39fa4
commit aedbca82be
5 changed files with 75 additions and 37 deletions

View File

@ -25,6 +25,7 @@ void
Fl_DialX::draw ( void ) Fl_DialX::draw ( void )
{ {
int X,Y,S; int X,Y,S;
int act = active_r();
{ {
int ox, oy, ww, hh, side; int ox, oy, ww, hh, side;
@ -68,17 +69,26 @@ Fl_DialX::draw ( void )
fl_line_style( FL_SOLID, S / 12 ); fl_line_style( FL_SOLID, S / 12 );
/* background arc */ /* 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() ); fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() );
/* foreground arc */ /* foreground arc */
fl_color( selection_color() ); c = selection_color();
fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle );
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 ); fl_line_style( FL_SOLID, 0 );
if ( active_r() ) if ( act )
{ {
int W = OS; int W = OS;
int H = OS; int H = OS;

View File

@ -24,6 +24,8 @@
void void
Fl_SliderX::draw ( int X, int Y, int W, int H) Fl_SliderX::draw ( int X, int Y, int W, int H)
{ {
int act = active_r();
if (damage()&FL_DAMAGE_ALL) draw_box(); if (damage()&FL_DAMAGE_ALL) draw_box();
double val; double val;
@ -70,21 +72,29 @@ Fl_SliderX::draw ( int X, int Y, int W, int H)
fl_push_clip(X, Y, W, H); fl_push_clip(X, Y, W, H);
draw_box(); draw_box();
fl_pop_clip(); fl_pop_clip();
Fl_Color black = active_r() ? FL_BLACK : FL_INACTIVE_COLOR;
} }
//draw_bg(X, Y, W, H); //draw_bg(X, Y, W, H);
fl_line_style( FL_SOLID, hh/6 ); 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() ) if ( horizontal() )
fl_line ( X + S/2, Y + hh/2, X + W - S/2, Y + hh/2 ); fl_line ( X + S/2, Y + hh/2, X + W - S/2, Y + hh/2 );
else else
fl_line ( X + hh/2, Y + S/2, X + hh/2, Y + H - S/2 ); 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() ) if ( horizontal() )
fl_line ( X + S/2, ysl, xsl + S/2, ysl ); 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_line_style( FL_SOLID, 0 );
fl_push_matrix(); if ( act )
if ( horizontal() ) {
fl_translate( xsl + (hh/2), ysl); fl_push_matrix();
else if ( horizontal() )
fl_translate( xsl, ysl + (hh/2) ); fl_translate( xsl + (hh/2), ysl);
else
fl_translate( xsl, ysl + (hh/2) );
fl_color( fl_color_add_alpha( FL_WHITE, 127 )); fl_color( fl_color_add_alpha( FL_WHITE, 127 ));
fl_begin_polygon(); fl_circle(0.0,0.0, hh/3); fl_end_polygon(); fl_begin_polygon(); fl_circle(0.0,0.0, hh/3); fl_end_polygon();
fl_color( FL_WHITE ); fl_color( FL_WHITE );
fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon(); fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon();
fl_pop_matrix(); fl_pop_matrix();
}
draw_label(xsl, ysl, wsl, hsl); draw_label(xsl, ysl, wsl, hsl);

View File

@ -459,7 +459,7 @@ Mixer::load_project_settings ( void )
{ {
reset_project_settings(); reset_project_settings();
if ( Project::open() ) // if ( Project::open() )
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), "options" ); ((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), "options" );
update_menu(); update_menu();
@ -481,6 +481,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
// fl_tooltip_docked = 1; // fl_tooltip_docked = 1;
_rows = 1; _rows = 1;
_strip_height = 0;
box( FL_FLAT_BOX ); box( FL_FLAT_BOX );
labelsize( 96 ); labelsize( 96 );
{ Fl_Group *o = new Fl_Group( X, Y, W, 24 ); { 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 )); Fl_Flowpack *o = mixer_strips = new Fl_Flowpack( X, Y + 24, W, H - ( 18*2 + 24 ));
// label( "Non-Mixer" ); // label( "Non-Mixer" );
align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) ); align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) );
o->flow( false );
o->box( FL_FLAT_BOX ); o->box( FL_FLAT_BOX );
o->type( Fl_Pack::HORIZONTAL ); o->type( Fl_Pack::HORIZONTAL );
o->hspacing( 2 ); o->hspacing( 2 );
@ -731,6 +733,8 @@ Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before )
{ {
// mixer_strips->remove( ms ); // mixer_strips->remove( ms );
mixer_strips->insert( *ms, before ); mixer_strips->insert( *ms, before );
// scroll->redraw();
} }
void void
Mixer::insert ( Mixer_Strip *ms, int i ) Mixer::insert ( Mixer_Strip *ms, int i )
@ -747,6 +751,9 @@ Mixer::move_left ( Mixer_Strip *ms )
if ( i > 0 ) if ( i > 0 )
insert( ms, i - 1 ); insert( ms, i - 1 );
/* FIXME: do better */
mixer_strips->redraw();
} }
void void
@ -756,6 +763,9 @@ Mixer::move_right ( Mixer_Strip *ms )
if ( i < mixer_strips->children() - 1 ) if ( i < mixer_strips->children() - 1 )
insert( ms, i + 2 ); insert( ms, i + 2 );
/* FIXME: do better */
mixer_strips->redraw();
} }
void Mixer::remove ( Mixer_Strip *ms ) void Mixer::remove ( Mixer_Strip *ms )
@ -793,27 +803,29 @@ Mixer::rows ( int ideal_rows )
int actual_rows = 1; 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)); sh = ( scroll->h() / (float)actual_rows ) - ( mixer_strips->vspacing() * ( actual_rows - 2 ));
mixer_strips->flow( true ); 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;
} }
else else
actual_rows = 1; actual_rows = 1;
if ( 1 == actual_rows ) if ( 1 == actual_rows )
{ {
sh = (scroll->h() - 18); sh = (scroll->h() - 18);
mixer_strips->flow(false); mixer_strips->flow( false );
actual_rows = 1;
} }
int tw = 0; int tw = 0;
@ -1049,8 +1061,6 @@ Mixer::command_load ( const char *path, const char *display_name )
if ( display_name ) if ( display_name )
Project::name( display_name ); Project::name( display_name );
load_project_settings();
load_translations(); load_translations();
update_menu(); update_menu();

View File

@ -745,6 +745,8 @@ Mixer_Strip::handle ( int m )
if ( dragging == this && ! Fl::event_is_click() ) if ( dragging == this && ! Fl::event_is_click() )
{ {
mixer->insert( this, mixer->event_inside() ); mixer->insert( this, mixer->event_inside() );
/* FIXME: do better! */
mixer->redraw();
dragging = NULL; dragging = NULL;
return 1; return 1;
} }

View File

@ -616,6 +616,9 @@ Module::draw_box ( int tx, int ty, int tw, int th )
c = active() && ! bypass() ? c : FL_GRAY; c = active() && ! bypass() ? c : FL_GRAY;
if ( ! active_r() )
c = fl_inactive( c );
int spacing = w() / instances(); int spacing = w() / instances();
for ( int i = instances(); i--; ) for ( int i = instances(); i--; )
{ {