FL/Fl_Blink_Button: Fix CPU wasting bug introduced in afd354.

This commit is contained in:
Jonathan Moore Liles 2012-11-16 01:01:53 -08:00
parent 1c7a64e266
commit 173ab99186
1 changed files with 10 additions and 3 deletions

View File

@ -35,10 +35,17 @@ class Fl_Blink_Button : public Fl_Button
((Fl_Blink_Button*)v)->update_cb();
}
float
blink_interval_as_fraction_of_seceond ( void ) const
{
return (float)_blink_interval / 1000;
}
void
update_cb ( void )
{
Fl::repeat_timeout( _blink_interval / 1000, update_cb, this );
Fl::repeat_timeout( blink_interval_as_fraction_of_seceond(), update_cb, this );
_on = ! _on;
@ -92,7 +99,7 @@ public:
if ( value() )
{
Fl::remove_timeout( update_cb, this );
Fl::add_timeout( _blink_interval / 1000, update_cb, this );
Fl::add_timeout( blink_interval_as_fraction_of_seceond(), update_cb, this );
}
}
@ -101,7 +108,7 @@ public:
if ( v )
{
if ( _blinking )
Fl::add_timeout( _blink_interval / 1000, update_cb, this );
Fl::add_timeout( blink_interval_as_fraction_of_seceond(), update_cb, this );
Fl_Button::value( v );
redraw();
}