completely remove animators and animations files

This commit is contained in:
Marco Martin 2012-09-25 18:45:55 +02:00
parent 1d520ac557
commit 885be389ff
44 changed files with 0 additions and 4103 deletions

View File

@ -209,21 +209,6 @@ set(plasma_LIB_SRCS
# private/themedwidgetinterface.cpp
#
# graphicsview/private/graphicsviewappletprivate.cpp
# animator.cpp
# animations/animation.cpp
# animations/easinganimation.cpp
# animations/fade.cpp
# animations/grow.cpp
# animations/pendulumcurve.cpp
# animations/pixmaptransition.cpp
# animations/pulser.cpp
# animations/rotation.cpp
# animations/rotationstacked.cpp
# animations/slide.cpp
# animations/stackedlayout.cpp
# animations/geometry.cpp
# animations/widgetsnapshot.cpp
# animations/zoom.cpp
#
# private/declarative/declarativenetworkaccessmanagerfactory.cpp
# private/declarative/dataenginebindings.cpp
@ -312,8 +297,6 @@ set(plasma_LIB_INCLUDES
abstractdialogmanager.h
abstractrunner.h
abstracttoolbox.h
animations/animation.h
animator.h
applet.h
configloader.h
containment.h
@ -403,13 +386,8 @@ if(PHONON_FOUND)
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/widgets COMPONENT Devel)
endif(PHONON_FOUND)
install(FILES
animations/animation.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel)
install(FILES
data/servicetypes/plasma-animator.desktop
data/servicetypes/plasma-applet.desktop
data/servicetypes/plasma-applet-popupapplet.desktop
data/servicetypes/plasma-containment.desktop

View File

@ -1,93 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "animation.h"
#include "private/animationprivate_p.h"
#include <QMapIterator>
#include <QObject>
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
#include <QDebug>
#include <kdebug.h>
#include <kglobalsettings.h>
namespace Plasma
{
AnimationPrivate::AnimationPrivate()
: easingCurve(QEasingCurve::Linear),
duration(250)
{
}
Animation::Animation(QObject* parent)
: QAbstractAnimation(parent),
d(new AnimationPrivate)
{
}
Animation::~Animation()
{
delete d;
}
int Animation::duration() const
{
return d->duration;
}
void Animation::setDuration(int duration)
{
d->duration = qMax(0, duration);
}
void Animation::setTargetWidget(QGraphicsWidget* widget)
{
d->animObject = widget;
if (parent() == 0) {
setParent(widget);
}
}
QGraphicsWidget* Animation::targetWidget() const
{
return d->animObject.data();
}
void Animation::setEasingCurve(const QEasingCurve &curve)
{
d->easingCurve = curve;
}
QEasingCurve Animation::easingCurve() const
{
return d->easingCurve;
}
void Animation::updateCurrentTime(int currentTime)
{
Q_UNUSED(currentTime)
}
} //namespace Plasma
#include "moc_animation.cpp"

View File

@ -1,153 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the abstract base class for all singular
* animations.
*/
#ifndef PLASMA_ANIMATION_H
#define PLASMA_ANIMATION_H
#include <QGraphicsWidget>
#include <QtCore/QObject>
#include <QtCore/QPropertyAnimation>
#include <QtCore/QAbstractAnimation>
#include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h>
#include <plasma/plasma.h>
namespace Plasma
{
class AnimationPrivate;
/**
* @brief Abstract representation of a single animation.
* @since 4.4
*/
class PLASMA_EXPORT Animation : public QAbstractAnimation
{
Q_OBJECT
Q_ENUMS(Reference)
Q_ENUMS(MovementDirection)
Q_PROPERTY(int duration READ duration WRITE setDuration)
Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
Q_PROPERTY(QGraphicsWidget *targetWidget READ targetWidget WRITE setTargetWidget)
public:
/**
* Get the animation duration. It can be set using the property duration.
* @return duration in ms.
*/
int duration() const;
/**
* Animation movement reference (used by \ref RotationAnimation).
*/
enum ReferenceFlag {
Center = 0,
Up = 0x1,
Down = 0x2,
Left = 0x4,
Right = 0x8
};
Q_DECLARE_FLAGS(Reference, ReferenceFlag)
/**
* Animation movement direction.
*/
enum MovementDirectionFlag {
MoveAny = 0,
MoveUp = 0x1,
MoveRight = 0x2,
MoveDown = 0x4,
MoveLeft = 0x8
};
Q_DECLARE_FLAGS(MovementDirection, MovementDirectionFlag)
/**
* Default constructor.
*
* @param parent Object parent (might be set when using
* \ref Animator::create factory).
*
*/
explicit Animation(QObject* parent = 0);
/**
* Destructor.
*/
~Animation() = 0;
/**
* Set the widget on which the animation is to be performed.
* @param widget The QGraphicsWidget to be animated.
*/
void setTargetWidget(QGraphicsWidget* widget);
/**
* @return The widget that the animation will be performed upon
*/
QGraphicsWidget *targetWidget() const;
/**
* Set the animation easing curve type
*/
void setEasingCurve(const QEasingCurve &curve);
/**
* Get the animation easing curve type
*/
QEasingCurve easingCurve() const;
protected:
/**
* Change the animation duration. Default is 250ms.
* @param duration The new duration of the animation.
*/
virtual void setDuration(int duration = 250);
/**
* QAbstractAnimation will call this method while the animation
* is running. Each specialized animation class should implement
* the correct behavior for it.
* @param currentTime Slapsed time using the \ref duration as reference
* (it will be from duration up to zero if the animation is running
* backwards).
*/
virtual void updateCurrentTime(int currentTime);
private:
/**
* Internal pimple (actually is used as a data structure, see
* \ref AnimationPrivate).
*/
AnimationPrivate *const d;
};
} //namespace Plasma
#endif

View File

@ -1,39 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "easinganimation_p.h"
#include <kdebug.h>
namespace Plasma
{
EasingAnimation::EasingAnimation(QObject *parent)
: Animation(parent)
{
}
void EasingAnimation::updateCurrentTime(int currentTime)
{
updateEffectiveTime(easingCurve().valueForProgress(currentTime / qreal(qMax(1, duration()))) * duration());
}
} // namespace Plasma
#include "moc_easinganimation_p.cpp"

View File

@ -1,46 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#ifndef PLASMA_EASINGANIMATION_H
#define PLASMA_EASINGANIMATION_H
#include "animation.h"
namespace Plasma
{
class EasingAnimation : public Animation
{
Q_OBJECT
public:
explicit EasingAnimation(QObject *parent = 0);
protected:
virtual void updateEffectiveTime(int currentTime) = 0;
private:
void updateCurrentTime(int currentTime);
};
} // namespace Plasma
#endif // PLASMA_EASINGANIMATION_H

View File

@ -1,86 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "fade_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
FadeAnimation::FadeAnimation(QObject *parent)
: EasingAnimation(parent),
m_startOpacity(0),
m_targetOpacity(1)
{
}
FadeAnimation::~FadeAnimation()
{
}
void FadeAnimation::setStartOpacity(qreal factor)
{
m_startOpacity = qBound(qreal(0.0), factor, qreal(1.0));
}
qreal FadeAnimation::startOpacity() const
{
return m_startOpacity;
}
void FadeAnimation::setTargetOpacity(qreal factor)
{
m_targetOpacity = qBound(qreal(0.0), factor, qreal(1.0));
}
qreal FadeAnimation::targetOpacity() const
{
return m_targetOpacity;
}
void FadeAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (oldState == Stopped && newState == Running) {
w->setOpacity(direction() == Forward ? m_startOpacity : m_targetOpacity);
} else if (newState == Stopped) {
w->setOpacity(direction() == Forward ? m_targetOpacity : m_startOpacity);
}
}
void FadeAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
qreal delta = currentTime / qreal(duration());
delta *= m_startOpacity - m_targetOpacity;
w->setOpacity(m_startOpacity - delta);
}
}
} //namespace Plasma
#include "moc_fade_p.cpp"

View File

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Fade effect.
*/
#ifndef PLASMA_ANIMATIONS_FADE_P_H
#define PLASMA_ANIMATIONS_FADE_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class Fade plasma/animations/fade.h
* @short Fade effect
*
* Effect that slowly transforms the opacity of the object from a starting
* value to a target value. The range is 0 (full translucent) to 1 (full
* opaque).
*/
class FadeAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal startOpacity READ startOpacity WRITE setStartOpacity)
Q_PROPERTY(qreal targetOpacity READ targetOpacity WRITE setTargetOpacity)
public:
/** Default constructor */
explicit FadeAnimation(QObject *parent = 0);
/** Destructor */
virtual ~FadeAnimation();
/**
* Access start opacity of the target widget.
*
* You can set both a start and an end opacity for an widget when
* using this animation class. See \ref setStartOpacity.
* @return The opacity (range is 0 to 1).
*/
qreal startOpacity() const;
/**
* Set the start opacity of the target widget.
*
* See also \ref targetOpacity.
* @param qreal The opacity (range is 0 to 1).
*/
void setStartOpacity(qreal);
/**
* Access final opacity of the target widget.
*
* You can set both a start and an end opacity for an widget when
* using this animation class. See \ref setTargetOpacity.
* @return The opacity (range is 0 to 1).
*/
qreal targetOpacity() const;
/**
* Set the final opacity of the target widget.
*
* See also \ref startOpacity.
* @param qreal The opacity (range is 0 to 1).
*/
void setTargetOpacity(qreal);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Initial opacity */
qreal m_startOpacity;
/** Final opacity */
qreal m_targetOpacity;
};
}
#endif // PLASMA_ANIMATIONS_FADE_P_H

View File

