animators

Aaron J. Seigo aseigo at kde.org
Thu Jul 10 18:52:23 CEST 2008


On Thursday 10 July 2008, Toussis Manolis wrote:
> I try to make an animation loop in my applet...
> I figure out to init the custom animator in the init() method of my applet
> and then to add a slot for the customAnimationFinished() in where I try to
> make a new custom animator
>
> some code :
> in init() of my applet:
> m_animID=-1;
>     m_animDuration=1000;
>     connect(Plasma::Animator::self(), SIGNAL (customAnimationFinished(int)
> ) ,this , SLOT( animationFinished(int)));
>     m_animID=Plasma::Animator::self()->customAnimation(10 , m_animDuration,
> 		      Plasma::Animator::EaseInOutCurve,this,"animationUpdate");
>
> in animationUpdate slot:
> void MyPlasma::animationUpdate(qreal progress)
> {
>   kDebug() << "progress:"<< progress<< " id:"<<m_animID;
>   //just check out that animation timer runs ok
> };
>
>
> and on the slot of customAnimationFinished() :
> void MyPlasma::animationFinished(int id)
> {
>   kDebug() << "animation end";
>   if(id!=-1) Plasma::Animator::self()->stopCustomAnimation(id);

if (id == m_animId)

you'll be stopping very custom animation with this, not that it's harmful 
because by the time animationFinished is called the custom animation will 
already be done and therefore stopped. so the stopCustomAnimation call is 
actully not useful at all here.

>   m_animID=Plasma::Animator::self()->customAnimation(10 , m_animDuration,
> 		      Plasma::Animator::EaseInCurve,this,"animationUpdate");
> };

it's probably not starting the time again at this point; the shared timer code 
probably doesn't handle the situation of adding a new entry to th list of 
animations from a call made inside the timer code =)

what is happening here is:

Animator:
shared timer loop
	process your custom anim
		custom anim done, signal that it's done

Your code:
get signal the anim is done
	create a new one

Animator:
		continue processing timers it knows about
	decide whether the timer needs to continue processing

so ... we either fix Animator to support this usage, or you call 
customAnimation from somewhere else.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080710/b44a46c6/attachment.pgp 


More information about the Panel-devel mailing list