2 * Copyright 2007 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2 or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "defaultAnimator.h"
22 #include <QGraphicsItem>
27 DefaultAnimator::DefaultAnimator(QObject
*parent
, const QVariantList
& list
)
28 : Plasma::AnimationDriver(parent
)
33 int DefaultAnimator::animationFps(Plasma::Animator::Animation animation
) const
36 case Plasma::Animator::AppearAnimation
:
38 case Plasma::Animator::DisappearAnimation
:
46 int DefaultAnimator::elementAnimationFps(Plasma::Animator::Animation animation
) const
49 case Plasma::Animator::AppearAnimation
:
51 case Plasma::Animator::DisappearAnimation
:
59 void DefaultAnimator::itemAppear(qreal progress
, QGraphicsItem
* item
)
61 //kDebug() << "DefaultAnimator::appear(" << progress << ", " << item << ")";
63 item
->resetTransform();
66 item
->resetTransform();
67 item
->scale(progress
, progress
);
68 QRectF r
= item
->boundingRect();
69 item
->translate(r
.width() / 2 * progress
, r
.height() / 2 * progress
);
72 void DefaultAnimator::itemDisappear(qreal progress
, QGraphicsItem
* item
)
75 //item->resetTransform();
78 item
->resetTransform();
79 item
->scale(1-progress
,1-progress
);
80 QRectF r
= item
->boundingRect();
81 item
->translate(r
.width() / 2 * progress
, r
.height() / 2 * progress
);
84 QPixmap
DefaultAnimator::elementAppear(qreal progress
, const QPixmap
& pixmap
)
86 //kDebug() << progress;
91 alpha
.setAlphaF(progress
);
93 QPainter
painter(&pix
);
94 painter
.setCompositionMode(QPainter::CompositionMode_DestinationIn
);
95 painter
.fillRect(pix
.rect(), alpha
);
101 QPixmap
DefaultAnimator::elementDisappear(qreal progress
, const QPixmap
& pixmap
)
103 //kDebug() << progress;
104 QPixmap pix
= pixmap
;
108 alpha
.setAlphaF(1 - progress
);
110 QPainter
painter(&pix
);
111 painter
.setCompositionMode(QPainter::CompositionMode_DestinationIn
);
112 painter
.fillRect(pix
.rect(), alpha
);
118 #include "defaultAnimator.moc"