From 34200e2c52c6d3cd22722c6328ee4b9b092d4794 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 18 Jan 2010 23:46:23 -0600 Subject: [PATCH] Make the interval of Fl_Blinker configurable. --- FL/Fl_Blinker.H | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/FL/Fl_Blinker.H b/FL/Fl_Blinker.H index 92167f1..ff3ac84 100644 --- a/FL/Fl_Blinker.H +++ b/FL/Fl_Blinker.H @@ -20,12 +20,10 @@ #include #include -const float BLINK_FREQ = 0.5f; - class Fl_Blinker : public Fl_Button { - bool _on; + float _blink_interval; static void update_cb ( void *v ) @@ -36,7 +34,7 @@ class Fl_Blinker : public Fl_Button void update_cb ( void ) { - Fl::repeat_timeout( BLINK_FREQ, update_cb, this ); + Fl::repeat_timeout( _blink_interval, update_cb, this ); _on = ! _on; @@ -45,11 +43,20 @@ class Fl_Blinker : public Fl_Button 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_Button( X, Y, W, H, L ) { _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 ); } @@ -60,6 +67,14 @@ public: 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 draw ( void ) {