From aa5f74730517b2a65db141abd769731f73679e67 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Thu, 24 Apr 2008 23:21:17 +0000 Subject: [PATCH] API REVIEW: Phase -> AnimatorDriver svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800840 --- animator.cpp | 28 ++++++++-------- animator.h | 18 +++++----- applethandle.cpp | 6 ++-- containment.cpp | 16 ++++----- containment.h | 2 +- desktoptoolbox.cpp | 20 +++++------ paneltoolbox.cpp | 20 +++++------ phase.cpp | 82 +++++++++++++++++++++++----------------------- phase.h | 16 ++++----- widgets/icon.cpp | 20 +++++------ 10 files changed, 114 insertions(+), 114 deletions(-) diff --git a/animator.cpp b/animator.cpp index c402cff39..5967cea57 100644 --- a/animator.cpp +++ b/animator.cpp @@ -36,34 +36,34 @@ Animator::~Animator() { } -int Animator::animationFPS(Plasma::Phase::Animation animation) const +int Animator::animationFPS(Plasma::AnimationDriver::Animation animation) const { Q_UNUSED(animation) return 0; } -int Animator::movementAnimationFPS(Plasma::Phase::Movement movement) const +int Animator::movementAnimationFPS(Plasma::AnimationDriver::Movement movement) const { Q_UNUSED(movement) return 20; } -int Animator::elementAnimationFPS(Plasma::Phase::Animation animation) const +int Animator::elementAnimationFPS(Plasma::AnimationDriver::Animation animation) const { Q_UNUSED(animation) return 0; } -int Animator::animationDuration(Plasma::Phase::Animation) const +int Animator::animationDuration(Plasma::AnimationDriver::Animation) const { return 200; } -int Animator::movementAnimationDuration(Plasma::Phase::Movement movement) const +int Animator::movementAnimationDuration(Plasma::AnimationDriver::Movement movement) const { switch (movement) { - case Phase::FastSlideInMovement: - case Phase::FastSlideOutMovement: + case AnimationDriver::FastSlideInMovement: + case AnimationDriver::FastSlideOutMovement: return 100; break; default: @@ -73,24 +73,24 @@ int Animator::movementAnimationDuration(Plasma::Phase::Movement movement) const return 270; } -int Animator::elementAnimationDuration(Plasma::Phase::Animation) const +int Animator::elementAnimationDuration(Plasma::AnimationDriver::Animation) const { return 333; } -Phase::CurveShape Animator::animationCurve(Plasma::Phase::Animation) const +AnimationDriver::CurveShape Animator::animationCurve(Plasma::AnimationDriver::Animation) const { - return Phase::EaseInOutCurve; + return AnimationDriver::EaseInOutCurve; } -Phase::CurveShape Animator::movementAnimationCurve(Plasma::Phase::Movement) const +AnimationDriver::CurveShape Animator::movementAnimationCurve(Plasma::AnimationDriver::Movement) const { - return Phase::EaseInOutCurve; + return AnimationDriver::EaseInOutCurve; } -Phase::CurveShape Animator::elementAnimationCurve(Plasma::Phase::Animation) const +AnimationDriver::CurveShape Animator::elementAnimationCurve(Plasma::AnimationDriver::Animation) const { - return Phase::EaseInOutCurve; + return AnimationDriver::EaseInOutCurve; } QPixmap Animator::elementAppear(qreal progress, const QPixmap& pixmap) diff --git a/animator.h b/animator.h index eae65c7ac..c30a8b98f 100644 --- a/animator.h +++ b/animator.h @@ -44,15 +44,15 @@ public: ~Animator(); // Parameter definitions - virtual int animationFPS(Plasma::Phase::Animation) const; - virtual int movementAnimationFPS(Plasma::Phase::Movement) const; - virtual int elementAnimationFPS(Plasma::Phase::Animation) const; - virtual int animationDuration(Plasma::Phase::Animation) const; - virtual int movementAnimationDuration(Plasma::Phase::Movement) const; - virtual int elementAnimationDuration(Plasma::Phase::Animation) const; - virtual Phase::CurveShape animationCurve(Plasma::Phase::Animation) const; - virtual Phase::CurveShape movementAnimationCurve(Plasma::Phase::Movement) const; - virtual Phase::CurveShape elementAnimationCurve(Plasma::Phase::Animation) const; + virtual int animationFPS(Plasma::AnimationDriver::Animation) const; + virtual int movementAnimationFPS(Plasma::AnimationDriver::Movement) const; + virtual int elementAnimationFPS(Plasma::AnimationDriver::Animation) const; + virtual int animationDuration(Plasma::AnimationDriver::Animation) const; + virtual int movementAnimationDuration(Plasma::AnimationDriver::Movement) const; + virtual int elementAnimationDuration(Plasma::AnimationDriver::Animation) const; + virtual AnimationDriver::CurveShape animationCurve(Plasma::AnimationDriver::Animation) const; + virtual AnimationDriver::CurveShape movementAnimationCurve(Plasma::AnimationDriver::Movement) const; + virtual AnimationDriver::CurveShape elementAnimationCurve(Plasma::AnimationDriver::Animation) const; // Element animations virtual QPixmap elementAppear(qreal progress, const QPixmap& pixmap); diff --git a/applethandle.cpp b/applethandle.cpp index 5d9d4a263..b9f2bd7e1 100644 --- a/applethandle.cpp +++ b/applethandle.cpp @@ -330,7 +330,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) case RemoveButton: if (m_pressedButton == releasedAtButton) { forceDisappear(); - Phase::self()->animateItem(m_applet, Phase::DisappearAnimation); + AnimationDriver::self()->animateItem(m_applet, AnimationDriver::DisappearAnimation); } break; case MoveButton: { @@ -615,7 +615,7 @@ void AppletHandle::appletResized() void AppletHandle::startFading(FadeType anim) { if (m_animId != 0) { - Phase::self()->stopCustomAnimation(m_animId); + AnimationDriver::self()->stopCustomAnimation(m_animId); } m_anim = anim; @@ -638,7 +638,7 @@ void AppletHandle::startFading(FadeType anim) time *= m_opacity; } - m_animId = Phase::self()->customAnimation(40, (int)time, Phase::EaseInOutCurve, this, "fadeAnimation"); + m_animId = AnimationDriver::self()->customAnimation(40, (int)time, AnimationDriver::EaseInOutCurve, this, "fadeAnimation"); } void AppletHandle::forceDisappear() diff --git a/containment.cpp b/containment.cpp index 5827dbc1c..16609503f 100644 --- a/containment.cpp +++ b/containment.cpp @@ -192,9 +192,9 @@ void Containment::init() setAcceptDrops(true); setAcceptsHoverEvents(true); - //TODO: would be nice to not do this on init, as it causes Phase to init - connect(Phase::self(), SIGNAL(animationComplete(QGraphicsItem*,Plasma::Phase::Animation)), - this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Phase::Animation))); + //TODO: would be nice to not do this on init, as it causes AnimationDriver to init + connect(AnimationDriver::self(), SIGNAL(animationComplete(QGraphicsItem*,Plasma::AnimationDriver::Animation)), + this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::AnimationDriver::Animation))); if (d->type == NoContainmentType) { setContainmentType(DesktopContainment); @@ -497,7 +497,7 @@ void Containment::destroyApplet() } Applet *applet = qobject_cast(action->data().value()); - Phase::self()->animateItem(applet, Phase::DisappearAnimation); + AnimationDriver::self()->animateItem(applet, AnimationDriver::DisappearAnimation); } void Containment::setFormFactor(FormFactor formFactor) @@ -756,7 +756,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) } } else { applet->init(); - Phase::self()->animateItem(applet, Phase::AppearAnimation); + AnimationDriver::self()->animateItem(applet, AnimationDriver::AppearAnimation); } applet->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint); @@ -790,9 +790,9 @@ void Containment::appletDestroyed(QObject* object) emit configNeedsSaving(); } -void Containment::appletAnimationComplete(QGraphicsItem *item, Plasma::Phase::Animation anim) +void Containment::appletAnimationComplete(QGraphicsItem *item, Plasma::AnimationDriver::Animation anim) { - if (anim == Phase::DisappearAnimation) { + if (anim == AnimationDriver::DisappearAnimation) { QGraphicsItem *parent = item->parentItem(); while (parent) { @@ -808,7 +808,7 @@ void Containment::appletAnimationComplete(QGraphicsItem *item, Plasma::Phase::An parent = parent->parentItem(); } - } else if (anim == Phase::AppearAnimation) { + } else if (anim == AnimationDriver::AppearAnimation) { if (containmentType() == DesktopContainment && item->parentItem() == this && qgraphicsitem_cast(item)) { diff --git a/containment.h b/containment.h index 484419229..82996787b 100644 --- a/containment.h +++ b/containment.h @@ -397,7 +397,7 @@ class PLASMA_EXPORT Containment : public Applet * @internal */ void appletDestroyed(QObject*); - void appletAnimationComplete(QGraphicsItem *item, Plasma::Phase::Animation anim); + void appletAnimationComplete(QGraphicsItem *item, Plasma::AnimationDriver::Animation anim); void dropEvent(QGraphicsSceneDragDropEvent* event); private Q_SLOTS: diff --git a/desktoptoolbox.cpp b/desktoptoolbox.cpp index a6fe14850..dff673d8f 100644 --- a/desktoptoolbox.cpp +++ b/desktoptoolbox.cpp @@ -97,7 +97,7 @@ DesktopToolbox::DesktopToolbox(QGraphicsItem *parent) : Toolbox(parent), d(new Private) { - connect(Plasma::Phase::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*))); + connect(Plasma::AnimationDriver::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*))); setZValue(10000000); setFlag(ItemClipsToShape, true); @@ -206,7 +206,7 @@ void DesktopToolbox::showToolbox() const int iconWidth = 32; int x = (int)boundingRect().left() - maxwidth - iconWidth - 5; int y = (int)boundingRect().top() + 5; - Plasma::Phase* phase = Plasma::Phase::self(); + Plasma::AnimationDriver* animdriver = Plasma::AnimationDriver::self(); foreach (QGraphicsItem* tool, QGraphicsItem::children()) { if (tool == d->toolBacker) { continue; @@ -215,14 +215,14 @@ void DesktopToolbox::showToolbox() if (!tool->isEnabled()) { if (tool->isVisible()) { const int height = static_cast(tool->boundingRect().height()); - phase->moveItem(tool, Plasma::Phase::SlideOutMovement, QPoint(size() * 2, -height)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideOutMovement, QPoint(size() * 2, -height)); } continue; } //kDebug() << "let's show and move" << tool << tool->boundingRect(); tool->show(); - phase->moveItem(tool, Plasma::Phase::SlideInMovement, QPoint(x, y)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideInMovement, QPoint(x, y)); //x += 0; y += static_cast(tool->boundingRect().height()) + 5; } @@ -234,13 +234,13 @@ void DesktopToolbox::showToolbox() d->toolBacker->show(); if (d->animId) { - phase->stopCustomAnimation(d->animId); + animdriver->stopCustomAnimation(d->animId); } setShowing(true); // TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to // match whatever the time is that moveItem() takes. Same in hoverLeaveEvent(). - d->animId = phase->customAnimation(10, 240, Plasma::Phase::EaseInCurve, this, "animate"); + d->animId = animdriver->customAnimation(10, 240, Plasma::AnimationDriver::EaseInCurve, this, "animate"); d->stopwatch.restart(); } @@ -264,22 +264,22 @@ void DesktopToolbox::hideToolbox() int x = size() * 2; int y = 0; - Plasma::Phase* phase = Plasma::Phase::self(); + Plasma::AnimationDriver* animdriver = Plasma::AnimationDriver::self(); foreach (QGraphicsItem* tool, QGraphicsItem::children()) { if (tool == d->toolBacker) { continue; } const int height = static_cast(tool->boundingRect().height()); - phase->moveItem(tool, Plasma::Phase::SlideOutMovement, QPoint(x, y-height)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideOutMovement, QPoint(x, y-height)); } if (d->animId) { - phase->stopCustomAnimation(d->animId); + animdriver->stopCustomAnimation(d->animId); } setShowing(false); - d->animId = phase->customAnimation(10, 240, Plasma::Phase::EaseOutCurve, this, "animate"); + d->animId = animdriver->customAnimation(10, 240, Plasma::AnimationDriver::EaseOutCurve, this, "animate"); if (d->toolBacker) { d->toolBacker->hide(); diff --git a/paneltoolbox.cpp b/paneltoolbox.cpp index c88681441..e56ac16af 100644 --- a/paneltoolbox.cpp +++ b/paneltoolbox.cpp @@ -96,7 +96,7 @@ PanelToolbox::PanelToolbox(QGraphicsItem *parent) : Toolbox(parent), d(new Private) { - connect(Plasma::Phase::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*))); + connect(Plasma::AnimationDriver::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*))); setZValue(10000000); setFlag(ItemClipsToShape, true); @@ -231,7 +231,7 @@ void PanelToolbox::showToolbox() const int iconWidth = 32; int x = size()*2 - maxwidth - iconWidth - 5; int y = 5; // pos().y(); - Plasma::Phase* phase = Plasma::Phase::self(); + Plasma::AnimationDriver* animdriver = Plasma::AnimationDriver::self(); foreach (QGraphicsItem* tool, QGraphicsItem::children()) { if (tool == d->toolBacker) { continue; @@ -240,14 +240,14 @@ void PanelToolbox::showToolbox() if (!tool->isEnabled()) { if (tool->isVisible()) { const int height = static_cast(tool->boundingRect().height()); - phase->moveItem(tool, Plasma::Phase::SlideOutMovement, QPoint(size() * 2, -height)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideOutMovement, QPoint(size() * 2, -height)); } continue; } //kDebug() << "let's show and move" << tool << tool->boundingRect(); tool->show(); - phase->moveItem(tool, Plasma::Phase::SlideInMovement, QPoint(x, y)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideInMovement, QPoint(x, y)); //x += 0; y += static_cast(tool->boundingRect().height()) + 5; } @@ -259,13 +259,13 @@ void PanelToolbox::showToolbox() d->toolBacker->show(); if (d->animId) { - phase->stopCustomAnimation(d->animId); + animdriver->stopCustomAnimation(d->animId); } setShowing(true); // TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to // match whatever the time is that moveItem() takes. Same in hoverLeaveEvent(). - d->animId = phase->customAnimation(10, 240, Plasma::Phase::EaseInCurve, this, "animate"); + d->animId = animdriver->customAnimation(10, 240, Plasma::AnimationDriver::EaseInCurve, this, "animate"); d->stopwatch.restart(); } @@ -289,22 +289,22 @@ void PanelToolbox::hideToolbox() int x = size() * 2; int y = 0; - Plasma::Phase* phase = Plasma::Phase::self(); + Plasma::AnimationDriver* animdriver = Plasma::AnimationDriver::self(); foreach (QGraphicsItem* tool, QGraphicsItem::children()) { if (tool == d->toolBacker) { continue; } const int height = static_cast(tool->boundingRect().height()); - phase->moveItem(tool, Plasma::Phase::SlideOutMovement, QPoint(x, y-height)); + animdriver->moveItem(tool, Plasma::AnimationDriver::SlideOutMovement, QPoint(x, y-height)); } if (d->animId) { - phase->stopCustomAnimation(d->animId); + animdriver->stopCustomAnimation(d->animId); } setShowing(false); - d->animId = phase->customAnimation(10, 240, Plasma::Phase::EaseOutCurve, this, "animate"); + d->animId = animdriver->customAnimation(10, 240, Plasma::AnimationDriver::EaseOutCurve, this, "animate"); if (d->toolBacker) { d->toolBacker->hide(); diff --git a/phase.cpp b/phase.cpp index a3520736d..2900fca95 100644 --- a/phase.cpp +++ b/phase.cpp @@ -39,8 +39,8 @@ struct AnimationState { QGraphicsItem *item; QObject *qobj; - Phase::Animation animation; - Phase::CurveShape curve; + AnimationDriver::Animation animation; + AnimationDriver::CurveShape curve; int interval; int currentInterval; int frames; @@ -51,8 +51,8 @@ struct ElementAnimationState { QGraphicsItem *item; QObject *qobj; - Phase::CurveShape curve; - Phase::Animation animation; + AnimationDriver::CurveShape curve; + AnimationDriver::Animation animation; int interval; int currentInterval; int frames; @@ -65,8 +65,8 @@ struct MovementState { QGraphicsItem *item; QObject *qobj; - Phase::CurveShape curve; - Phase::Movement movement; + AnimationDriver::CurveShape curve; + AnimationDriver::Movement movement; int interval; int currentInterval; int frames; @@ -77,7 +77,7 @@ struct MovementState struct CustomAnimationState { - Phase::CurveShape curve; + AnimationDriver::CurveShape curve; int frames; int currentFrame; int interval; @@ -87,7 +87,7 @@ struct CustomAnimationState char* slot; }; -class Phase::Private +class AnimationDriver::Private { public: @@ -130,16 +130,16 @@ class Phase::Private void performAnimation(qreal amount, const AnimationState* state) { switch (state->animation) { - case Phase::AppearAnimation: + case AnimationDriver::AppearAnimation: animator->itemAppear(amount, state->item); break; - case Phase::DisappearAnimation: + case AnimationDriver::DisappearAnimation: animator->itemDisappear(amount, state->item); if (amount >= 1) { state->item->hide(); } break; - case Phase::ActivateAnimation: + case AnimationDriver::ActivateAnimation: animator->itemActivated(amount, state->item); break; } @@ -148,13 +148,13 @@ class Phase::Private void performMovement(qreal amount, const MovementState* state) { switch (state->movement) { - case Phase::SlideInMovement: - case Phase::FastSlideInMovement: + case AnimationDriver::SlideInMovement: + case AnimationDriver::FastSlideInMovement: //kDebug() << "performMovement, SlideInMovement"; animator->itemSlideIn(amount, state->item, state->start, state->destination); break; - case Phase::SlideOutMovement: - case Phase::FastSlideOutMovement: + case AnimationDriver::SlideOutMovement: + case AnimationDriver::FastSlideOutMovement: //kDebug() << "performMovement, SlideOutMovement"; animator->itemSlideOut(amount, state->item, state->start, state->destination); break; @@ -175,33 +175,33 @@ class Phase::Private QMap customAnims; }; -class PhaseSingleton +class AnimationDriverSingleton { public: - Phase self; + AnimationDriver self; }; -K_GLOBAL_STATIC( PhaseSingleton, privateSelf ) +K_GLOBAL_STATIC( AnimationDriverSingleton, privateSelf ) -Phase* Phase::self() +AnimationDriver* AnimationDriver::self() { return &privateSelf->self; } -Phase::Phase(QObject * parent) +AnimationDriver::AnimationDriver(QObject * parent) : QObject(parent), d(new Private) { init(); } -Phase::~Phase() +AnimationDriver::~AnimationDriver() { delete d; } -void Phase::animatedItemDestroyed(QObject* o) +void AnimationDriver::animatedItemDestroyed(QObject* o) { //kDebug() << "testing for" << (void*)o; QMutableMapIterator it(d->animatedItems); @@ -216,7 +216,7 @@ void Phase::animatedItemDestroyed(QObject* o) } } -void Phase::movingItemDestroyed(QObject* o) +void AnimationDriver::movingItemDestroyed(QObject* o) { QMutableMapIterator it(d->movingItems); while (it.hasNext()) { @@ -228,7 +228,7 @@ void Phase::movingItemDestroyed(QObject* o) } } -void Phase::animatedElementDestroyed(QObject* o) +void AnimationDriver::animatedElementDestroyed(QObject* o) { QMutableMapIterator it(d->animatedElements); while (it.hasNext()) { @@ -240,7 +240,7 @@ void Phase::animatedElementDestroyed(QObject* o) } } -void Phase::customAnimReceiverDestroyed(QObject* o) +void AnimationDriver::customAnimReceiverDestroyed(QObject* o) { QMutableMapIterator it(d->customAnims); while (it.hasNext()) { @@ -252,7 +252,7 @@ void Phase::customAnimReceiverDestroyed(QObject* o) } } -void Phase::animateItem(QGraphicsItem* item, Animation animation) +void AnimationDriver::animateItem(QGraphicsItem* item, Animation animation) { //kDebug(); // get rid of any existing animations on this item. @@ -298,7 +298,7 @@ void Phase::animateItem(QGraphicsItem* item, Animation animation) } } -void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination) +void AnimationDriver::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination) { //kDebug(); QMap::iterator it = d->movingItems.find(item); @@ -342,7 +342,7 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti } } -int Phase::customAnimation(int frames, int duration, Phase::CurveShape curve, +int AnimationDriver::customAnimation(int frames, int duration, AnimationDriver::CurveShape curve, QObject* receiver, const char* slot) { if (frames < 1 || duration < 1 || !receiver || !slot) { @@ -378,7 +378,7 @@ int Phase::customAnimation(int frames, int duration, Phase::CurveShape curve, return state->id; } -void Phase::stopCustomAnimation(int id) +void AnimationDriver::stopCustomAnimation(int id) { QMap::iterator it = d->customAnims.find(id); if (it != d->customAnims.end()) { @@ -389,7 +389,7 @@ void Phase::stopCustomAnimation(int id) //kDebug() << "stopCustomAnimation(AnimId " << id << ") done"; } -int Phase::animateElement(QGraphicsItem *item, Animation animation) +int AnimationDriver::animateElement(QGraphicsItem *item, Animation animation) { //kDebug() << "startElementAnimation(AnimId " << animation << ")"; ElementAnimationState *state = new ElementAnimationState; @@ -430,7 +430,7 @@ int Phase::animateElement(QGraphicsItem *item, Animation animation) return state->id; } -void Phase::stopElementAnimation(int id) +void AnimationDriver::stopElementAnimation(int id) { QMap::iterator it = d->animatedElements.find(id); if (it != d->animatedElements.end()) { @@ -440,33 +440,33 @@ void Phase::stopElementAnimation(int id) //kDebug() << "stopElementAnimation(AnimId " << id << ") done"; } -void Phase::setInitialPixmap(int id, const QPixmap &pixmap) +void AnimationDriver::setInitialPixmap(int id, const QPixmap &pixmap) { QMap::iterator it = d->animatedElements.find(id); if (it == d->animatedElements.end()) { - kDebug() << "Phase::setInitialPixmap(" << id << ") found no entry for it!"; + kDebug() << "AnimationDriver::setInitialPixmap(" << id << ") found no entry for it!"; return; } it.value()->pixmap = pixmap; } -QPixmap Phase::currentPixmap(int id) +QPixmap AnimationDriver::currentPixmap(int id) { QMap::const_iterator it = d->animatedElements.find(id); if (it == d->animatedElements.constEnd()) { - //kDebug() << "Phase::currentPixmap(" << id << ") found no entry for it!"; + //kDebug() << "AnimationDriver::currentPixmap(" << id << ") found no entry for it!"; return QPixmap(); } ElementAnimationState* state = it.value(); qreal progress = state->frames; - //kDebug() << "Phase::currentPixmap(" << id << " at " << progress; + //kDebug() << "AnimationDriver::currentPixmap(" << id << " at " << progress; progress = state->currentFrame / progress; progress = qMin(qreal(1.0), qMax(qreal(0.0), progress)); - //kDebug() << "Phase::currentPixmap(" << id << " at " << progress; + //kDebug() << "AnimationDriver::currentPixmap(" << id << " at " << progress; switch (state->animation) { case AppearAnimation: @@ -480,7 +480,7 @@ QPixmap Phase::currentPixmap(int id) return state->pixmap; } -bool Phase::isAnimating() const +bool AnimationDriver::isAnimating() const { return (!d->animatedItems.isEmpty() || !d->movingItems.isEmpty() || @@ -488,7 +488,7 @@ bool Phase::isAnimating() const !d->customAnims.isEmpty()); } -void Phase::timerEvent(QTimerEvent *event) +void AnimationDriver::timerEvent(QTimerEvent *event) { Q_UNUSED(event) bool animationsRemain = false; @@ -616,10 +616,10 @@ void Phase::timerEvent(QTimerEvent *event) } } -void Phase::init() +void AnimationDriver::init() { KConfig c("plasmarc"); - KConfigGroup cg(&c, "Phase"); + KConfigGroup cg(&c, "AnimationDriver"); QString pluginName = cg.readEntry("animator", "default"); if (!pluginName.isEmpty()) { diff --git a/phase.h b/phase.h index c45ccced5..b613b72e9 100644 --- a/phase.h +++ b/phase.h @@ -18,8 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef PHASE_H -#define PHASE_H +#ifndef ANIMATIONCONTROLLER_H +#define ANIMATIONCONTROLLER_H #include #include @@ -35,7 +35,7 @@ namespace Plasma /** * @short A system for applying effects to Plasma elements */ -class PLASMA_EXPORT Phase : public QObject +class PLASMA_EXPORT AnimationDriver : public QObject { Q_OBJECT Q_ENUMS( Animation ) @@ -70,10 +70,10 @@ public: /** * Singleton accessor **/ - static Phase* self(); + static AnimationDriver* self(); - explicit Phase(QObject * parent = 0); - ~Phase(); + explicit AnimationDriver(QObject * parent = 0); + ~AnimationDriver(); Q_INVOKABLE void animateItem(QGraphicsItem* item, Animation anim); Q_INVOKABLE void moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination); @@ -92,7 +92,7 @@ public: * * @return an id that can be used to identify this animation. */ - Q_INVOKABLE int customAnimation(int frames, int duration, Phase::CurveShape curve, + Q_INVOKABLE int customAnimation(int frames, int duration, AnimationDriver::CurveShape curve, QObject* receiver, const char* method); /** @@ -118,7 +118,7 @@ public: Q_INVOKABLE bool isAnimating() const; Q_SIGNALS: - void animationFinished(QGraphicsItem *item, Plasma::Phase::Animation anim); + void animationFinished(QGraphicsItem *item, Plasma::AnimationDriver::Animation anim); void movementFinished(QGraphicsItem *item); void elementAnimationFinished(int id); void customAnimationFinished(int id); diff --git a/widgets/icon.cpp b/widgets/icon.cpp index 3236b1b4b..1eb01f7fc 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -97,26 +97,26 @@ IconAction::IconAction(Icon* icon, QAction *action) void IconAction::show() { if (m_animationId) { - Phase::self()->stopElementAnimation(m_animationId); + AnimationDriver::self()->stopElementAnimation(m_animationId); } rebuildPixmap(); - m_animationId = Phase::self()->animateElement(m_icon, Phase::AppearAnimation); - Phase::self()->setInitialPixmap(m_animationId, m_pixmap); + m_animationId = AnimationDriver::self()->animateElement(m_icon, AnimationDriver::AppearAnimation); + AnimationDriver::self()->setInitialPixmap(m_animationId, m_pixmap); m_visible = true; } void IconAction::hide() { if (m_animationId) { - Phase::self()->stopElementAnimation(m_animationId); + AnimationDriver::self()->stopElementAnimation(m_animationId); } rebuildPixmap(); - m_animationId = Phase::self()->animateElement(m_icon, Phase::DisappearAnimation); - Phase::self()->setInitialPixmap(m_animationId, m_pixmap); + m_animationId = AnimationDriver::self()->animateElement(m_icon, AnimationDriver::DisappearAnimation); + AnimationDriver::self()->setInitialPixmap(m_animationId, m_pixmap); m_visible = false; } @@ -247,7 +247,7 @@ void IconAction::paint(QPainter *painter) const return; } - QPixmap animPixmap = Phase::self()->currentPixmap(m_animationId); + QPixmap animPixmap = AnimationDriver::self()->currentPixmap(m_animationId); if (m_visible && animPixmap.isNull()) { painter->drawPixmap(m_rect.toRect(), m_pixmap); @@ -485,10 +485,10 @@ void Icon::hoverEffect(bool show) const int FadeInDuration = 150; if (d->m_hoverAnimId != -1) { - Phase::self()->stopCustomAnimation(d->m_hoverAnimId); + AnimationDriver::self()->stopCustomAnimation(d->m_hoverAnimId); } - d->m_hoverAnimId = Phase::self()->customAnimation(40 / (1000 / FadeInDuration), FadeInDuration, - Phase::EaseOutCurve, this, + d->m_hoverAnimId = AnimationDriver::self()->customAnimation(40 / (1000 / FadeInDuration), FadeInDuration, + AnimationDriver::EaseOutCurve, this, "hoverAnimationUpdate"); }