Mixer: Try harder to avoid drawing meters more than necessary.

This commit is contained in:
Jonathan Moore Liles 2012-03-02 00:16:55 -08:00
parent 32bd29a28b
commit 5fbdd940be
3 changed files with 21 additions and 5 deletions

View File

@ -31,6 +31,8 @@ class DPM : public Meter
int _pixels_per_segment; int _pixels_per_segment;
int _last_drawn_hi_segment; int _last_drawn_hi_segment;
float _value;
int pos ( float v ) int pos ( float v )
{ {
return deflection( v ) * _segments; return deflection( v ) * _segments;
@ -63,7 +65,21 @@ public:
DPM ( int X, int Y, int W, int H, const char *L = 0 ); DPM ( int X, int Y, int W, int H, const char *L = 0 );
// void value ( float v ) { if ( pos( v ) != pos( value() ) ) redraw(); Meter::value( v ) } void value ( float v )
{
if ( _value != v )
{
if ( pos( v ) != pos( _value ) )
Meter::value( v );
}
_value = v;
}
float value ( void ) const
{
return _value;
}
void pixels_per_segment ( int v ) { _pixels_per_segment = v; } void pixels_per_segment ( int v ) { _pixels_per_segment = v; }

View File

@ -81,7 +81,7 @@ public:
virtual ~Meter ( ) { } virtual ~Meter ( ) { }
void value ( float v ) virtual void value ( float v )
{ {
damage( FL_DAMAGE_USER1 ); damage( FL_DAMAGE_USER1 );
@ -91,7 +91,7 @@ public:
_peak = _value; _peak = _value;
} }
float value ( void ) const { return _value; } virtual float value ( void ) const { return _value; }
float peak ( void ) const { return _peak; } float peak ( void ) const { return _peak; }
void reset ( void ) { _peak = -80.0f; redraw(); } void reset ( void ) { _peak = -80.0f; redraw(); }

View File

@ -371,9 +371,9 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
o->add( "_&Options/&Display/&Colors/&Light", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&Light", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&Gray", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&Gray", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Knobs/&Arc", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE ); o->add( "_&Options/&Display/&Knobs/&Arc", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Knobs/&Burnished", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Knobs/&Burnished", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Knobs/&Plastic", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Knobs/&Plastic", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO );
o->add( "&Help/&Manual" ); o->add( "&Help/&Manual" );
o->add( "&Help/&About" ); o->add( "&Help/&About" );