diff --git a/ecorexx/include/ecorexx/EcoreTimer.h b/ecorexx/include/ecorexx/EcoreTimer.h index 68eda4b..e97e2dc 100644 --- a/ecorexx/include/ecorexx/EcoreTimer.h +++ b/ecorexx/include/ecorexx/EcoreTimer.h @@ -11,21 +11,41 @@ namespace efl { class EcoreTimer { - typedef sigc::signal Signal; - typedef sigc::slot1 Slot; + typedef sigc::signal Signal; + typedef sigc::signal Loop; + typedef sigc::slot1 Slot; public: EcoreTimer( double seconds, bool singleshot = false ); virtual ~EcoreTimer(); - virtual void tick(); - void setInterval( double ); + //virtual void tick(); - static EcoreTimer* singleShot( double seconds, const EcoreTimer::Slot& ); + static EcoreTimer* singleShot( double seconds, const EcoreTimer::Slot& ); // TODO: CountedPtr + + void del (); + + void setInterval (double interval); + + double getInterval (); + + void freeze (); + + void thaw (); + + void delay (double add); + + double getPending (); + static double getPrecision (); + + static void setPrecision (double precision); + + public: /* signals */ EcoreTimer::Signal timeout; - + EcoreTimer::Loop loop; + private: Ecore_Timer* _et; bool _ss; @@ -35,4 +55,4 @@ private: } // end namespace efl -#endif // ECORETIMER_H \ No newline at end of file +#endif // ECORETIMER_H diff --git a/ecorexx/src/EcoreTimer.cpp b/ecorexx/src/EcoreTimer.cpp index 3ba80e6..1b6d52b 100644 --- a/ecorexx/src/EcoreTimer.cpp +++ b/ecorexx/src/EcoreTimer.cpp @@ -14,6 +14,9 @@ EcoreTimer::EcoreTimer( double seconds, bool singleshot ) { Dout( dc::notice, "EcoreTimer::EcoreTimer() - current frequency is " << seconds ); _et = ecore_timer_add( seconds, &EcoreTimer::__dispatcher, this ); + + // TODO: find out why to use this function and the difference between ecore_time_get() and ecore_loop_time_get() + //ecore_timer_loop_add (double in, int (*func) (void *data), const void *data); } EcoreTimer::~EcoreTimer() @@ -28,22 +31,62 @@ EcoreTimer* EcoreTimer::singleShot( double seconds, const EcoreTimer::Slot& slot return ecoretimer; } -void EcoreTimer::setInterval( double seconds ) +void EcoreTimer::del () { - ecore_timer_interval_set( _et, seconds ); + assert (ecore_timer_del (_et)); } -void EcoreTimer::tick() +void EcoreTimer::setInterval (double seconds) +{ + ecore_timer_interval_set (_et, seconds); +} + +double EcoreTimer::getInterval () +{ + return ecore_timer_interval_get (_et); +} + +void EcoreTimer::freeze () +{ + ecore_timer_freeze (_et); +} + +void EcoreTimer::thaw () +{ + ecore_timer_thaw (_et); +} + +void EcoreTimer::delay (double add) +{ + ecore_timer_delay (_et, add); +} + +double EcoreTimer::getPending () +{ + return ecore_timer_pending_get (_et); +} + +double EcoreTimer::getPrecision () +{ + return ecore_timer_precision_get (); +} + +void EcoreTimer::setPrecision (double precision) +{ + ecore_timer_precision_set (precision); +} + +/*void EcoreTimer::tick() { Dout( dc::notice, "EcoreTimer[ " << this << " ]::tick()" ); -} +}*/ int EcoreTimer::__dispatcher( void* data ) { EcoreTimer* object = reinterpret_cast( data ); assert( object ); object->timeout.emit( object ); - object->tick(); + //object->tick(); bool singleshot = object->_ss; if ( singleshot ) delete object; return singleshot? 0:1; diff --git a/edjexx/include/edjexx/EdjeEdit.h b/edjexx/include/edjexx/EdjeEdit.h index 7e35230..0d2d628 100644 --- a/edjexx/include/edjexx/EdjeEdit.h +++ b/edjexx/include/edjexx/EdjeEdit.h @@ -19,6 +19,7 @@ namespace efl { /** * @todo port to EFLxx! + * @todo return error states with Exceptions? * @file * @brief Functions to deal with edje internal object. Don't use in standard * situations. The use of any of the edje_edit_* functions can break your diff --git a/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp b/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp index 658be6f..7eba04f 100644 --- a/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp +++ b/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp @@ -12,12 +12,12 @@ typedef struct Progressbar ElmProgressbar *pb6; ElmProgressbar *pb7; bool run; - Ecore_Timer *timer; // TODO: port to EcoreTimer + EcoreTimer *timer; } Progressbar; static Progressbar _test_progressbar; -static int _my_progressbar_value_set (void *data) +static void _my_progressbar_value_set (EcoreTimer *timer) { double progress; @@ -32,20 +32,16 @@ static int _my_progressbar_value_set (void *data) progress = 0.0; } - _test_progressbar.pb1->setValue (progress); _test_progressbar.pb4->setValue (progress); _test_progressbar.pb3->setValue (progress); _test_progressbar.pb6->setValue (progress); - if (progress < 1.0) + if (progress > 1.0) { - return ECORE_CALLBACK_RENEW; + _test_progressbar.run = false; + timer->del (); } - - _test_progressbar.run = false; - - return ECORE_CALLBACK_CANCEL; } static void my_progressbar_test_start (Evas_Object *obj, void *event_info) @@ -56,7 +52,8 @@ static void my_progressbar_test_start (Evas_Object *obj, void *event_info) if (!_test_progressbar.run) { - _test_progressbar.timer = ecore_timer_add (0.1, _my_progressbar_value_set, NULL); + _test_progressbar.timer = new EcoreTimer (0.1); + _test_progressbar.timer->timeout.connect (sigc::ptr_fun (&_my_progressbar_value_set)); _test_progressbar.run = true; } } @@ -69,7 +66,7 @@ static void my_progressbar_test_stop (Evas_Object *obj, void *event_info) if (_test_progressbar.run) { - ecore_timer_del(_test_progressbar.timer); + _test_progressbar.timer->del (); _test_progressbar.run = false; } }