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 )
{
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;

View File

@ -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,6 +103,8 @@ Fl_SliderX::draw ( int X, int Y, int W, int H)
fl_line_style( FL_SOLID, 0 );
if ( act )
{
fl_push_matrix();
if ( horizontal() )
fl_translate( xsl + (hh/2), ysl);
@ -105,6 +117,7 @@ Fl_SliderX::draw ( int X, int Y, int W, int H)
fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon();
fl_pop_matrix();
}
draw_label(xsl, ysl, wsl, hsl);

View File

@ -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,19 +803,19 @@ Mixer::rows ( int ideal_rows )
int actual_rows = 1;
if ( ideal_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();
/* calculate how many rows will actually fit */
int can_fit = scroll->h() / ( Mixer_Strip::min_h() );
actual_rows = can_fit > 0 ? can_fit : 1;
}
else
if ( actual_rows > ideal_rows )
actual_rows = ideal_rows;
/* calculate strip height */
if ( actual_rows > 1 )
{
sh = ( scroll->h() / (float)actual_rows ) - ( mixer_strips->vspacing() * ( actual_rows - 2 ));
mixer_strips->flow(true);
}
else
actual_rows = 1;
@ -814,6 +824,8 @@ Mixer::rows ( int ideal_rows )
{
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();

View File

@ -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;
}

View File

@ -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--; )
{