@ -1,99 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "geometry_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
GeometryAnimation::GeometryAnimation(QObject *parent)
: EasingAnimation(parent),
m_startGeometry(-1, -1, -1, -1)
{
}
GeometryAnimation::~GeometryAnimation()
{
}
void GeometryAnimation::setStartGeometry(const QRectF &geometry)
{
m_startGeometry = geometry;
}
QRectF GeometryAnimation::startGeometry() const
{
return m_startGeometry;
}
void GeometryAnimation::setTargetGeometry(const QRectF &geometry)
{
m_targetGeometry = geometry;
}
QRectF GeometryAnimation::targetGeometry() const
{
return m_targetGeometry;
}
void GeometryAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (m_startGeometry == QRectF(-1, -1, -1, -1)) {
m_startGeometry = w->geometry();
}
if (oldState == Stopped && newState == Running) {
w->setGeometry(direction() == Forward ? m_startGeometry : m_targetGeometry);
} else if (newState == Stopped) {
w->setGeometry(direction() == Forward ? m_targetGeometry : m_startGeometry);
}
}
void GeometryAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
const qreal delta = currentTime / qreal(duration());
QRectF newGeo;
newGeo.moveTopLeft(QPointF(m_startGeometry.left()*(1-delta) + m_targetGeometry.left()*(delta),
m_startGeometry.top()*(1-delta) + m_targetGeometry.top()*(delta)));
if (m_startGeometry.size() != m_targetGeometry.size()) {
newGeo.setSize(QSizeF(m_startGeometry.width()*(1-delta) + m_targetGeometry.width()*(delta),
m_startGeometry.height()*(1-delta) + m_targetGeometry.height()*(delta)));
} else {
newGeo.setSize(m_targetGeometry.size());
}
w->setGeometry(newGeo);
}
}
} //namespace Plasma
#include "moc_geometry_p.cpp"

View File

@ -1,97 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Geometry effect.
*/
#ifndef PLASMA_ANIMATIONS_GEOMETRY_P_H
#define PLASMA_ANIMATIONS_GEOMETRY_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class GeometryAnimation plasma/animations/geo_p.h
* @short Geometry Animation
* Use this class when you want to change the geometry of an QGraphicsWidget
* in an animated way (you should at least set the target geometry).
*/
class GeometryAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(QRectF startGeometry READ startGeometry WRITE setStartGeometry)
Q_PROPERTY(QRectF targetGeometry READ targetGeometry WRITE setTargetGeometry)
public:
/** Default constructor */
explicit GeometryAnimation(QObject *parent = 0);
/** Destructor */
virtual ~GeometryAnimation();
/**
* Access the initial geometry of animated widget.
*
* If no geometry is set, it will use the widget current geometry
* when the animation is first run).
* @return Start geometry.
*/
QRectF startGeometry() const;
/**
* Set the initial geometry of animated widget.
*
* If no geometry is set, it will use the widget current geometry
* when the animation is first run).
* @param geometry The initial geometry.
*/
void setStartGeometry(const QRectF &geometry);
/**
* Access the final geometry of animated widget.
*
* \todo: check if it was set and case negative, handle the error.
* @return Target geometry.
*/
QRectF targetGeometry() const;
/**
* Set the final geometry of animated widget.
*
* See also \ref setStartGeometry.
* @param geometry Returns the target geometry of animated widget.
*/
void setTargetGeometry(const QRectF &geometry);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Initial geometry */
QRectF m_startGeometry;
/** Final geometry */
QRectF m_targetGeometry;
};
} // PLASMA_ANIMATIONS_GEOMETRY_P_H
#endif

View File

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "grow_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
GrowAnimation::GrowAnimation(QObject *parent, qreal factor)
: EasingAnimation(parent), m_animFactor(factor)
{
}
void GrowAnimation::setFactor(const qreal factor)
{
m_animFactor = qMax(qreal(0.0), factor);
}
qreal GrowAnimation::factor() const
{
return m_animFactor;
}
void GrowAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w && state() == QAbstractAnimation::Running) {
const qreal delta = currentTime / qreal(duration());
QRectF geometry;
geometry.setTopLeft(m_startGeometry.topLeft() * (1-delta) + (m_targetGeometry.topLeft() * delta));
geometry.setSize(m_startGeometry.size() * (1-delta) + (m_targetGeometry.size() * delta));
w->setGeometry(geometry);
}
}
void GrowAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
QGraphicsWidget *widget = targetWidget();
if (!widget) {
return;
}
QSizeF minimum = widget->effectiveSizeHint(Qt::MinimumSize);
QSizeF maximum = widget->effectiveSizeHint(Qt::MaximumSize);
m_startGeometry = widget->geometry();
qreal w = m_startGeometry.width();
qreal h = m_startGeometry.height();
qreal factor = m_animFactor;
//compute new geometry values
qreal newWidth;
qreal newHeight;
if (direction() == QAbstractAnimation::Forward) {
newWidth = qBound(minimum.width(), w * factor, maximum.width());
newHeight = qBound(minimum.height(), h * factor, maximum.height());
} else {
newWidth = qBound(minimum.width(), w / factor, maximum.width());
newHeight = qBound(minimum.height(), h / factor, maximum.height());
}
qreal newX;
qreal newY;
newX = m_startGeometry.x() - (newWidth - w)/2;
newY = m_startGeometry.y() - (newHeight - h)/2;
if (direction() == QAbstractAnimation::Forward) {
//the end geometry gets rounded to prevent things looking ugly
m_targetGeometry = QRect(newX, newY, newWidth, newHeight);
} else {
m_targetGeometry = m_startGeometry;
m_startGeometry = QRectF(newX, newY, newWidth, newHeight);
}
}
}
} //namespace Plasma
#include "moc_grow_p.cpp"

View File

@ -1,89 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Grow effect.
*/
#ifndef PLASMA_ANIMATIONS_GROW_P_H
#define PLASMA_ANIMATIONS_GROW_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class GrowAnimation plasma/animations/grow.h
* @short Grow effect
*
* Effect that grows any QGraphicsWidget by a multiple given in the
* constructor. The center of the object stays in place while the sides grow
* (it does the animation by changing the objects geometry). Also see
* \ref ZoomAnimation.
*/
class GrowAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal factor READ factor WRITE setFactor)
public:
/** Default Constructor
* @param parent Animation object parent.
* @param factor Expand factor (default is twice the size of
* animated widget).
*/
explicit GrowAnimation(QObject *parent = 0, qreal factor = 2);
/** Destructor */
virtual ~GrowAnimation(){};
/**
* Access expansion factor of the shadow pulsable copy.
*
* If not set, the default is twice (2x) the size of animated widget.
* See \ref setFactor.
* @return Expansion factor.
*/
qreal factor() const;
/**
* Set expansion factor of target widget.
*
* If not set, the default is twice (2x) the size of animated widget.
* @param factor A expansion factor
*/
void setFactor(const qreal factor);
protected:
void updateEffectiveTime(int currentTime);
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
/** Animation grow factor */
qreal m_animFactor;
/** Widget start geometry */
QRectF m_startGeometry;
/** Widget final geometry */
QRectF m_targetGeometry;
};
}
#endif // PLASMA_ANIMATIONS_GROW_P_H

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pendulumcurve_p.h"
/**
* This static method is used to create a custom easing curve type.
* @param progress animation progress value
* @return pendulum easing curve progress value
*/
static qreal pendulumFunction(qreal progress)
{
if (progress <= 0.25) {
progress *= 4;
} else if (progress <= 0.50) {
progress -= 0.25;
progress *= 4;
progress = 1 - progress;
} else if (progress <= 0.75) {
progress -= 0.50;
progress *= -4;
} else {
progress -= 0.75;
progress *= 4;
progress = 1 - progress;
progress *= -1;
}
return progress;
}
namespace Plasma
{
PendulumCurve::PendulumCurve()
: QEasingCurve()
{
setCustomType(pendulumFunction);
}
} // namespace Plasma

View File

@ -1,44 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#define PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#include <QtCore/QEasingCurve>
namespace Plasma
{
/*
* @class PendulumCurve plasma/animations/pendulumcurve.h
* @shot Pendulum Easing Curve
*
* This easing curve provides values which are split in 4 parts:
* from 0 to 1, from 1 to 0, from 0 to -1, and from -1 to 0, in a linear way.
*/
class PendulumCurve : public QEasingCurve
{
public:
/**
* default constructor
*/
PendulumCurve();
};
} // namespace Plasma
#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_P_H

View File

