1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
22
#include <QtCore/QTimeLine>
27
KWIN_EFFECT(scalein, ScaleInEffect)
29
ScaleInEffect::ScaleInEffect()
32
connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*)));
33
connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*)));
36
void ScaleInEffect::prePaintScreen(ScreenPrePaintData& data, int time)
38
if (!mTimeLineWindows.isEmpty())
39
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
40
effects->prePaintScreen(data, time);
43
void ScaleInEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
45
if (mTimeLineWindows.contains(w)) {
46
mTimeLineWindows[ w ]->setCurveShape(QTimeLine::EaseInOutCurve);
47
mTimeLineWindows[ w ]->setCurrentTime(mTimeLineWindows[ w ]->currentTime() + time);
48
if (mTimeLineWindows[ w ]->currentValue() < 1)
49
data.setTransformed();
51
delete mTimeLineWindows.take(w);
53
effects->prePaintWindow(w, data, time);
56
void ScaleInEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
58
if (mTimeLineWindows.contains(w) && isScaleWindow(w)) {
59
const qreal value = mTimeLineWindows[ w ]->currentValue();
60
data.opacity *= value;
63
data.xTranslate += int(w->width() / 2 * (1 - value));
64
data.yTranslate += int(w->height() / 2 * (1 - value));
66
effects->paintWindow(w, mask, region, data);
69
bool ScaleInEffect::isScaleWindow(EffectWindow* w)
71
const void* e = w->data(WindowAddedGrabRole).value<void*>();
72
// TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately?
73
if (w->isPopupMenu() || w->isSpecialWindow() || w->isUtility() || (e && e != this))
78
void ScaleInEffect::postPaintWindow(EffectWindow* w)
80
if (mTimeLineWindows.contains(w))
81
w->addRepaintFull(); // trigger next animation repaint
82
effects->postPaintWindow(w);
85
void ScaleInEffect::slotWindowAdded(EffectWindow* c)
87
if (c->isOnCurrentDesktop()) {
88
mTimeLineWindows.insert(c, new QTimeLine(animationTime(250), this));
93
void ScaleInEffect::slotWindowClosed(EffectWindow* c)
95
delete mTimeLineWindows.take(c);