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
This commit is contained in:
Jonathan Moore Liles 2013-06-24 17:17:15 -07:00
parent 3b8991c54c
commit bc78302220
9 changed files with 52 additions and 45 deletions

View File

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

View File

@ -566,6 +566,7 @@ 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() );
if ( visible_r() )
pan->redraw();
}
else

View File

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

View File

@ -83,6 +83,7 @@ public:
virtual void value ( float v )
{
if ( visible_r() )
damage( FL_DAMAGE_USER1 );
_value = v;

View File

@ -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,6 +491,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 - 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 );
@ -563,13 +564,12 @@ void Mixer::add ( Mixer_Strip *ms )
mixer_strips->add( ms );
ms->size( ms->w(), _strip_height );
ms->redraw();
ms->take_focus();
rows( _rows );
// scroll->redraw();
}
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 )
{
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
actual_rows = ideal_rows;
}
else
actual_rows = 1;
if ( 1 == actual_rows )
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
{
sh = (scroll->h() - 18);
mixer_strips->flow(false);
actual_rows = 1;
}
int tw = 0;
@ -691,7 +686,11 @@ Mixer::rows ( int ideal_rows )
_rows = ideal_rows;
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 ) );

View File

@ -47,6 +47,7 @@ private:
float _update_interval;
int _rows;
int _strip_height;
Fl_Color system_colors[3];

View File

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

View File

@ -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 */

View File

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