@ -1,179 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
* Copyright 2010 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "pixmaptransition_p.h"
#include <QPainter>
#include <QPixmap>
#include <kdebug.h>
#include "paintutils.h"
namespace Plasma
{
PixmapTransition::PixmapTransition(QObject *parent)
: EasingAnimation(parent),
m_cache(false),
m_dirty(false)
{
}
PixmapTransition::~PixmapTransition()
{
}
void PixmapTransition::setStartPixmap(const QPixmap &pixmap)
{
if (state() == Running) {
stop();
}
m_startPixmap = pixmap;
//this will center the pixmaps if needed
updateEffectiveTime(0);
}
QPixmap PixmapTransition::startPixmap() const
{
return m_startPixmap;
}
void PixmapTransition::setTargetPixmap(const QPixmap &pixmap)
{
if (state() == Running) {
stop();
}
m_targetPixmap = pixmap;
updateEffectiveTime(0);
}
void PixmapTransition::setUsesCache(bool cache)
{
m_cache = cache;
}
bool PixmapTransition::usesCache() const
{
return m_cache;
}
QPixmap PixmapTransition::targetPixmap() const
{
return m_targetPixmap;
}
QPixmap PixmapTransition::currentPixmap() const
{
if (m_cache && !m_dirty) {
return m_currentPixmap;
}
QPixmap currentPixmap;
qreal delta = currentTime() / qreal(duration());
if (!m_startPixmap.isNull() && !m_targetPixmap.isNull()) {
//kDebug() << "transitioning";
currentPixmap = Plasma::PaintUtils::transition(m_startPixmap, m_targetPixmap, delta);
} else if (m_startPixmap.isNull()) {
if (qFuzzyCompare(delta, qreal(1.0))) {
currentPixmap = alignedTargetPixmap();
return currentPixmap;
}
if (currentPixmap.isNull()) {
currentPixmap = QPixmap(m_pixmapSize);
}
currentPixmap.fill(QColor(0, 0, 0, (int)(((qreal)255)*delta)));
QPainter p(&currentPixmap);
p.setCompositionMode(QPainter::CompositionMode_SourceIn);
//kDebug() << "painting" << m_targetPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size();
p.drawPixmap(m_targetRect, m_targetPixmap);
p.end();
} else if (m_targetPixmap.isNull()) {
currentPixmap = alignedStartPixmap();
if (qFuzzyCompare(delta, qreal(1.0))) {
return m_currentPixmap;
}
//kDebug() << "painting" << m_startPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size();
QPainter p(&currentPixmap);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(currentPixmap.rect(), QColor(0, 0, 0, (int)(254 - ((qreal)254)*delta)));
p.end();
}
if (m_cache) {
const_cast<PixmapTransition *>(this)->m_currentPixmap = currentPixmap;
}
return currentPixmap;
}
QPixmap PixmapTransition::alignedTargetPixmap() const
{
QPixmap pm(m_pixmapSize);
pm.fill(Qt::transparent);
QPainter p(&pm);
p.drawPixmap(m_targetRect, m_targetPixmap);
return pm;
}
QPixmap PixmapTransition::alignedStartPixmap() const
{
QPixmap pm(m_pixmapSize);
pm.fill(Qt::transparent);
QPainter p(&pm);
p.drawPixmap(m_startRect, m_startPixmap);
return pm;
}
void PixmapTransition::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == Stopped && newState == Running) {
m_targetRect = m_targetPixmap.rect();
m_startRect = m_startPixmap.rect();
m_pixmapSize = m_startRect.size().expandedTo(m_targetRect.size());
QRect actualRect = QRect(QPoint(0,0), m_pixmapSize);
m_targetRect.moveCenter(actualRect.center());
m_startRect.moveCenter(actualRect.center());
} else if (QGraphicsWidget *w = targetWidget()) {
w->update();
}
m_dirty = true;
}
void PixmapTransition::updateEffectiveTime(int currentTime)
{
Q_UNUSED(currentTime)
m_dirty = true;
QGraphicsWidget *w = targetWidget();
if (w) {
w->update();
}
}
} //namespace Plasma
#include "moc_pixmaptransition_p.cpp"

View File

@ -1,111 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
* Copyright 2010 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the PixmapTransition effect.
*/
#ifndef PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
#define PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class Fade plasma/animations/pixmaptransition.h
* @short PixmapTransition effect
*
* Effect that paints a transition between two pixmaps
*/
class PixmapTransition : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(QPixmap startPixmap READ startPixmap WRITE setStartPixmap)
Q_PROPERTY(QPixmap targetPixmap READ targetPixmap WRITE setTargetPixmap)
Q_PROPERTY(bool usesCache READ usesCache WRITE setUsesCache)
Q_PROPERTY(QPixmap currentPixmap READ currentPixmap)
public:
explicit PixmapTransition(QObject *parent = 0);
virtual ~PixmapTransition();
/**
* @return The first pixmap of the animation
*/
QPixmap startPixmap() const;
/**
* Set the first pixmap of the animation
*/
void setStartPixmap(const QPixmap &);
/**
* The pixmap the animation will evolve to
*/
QPixmap targetPixmap() const;
/**
* Set the pixmap the animation will evolve to
*/
void setTargetPixmap(const QPixmap &);
/**
* @return the current pixmap
*/
QPixmap currentPixmap() const;
/**
* Enable caching of the resulting pixmap, otherwise it will be regenerated on
* each call to currentPixmap; for elements which already have their own caching
* this is not a problem.
*/
void setUsesCache(bool cache);
/**
* @return whether or not caching is on
*/
bool usesCache() const;
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
QPixmap alignedTargetPixmap() const;
QPixmap alignedStartPixmap() const;
private:
QPixmap m_startPixmap;
QPixmap m_targetPixmap;
QPixmap m_currentPixmap;
QRect m_startRect;
QRect m_targetRect;
QSize m_pixmapSize;
bool m_cache;
bool m_dirty;
};
}
#endif // PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H

View File

@ -1,144 +0,0 @@
/* Copyright (C) 2009 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "widgetsnapshot_p.h"
#include "pulser_p.h"
#include <QEvent>
#include <QGraphicsWidget>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QWeakPointer>
#include <kdebug.h>
namespace Plasma
{
PulseAnimation::PulseAnimation(QObject *parent)
: EasingAnimation(parent),
m_zvalue(0),
m_scale(0),
m_opacity(0),
m_endScale(1.5)
{
}
PulseAnimation::~PulseAnimation()
{
delete m_under.data();
}
void PulseAnimation::setTargetScale(qreal scale)
{
m_endScale = scale;
}
qreal PulseAnimation::targetScale() const
{
return m_endScale;
}
void PulseAnimation::setCopy()
{
QGraphicsWidget *target = targetWidget();
if (!target) {
m_under.clear();
return;
}
if (!m_under.data()) {
m_under = new WidgetSnapShot;
}
m_under.data()->setTarget(target);
m_zvalue = target->zValue() - 1;
m_scale = target->scale();
m_under.data()->setOpacity(m_opacity);
m_under.data()->setScale(m_scale);
m_under.data()->setZValue(m_zvalue);
}
void PulseAnimation::resetPulser()
{
if (m_under.data()) {
m_under.data()->setOpacity(m_opacity);
m_under.data()->setScale(m_scale);
m_under.data()->setZValue(m_zvalue);
m_under.data()->hide();
}
}
void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (!targetWidget()) {
return;
}
if (oldState == Stopped && newState == Running) {
if (!m_under.data() || m_under.data()->target() != targetWidget() || m_under.data()->size() != targetWidget()->size()) {
setCopy();
}
if (m_under.data()->isIconBigger()) {
m_under.data()->setScale(0);
m_endScale = 1.0;
} else {
m_scale = 0;
m_endScale = 1.5;
}
if (m_under.data()->isVisible() == false) {
m_under.data()->setVisible(true);
}
m_under.data()->setOpacity(direction() == Forward ? 1 : 0);
m_under.data()->setScale(direction() == Forward ? m_scale : m_endScale);
} else if (newState == Stopped) {
resetPulser();
}
}
void PulseAnimation::updateEffectiveTime(int currentTime)
{
if (m_under.data()) {
qreal delta = currentTime / qreal(duration());
if (m_under.data()->isIconBigger()) {
m_under.data()->setScale(delta);
} else {
m_under.data()->setScale(delta);
delta = (1 - m_endScale) * delta;
m_under.data()->setScale(1 - delta);
}
delta = currentTime / qreal(duration());
if (direction() == Forward) {
m_under.data()->setOpacity(1.0 - delta);
} else if (direction() == Backward) {
m_under.data()->setOpacity(delta);
}
}
}
} //namespace Plasma
#include "moc_pulser_p.cpp"

View File

@ -1,110 +0,0 @@
/* Copyright (C) 2009 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Pulse effect.
*/
#ifndef PLASMA_ANIMATIONS_PULSER_P_H
#define PLASMA_ANIMATIONS_PULSER_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
class WidgetSnapShot;
/**
* @class PulseAnimation plasma/animations/pulser_p.h
* @short Pulse effect
*
* Effect that pulses a shadow copy of any QGraphicsWidget making
* it more translucent and bigger along the time until it vanishes.
*/
class PulseAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal targetScale READ targetScale WRITE setTargetScale)
public:
/** Default Constructor */
explicit PulseAnimation(QObject *parent = 0);
/** Destructor */
~PulseAnimation();
/** Pulse scale factor.
*
* How much the pulsed shadow will expand (the default is 1.5x the
* size of pulsed widget).
*
* @param scale Pulse scale value (should be bigger than 1.0).
*/
void setTargetScale(qreal scale);
/** Returns pulsed scale factor.
*
* The amount of pulsed shadow factor used (default is 1.5x the size
* of widget).
*/
qreal targetScale() const;
/**
* Resets the shadow widget to its initial state (full translucent
* and with same geometry as the target widget). It is executed
* when the animation is over.
*/
void resetPulser();
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
void setCopy();
private:
/** Zvalue (tipically -1 than the target widget) */
qreal m_zvalue;
/** Original widget scale */
qreal m_scale;
/** Opacity of shadow widget (full translucent) */
qreal m_opacity;
/** Target scale of shadow widget (default is 1.5x the animated
* widget scale).
*/
qreal m_endScale;
/** The shadow copy (it really is a QGraphicsWidget with a pixmap
* copy of the original widget).
*/
QWeakPointer<WidgetSnapShot> m_under;
};
}
#endif // PLASMA_ANIMATIONS_PULSER_P_H

View File

