changed all Ecorexx:Timer code to the new API
SVN revision: 61599
This commit is contained in:
parent
053bedcd17
commit
2de74a1dc2
|
@ -78,13 +78,15 @@ typedef list<Star*> Starfield;
|
|||
typedef list<Star*>::iterator StarfieldIterator;
|
||||
Starfield starfield;
|
||||
|
||||
void advance()
|
||||
bool advance (Ecorexx::Timer &timer)
|
||||
{
|
||||
for (StarfieldIterator it = starfield.begin(); it != starfield.end(); ++it )
|
||||
{
|
||||
Star* star = *it;
|
||||
star->advance( speed, rotation );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main( int argc, const char **argv )
|
||||
|
@ -108,16 +110,18 @@ int main( int argc, const char **argv )
|
|||
// better use CountedPtr or delete it at the end
|
||||
starfield.push_back( new Star( evas ) );
|
||||
}
|
||||
|
||||
sigc::slot <bool, Ecorexx::Timer&> timerSlot = sigc::ptr_fun (&::advance);
|
||||
|
||||
// FIXME: Memory leak, but ok for this example
|
||||
// better use CountedPtr or delete it at the end
|
||||
(new Ecorexx::Timer( 0.05 ) )->timeout.connect( sigc::ptr_fun( ::advance ) );
|
||||
Ecorexx::Timer *timer = Ecorexx::Timer::factory (0.05, timerSlot);
|
||||
|
||||
mw->show();
|
||||
|
||||
/* Enter the application main loop */
|
||||
app->exec();
|
||||
|
||||
timer->destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,12 +56,19 @@ public:
|
|||
balls[i]->show();
|
||||
}
|
||||
|
||||
ecoreTimer = new Ecorexx::Timer( 1.0 / 25 );
|
||||
ecoreTimer->timeout.connect( sigc::mem_fun( this, &TimerApp::timerEvent ) );
|
||||
|
||||
sigc::slot <bool, Ecorexx::Timer&> timerSlot = sigc::mem_fun (*this, &TimerApp::timerEvent);
|
||||
|
||||
ecoreTimer = Ecorexx::Timer::factory (1.0 / 25, timerSlot);
|
||||
|
||||
mw->show();
|
||||
}
|
||||
|
||||
~TimerApp ()
|
||||
{
|
||||
ecoreTimer->destroy ();
|
||||
}
|
||||
|
||||
Evasxx::Image* image, *shadow, *logo;
|
||||
Evasxx::Image* balls[NUMBALLS];
|
||||
double xoffset;
|
||||
|
@ -76,7 +83,7 @@ public:
|
|||
double yaddfactor;
|
||||
Ecorexx::Timer* ecoreTimer;
|
||||
|
||||
void timerEvent()
|
||||
bool timerEvent(Ecorexx::Timer &timer)
|
||||
{
|
||||
|
||||
logo->setColor( Color (255, 255, 255, alpha) );
|
||||
|
@ -100,6 +107,8 @@ public:
|
|||
xaddfactor = -2 + (4.0*rand()/(RAND_MAX));
|
||||
yaddfactor = -2 + (4.0*rand()/(RAND_MAX));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <sigc++/sigc++.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
using namespace Eflxx;
|
||||
using namespace std;
|
||||
|
@ -19,7 +20,7 @@ Starfield starfield;
|
|||
|
||||
int width = 0;
|
||||
|
||||
void advance( )
|
||||
bool advance (Ecorexx::Timer &timer)
|
||||
{
|
||||
for (StarfieldIterator it = starfield.begin(); it != starfield.end(); ++it )
|
||||
{
|
||||
|
@ -29,12 +30,14 @@ void advance( )
|
|||
Rect g = line->getGeometry();
|
||||
line->setGeometry( Rect ((g.x()+speed ) % width, g.y(), 1, 0) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main( int argc, const char **argv )
|
||||
{
|
||||
Ecorexx::Application* app = new Ecorexx::Application( argc, argv, "Ecore Stars Test" );
|
||||
Ecorexx::EvasWindowSoftwareX11* mw = new Ecorexx::EvasWindowSoftwareX11( Size (WIDTH, HEIGHT) );
|
||||
auto_ptr <Ecorexx::Application> app (new Ecorexx::Application( argc, argv, "Ecore Stars Test" ));
|
||||
auto_ptr <Ecorexx::EvasWindowSoftwareX11> mw (new Ecorexx::EvasWindowSoftwareX11( Size (WIDTH, HEIGHT) ));
|
||||
Evasxx::Canvas &evas = mw->getCanvas();
|
||||
|
||||
Rect bg = evas.getGeometry();
|
||||
|
@ -57,15 +60,18 @@ int main( int argc, const char **argv )
|
|||
starfield.push_back( new Star( line, speed ) );
|
||||
}
|
||||
|
||||
( new Ecorexx::Timer( 0.08 ) )->timeout.connect( sigc::ptr_fun( ::advance ) );
|
||||
sigc::slot <bool, Ecorexx::Timer&> timerSlot = sigc::ptr_fun (&::advance);
|
||||
|
||||
Ecorexx::Timer *timer = Ecorexx::Timer::factory (0.08, timerSlot);
|
||||
|
||||
// ( new Ecorexx::Timer( 0.08 ) )->timeout.connect( sigc::ptr_fun( ::advance ) );
|
||||
|
||||
mw->show ();
|
||||
|
||||
/* Enter the application main loop */
|
||||
app->exec();
|
||||
|
||||
/* Delete the application */
|
||||
delete app;
|
||||
timer->destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,9 @@ public:
|
|||
balls[i]->show();
|
||||
}
|
||||
|
||||
ecoreTimer = new Ecorexx::Timer( 1.0 / 25 );
|
||||
ecoreTimer->timeout.connect( sigc::mem_fun( this, &TimerApp::timerEvent ) );
|
||||
sigc::slot <bool, Ecorexx::Timer&> timerSlot = sigc::mem_fun (*this, &TimerApp::timerEvent);
|
||||
|
||||
ecoreTimer = Ecorexx::Timer::factory (1.0 / 25, timerSlot);
|
||||
|
||||
mw->show();
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
double yaddfactor;
|
||||
Ecorexx::Timer* ecoreTimer;
|
||||
|
||||
void timerEvent()
|
||||
bool timerEvent (Ecorexx::Timer &timer)
|
||||
{
|
||||
|
||||
logo->setColor( Color (255, 255, 255, alpha) );
|
||||
|
@ -100,11 +101,13 @@ public:
|
|||
xaddfactor = -2 + (4.0*rand()/(RAND_MAX));
|
||||
yaddfactor = -2 + (4.0*rand()/(RAND_MAX));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
~TimerApp ()
|
||||
{
|
||||
delete ecoreTimer;
|
||||
ecoreTimer->destroy ();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ typedef struct _MyProgressbar
|
|||
|
||||
static MyProgressbar _test_progressbar;
|
||||
|
||||
static void _my_progressbar_value_set ()
|
||||
bool _my_progressbar_value_set (Ecorexx::Timer &timer)
|
||||
{
|
||||
double progress;
|
||||
|
||||
|
@ -40,9 +40,10 @@ static void _my_progressbar_value_set ()
|
|||
if (progress > 1.0)
|
||||
{
|
||||
_test_progressbar.run = false;
|
||||
//timer->del ();
|
||||
// FIXME: new design offern no timers pointer!
|
||||
return false; // don't run again and delete timer
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void my_progressbar_test_start (Evasxx::Object &obj, void *event_info)
|
||||
|
@ -53,8 +54,10 @@ static void my_progressbar_test_start (Evasxx::Object &obj, void *event_info)
|
|||
|
||||
if (!_test_progressbar.run)
|
||||
{
|
||||
_test_progressbar.timer = new Ecorexx::Timer (0.1);
|
||||
_test_progressbar.timer->timeout.connect (sigc::ptr_fun (&_my_progressbar_value_set));
|
||||
sigc::slot <bool, Ecorexx::Timer&> timerSlot = sigc::ptr_fun (&_my_progressbar_value_set);
|
||||
|
||||
_test_progressbar.timer = Ecorexx::Timer::factory (0.1, timerSlot);
|
||||
|
||||
_test_progressbar.run = true;
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +70,7 @@ static void _test_stop ()
|
|||
|
||||
if (_test_progressbar.run)
|
||||
{
|
||||
_test_progressbar.timer->del ();
|
||||
_test_progressbar.timer->destroy ();
|
||||
_test_progressbar.run = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue