Avoid some unnecessary redrawing.

This commit is contained in:
Jonathan Moore Liles 2008-03-12 00:23:12 -05:00
parent b90a3ac6e5
commit 43fe378e17
2 changed files with 6 additions and 5 deletions

View File

@ -18,7 +18,7 @@
/*******************************************************************************/
/* a VU meter, either horizontal or vertical. Color is a gradient
from color() to selection_color(). box() is used to draw the
from min_color() to max_color(). box() is used to draw the
individual 'lights'. division() controls how many 'lights' there
are. */
@ -53,9 +53,8 @@ void
VU_Meter::draw ( void )
{
// draw_box( FL_FLAT_BOX, x(), y(), w(), h(), color() );
int v = (value() / maximum()) * _divisions;
int pv = (_peak / maximum()) * _divisions;
int v = pos( value() );
int pv = pos( _peak );
int bh = h() / _divisions;
int bw = w() / _divisions;

View File

@ -37,6 +37,8 @@ class VU_Meter : public Fl_Widget
Fl_Color _min_color;
Fl_Color _max_color;
int pos ( float v ) { return ( v / _maximum ) * _divisions; }
protected:
virtual void draw ( void );
@ -52,7 +54,7 @@ public:
void minimum ( float v ) { _minimum = v; redraw(); }
float minimum ( void ) const { return _minimum; }
void value ( float v ) { _value = v; redraw(); }
void value ( float v ) { if ( pos( v ) != pos( _value ) ) redraw(); _value = v; }
float value ( void ) const { return _value; }
void reset ( void ) { _peak = 0.0f; }