@ -1,167 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QGraphicsRotation>
#include <QEasingCurve>
#include <QVector3D>
#include "kdebug.h"
#include "rotation_p.h"
namespace Plasma
{
RotationAnimation::RotationAnimation(QObject *parent, qint8 reference, Qt::Axis axis, qreal angle)
: EasingAnimation(parent),
m_rotation(new QGraphicsRotation(this)),
m_angle(angle),
m_axis(axis),
m_reference(reference)
{
}
RotationAnimation::~RotationAnimation()
{
}
Qt::Axis RotationAnimation::axis() const
{
return m_axis;
}
void RotationAnimation::setAxis(const Qt::Axis &axis)
{
m_axis = axis;
}
qint8 RotationAnimation::reference() const
{
return m_reference;
}
void RotationAnimation::setReference(const qint8 &reference)
{
m_reference = reference;
}
qreal RotationAnimation::angle() const
{
return m_angle;
}
void RotationAnimation::setAngle(const qreal &angle)
{
m_angle = angle;
}
void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
Q_UNUSED(newState)
Q_UNUSED(oldState)
QGraphicsWidget *m_object = targetWidget();
if (!m_object) {
return;
}
QVector3D vector(0, 0, 0);
const qreal widgetWidth = m_object->size().width();
const qreal widgetHeight = m_object->size().height();
if (axis() == Qt::XAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Up:
vector.setX(widgetWidth/2);
vector.setY(0);
break;
case Down:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight);
break;
}
} else if(axis() == Qt::YAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Left:
vector.setX(0);
vector.setY(widgetHeight/2);
break;
case Right:
vector.setX(widgetWidth);
vector.setY(widgetHeight/2);
break;
}
} else if (axis() == Qt::ZAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Center|Up:
vector.setX(widgetWidth/2);
vector.setY(0);
break;
case Center|Down:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight);
break;
case Center|Left:
vector.setX(0);
vector.setY(widgetHeight/2);
break;
case Center|Right:
vector.setX(widgetWidth);
vector.setY(widgetHeight/2);
break;
}
}
m_rotation->setOrigin(vector);
m_rotation->setAxis(axis());
QList<QGraphicsTransform *> transformation;
transformation.append(m_rotation);
m_object->setTransformations(transformation);
}
void RotationAnimation::updateEffectiveTime(int currentTime)
{
if (targetWidget()) {
qreal delta = currentTime * angle() / qreal(duration());
m_rotation->setAngle(delta);
}
}
}
#include "moc_rotation_p.cpp"

View File

@ -1,123 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file This file contains the definition for the 2D Rotation effect.
*/
#ifndef PLASMA_ROTATION_P_H
#define PLASMA_ROTATION_P_H
#include <plasma/animations/easinganimation_p.h>
class QGraphicsRotation;
namespace Plasma {
/**
* @class RotationAnimation plasma/animations/rotation_p.h
* @short 2D rotation animation.
*
* This animation rotates a QGraphicsWidget in a axis (reference and
* axis can be defined using properties). See also
* \ref StackedRotationAnimation.
*/
class RotationAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis)
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
public:
/**
* Default constructor
*
* @param parent Animation object parent.
* @param reference See \ref Animation::Reference.
* @param axis Which axis to rotate (XAxis, YAxis, ZAxis).
* @param angle Rotation angle (0 to 360)
*
*/
explicit RotationAnimation(QObject *parent = 0,
qint8 reference = Center,
Qt::Axis axis = Qt::ZAxis,
qreal angle = 180);
/** Destructor */
~RotationAnimation();
/**
* get animation rotation axis (e.g. YAxis, ZAxis, XAxis)
*/
Qt::Axis axis() const;
/**
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
* be combined (i.e. Center|Up)
*/
qint8 reference() const;
/**
* Animation rotation angle (e.g. 45, 180, etc)
*/
qreal angle() const;
/**
* Reimplemented from Plasma::Animation
* @param curve Easing curve
*/
void setEasingCurve(const QEasingCurve &curve);
public slots:
/**
* set animation rotation axis
* @param axis Rotation (e.g. YAxis, ZAxis, XAxis)
*/
void setAxis(const Qt::Axis &axis);
/**
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
* be combined (i.e. Center|Up)
* @param reference The reference
*/
void setReference(const qint8 &reference);
/**
* Set animation rotation angle (e.g. 45, 180, etc)
* @param angle The angle
*/
void setAngle(const qreal &angle);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Rotation transform object */
QGraphicsRotation *m_rotation;
/** Rotation angle */
qreal m_angle;
/** Axis where to perform the rotation */
Qt::Axis m_axis;
/** Reference, the default is Up (see \ref Animation::Reference) */
qint8 m_reference;
};
} // Plasma
#endif

View File

@ -1,188 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rotationstacked_p.h"
#include <QGraphicsRotation>
#include <QSequentialAnimationGroup>
#include <QWeakPointer>
#include <kdebug.h>
#include "stackedlayout.h"
#include "plasma.h"
namespace Plasma
{
const int RotationStackedAnimation::s_sideAngle = 90;
RotationStackedAnimation::RotationStackedAnimation(QObject *parent)
: EasingAnimation(parent)
{
m_backRotation = new QGraphicsRotation(this);
m_frontRotation = new QGraphicsRotation(this);
m_wLayout = new StackedLayout;
}
RotationStackedAnimation::~RotationStackedAnimation()
{
delete m_wLayout.data();
}
void RotationStackedAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
QVector3D animDirection(0, 0, 0);
if (m_animDirection.testFlag(MoveUp)) {
animDirection.setX(1);
} else if (m_animDirection.testFlag(MoveDown)) {
animDirection.setX(-1);
}
if (m_animDirection.testFlag(MoveLeft)) {
animDirection.setY(-1);
} else if (m_animDirection.testFlag(MoveRight)) {
animDirection.setY(1);
}
m_frontRotation->setAxis(animDirection);
m_backRotation->setAxis(animDirection);
updateTransformations();
}
Animation::MovementDirection RotationStackedAnimation::movementDirection() const
{
return m_animDirection;
}
void RotationStackedAnimation::setReference(const Animation::Reference &reference)
{
m_animReference = reference;
if (!targetWidget() || !backWidget()) {
return;
}
const QSizeF transformArea = targetWidget()->size().expandedTo(backWidget()->size());
QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
if (m_animReference.testFlag(Up)) {
frontTransformOrigin.setY(0);
backTransformOrigin.setY(0);
} else if (m_animReference.testFlag(Down)) {
frontTransformOrigin.setY(transformArea.height());
backTransformOrigin.setY(transformArea.height());
}
if (m_animReference.testFlag(Left)) {
frontTransformOrigin.setX(0);
backTransformOrigin.setX(0);
} else if (m_animReference.testFlag(Right)) {
frontTransformOrigin.setX(transformArea.width());
backTransformOrigin.setX(transformArea.width());
}
m_frontRotation->setOrigin(frontTransformOrigin);
m_backRotation->setOrigin(backTransformOrigin);
updateTransformations();
}
Animation::Reference RotationStackedAnimation::reference() const
{
return m_animReference;
}
QGraphicsWidget *RotationStackedAnimation::backWidget()
{
return m_backWidget.data();
}
void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
{
m_backWidget = backWidget;
StackedLayout *layout = m_wLayout.data();
if(targetWidget() && backWidget && layout) {
layout->addWidget(targetWidget());
layout->addWidget(backWidget);
}
}
QGraphicsLayoutItem *RotationStackedAnimation::layout()
{
return m_wLayout.data();
}
void RotationStackedAnimation::updateState(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState)
{
if (oldState == Stopped && newState == Running) {
setReference(reference());
}
}
void RotationStackedAnimation::updateEffectiveTime(int currentTime)
{
if (!targetWidget() || !backWidget()) {
return;
}
StackedLayout *layout = m_wLayout.data();
if (!layout) {
return;
}
qreal delta;
if (currentTime <= duration()/2) {
layout->setCurrentWidgetIndex(0);
delta = (currentTime*2) / qreal(duration());
delta *= s_sideAngle;
m_frontRotation->setAngle(delta);
} else {
layout->setCurrentWidgetIndex(1);
delta = 1 - (((currentTime*2) - duration()) / qreal(duration()));
delta = -delta;
delta *= s_sideAngle;
m_backRotation->setAngle(delta);
}
}
void RotationStackedAnimation::updateTransformations()
{
if (!targetWidget() || !backWidget()) {
return;
}
QList<QGraphicsTransform *> frontTransformation;
QList<QGraphicsTransform *> backTransformation;
frontTransformation.append(m_frontRotation);
backTransformation.append(m_backRotation);
targetWidget()->setTransformations(frontTransformation);
backWidget()->setTransformations(backTransformation);
}
} //namespace Plasma
#include "moc_rotationstacked_p.cpp"

View File

