Rewrite Scale In effect in JavaScript

REVIEW: 109075
icc-effect-5.14.5
Kai Uwe Broulik 2013-05-11 22:20:39 +00:00
parent dd8cf0b678
commit ed955e9488
7 changed files with 80 additions and 174 deletions

View File

@ -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 )

View File

@ -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 )

View File

@ -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)

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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