Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / libs / plasma / animator.cpp
blob85a6c3ac81a155621b8dc8f2b07693528f040bf1
1 /*
2 * Copyright 2007 Aaron Seigo <aseigo@kde.org>
3 * 2007 Alexis Ménard <darktears31@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "animator.h"
23 #include <QPainter>
24 #include <QGraphicsItem>
26 namespace Plasma
29 Animator::Animator(QObject *parent)
30 : QObject(parent),
31 d(0)
35 Animator::~Animator()
39 int Animator::framesPerSecond(Plasma::Phase::Animation animation) const
41 Q_UNUSED(animation)
42 return 0;
45 int Animator::framesPerSecond(Plasma::Phase::Movement movement) const
47 Q_UNUSED(movement)
48 return 20;
51 int Animator::framesPerSecond(Plasma::Phase::ElementAnimation animation) const
53 Q_UNUSED(animation)
54 return 0;
57 int Animator::duration(Plasma::Phase::Animation) const
59 return 200;
62 int Animator::duration(Plasma::Phase::Movement movement) const
64 switch (movement) {
65 case Phase::FastSlideIn:
66 case Phase::FastSlideOut:
67 return 100;
68 break;
69 default:
70 break;
73 return 270;
76 int Animator::duration(Plasma::Phase::ElementAnimation) const
78 return 333;
81 Phase::CurveShape Animator::curve(Plasma::Phase::Animation) const
83 return Phase::EaseInOutCurve;
86 Phase::CurveShape Animator::curve(Plasma::Phase::Movement) const
88 return Phase::EaseInOutCurve;
91 Phase::CurveShape Animator::curve(Plasma::Phase::ElementAnimation) const
93 return Phase::EaseInOutCurve;
96 QPixmap Animator::elementAppear(qreal frame, const QPixmap& pixmap)
98 Q_UNUSED(frame)
99 return pixmap;
102 QPixmap Animator::elementDisappear(qreal frame, const QPixmap& pixmap)
104 Q_UNUSED(frame)
105 QPixmap pix(pixmap.size());
106 pix.fill(Qt::transparent);
108 return pix;
111 void Animator::appear(qreal frame, QGraphicsItem* item)
113 Q_UNUSED(frame)
114 Q_UNUSED(item)
117 void Animator::disappear(qreal frame, QGraphicsItem* item)
119 Q_UNUSED(frame)
120 Q_UNUSED(item)
123 void Animator::activate(qreal frame, QGraphicsItem* item)
125 Q_UNUSED(frame)
126 Q_UNUSED(item)
129 void Animator::slideIn(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
131 double x = start.x() + (destination.x() - start.x()) * progress;
132 double y = start.y() + (destination.y() - start.y()) * progress;
133 item->setPos(x, y);
136 void Animator::slideOut(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
138 //kDebug();
139 double x = start.x() + (destination.x() - start.x()) * progress;
140 double y = start.y() + (destination.y() - start.y()) * progress;
141 item->setPos(x, y);
144 } // Plasma namespace
146 #include "animator.moc"