@ -1,126 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file This file contains the definition for the StackedRotationAnimation.
*/
#ifndef PLASMA_ROTATIONSTACKED_P_H
#define PLASMA_ROTATIONSTACKED_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
#include <QGraphicsLayoutItem>
class QGraphicsRotation;
class StackedLayout;
namespace Plasma {
/* TODO:
* create a parent class for rotations
*/
/**
* @class RotationStackedAnimation plasma/animations/rotationstacked_p.h
* @short 3D like rotation animation
* Use this class when you want to rotate a widget along an axis (e.g. Y)
* and display a 'hidden' widget behind it. See also \ref RotationAnimation.
*/
class RotationStackedAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(Reference reference READ reference WRITE setReference)
Q_PROPERTY(QGraphicsLayoutItem* layout READ layout)
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
public:
explicit RotationStackedAnimation(QObject *parent = 0);
~RotationStackedAnimation();
/**
* Set the animation movement direction (e.g. MoveAny, MoveUp, MoveDown,
* MoveLeft, MoveRight) which can be combined (i.e. MoveUp|MoveLeft).
* @param direction animation direction
*/
void setMovementDirection(const Animation::MovementDirection &direction);
/**
* Get the animation movement direction.
*/
Animation::MovementDirection movementDirection() const;
/**
* Set the animation rotation reference (e.g. Center, Up, Down, Left,
* Right) which can be combined (i.e. Center|Up).
* @param reference animation reference
*/
void setReference(const Animation::Reference &reference);
/**
* Get the animation rotation reference.
*/
Animation::Reference reference() const;
/**
* Get the layout where the widgetToAnimate and backWidget are.
*/
QGraphicsLayoutItem *layout();
/**
* Get the back widget
*/
QGraphicsWidget *backWidget();
/**
* Set the back widget that is used after the animation to be finished
* @param backWidget The back widget
*/
void setBackWidget(QGraphicsWidget *backWidget);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/**
* Updates the front and back widget rotation animation transformations,
* according to the given animation reference point and direction.
*/
void updateTransformations();
/** Animation reference (see \ref Animation::Reference) */
Animation::Reference m_animReference;
/** Animation movement direction (see \ref Animation::MovementDirection) */
Animation::MovementDirection m_animDirection;
/** Object the animation(s) should act upon. */
QWeakPointer<QGraphicsWidget> m_backWidget;
/** Layout where widget would be added */
QWeakPointer<StackedLayout> m_wLayout;
/** Back Widget Rotation transform object */
QGraphicsRotation *m_backRotation;
/** Front Widget Rotation transform object */
QGraphicsRotation *m_frontRotation;
static const int s_sideAngle;
};
} // Plasma
#endif // PLASMA_ROTATIONSTACKED_P_H

View File

@ -1,129 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "slide_p.h"
#include <QPointF>
#include <kdebug.h>
namespace Plasma
{
void SlideAnimation::setDistance(qreal distance)
{
m_animDistance = QPointF(distance, 0.0);
}
qreal SlideAnimation::distance() const
{
return m_animDistance.x();
}
void SlideAnimation::setDistancePointF(const QPointF &distance)
{
m_animDistance = distance;
}
QPointF SlideAnimation::distancePointF() const
{
return m_animDistance;
}
SlideAnimation::~SlideAnimation()
{
}
SlideAnimation::SlideAnimation(QObject *parent,
MovementDirection direction,
qreal distance) : EasingAnimation(parent)
{
setMovementDirection(direction);
setDistance(distance);
setEasingCurve(QEasingCurve::OutCirc);
}
void SlideAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
}
Animation::MovementDirection SlideAnimation::movementDirection() const
{
return m_animDirection;
}
void SlideAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w && state() == QAbstractAnimation::Running) {
const qreal delta = currentTime / qreal(duration());
w->setPos(m_startPos * (1-delta) + (m_targetPos * delta));
}
}
void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
if (!targetWidget()) {
return;
}
m_startPos = targetWidget()->pos();
qreal newX = m_startPos.x();
qreal newY = m_startPos.y();
QPointF actualDistance = (direction() == \
QAbstractAnimation::Forward ? \
distancePointF():-distancePointF());
bool moveAnyOnly = true;
if (m_animDirection.testFlag(MoveUp)) {
newY -= actualDistance.x();
moveAnyOnly = false;
} else if (m_animDirection.testFlag(MoveDown)) {
newY += actualDistance.x();
moveAnyOnly = false;
}
if (m_animDirection.testFlag(MoveRight)) {
newX += actualDistance.x();
moveAnyOnly = false;
} else if (m_animDirection.testFlag(MoveLeft)) {
newX -= actualDistance.x();
moveAnyOnly = false;
}
if (moveAnyOnly && m_animDirection.testFlag(MoveAny)) {
newX += actualDistance.x();
newY += actualDistance.y();
}
if (direction() == QAbstractAnimation::Forward) {
m_targetPos = QPointF(newX, newY);
} else {
m_targetPos = m_startPos;
m_startPos = QPointF(newX, newY);
}
}
}
} //namespace Plasma
#include "moc_slide_p.cpp"

View File

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Slide effect.
*/
#ifndef PLASMA_ANIMATIONS_SLIDE_P_H
#define PLASMA_ANIMATIONS_SLIDE_P_H
#include "plasma/animations/easinganimation_p.h"
#include "plasma/plasma_export.h"
#include "plasma/plasma.h"
namespace Plasma
{
class SlideAnimationPrivate;
/**
* @class Slide plasma/animations/slide.h
* @short Slide effect
*
* Effect that moves the object a specific distance in a given direction. The
* object is optionally made invisible at the beginning or at the end.
*/
class SlideAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF)
public:
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
~SlideAnimation();
/**
* Set the animation distance
* @distance animation distance
*/
void setDistance(qreal distance);
/**
* Get the animation distance
*/
qreal distance() const;
void setDistancePointF(const QPointF &distance);
QPointF distancePointF() const;
/**
* Set the animation direction
* @param direction animation direction
*/
void setMovementDirection(const Animation::MovementDirection&direction);
/**
* Get the animation direction
*/
Animation::MovementDirection movementDirection() const;
protected:
void updateEffectiveTime(int currentTime);
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
/**
* Animation direction: where the animation will move.
*/
Animation::MovementDirection m_animDirection;
/**
* Animation distance: displacement factor for animations where
* there is change in the position of animated widget.
*/
QPointF m_animDistance;
QPointF m_startPos;
QPointF m_targetPos;
};
}
#endif // PLASMA_ANIMATIONS_SLIDE_P_H

View File

@ -1,110 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stackedlayout.h"
#include <QGraphicsWidget>
#include <QDebug>
StackedLayout::StackedLayout(QGraphicsLayoutItem *parent)
: QObject(0),
QGraphicsLayout(parent),
m_currentWidgetIndex(-1)
{
}
StackedLayout::~StackedLayout()
{
}
void StackedLayout::setGeometry(const QRectF &rect)
{
QGraphicsLayout::setGeometry(rect);
const QRectF effectiveRect = geometry();
for(int i = 0; i < items.size(); i++) {
itemAt(i)->setGeometry(effectiveRect);
}
}
QSizeF StackedLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(which);
Q_UNUSED(constraint);
qreal left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
if (m_currentWidgetIndex <= 0 || !itemAt(m_currentWidgetIndex)) {
return QSizeF();
}
QSizeF currentWidgetSize = itemAt(m_currentWidgetIndex)->effectiveSizeHint(which, constraint);
return QSizeF( left + right + currentWidgetSize.width(), right + bottom + currentWidgetSize.height());
}
int StackedLayout::count() const
{
return items.count();
}
QGraphicsLayoutItem *StackedLayout::itemAt(int i) const
{
return items.at(i);
}
void StackedLayout::insertWidget(QGraphicsLayoutItem *item, int pos)
{
if(!pos && (m_currentWidgetIndex == -1)) {
m_currentWidgetIndex = 0;
} else {
item->graphicsItem()->hide();
}
items.insert(pos, item);
activate();
}
void StackedLayout::addWidget(QGraphicsLayoutItem *item)
{
insertWidget(item, items.size());
}
void StackedLayout::removeAt(int index)
{
items.removeAt(index);
}
void StackedLayout::setCurrentWidgetIndex(qint32 index)
{
QGraphicsItem *currentWidget = itemAt(m_currentWidgetIndex)->graphicsItem();
QGraphicsItem *hiddenWidget = itemAt(index)->graphicsItem();
currentWidget->hide();
hiddenWidget->show();
m_currentWidgetIndex = index;
}
qint32 StackedLayout::currentWidgetIndex() const
{
return m_currentWidgetIndex;
}
#include "moc_stackedlayout.cpp"

View File

@ -1,54 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STACKEDLAYOUT_H
#define STACKEDLAYOUT_H
/* TODO: document the methods */
#include <QGraphicsLayout>
#include <QList>
#include <QObject>
class StackedLayout : public QObject, public QGraphicsLayout
{
Q_OBJECT
Q_INTERFACES(QGraphicsLayout)
public:
explicit StackedLayout(QGraphicsLayoutItem *parent = 0);
~StackedLayout();
void setGeometry(const QRectF &rect);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const;
int count() const;
QGraphicsLayoutItem *itemAt(int i) const;
void insertWidget(QGraphicsLayoutItem *item, int pos);
void addWidget(QGraphicsLayoutItem *item);
void removeAt(int index);
qint32 currentWidgetIndex() const;
void setCurrentWidgetIndex(qint32 index);
private:
QList<QGraphicsLayoutItem *> items;
qint32 m_currentWidgetIndex;
};
#endif

View File

@ -1,128 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "widgetsnapshot_p.h"
#include <QPainter>
#include <QImage>
#include <QPixmap>
#include <QStyleOptionGraphicsItem>
#include <QDebug>
static const int RECURSION_MAX = 20;
namespace Plasma
{
WidgetSnapShot::WidgetSnapShot(QGraphicsItem *parent)
: QGraphicsWidget(parent),
m_iconBig(false),
stack(0),
m_target(0)
{
}
WidgetSnapShot::~WidgetSnapShot()
{
}
void WidgetSnapShot::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPixmap(option->exposedRect, m_snapShot, option->exposedRect);
}
void WidgetSnapShot::paintSubChildren(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QGraphicsItem *target)
{
++stack;
QList<QGraphicsItem *> list = target->childItems();
QGraphicsItem *tmp;
if (list.size() > 0) {
for (int i = 0; i < list.size(); ++i) {
tmp = list.value(i);
if ((tmp->childItems().size() > 0) && (stack < RECURSION_MAX)) {
paintSubChildren(painter, option, tmp);
}
if (tmp->isVisible()) {
tmp->paint(painter, option, 0);
}
}
}
--stack;
}
void WidgetSnapShot::setTarget(QGraphicsWidget *target)
{
stack = 0;
m_target = target;
setParentItem(target);
QSize size(target->size().toSize());
m_iconBig = false;
if (m_target->property("iconRepresentation").isValid()) {
m_iconBig = true;
m_snapShot = QPixmap::fromImage(
m_target->property("iconRepresentation").value<QImage>());
if ((m_snapShot.height() > 0) && (m_snapShot.width() > 0)) {
resize(m_snapShot.size());
setTransformOriginPoint(target->geometry().center());
return;
}
}
resize(target->size());
m_snapShot = QPixmap(size);
m_snapShot.fill(Qt::transparent);
QPainter painter(&m_snapShot);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(target->rect(), Qt::transparent);
QStyleOptionGraphicsItem style;
style.exposedRect = target->boundingRect();
style.rect = target->rect().toRect();
target->paint(&painter, &style, 0);
paintSubChildren(&painter, &style, target);
painter.end();
setTransformOriginPoint(geometry().center());
}
QGraphicsWidget *WidgetSnapShot::target() const
{
return m_target;
}
bool WidgetSnapShot::isIconBigger() const
{
return m_iconBig;
}
QPixmap WidgetSnapShot::snapShot() const
{
return m_snapShot;
}
}

