2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #include "mainanimation.h"
13 using namespace boost
;
15 MainAnimation::MainAnimation(double speed
)
16 : AnimationGroup(true)
21 connect(&m_timer
, SIGNAL(timeout()), this, SLOT(tick()));
24 void MainAnimation::addAnimation(const shared_ptr
<Animation
>& a
) {
25 if (!m_timer
.isActive()) {
26 m_timer
.start(m_delay
);
30 AnimationGroup::addPostAnimation(a
);
34 void MainAnimation::stop() {
35 AnimationGroup::stop();
38 void MainAnimation::tick() {
39 animationAdvance(static_cast<int>(m_time
.elapsed() * m_speed
) + m_translate
);
41 // no more animations, stop the clock!
46 void MainAnimation::setSpeed(double speed
) {
47 int e
= m_time
.elapsed();
48 m_translate
= int((e
*m_speed
+ m_translate
) - e
*speed
);
52 void MainAnimation::setDelay(int delay
) {
53 m_timer
.setInterval(m_delay
= delay
);
56 MainAnimation
& MainAnimation::global() {
57 static MainAnimation instance
;