parent
dd8cf0b678
commit
ed955e9488
7 changed files with 80 additions and 174 deletions
@ -1,12 +1 @@ |
||||
####################################### |
||||
# Effect |
||||
|
||||
# Source files |
||||
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} |
||||
scalein/scalein.cpp |
||||
) |
||||
|
||||
# .desktop files |
||||
install( FILES |
||||
scalein/scalein.desktop |
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) |
||||
add_subdirectory( package ) |
||||
|
||||
@ -0,0 +1,6 @@ |
||||
install(DIRECTORY contents DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_scalein) |
||||
install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_scalein) |
||||
|
||||
install(FILES metadata.desktop |
||||
DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} |
||||
RENAME kwin4_effect_scalein.desktop) |
||||
@ -0,0 +1,65 @@ |
||||
/******************************************************************** |
||||
KWin - the KDE window manager |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2013 Kai Uwe Broulik <kde@privat.broulik.de> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
/*global effect, effects, animate, animationTime, Effect, QEasingCurve */ |
||||
var scaleInEffect = { |
||||
duration: animationTime(250), |
||||
loadConfig: function () { |
||||
"use strict"; |
||||
scaleInEffect.duration = animationTime(250); |
||||
}, |
||||
isScaleWindow: function (window) { |
||||
"use strict"; |
||||
if (window.popupMenu || window.specialWindow || window.utility || |
||||
effect.isGrabbed(window, Effect.WindowAddedGrabRole)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
}, |
||||
scaleIn: function (window) { |
||||
"use strict"; |
||||
animate({ |
||||
window: window, |
||||
duration: scaleInEffect.duration, |
||||
curve: QEasingCurve.InOutQuad, |
||||
animations: [{ |
||||
type: Effect.Opacity, |
||||
from: 0.0, |
||||
to: 1.0 |
||||
}, { |
||||
type: Effect.Scale, |
||||
from: 0.0, |
||||
to: 1.0 |
||||
}] |
||||
}); |
||||
}, |
||||
added: function (window) { |
||||
"use strict"; |
||||
if (!scaleInEffect.isScaleWindow(window)) { |
||||
return; |
||||
} |
||||
scaleInEffect.scaleIn(window); |
||||
}, |
||||
init: function () { |
||||
"use strict"; |
||||
effect.configChanged.connect(scaleInEffect.loadConfig); |
||||
effects.windowAdded.connect(scaleInEffect.added); |
||||
} |
||||
}; |
||||
scaleInEffect.init(); |
||||
@ -1,102 +0,0 @@ |
||||
/********************************************************************
|
||||
KWin - the KDE window manager |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
|
||||
#include "scalein.h" |
||||
#include <QTimeLine> |
||||
#include <QtGui/QVector2D> |
||||
|
||||
namespace KWin |
||||
{ |
||||
|
||||
KWIN_EFFECT(scalein, ScaleInEffect) |
||||
|
||||
ScaleInEffect::ScaleInEffect() |
||||
: Effect() |
||||
{ |
||||
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*))); |
||||
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); |
||||
} |
||||
|
||||
void ScaleInEffect::prePaintScreen(ScreenPrePaintData& data, int time) |
||||
{ |
||||
if (!mTimeLineWindows.isEmpty()) |
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; |
||||
effects->prePaintScreen(data, time); |
||||
} |
||||
|
||||
void ScaleInEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) |
||||
{ |
||||
if (mTimeLineWindows.contains(w)) { |
||||
mTimeLineWindows[ w ]->setCurveShape(QTimeLine::EaseInOutCurve); |
||||
mTimeLineWindows[ w ]->setCurrentTime(mTimeLineWindows[ w ]->currentTime() + time); |
||||
if (mTimeLineWindows[ w ]->currentValue() < 1) |
||||
data.setTransformed(); |
||||
else |
||||
delete mTimeLineWindows.take(w); |
||||
} |
||||
effects->prePaintWindow(w, data, time); |
||||
} |
||||
|
||||
void ScaleInEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) |
||||
{ |
||||
if (mTimeLineWindows.contains(w) && isScaleWindow(w)) { |
||||
const qreal value = mTimeLineWindows[ w ]->currentValue(); |
||||
data.multiplyOpacity(value); |
||||
data *= QVector2D(value, value); |
||||
data += QPoint(int(w->width() / 2 * (1 - value)), int(w->height() / 2 * (1 - value))); |
||||
} |
||||
effects->paintWindow(w, mask, region, data); |
||||
} |
||||
|
||||
bool ScaleInEffect::isScaleWindow(EffectWindow* w) |
||||
{ |
||||
const void* e = w->data(WindowAddedGrabRole).value<void*>(); |
||||
// TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately?
|
||||
if (w->isPopupMenu() || w->isSpecialWindow() || w->isUtility() || (e && e != this)) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
void ScaleInEffect::postPaintWindow(EffectWindow* w) |
||||
{ |
||||
if (mTimeLineWindows.contains(w)) |
||||
w->addRepaintFull(); // trigger next animation repaint
|
||||
effects->postPaintWindow(w); |
||||
} |
||||
|
||||
void ScaleInEffect::slotWindowAdded(EffectWindow* c) |
||||
{ |
||||
if (c->isOnCurrentDesktop()) { |
||||
mTimeLineWindows.insert(c, new QTimeLine(animationTime(250), this)); |
||||
c->addRepaintFull(); |
||||
} |
||||
} |
||||
|
||||
void ScaleInEffect::slotWindowClosed(EffectWindow* c) |
||||
{ |
||||
delete mTimeLineWindows.take(c); |
||||
} |
||||
|
||||
bool ScaleInEffect::isActive() const |
||||
{ |
||||
return !mTimeLineWindows.isEmpty(); |
||||
} |
||||
|
||||
} // namespace
|
||||
@ -1,53 +0,0 @@ |
||||
/********************************************************************
|
||||
KWin - the KDE window manager |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
|
||||
#ifndef KWIN_SCALEIN_H |
||||
#define KWIN_SCALEIN_H |
||||
|
||||
#include <kwineffects.h> |
||||
|
||||
class QTimeLine; |
||||
|
||||
namespace KWin |
||||
{ |
||||
|
||||
class ScaleInEffect |
||||
: public Effect |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
ScaleInEffect(); |
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time); |
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); |
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); |
||||
virtual void postPaintWindow(EffectWindow* w); |
||||
virtual bool isActive() const; |
||||
// TODO react also on virtual desktop changes
|
||||
public Q_SLOTS: |
||||
void slotWindowAdded(KWin::EffectWindow* c); |
||||
void slotWindowClosed(KWin::EffectWindow *c); |
||||
private: |
||||
bool isScaleWindow(EffectWindow* w); |
||||
QHash< const EffectWindow*, QTimeLine* > mTimeLineWindows; |
||||
}; |
||||
|
||||
} // namespace
|
||||
|
||||
#endif |
||||
Loading…
Reference in new issue