Browse Source

Make the interval of Fl_Blinker configurable.

tags/non-daw-v1.1.0
Jonathan Moore Liles 15 years ago
parent
commit
34200e2c52
1 changed files with 20 additions and 5 deletions
  1. +20
    -5
      FL/Fl_Blinker.H

+ 20
- 5
FL/Fl_Blinker.H View File

@@ -20,12 +20,10 @@
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
#include <FL/Fl.H> #include <FL/Fl.H>


const float BLINK_FREQ = 0.5f;

class Fl_Blinker : public Fl_Button class Fl_Blinker : public Fl_Button
{ {

bool _on; bool _on;
float _blink_interval;


static void static void
update_cb ( void *v ) update_cb ( void *v )
@@ -36,7 +34,7 @@ class Fl_Blinker : public Fl_Button
void void
update_cb ( void ) update_cb ( void )
{ {
Fl::repeat_timeout( BLINK_FREQ, update_cb, this );
Fl::repeat_timeout( _blink_interval, update_cb, this );


_on = ! _on; _on = ! _on;


@@ -45,11 +43,20 @@ class Fl_Blinker : public Fl_Button


public: public:


static const float SLOW = 0.5f;
static const float MEDIUM = 0.3f;
static const float FAST = 0.1f;
static const float DEFAULT = 0.5f;

Fl_Blinker ( int X, int Y, int W, int H, const char *L ) Fl_Blinker ( int X, int Y, int W, int H, const char *L )
: Fl_Button( X, Y, W, H, L ) : Fl_Button( X, Y, W, H, L )
{ {
_on = false; _on = false;
Fl::add_timeout( BLINK_FREQ, update_cb, this );

_blink_interval = DEFAULT;

Fl::add_timeout( _blink_interval, update_cb, this );



type( FL_TOGGLE_BUTTON ); type( FL_TOGGLE_BUTTON );
} }
@@ -60,6 +67,14 @@ public:
Fl::remove_timeout( update_cb, this ); Fl::remove_timeout( update_cb, this );
} }


void
interval ( float v )
{
_blink_interval = v;
Fl::remove_timeout( update_cb, this );
Fl::add_timeout( _blink_interval, update_cb, this );
}

virtual void virtual void
draw ( void ) draw ( void )
{ {


Loading…
Cancel
Save