1/*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8*/
9
10#include "animator.h"
11#include <kdebug.h>
12
13Animator::Animator()
14{
15 connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
16}
17
18void Animator::add(Animation* a)
19{
20 if (!m_timer.isActive()) {
21 startTimer();
22 }
23 AnimationGroup::add(a);
24}
25
26void Animator::startTimer()
27{
28 m_time.restart();
29 m_timer.start(0);
30 start(0);
31}
32
33void Animator::stopTimer()
34{
35 m_timer.stop();
36 stop();
37}
38
39void Animator::tick()
40{
41 if (AnimationGroup::step(m_time.elapsed())) {
42 stopTimer();
43 }
44}
45
46
47#include "animator.moc"
48
49
50