View File

@ -1,59 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_WIDGETSNAPSHOT_P_H
#define PLASMA_WIDGETSNAPSHOT_P_H
#include <QGraphicsWidget>
namespace Plasma
{
class WidgetSnapShot : public QGraphicsWidget
{
Q_OBJECT
Q_PROPERTY(QGraphicsWidget *target READ target WRITE setTarget)
public:
explicit WidgetSnapShot(QGraphicsItem *parent = 0);
virtual ~WidgetSnapShot();
virtual void setTarget(QGraphicsWidget *target);
QGraphicsWidget *target() const;
virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget);
bool isIconBigger() const;
QPixmap snapShot() const;
private:
void paintSubChildren(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QGraphicsItem *target);
bool m_iconBig;
int stack;
QPixmap m_snapShot;
QGraphicsWidget *m_target;
};
} // namespace Plasma
#endif // PLASMA_WIDGETSNAPSHOT_P_H

View File

@ -1,76 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "zoom_p.h"
#include <kdebug.h>
namespace Plasma
{
ZoomAnimation::ZoomAnimation(QObject *parent)
: EasingAnimation(parent),
m_zoom(0)
{
}
ZoomAnimation::~ZoomAnimation()
{
}
void ZoomAnimation::setZoom(qreal zoom)
{
m_zoom = zoom;
}
qreal ZoomAnimation::zoom() const
{
return m_zoom;
}
void ZoomAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (oldState == Stopped && newState == Running) {
w->setTransformOriginPoint(w->size().width()/2, w->size().height()/2);
w->setScale(direction() == Forward ? 1 : m_zoom);
} else if (newState == Stopped) {
w->setScale(direction() == Forward ? m_zoom : 1);
}
}
void ZoomAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
qreal delta = currentTime / qreal(duration());
if (m_zoom != 1) {
delta = (1 - m_zoom) * delta;
w->setScale(1 - delta);
} else {
w->setScale(delta);
}
}
}
} //namespace Plasma

View File

@ -1,60 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/**
* @file This file contains the definition for the Zoom animation.
*/
#ifndef PLASMA_ANIMATIONS_ZOOM_P_H
#define PLASMA_ANIMATIONS_ZOOM_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class ZoomAnimation plasma/animations/zoom_p.h
* @short Zoom Animation
*
*/
class ZoomAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom)
public:
explicit ZoomAnimation(QObject *parent = 0);
virtual ~ZoomAnimation();
qreal zoom() const;
void setZoom(qreal);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
qreal m_zoom;
};
}
#endif // PLASMA_ANIMATIONS_ZOOM_P_H

View File

@ -1,130 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "animator.h"
#include <kdebug.h>
#include "animations/animation.h"
#include "animations/fade_p.h"
#include "animations/grow_p.h"
#include "animations/pulser_p.h"
#include "animations/rotation_p.h"
#include "animations/slide_p.h"
#include "animations/rotationstacked_p.h"
#include "animations/geometry_p.h"
#include "animations/zoom_p.h"
#include "animations/pixmaptransition_p.h"
#include "animations/pendulumcurve_p.h"
#include "theme.h"
namespace Plasma
{
Animator::Animator(QObject *parent)
: QObject(parent),
d(0)
{
}
Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
{
Plasma::Animation *result = 0;
switch (type) {
case FadeAnimation:
result = new Plasma::FadeAnimation(parent);
break;
case GrowAnimation:
result = new Plasma::GrowAnimation(parent);
break;
case PulseAnimation:
result = new Plasma::PulseAnimation(parent);
break;
case RotationAnimation:
result = new Plasma::RotationAnimation(parent);
break;
case RotationStackedAnimation:
result = new Plasma::RotationStackedAnimation(parent);
break;
case SlideAnimation:
result = new Plasma::SlideAnimation(parent);
break;
case GeometryAnimation:
result = new Plasma::GeometryAnimation(parent);
break;
case ZoomAnimation:
result = new Plasma::ZoomAnimation(parent);
break;
case PixmapTransitionAnimation:
result = new Plasma::PixmapTransition(parent);
break;
default:
//kDebug() << "Unsupported animation type.";
break;
}
return result;
}
QEasingCurve Animator::create(Animator::CurveShape type)
{
QEasingCurve result;
switch (type) {
case EaseInCurve:
result.setType(QEasingCurve::InQuad);
break;
case EaseOutCurve:
result.setType(QEasingCurve::OutQuad);
break;
case EaseInOutCurve:
result.setType(QEasingCurve::InOutQuad);
break;
case LinearCurve:
result.setType(QEasingCurve::Linear);
break;
case PendularCurve:
result = PendulumCurve();
break;
default:
#ifndef NDEBUG
kDebug() << "Unsupported easing curve type.";
#endif
break;
}
return result;
}
} // namespace Plasma
#include "moc_animator.cpp"

View File

@ -1,100 +0,0 @@
/*
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
* 2007 Alexis Ménard <darktears31@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#ifndef PLASMA_ANIMATOR_H
#define PLASMA_ANIMATOR_H
#include <QImage>
#include <QtCore/QObject>
#include <QtCore/QAbstractAnimation>
#include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h>
class QGraphicsItem;
class QGraphicsWidget;
class QTimeLine;
namespace Plasma
{
class AnimatorPrivate;
class Animation;
/**
* @class Animator plasma/animator.h <Plasma/Animator>
*
* @short A system for applying effects to Plasma elements
*/
class PLASMA_EXPORT Animator : public QObject
{
Q_OBJECT
Q_ENUMS(Animation)
Q_ENUMS(CurveShape)
public:
enum Animation {
AppearAnimation = 0, /*<< Animate the appearance of an element */
DisappearAnimation, /*<< Animate the disappearance of an element */
ActivateAnimation, /*<< When something is activated or launched,
such as an app icon being clicked */
FadeAnimation, /*<< Can be used for both fade in and out */
GrowAnimation, /*<< Grow animated object geometry */
PulseAnimation, /*<< Pulse animated object (opacity/geometry/scale) */
RotationAnimation, /*<< Rotate an animated object */
RotationStackedAnimation, /*<< for flipping one object with another */
SlideAnimation, /*<< Move the position of animated object */
GeometryAnimation, /*<< Geometry animation*/
ZoomAnimation, /*<<Zoom animation */
PixmapTransitionAnimation, /*<< Transition between two pixmaps*/
LastAnimation = 1024
};
enum CurveShape {
EaseInCurve = 0,
EaseOutCurve,
EaseInOutCurve,
LinearCurve,
PendularCurve
};
explicit Animator(QObject *parent = 0);
/**
* Factory to build new animation objects. To control their behavior,
* check \ref AbstractAnimation properties.
* @since 4.4
**/
static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0);
/**
* Factory to build new custom easing curves.
* @since 4.5
*/
static QEasingCurve create(Animator::CurveShape type);
private:
AnimatorPrivate * const d;
};
} // namespace Plasma
#endif

View File

@ -91,8 +91,6 @@
#include "remote/authorizationmanager.h"
#include "remote/authorizationmanager_p.h"
#include "theme.h"
#include "widgets/iconwidget.h"
#include "widgets/label.h"
#include "tooltipmanager.h"
#include "wallpaper.h"
#include "paintutils.h"

View File

@ -33,7 +33,6 @@
#include <plasma/configloader.h>
#include <plasma/plasma.h>
#include <plasma/animator.h>
#include <plasma/version.h>
#include <plasma/framesvg.h>

View File

@ -52,7 +52,6 @@
#include "kio/scheduler.h"
#endif
#include "animator.h"
#include "containmentactions.h"
#include "containmentactionspluginsconfig.h"
#include "corona.h"

View File

@ -29,7 +29,6 @@
#include <ksharedconfig.h>
#include <plasma/applet.h>
#include <plasma/animator.h>
namespace Plasma

View File

