Browse Source

Avoid some unnecessary redrawing.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
43fe378e17
2 changed files with 6 additions and 5 deletions
  1. +3
    -4
      VU_Meter.C
  2. +3
    -1
      VU_Meter.H

+ 3
- 4
VU_Meter.C 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;


+ 3
- 1
VU_Meter.H 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; }


Loading…
Cancel
Save