2007-06-08 07:24:19 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
2007-11-22 08:16:34 +01:00
|
|
|
* 2007 Alexis Ménard <darktears31@gmail.com>
|
2007-06-08 07:24:19 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2007-06-08 07:24:19 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-04-25 05:17:00 +02:00
|
|
|
#include "animationdriver.h"
|
2007-06-08 07:24:19 +02:00
|
|
|
|
2007-06-19 23:53:19 +02:00
|
|
|
#include <QPainter>
|
2007-07-06 18:26:48 +02:00
|
|
|
#include <QGraphicsItem>
|
2007-06-19 23:53:19 +02:00
|
|
|
|
2007-06-08 07:24:19 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
AnimationDriver::AnimationDriver(QObject *parent)
|
2007-07-06 12:28:28 +02:00
|
|
|
: QObject(parent),
|
|
|
|
d(0)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
AnimationDriver::~AnimationDriver()
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::animationFPS(Plasma::Animator::Animation animation) const
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2007-06-19 23:53:19 +02:00
|
|
|
Q_UNUSED(animation)
|
2007-06-08 07:24:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::movementAnimationFPS(Plasma::Animator::Movement movement) const
|
2007-07-04 11:36:50 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(movement)
|
2007-11-04 18:07:57 +01:00
|
|
|
return 20;
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::elementAnimationFPS(Plasma::Animator::Animation animation) const
|
2007-06-19 23:53:19 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(animation)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::animationDuration(Plasma::Animator::Animation) const
|
2008-01-23 00:37:48 +01:00
|
|
|
{
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::movementAnimationDuration(Plasma::Animator::Movement movement) const
|
2008-01-23 00:37:48 +01:00
|
|
|
{
|
|
|
|
switch (movement) {
|
2008-04-25 05:11:59 +02:00
|
|
|
case Animator::FastSlideInMovement:
|
|
|
|
case Animator::FastSlideOutMovement:
|
2008-01-23 00:37:48 +01:00
|
|
|
return 100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 270;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int AnimationDriver::elementAnimationDuration(Plasma::Animator::Animation) const
|
2008-01-23 00:37:48 +01:00
|
|
|
{
|
|
|
|
return 333;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape AnimationDriver::animationCurve(Plasma::Animator::Animation) const
|
2007-06-25 07:57:47 +02:00
|
|
|
{
|
2008-04-25 05:11:59 +02:00
|
|
|
return Animator::EaseInOutCurve;
|
2007-06-25 07:57:47 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape AnimationDriver::movementAnimationCurve(Plasma::Animator::Movement) const
|
2007-07-04 11:36:50 +02:00
|
|
|
{
|
2008-04-25 05:11:59 +02:00
|
|
|
return Animator::EaseInOutCurve;
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape AnimationDriver::elementAnimationCurve(Plasma::Animator::Animation) const
|
2007-06-25 07:57:47 +02:00
|
|
|
{
|
2008-04-25 05:11:59 +02:00
|
|
|
return Animator::EaseInOutCurve;
|
2007-06-25 07:57:47 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
QPixmap AnimationDriver::elementAppear(qreal progress, const QPixmap& pixmap)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2008-04-24 19:57:56 +02:00
|
|
|
Q_UNUSED(progress)
|
2007-06-19 23:53:19 +02:00
|
|
|
return pixmap;
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap& pixmap)
|
2007-06-19 23:53:19 +02:00
|
|
|
{
|
2008-04-24 19:57:56 +02:00
|
|
|
Q_UNUSED(progress)
|
2007-06-19 23:53:19 +02:00
|
|
|
QPixmap pix(pixmap.size());
|
2007-06-21 01:33:26 +02:00
|
|
|
pix.fill(Qt::transparent);
|
2007-06-19 23:53:19 +02:00
|
|
|
|
|
|
|
return pix;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void AnimationDriver::itemAppear(qreal frame, QGraphicsItem* item)
|
2007-06-10 09:09:07 +02:00
|
|
|
{
|
2007-06-19 23:53:19 +02:00
|
|
|
Q_UNUSED(frame)
|
2007-06-10 09:09:07 +02:00
|
|
|
Q_UNUSED(item)
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void AnimationDriver::itemDisappear(qreal frame, QGraphicsItem* item)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(frame)
|
|
|
|
Q_UNUSED(item)
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void AnimationDriver::itemActivated(qreal frame, QGraphicsItem* item)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(frame)
|
|
|
|
Q_UNUSED(item)
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void AnimationDriver::itemSlideIn(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
|
2007-07-04 11:36:50 +02:00
|
|
|
{
|
2007-11-22 08:16:34 +01:00
|
|
|
double x = start.x() + (destination.x() - start.x()) * progress;
|
|
|
|
double y = start.y() + (destination.y() - start.y()) * progress;
|
2007-10-11 22:19:51 +02:00
|
|
|
item->setPos(x, y);
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void AnimationDriver::itemSlideOut(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
|
2007-07-04 11:36:50 +02:00
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug();
|
2007-11-22 08:16:34 +01:00
|
|
|
double x = start.x() + (destination.x() - start.x()) * progress;
|
|
|
|
double y = start.y() + (destination.y() - start.y()) * progress;
|
2007-10-11 22:19:51 +02:00
|
|
|
item->setPos(x, y);
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 09:23:09 +02:00
|
|
|
} // Plasma namespace
|
2007-06-08 07:24:19 +02:00
|
|
|
|
2008-04-25 05:17:00 +02:00
|
|
|
#include "animationdriver.moc"
|