@ -1,81 +0,0 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Plasma/Animator
Comment=Plasma Animation Engine
Comment[ar]=محرك تحريك البلازما
Comment[as]=Plasma Animation Engine
Comment[ast]=Motor d'animación Plasma
Comment[be@latin]=Systema animacyi Plasma
Comment[bg]=Ядро за анимации на Plasma
Comment[bn]= ি ি
Comment[bn_IN]=Plasma ি ি
Comment[bs]=Plazma motor animacija
Comment[ca]=Motor d'animació del Plasma
Comment[ca@valencia]=Motor d'animació del Plasma
Comment[cs]=Animační nástroj Plasma
Comment[da]=Plasma-animationsmotor
Comment[de]=Plasma-Animations-Treiber
Comment[el]=Μηχανή εφέ κίνησης του Plasma
Comment[en_GB]=Plasma Animation Engine
Comment[eo]=Viviga motoro de Plasma
Comment[es]=Motor de animación para Plasma
Comment[et]=Plasma animatsiooni mootor
Comment[eu]=Plasma animazio motorra
Comment[fi]=Plasma-animointimoottori
Comment[fr]=Moteur d'animation Plasma
Comment[fy]=Plasma animaasje motor
Comment[ga]=Inneall Beochana Plasma
Comment[gl]=Motor de animación de Plasma
Comment[gu]= િ િ
Comment[he]=מנוע אנימציה של Plasma
Comment[hne]= ि ि
Comment[hr]=Plasmin animatorski mehanizam
Comment[hsb]=Plasma-engine za animacije
Comment[hu]=Plasma animációkezelő
Comment[ia]=Motor de animation Plasma
Comment[id]=Mesin Animasi Plasma
Comment[is]=Plasma hreyfingastjóri
Comment[it]=Motore animazione Plasma
Comment[ja]=Plasma
Comment[kk]=Plasma анимация тетігі
Comment[km]=
Comment[kn]= (ಿ)
Comment[ko]=Plasma
Comment[ku]=Motora Zindîkirina Plasma
Comment[lt]=Plasma animacijos varikliukas
Comment[lv]=Plasma animācijas dzinējs
Comment[mai]= ि
Comment[ml]= ി ി
Comment[nb]=Plasma animasjonsmotor
Comment[nds]=Plasma-Animeerkarn
Comment[nl]=Plasma-animatie-engine
Comment[nn]=Plasma-animasjonsmotor
Comment[pa]=
Comment[pl]=Silnik animacji Plazmy
Comment[pt]=Motor de Animação do Plasma
Comment[pt_BR]=Mecanismo de animação do Plasma
Comment[ro]=Motor de animație Plasma
Comment[ru]=Движок анимации для Plasma
Comment[se]=Plasma-animerenmohtor
Comment[si]=Plasma
Comment[sk]=Animačný nástroj Plasma
Comment[sl]=Animacijski pogon za Plasmo
Comment[sr]=Плазма мотор анимација
Comment[sr@ijekavian]=Плазма мотор анимација
Comment[sr@ijekavianlatin]=Plasma motor animacija
Comment[sr@latin]=Plasma motor animacija
Comment[sv]=Animeringsgränssnitt i Plasma
Comment[ta]=ி ி
Comment[tg]=Системаи аниматсионии Plasma
Comment[th]=
Comment[tr]=Plasma Canlandırma Motoru
Comment[tt]=Plasma анимация өчен корал
Comment[ug]=Plasma جانلاندۇرۇم ماتورى
Comment[uk]=Рушій анімації Плазми
Comment[vi]=Cơ chế hot nh Plasma
Comment[wa]=Moteur d' animåcion di Plasma
Comment[x-test]=xxPlasma Animation Enginexx
Comment[zh_CN]=Plasma
Comment[zh_TW]=Plasma

View File

@ -1,222 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
/* TODO:
*
* - cleanup debug messages
*/
#include "animationscriptengine_p.h"
#include <QFile>
#include <QMetaEnum>
#include <QParallelAnimationGroup>
#include <QPauseAnimation>
#include <QSequentialAnimationGroup>
#include <QTextStream>
#include <kdebug.h>
#include <klocalizedstring.h>
#include "animator.h"
#include "javascriptanimation_p.h"
#include "bindings/animationgroup_p.h"
namespace Plasma
{
QScriptValue constructEasingCurveClass(QScriptEngine *engine);
namespace AnimationScriptEngine
{
QScriptEngine* inst = 0;
QHash<QString, QScriptValue> s_animFuncs;
QSet<QString> s_animFailures;
QString s_prefix;
QScriptValue animation(const QString &anim)
{
return s_animFuncs.value(anim);
}
bool isAnimationRegistered(const QString &anim)
{
return s_animFuncs.contains(anim);
}
void addToLoadFailures(const QString &anim)
{
s_animFailures.insert(anim);
}
bool animationFailedToLoad(const QString &anim)
{
return s_animFailures.contains(anim);
}
void clearAnimations()
{
s_animFuncs.clear();
s_animFailures.clear();
delete inst;
inst = 0;
}
QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() > 1) {
const QString name = s_prefix + context->argument(0).toString();
if (!s_animFuncs.contains(name)) {
const QScriptValue func = context->argument(1);
if (func.isFunction()) {
s_animFuncs.insert(name, func);
}
}
}
return engine->undefinedValue();
}
QObject *extractParent(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
return context->thisObject().property("__plasma_javascriptanimation").toQObject();
}
QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = extractParent(context, engine);
if (!parent) {
return engine->undefinedValue();
}
QSequentialAnimationGroup *group = new SequentialAnimationGroup(parent);
return engine->newQObject(group);
}
QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = extractParent(context, engine);
if (!parent) {
return engine->undefinedValue();
}
ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
return engine->newQObject(group);
}
void registerEnums(QScriptValue &scriptValue, const QMetaObject &meta)
{
//manually create enum values. ugh
QScriptEngine *engine = scriptValue.engine();
for (int i = 0; i < meta.enumeratorCount(); ++i) {
QMetaEnum e = meta.enumerator(i);
//kDebug() << e.name();
for (int i=0; i < e.keyCount(); ++i) {
//kDebug() << e.key(i) << e.value(i);
scriptValue.setProperty(e.key(i), QScriptValue(engine, e.value(i)));
}
}
}
QScriptValue animation(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("animation() takes one argument"));
}
QObject *parent = extractParent(context, engine);
QAbstractAnimation *anim = 0;
if (context->argument(0).isString()) {
const QString animName = context->argument(0).toString();
anim = Plasma::Animator::create(animName, parent);
} else {
int animId = context->argument(0).toInt32();
if (animId == JavascriptAnimation::PauseAnimation) {
anim = new QPauseAnimation(parent);
} else if (animId == JavascriptAnimation::PropertyAnimation) {
anim = new QPropertyAnimation(parent);
} else {
anim = Plasma::Animator::create(static_cast<Animator::Animation>(animId), parent);
}
}
if (anim) {
QScriptValue value = engine->newQObject(anim);
registerEnums(value, *anim->metaObject());
return value;
}
return context->throwError(i18n("%1 is not a known animation type", context->argument(0).isString()));
}
QScriptEngine *globalEngine()
{
if (!inst) {
inst = new QScriptEngine;
QScriptValue global = inst->globalObject();
global.setProperty("registerAnimation", inst->newFunction(AnimationScriptEngine::registerAnimation));
global.setProperty("AnimationGroup", inst->newFunction(AnimationScriptEngine::animationGroup));
global.setProperty("ParallelAnimationGroup", inst->newFunction(AnimationScriptEngine::parallelAnimationGroup));
global.setProperty("QEasingCurve", constructEasingCurveClass(inst));
#ifndef NDEBUG
kDebug() << "........... first js animation, creating the engine!";
#endif
}
return inst;
}
bool loadScript(const QString &path, const QString &prefix)
{
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
kError() << "failed to open script file" << path;
return false;
}
QTextStream buffer(&file);
QString tmp(buffer.readAll());
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
engine->pushContext();
s_prefix = prefix;
QScriptValue def(engine->evaluate(tmp, path));
s_prefix.clear();
engine->popContext();
if (engine->hasUncaughtException()) {
const QScriptValue error = engine->uncaughtException();
QString file = error.property("fileName").toString();
const QString failureMsg = QString("Error in %1 on line %2.\n%3")
.arg(file)
.arg(error.property("lineNumber").toString())
.arg(error.toString());
kError() << failureMsg;
return false;
}
return true;
}
} // namespace AnimationEngine
} // namespace Plasma

View File

@ -1,49 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#ifndef __ENGINE__
#define __ENGINE__
#include <QScriptEngine>
#include <QScriptString>
#include <QScriptValue>
#include <QScriptContext>
#include <QDebug>
/* Plasma-shell will have an engine */
namespace Plasma
{
namespace AnimationScriptEngine
{
void clearAnimations();
bool isAnimationRegistered(const QString &anim);
QScriptEngine* globalEngine();
QScriptValue animation(const QString &anim);
bool loadScript(const QString &path, const QString &prefix = QString());
void addToLoadFailures(const QString &anim);
bool animationFailedToLoad(const QString &anim);
}
} // namespace Plasma
#endif

View File

@ -1,93 +0,0 @@
#include "animations/animationscriptengine_p.h"
#include "animator.h"
/**
* Loads an animation from the applet package
* @param animation the animation to load
* @return an Animation object on success, a NULL pointer on failure
* @since 4.5
*/
Animation *loadAnimationFromPackage(const QString &name, QObject *parent);
Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject *parent)
{
if (applet()) {
const QString scopedName = applet()->pluginName() + ":" + name;
if (!AnimationScriptEngine::isAnimationRegistered(scopedName)) {
KConfig conf(applet()->package().path() + "/metadata.desktop", KConfig::SimpleConfig);
KConfigGroup animConf(&conf, "Animations");
QString file;
foreach (const QString &possibleFile, animConf.keyList()) {
const QStringList anims = animConf.readEntry(possibleFile, QStringList());
if (anims.contains(name)) {
file = possibleFile;
break;
}
}
if (file.isEmpty()) {
return 0;
}
const QString path = applet()->package().filePath("animations", file);
if (path.isEmpty()) {
#ifndef NDEBUG
kDebug() << "file path was empty for" << file;
#endif
return 0;
}
if (!AnimationScriptEngine::loadScript(path, applet()->pluginName() + ':') ||
!AnimationScriptEngine::isAnimationRegistered(scopedName)) {
#ifndef NDEBUG
kDebug() << "script engine loading failed for" << path;
#endif
return 0;
}
}
Animation *anim = Animator::create(scopedName, parent ? parent : this);
return anim;
}
return 0;
}
/**
* Factory to build new animation objects from Javascript files. To control their behavior,
* check \ref AbstractAnimation properties.
* @since 4.5
**/
static Plasma::Animation *create(const QString &animationName, QObject *parent = 0);
Plasma::Animation *Animator::create(const QString &anim, QObject *parent)
{
if (AnimationScriptEngine::animationFailedToLoad(anim)) {
return 0;
}
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
const QString path = Theme::defaultTheme()->animationPath(anim);
if (path.isEmpty()) {
AnimationScriptEngine::addToLoadFailures(anim);
//kError() << "************ failed to find script file for animation" << anim;
return 0;
}
if (!AnimationScriptEngine::loadScript(path)) {
AnimationScriptEngine::addToLoadFailures(anim);
return 0;
}
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
//kError() << "successfully loaded script file" << path << ", but did not get animation object for" << anim;
AnimationScriptEngine::addToLoadFailures(anim);
return 0;
}
}
return new Plasma::JavascriptAnimation(anim, parent);
}

