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