diff --git a/VU_Meter.C b/VU_Meter.C index 4cd237b..4fd347d 100644 --- a/VU_Meter.C +++ b/VU_Meter.C @@ -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; diff --git a/VU_Meter.H b/VU_Meter.H index 3caef21..dfdaf85 100644 --- a/VU_Meter.H +++ b/VU_Meter.H @@ -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; }