diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index c580568345..e89576c521 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -104,6 +104,7 @@ add_subdirectory( login ) if( NOT KWIN_MOBILE_EFFECTS ) add_subdirectory( fadedesktop ) add_subdirectory( maximize ) + add_subdirectory( scalein ) endif() ############################################################################### @@ -128,7 +129,6 @@ if( NOT KWIN_MOBILE_EFFECTS ) include( translucency/CMakeLists.txt ) include( minimizeanimation/CMakeLists.txt ) include( resize/CMakeLists.txt ) - include( scalein/CMakeLists.txt ) include( showfps/CMakeLists.txt ) include( showpaint/CMakeLists.txt ) include( slide/CMakeLists.txt ) diff --git a/effects/scalein/CMakeLists.txt b/effects/scalein/CMakeLists.txt index 6a16861531..28f40b3371 100644 --- a/effects/scalein/CMakeLists.txt +++ b/effects/scalein/CMakeLists.txt @@ -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 ) diff --git a/effects/scalein/package/CMakeLists.txt b/effects/scalein/package/CMakeLists.txt new file mode 100644 index 0000000000..3b37218c63 --- /dev/null +++ b/effects/scalein/package/CMakeLists.txt @@ -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) diff --git a/effects/scalein/package/contents/code/main.js b/effects/scalein/package/contents/code/main.js new file mode 100644 index 0000000000..91f6cfea6c --- /dev/null +++ b/effects/scalein/package/contents/code/main.js @@ -0,0 +1,65 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2013 Kai Uwe Broulik + +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 . +*********************************************************************/ +/*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(); diff --git a/effects/scalein/scalein.desktop b/effects/scalein/package/metadata.desktop similarity index 95% rename from effects/scalein/scalein.desktop rename to effects/scalein/package/metadata.desktop index a084435636..08e78cb870 100644 --- a/effects/scalein/scalein.desktop +++ b/effects/scalein/package/metadata.desktop @@ -103,7 +103,7 @@ Comment[gl]=Anima a aparición das xanelas Comment[gu]=વિન્ડોનો દેખાવ એનિમેટ કરો Comment[he]=הנפשת ההופעה של חלונות Comment[hi]=विंडो प्रकट होने को एनिमेट करता है -Comment[hne]=विंडो ल देखाय के बेरा मं एनीमेट करथे +Comment[hne]=विंडो ल देखाय के बेरा मं एनीमेट करथे Comment[hr]=Animacija pojavljivanja prozora Comment[hu]=Animáció történik ablakok megjelenésekor Comment[ia]=Anima le apparentia de fenestras @@ -118,7 +118,7 @@ Comment[ko]=창이 등장하는 것을 애니메이션으로 보여 줍니다 Comment[lt]=Animuoja langų atsiradimą Comment[lv]=Animē logu parādīšanos Comment[mk]=Го анимира појавувањето прозорци -Comment[ml]=ജാലകങ്ങള്‍ കളിച്ചുകൊണ്ടു് വരട്ടെ. +Comment[ml]=ജാലകങ്ങള്‍ കളിച്ചുകൊണ്ടു് വരട്ടെ. Comment[mr]=चौकट दर्शविणे एनीमेट करा Comment[nb]=Animer vinduer som dukker opp Comment[nds]=Dat Opduken vun Finstern animeren @@ -151,14 +151,15 @@ Comment[zh_CN]=动画显示窗口的出现 Comment[zh_TW]=動畫顯示視窗出現 Type=Service +X-Plasma-API=javascript +X-Plasma-MainScript=code/main.js X-KDE-ServiceTypes=KWin/Effect -X-KDE-PluginInfo-Author=Luboš Luňák -X-KDE-PluginInfo-Email=l.lunak@kde.org +X-KDE-PluginInfo-Author=Luboš Luňák, Kai Uwe Broulik +X-KDE-PluginInfo-Email=l.lunak@kde.org, kde@privat.broulik.de X-KDE-PluginInfo-Name=kwin4_effect_scalein -X-KDE-PluginInfo-Version=0.1.0 +X-KDE-PluginInfo-Version=0.2.0 X-KDE-PluginInfo-Category=Appearance X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 diff --git a/effects/scalein/scalein.cpp b/effects/scalein/scalein.cpp deleted file mode 100644 index ad0178c79b..0000000000 --- a/effects/scalein/scalein.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - -Copyright (C) 2006 Lubos Lunak - -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 . -*********************************************************************/ - -#include "scalein.h" -#include -#include - -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(); - // 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 diff --git a/effects/scalein/scalein.h b/effects/scalein/scalein.h deleted file mode 100644 index 0b3ae56eb6..0000000000 --- a/effects/scalein/scalein.h +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - -Copyright (C) 2006 Lubos Lunak - -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 . -*********************************************************************/ - -#ifndef KWIN_SCALEIN_H -#define KWIN_SCALEIN_H - -#include - -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