View File

@ -1,107 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#include "animationgroup_p.h"
namespace Plasma
{
ParallelAnimationGroup::ParallelAnimationGroup(QObject *parent)
: QParallelAnimationGroup(parent)
{
}
void ParallelAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *ParallelAnimationGroup::animationAt(int index) const
{
return QParallelAnimationGroup::animationAt(index);
}
int ParallelAnimationGroup::animationCount() const
{
return QParallelAnimationGroup::animationCount();
}
void ParallelAnimationGroup::clear()
{
QParallelAnimationGroup::clear();
}
int ParallelAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QParallelAnimationGroup::indexOfAnimation(animation);
}
void ParallelAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
{
QParallelAnimationGroup::insertAnimation(index, animation);
}
void ParallelAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::removeAnimation(animation);
}
SequentialAnimationGroup::SequentialAnimationGroup(QObject *parent)
: QSequentialAnimationGroup(parent)
{
}
void SequentialAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *SequentialAnimationGroup::animationAt(int index) const
{
return QSequentialAnimationGroup::animationAt(index);
}
int SequentialAnimationGroup::animationCount() const
{
return QSequentialAnimationGroup::animationCount();
}
void SequentialAnimationGroup::clear()
{
QSequentialAnimationGroup::clear();
}
int SequentialAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QSequentialAnimationGroup::indexOfAnimation(animation);
}
void SequentialAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
{
QSequentialAnimationGroup::insertAnimation(index, animation);
}
void SequentialAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::removeAnimation(animation);
}
} // namespace Plasma
#include "moc_animationgroup_p.cpp"

View File

@ -1,65 +0,0 @@
/*
* Copyright 2009 Aaron J. Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#ifndef JAVASCRIPTANIMATIONBINDINGS_P_H
#define JAVASCRIPTANIMATIONBINDINGS_P_H
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
namespace Plasma
{
class ParallelAnimationGroup : public QParallelAnimationGroup
{
Q_OBJECT
public:
ParallelAnimationGroup(QObject *parent);
public Q_SLOTS:
void addAnimation(QAbstractAnimation * animation);
QAbstractAnimation *animationAt(int index) const;
int animationCount() const;
void clear();
int indexOfAnimation(QAbstractAnimation *animation) const;
void insertAnimation(int index, QAbstractAnimation * animation);
void removeAnimation(QAbstractAnimation * animation);
};
class SequentialAnimationGroup : public QSequentialAnimationGroup
{
Q_OBJECT
public:
SequentialAnimationGroup(QObject *parent);
public Q_SLOTS:
void addAnimation(QAbstractAnimation * animation);
QAbstractAnimation *animationAt(int index) const;
int animationCount() const;
void clear();
int indexOfAnimation(QAbstractAnimation *animation) const;
void insertAnimation(int index, QAbstractAnimation * animation);
void removeAnimation(QAbstractAnimation * animation);
};
} // namespace Plasma
#endif

View File

@ -1,172 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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.
*/
#include <QEasingCurve>
#include <QMetaEnum>
#include <QScriptValue>
#include <QScriptEngine>
#include <QScriptContext>
#include <QScriptable>
Q_DECLARE_METATYPE(QEasingCurve)
Q_DECLARE_METATYPE(QEasingCurve*)
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \
return ctx->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
}
namespace Plasma
{
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
if (arg.isNumber()) {
qint32 type = arg.toInt32();
if (type > -1 && type < QEasingCurve::Custom) {
return qScriptValueFromValue(eng, QEasingCurve(static_cast<QEasingCurve::Type>(type)));
}
}
}
return qScriptValueFromValue(eng, QEasingCurve());
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, toString);
return QScriptValue(eng, QString::fromLatin1("QEasingCurve(type=%0)").arg(self->type()));
}
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, type);
if (ctx->argumentCount()) {
QScriptValue arg = ctx->argument(0);
qint32 type = -1;
if (arg.isNumber()) {
type = arg.toInt32();
} else if (arg.isString()) {
QMetaObject meta = QEasingCurve::staticMetaObject;
QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type"));
type = easingCurveEnum.keyToValue(arg.toString().toAscii().data());
}
if (type > -1 && type < QEasingCurve::Custom) {
self->setType(static_cast<QEasingCurve::Type>(type));
}
}
return QScriptValue(eng, self->type());
}
static QScriptValue valueForProgress(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, valueForProgress);
if (ctx->argumentCount() < 1 || !ctx->argument(0).isNumber()) {
return eng->undefinedValue();
}
return self->valueForProgress(ctx->argument(0).toNumber());
}
QScriptValue constructEasingCurveClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QEasingCurve());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("type", eng->newFunction(type), getter | setter);
proto.setProperty("toString", eng->newFunction(toString), getter);
proto.setProperty("valueForProgress", eng->newFunction(valueForProgress), getter);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, Linear);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, SineCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, CosineCurve);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve*>(), proto);
return ctorFun;
}
}

View File

@ -1,128 +0,0 @@
/*
* Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#include "javascriptanimation_p.h"
#include <kdebug.h>
#include "animationscriptengine_p.h"
/* TODO:
* - support passing more parameters to the js animation object
* - support more properties: angle, direction, etc
* - support calling a 'resetAnimation' in js class when animation is stopped
*/
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
namespace Plasma
{
JavascriptAnimation::JavascriptAnimation(const QString &name, QObject *parent)
: EasingAnimation(parent),
#ifdef PLASMA_JSANIM_FPS
m_fps(0),
#endif
m_name(name)
{
}
JavascriptAnimation::~JavascriptAnimation()
{
}
void JavascriptAnimation::prepInstance()
{
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
m_instance.setProperty("__plasma_javascriptanimation", engine->newQObject(this),
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, AppearAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, DisappearAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, ActivateAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, GrowAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, PulseAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationStackedAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, SlideAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, GeometryAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, ZoomAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, PixmapTransitionAnimation);
ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PauseAnimation);
ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PropertyAnimation);
}
void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
//kDebug() << ".................. state: " << newState;
if (oldState == Stopped && newState == Running) {
if (!m_method.isFunction()) {
//Define the class and create an instance
m_instance = AnimationScriptEngine::animation(m_name).construct();
#ifndef NDEBUG
kDebug() << "trying for" << m_name << m_instance.isFunction();
#endif
//Get the method of the object
m_method = m_instance.property(QString("updateCurrentTime"));
if (!m_method.isFunction()) {
qDebug() << "**************** ERROR! Name: " << m_name << " ************";
m_instance = m_method = QScriptValue();
} else {
prepInstance();
//TODO: this really should be done in the bindings provided
//Center the widget for transformation
qreal x = targetWidget()->geometry().height()/2;
qreal y = targetWidget()->geometry().width()/2;
targetWidget()->setTransformOriginPoint(x, y);
}
}
if (m_method.isFunction()) {
m_instance.setProperty("duration", duration(), QScriptValue::ReadOnly);
m_instance.setProperty("target", m_instance.engine()->newQObject(targetWidget()), QScriptValue::ReadOnly);
}
#ifdef PLASMA_JSANIM_FPS
m_fps = 0;
} else if (oldState == Running && newState == Stopped) {
#ifndef NDEBUG
kDebug() << ".........." << m_name << " fps: " << m_fps * 1000/duration();
#endif
#endif
}
}
void JavascriptAnimation::updateEffectiveTime(int currentTime)
{
if (m_method.isFunction()) {
#ifdef PLASMA_JSANIM_FPS
++m_fps;
#endif
QScriptValueList args;
args << currentTime;
m_method.call(m_instance, args);
}
}
} //namespace Plasma
#include "moc_javascriptanimation_p.cpp"

View File

@ -1,68 +0,0 @@
/*
* Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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.
*/
#ifndef PLASMA_ANIMATIONS_JS_P_H
#define PLASMA_ANIMATIONS_JS_P_H
#include <QScriptValue>
#include "animator.h"
#include "easinganimation_p.h"
#include "plasma_export.h"
class QString;
class QScriptEngine;
//#define PLASMA_JSANIM_FPS
namespace Plasma
{
class JavascriptAnimation: public EasingAnimation
{
Q_OBJECT
public:
enum { PauseAnimation = Animator::LastAnimation + 1,
PropertyAnimation = Animator::LastAnimation + 2
};
explicit JavascriptAnimation(const QString &name, QObject *parent = 0);
~JavascriptAnimation();
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
void prepInstance();
#ifdef PLASMA_JSANIM_FPS
int m_fps;
#endif
QString m_name;
QScriptValue m_instance;
QScriptValue m_method;
};
}
#endif