Moved all variables from a pimple to data members in pulse
(saves one new/delete operation). svn path=/trunk/KDE/kdelibs/; revision=1060043
This commit is contained in:
parent
253fad3389
commit
6afab7d906
@ -26,25 +26,16 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class PulseAnimationPrivate
|
PulseAnimation::PulseAnimation(QObject *parent)
|
||||||
|
: Animation(parent),
|
||||||
|
zvalue(0), scale(0), mopacity(0), endScale(1.5),
|
||||||
|
under(0)
|
||||||
{
|
{
|
||||||
public :
|
}
|
||||||
PulseAnimationPrivate()
|
|
||||||
: under(0),
|
|
||||||
zvalue(0),
|
|
||||||
scale(0),
|
|
||||||
mopacity(0),
|
|
||||||
endScale(1.5)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~PulseAnimationPrivate()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
QGraphicsWidget *under;
|
|
||||||
qreal zvalue, scale, mopacity;
|
|
||||||
qreal endScale;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
PulseAnimation::~PulseAnimation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||||
{
|
{
|
||||||
@ -58,45 +49,31 @@ void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PulseAnimation::PulseAnimation(QObject *parent)
|
|
||||||
: Animation(parent), d(new PulseAnimationPrivate)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PulseAnimation::~PulseAnimation()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PulseAnimation::setCopy()
|
void PulseAnimation::setCopy()
|
||||||
{
|
{
|
||||||
QGraphicsWidget *target = widgetToAnimate();
|
QGraphicsWidget *target = widgetToAnimate();
|
||||||
/* the parent to an image, the animation will happen on the pixmap copy.
|
/* the parent to an image, the animation will happen on the pixmap copy.
|
||||||
*/
|
*/
|
||||||
ShadowFake *shadow = 0;
|
if (!under)
|
||||||
if (!d->under)
|
under = new ShadowFake;
|
||||||
shadow = new ShadowFake;
|
|
||||||
else
|
|
||||||
shadow = dynamic_cast<ShadowFake*>(d->under);
|
|
||||||
|
|
||||||
shadow->copyTarget(target);
|
under->copyTarget(target);
|
||||||
|
|
||||||
d->zvalue = target->zValue();
|
zvalue = target->zValue();
|
||||||
--d->zvalue;
|
--zvalue;
|
||||||
d->scale = target->scale();
|
scale = target->scale();
|
||||||
|
|
||||||
d->under = shadow;
|
under->setOpacity(mopacity);
|
||||||
d->under->setOpacity(d->mopacity);
|
under->setScale(scale);
|
||||||
d->under->setScale(d->scale);
|
under->setZValue(zvalue);
|
||||||
d->under->setZValue(d->zvalue);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PulseAnimation::resetPulser()
|
void PulseAnimation::resetPulser()
|
||||||
{
|
{
|
||||||
d->under->setOpacity(d->mopacity);
|
under->setOpacity(mopacity);
|
||||||
d->under->setScale(d->scale);
|
under->setScale(scale);
|
||||||
d->under->setZValue(d->zvalue);
|
under->setZValue(zvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -104,12 +81,12 @@ void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (oldState == Stopped && newState == Running) {
|
if (oldState == Stopped && newState == Running) {
|
||||||
if (d->under->size() != widgetToAnimate()->size()) {
|
if (under->size() != widgetToAnimate()->size()) {
|
||||||
setCopy();
|
setCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->under->setOpacity(direction() == Forward ? 1 : 0);
|
under->setOpacity(direction() == Forward ? 1 : 0);
|
||||||
d->under->setScale(direction() == Forward ? d->scale : d->endScale);
|
under->setScale(direction() == Forward ? scale : endScale);
|
||||||
|
|
||||||
} else if (newState == Stopped) {
|
} else if (newState == Stopped) {
|
||||||
resetPulser();
|
resetPulser();
|
||||||
@ -119,10 +96,10 @@ void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
|||||||
|
|
||||||
void PulseAnimation::updateCurrentTime(int currentTime)
|
void PulseAnimation::updateCurrentTime(int currentTime)
|
||||||
{
|
{
|
||||||
QGraphicsWidget *w = d->under;
|
QGraphicsWidget *w = under;
|
||||||
if (w) {
|
if (w) {
|
||||||
qreal delta = currentTime / qreal(duration());
|
qreal delta = currentTime / qreal(duration());
|
||||||
delta = (1 - d->endScale) * delta;
|
delta = (1 - endScale) * delta;
|
||||||
w->setScale(1 - delta);
|
w->setScale(1 - delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class PulseAnimationPrivate;
|
class ShadowFake;
|
||||||
|
|
||||||
class PulseAnimation : public Animation
|
class PulseAnimation : public Animation
|
||||||
{
|
{
|
||||||
@ -46,8 +46,11 @@ protected:
|
|||||||
void setCopy();
|
void setCopy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
qreal zvalue;
|
||||||
PulseAnimationPrivate *d;
|
qreal scale;
|
||||||
|
qreal mopacity;
|
||||||
|
qreal endScale;
|
||||||
|
ShadowFake *under;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user