Plasma
animator.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2007 Aaron Seigo <aseigo@kde.org> 00003 * 2007 Alexis Ménard <darktears31@gmail.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Library General Public License as 00007 * published by the Free Software Foundation; either version 2, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details 00014 * 00015 * You should have received a copy of the GNU Library General Public 00016 * License along with this program; if not, write to the 00017 * Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef PLASMA_ANIMATOR_H 00022 #define PLASMA_ANIMATOR_H 00023 00024 #include <QtGui/QImage> 00025 #include <QtCore/QObject> 00026 #include <QtCore/QAbstractAnimation> 00027 #include <QtCore/QEasingCurve> 00028 00029 #include <plasma/plasma_export.h> 00030 00031 class QGraphicsItem; 00032 class QGraphicsWidget; 00033 class QTimeLine; 00034 00035 namespace Plasma 00036 { 00037 00038 class AnimatorPrivate; 00039 class Animation; 00040 00046 class PLASMA_EXPORT Animator : public QObject 00047 { 00048 Q_OBJECT 00049 Q_ENUMS(Animation) 00050 Q_ENUMS(CurveShape) 00051 Q_ENUMS(Movement) 00052 00053 public: 00054 00055 enum Animation { 00056 AppearAnimation = 0, /*<< Animate the appearance of an element */ 00057 DisappearAnimation, /*<< Animate the disappearance of an element */ 00058 ActivateAnimation, /*<< When something is activated or launched, 00059 such as an app icon being clicked */ 00060 FadeAnimation, /*<< Can be used for both fade in and out */ 00061 GrowAnimation, /*<< Grow animated object geometry */ 00062 PulseAnimation, /*<< Pulse animated object (opacity/geometry/scale) */ 00063 RotationAnimation, /*<< Rotate an animated object */ 00064 RotationStackedAnimation, /*<< for flipping one object with another */ 00065 SlideAnimation, /*<< Move the position of animated object */ 00066 GeometryAnimation, /*<< Geometry animation*/ 00067 ZoomAnimation, /*<<Zoom animation */ 00068 PixmapTransitionAnimation, /*<< Transition between two pixmaps*/ 00069 WaterAnimation /*<< Water animation using ripple effect */, 00070 LastAnimation = 1024 00071 }; 00072 00073 enum CurveShape { 00074 EaseInCurve = 0, 00075 EaseOutCurve, 00076 EaseInOutCurve, 00077 LinearCurve, 00078 PendularCurve 00079 }; 00080 00081 enum Movement { 00082 SlideInMovement = 0, 00083 SlideOutMovement, 00084 FastSlideInMovement, 00085 FastSlideOutMovement 00086 }; 00087 00091 #ifndef KDE_NO_DEPRECATED 00092 static KDE_DEPRECATED Animator *self(); 00093 #endif 00094 00100 static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0); 00101 00107 static Plasma::Animation *create(const QString &animationName, QObject *parent = 0); 00108 00113 static QEasingCurve create(Animator::CurveShape type); 00114 00123 #ifndef KDE_NO_DEPRECATED 00124 KDE_DEPRECATED Q_INVOKABLE int animateItem(QGraphicsItem *item,Animation anim); 00125 #endif 00126 00135 #ifndef KDE_NO_DEPRECATED 00136 KDE_DEPRECATED Q_INVOKABLE void stopItemAnimation(int id); 00137 #endif 00138 00147 #ifndef KDE_NO_DEPRECATED 00148 KDE_DEPRECATED Q_INVOKABLE int moveItem(QGraphicsItem *item, Movement movement, const QPoint &destination); 00149 #endif 00150 00159 #ifndef KDE_NO_DEPRECATED 00160 KDE_DEPRECATED Q_INVOKABLE void stopItemMovement(int id); 00161 #endif 00162 00181 #ifndef KDE_NO_DEPRECATED 00182 KDE_DEPRECATED Q_INVOKABLE int customAnimation(int frames, int duration, 00183 Animator::CurveShape curve, QObject *receiver, const char *method); 00184 #endif 00185 00194 #ifndef KDE_NO_DEPRECATED 00195 KDE_DEPRECATED Q_INVOKABLE void stopCustomAnimation(int id); 00196 #endif 00197 00198 #ifndef KDE_NO_DEPRECATED 00199 KDE_DEPRECATED Q_INVOKABLE int animateElement(QGraphicsItem *obj, Animation); 00200 #endif 00201 #ifndef KDE_NO_DEPRECATED 00202 KDE_DEPRECATED Q_INVOKABLE void stopElementAnimation(int id); 00203 #endif 00204 #ifndef KDE_NO_DEPRECATED 00205 KDE_DEPRECATED Q_INVOKABLE void setInitialPixmap(int id, const QPixmap &pixmap); 00206 #endif 00207 #ifndef KDE_NO_DEPRECATED 00208 KDE_DEPRECATED Q_INVOKABLE QPixmap currentPixmap(int id); 00209 #endif 00210 00218 #ifndef KDE_NO_DEPRECATED 00219 KDE_DEPRECATED Q_INVOKABLE bool isAnimating() const; 00220 #endif 00221 00230 #ifndef KDE_NO_DEPRECATED 00231 KDE_DEPRECATED void registerScrollingManager(QGraphicsWidget *widget); 00232 #endif 00233 00241 #ifndef KDE_NO_DEPRECATED 00242 KDE_DEPRECATED void unregisterScrollingManager(QGraphicsWidget *widget); 00243 #endif 00244 00245 Q_SIGNALS: 00246 void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim); 00247 void movementFinished(QGraphicsItem *item); 00248 void elementAnimationFinished(int id); 00249 void customAnimationFinished(int id); 00250 #ifndef KDE_NO_DEPRECATED 00251 KDE_DEPRECATED void scrollStateChanged(QGraphicsWidget *widget, QAbstractAnimation::State newState, 00252 QAbstractAnimation::State oldState); 00253 #endif 00254 00255 #ifndef KDE_NO_DEPRECATED 00256 protected: 00257 void timerEvent(QTimerEvent *event); 00258 #endif 00259 00260 private: 00261 #ifndef KDE_NO_DEPRECATED 00262 friend class AnimatorSingleton; 00263 explicit Animator(QObject * parent = 0); 00264 ~Animator(); 00265 00266 Q_PRIVATE_SLOT(d, void animatedItemDestroyed(QObject*)) 00267 Q_PRIVATE_SLOT(d, void movingItemDestroyed(QObject*)) 00268 Q_PRIVATE_SLOT(d, void animatedElementDestroyed(QObject*)) 00269 Q_PRIVATE_SLOT(d, void customAnimReceiverDestroyed(QObject*)) 00270 Q_PRIVATE_SLOT(d, void scrollStateChanged(QAbstractAnimation::State, 00271 QAbstractAnimation::State)) 00272 #else 00273 Animator(); 00274 #endif 00275 00276 friend class AnimatorPrivate; 00277 AnimatorPrivate * const d; 00278 }; 00279 00280 } // namespace Plasma 00281 00282 #endif 00283
KDE 4.6 API Reference