2011-10-19 23:04:52 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Thomas Lübking <thomas.luebking@web.de>
|
2020-01-14 16:17:18 +00:00
|
|
|
Copyright (C) 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2011-10-19 23:04:52 +00:00
|
|
|
|
|
|
|
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 ANIMATION_EFFECT_H
|
|
|
|
#define ANIMATION_EFFECT_H
|
|
|
|
|
|
|
|
#include <QEasingCurve>
|
2012-11-03 20:33:34 +00:00
|
|
|
#include <QElapsedTimer>
|
2019-07-09 19:19:26 +00:00
|
|
|
#include <QtMath>
|
2011-10-19 23:04:52 +00:00
|
|
|
#include <kwineffects.h>
|
2013-12-01 19:45:39 +00:00
|
|
|
#include <kwineffects_export.h>
|
2011-10-19 23:04:52 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-12-01 19:45:39 +00:00
|
|
|
class KWINEFFECTS_EXPORT FPx2 {
|
2011-10-19 23:04:52 +00:00
|
|
|
public:
|
|
|
|
FPx2() { f[0] = f[1] = 0.0; valid = false; }
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit FPx2(float v) { f[0] = f[1] = v; valid = true; }
|
2011-10-19 23:04:52 +00:00
|
|
|
FPx2(float v1, float v2) { f[0] = v1; f[1] = v2; valid = true; }
|
|
|
|
FPx2(const FPx2 &other) { f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; }
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit FPx2(const QPoint &other) { f[0] = other.x(); f[1] = other.y(); valid = true; }
|
|
|
|
explicit FPx2(const QPointF &other) { f[0] = other.x(); f[1] = other.y(); valid = true; }
|
|
|
|
explicit FPx2(const QSize &other) { f[0] = other.width(); f[1] = other.height(); valid = true; }
|
|
|
|
explicit FPx2(const QSizeF &other) { f[0] = other.width(); f[1] = other.height(); valid = true; }
|
2011-10-19 23:04:52 +00:00
|
|
|
inline void invalidate() { valid = false; }
|
|
|
|
inline bool isValid() const { return valid; }
|
|
|
|
inline float operator[](int n) const { return f[n]; }
|
|
|
|
inline QString toString() const {
|
|
|
|
QString ret;
|
|
|
|
if (valid)
|
2015-11-05 14:14:06 +00:00
|
|
|
ret = QString::number(f[0]) + QLatin1Char(',') + QString::number(f[1]);
|
2011-10-19 23:04:52 +00:00
|
|
|
else
|
2013-07-23 05:02:52 +00:00
|
|
|
ret = QString();
|
2011-10-19 23:04:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-09 22:42:48 +00:00
|
|
|
inline FPx2 &operator=(const FPx2 &other)
|
|
|
|
{ f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; return *this; }
|
2011-10-19 23:04:52 +00:00
|
|
|
inline FPx2 &operator+=(const FPx2 &other)
|
|
|
|
{ f[0] += other[0]; f[1] += other[1]; return *this; }
|
|
|
|
inline FPx2 &operator-=(const FPx2 &other)
|
|
|
|
{ f[0] -= other[0]; f[1] -= other[1]; return *this; }
|
|
|
|
inline FPx2 &operator*=(float fl)
|
|
|
|
{ f[0] *= fl; f[1] *= fl; return *this; }
|
|
|
|
inline FPx2 &operator/=(float fl)
|
|
|
|
{ f[0] /= fl; f[1] /= fl; return *this; }
|
|
|
|
|
|
|
|
friend inline bool operator==(const FPx2 &f1, const FPx2 &f2)
|
|
|
|
{ return f1[0] == f2[0] && f1[1] == f2[1]; }
|
|
|
|
friend inline bool operator!=(const FPx2 &f1, const FPx2 &f2)
|
|
|
|
{ return f1[0] != f2[0] || f1[1] != f2[1]; }
|
|
|
|
friend inline const FPx2 operator+(const FPx2 &f1, const FPx2 &f2)
|
|
|
|
{ return FPx2( f1[0] + f2[0], f1[1] + f2[1] ); }
|
|
|
|
friend inline const FPx2 operator-(const FPx2 &f1, const FPx2 &f2)
|
|
|
|
{ return FPx2( f1[0] - f2[0], f1[1] - f2[1] ); }
|
|
|
|
friend inline const FPx2 operator*(const FPx2 &f, float fl)
|
|
|
|
{ return FPx2( f[0] * fl, f[1] * fl ); }
|
|
|
|
friend inline const FPx2 operator*(float fl, const FPx2 &f)
|
|
|
|
{ return FPx2( f[0] * fl, f[1] *fl ); }
|
|
|
|
friend inline const FPx2 operator-(const FPx2 &f)
|
|
|
|
{ return FPx2( -f[0], -f[1] ); }
|
|
|
|
friend inline const FPx2 operator/(const FPx2 &f, float fl)
|
|
|
|
{ return FPx2( f[0] / fl, f[1] / fl ); }
|
|
|
|
|
|
|
|
inline void set(float v) { f[0] = v; valid = true; }
|
|
|
|
inline void set(float v1, float v2) { f[0] = v1; f[1] = v2; valid = true; }
|
2012-10-27 21:35:19 +00:00
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
private:
|
|
|
|
float f[2];
|
|
|
|
bool valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AniData;
|
|
|
|
class AnimationEffectPrivate;
|
2019-01-08 18:08:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for animation effects.
|
|
|
|
*
|
|
|
|
* AnimationEffect serves as a base class for animation effects. It makes easier
|
|
|
|
* implementing animated transitions, without having to worry about low-level
|
|
|
|
* specific stuff, e.g. referencing and unreferencing deleted windows, scheduling
|
|
|
|
* repaints for the next frame, etc.
|
|
|
|
*
|
|
|
|
* Each animation animates one specific attribute, e.g. size, position, scale, etc.
|
|
|
|
* You can provide your own implementation of the Generic attribute if none of the
|
|
|
|
* standard attributes(e.g. size, position, etc) satisfy your requirements.
|
|
|
|
*
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-12-01 19:45:39 +00:00
|
|
|
class KWINEFFECTS_EXPORT AnimationEffect : public Effect
|
2011-10-19 23:04:52 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-12-21 00:24:32 +00:00
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
public:
|
|
|
|
enum Anchor { Left = 1<<0, Top = 1<<1, Right = 1<<2, Bottom = 1<<3,
|
|
|
|
Horizontal = Left|Right, Vertical = Top|Bottom, Mouse = 1<<4 };
|
2018-12-21 00:24:32 +00:00
|
|
|
Q_ENUM(Anchor)
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
enum Attribute {
|
2014-08-04 19:12:34 +00:00
|
|
|
Opacity = 0, Brightness, Saturation, Scale, Rotation,
|
2013-05-13 06:17:28 +00:00
|
|
|
Position, Size, Translation, Clip, Generic, CrossFadePrevious,
|
2011-10-19 23:04:52 +00:00
|
|
|
NonFloatBase = Position
|
|
|
|
};
|
2018-12-21 00:24:32 +00:00
|
|
|
Q_ENUM(Attribute)
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
enum MetaType { SourceAnchor, TargetAnchor,
|
|
|
|
RelativeSourceX, RelativeSourceY, RelativeTargetX, RelativeTargetY, Axis };
|
2018-12-21 00:24:32 +00:00
|
|
|
Q_ENUM(MetaType)
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This enum type is used to specify the direction of the animation.
|
2019-01-08 18:08:15 +00:00
|
|
|
*
|
|
|
|
* @since 5.15
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
enum Direction {
|
|
|
|
Forward, ///< The animation goes from source to target.
|
|
|
|
Backward ///< The animation goes from target to source.
|
|
|
|
};
|
|
|
|
Q_ENUM(Direction)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This enum type is used to specify when the animation should be terminated.
|
|
|
|
*
|
2019-01-08 18:08:15 +00:00
|
|
|
* @since 5.15
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
enum TerminationFlag {
|
2019-01-08 18:08:15 +00:00
|
|
|
/**
|
|
|
|
* Don't terminate the animation when it reaches source or target position.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
DontTerminate = 0x00,
|
2019-01-08 18:08:15 +00:00
|
|
|
/**
|
|
|
|
* Terminate the animation when it reaches the source position. An animation
|
|
|
|
* can reach the source position if its direction was changed to go backward
|
|
|
|
* (from target to source).
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
TerminateAtSource = 0x01,
|
2019-01-08 18:08:15 +00:00
|
|
|
/**
|
|
|
|
* Terminate the animation when it reaches the target position. If this flag
|
|
|
|
* is not set, then the animation will be persistent.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
TerminateAtTarget = 0x02
|
|
|
|
};
|
|
|
|
Q_FLAGS(TerminationFlag)
|
|
|
|
Q_DECLARE_FLAGS(TerminationFlags, TerminationFlag)
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Constructs AnimationEffect.
|
|
|
|
*
|
|
|
|
* Whenever you intend to connect to the EffectsHandler::windowClosed() signal,
|
|
|
|
* do so when reimplementing the constructor. Do not add private slots named
|
|
|
|
* _windowClosed or _windowDeleted! The AnimationEffect connects them right after
|
|
|
|
* the construction.
|
|
|
|
*
|
|
|
|
* If you shadow the _windowDeleted slot (it doesn't matter that it's a private
|
|
|
|
* slot), this will lead to segfaults.
|
|
|
|
*
|
|
|
|
* If you shadow _windowClosed or connect your slot to EffectsHandler::windowClosed()
|
|
|
|
* after _windowClosed was connected, animations for closing windows will fail.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2011-10-19 23:04:52 +00:00
|
|
|
AnimationEffect();
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~AnimationEffect() override;
|
2011-10-19 23:04:52 +00:00
|
|
|
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
bool isActive() const override;
|
2019-01-08 18:08:15 +00:00
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Gets stored metadata.
|
|
|
|
*
|
|
|
|
* Metadata can be used to store some extra information, for example rotation axis,
|
|
|
|
* etc. The first 24 bits are reserved for the AnimationEffect class, you can use
|
|
|
|
* the last 8 bits for custom hints. In case when you transform a Generic attribute,
|
|
|
|
* all 32 bits are yours and you can use them as you want and read them in your
|
|
|
|
* genericAnimation() implementation.
|
|
|
|
*
|
|
|
|
* @param type The type of the metadata.
|
|
|
|
* @param meta Where the metadata is stored.
|
|
|
|
* @returns Stored metadata.
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2011-10-19 23:04:52 +00:00
|
|
|
static int metaData(MetaType type, uint meta );
|
|
|
|
|
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Sets metadata.
|
|
|
|
*
|
|
|
|
* @param type The type of the metadata.
|
|
|
|
* @param value The data to be stored.
|
|
|
|
* @param meta Where the metadata will be stored.
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-01-08 18:08:15 +00:00
|
|
|
static void setMetaData(MetaType type, uint value, uint &meta );
|
|
|
|
|
|
|
|
// Reimplemented from KWin::Effect.
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
QString debug(const QString ¶meter) const override;
|
|
|
|
void prePaintScreen( ScreenPrePaintData& data, int time ) override;
|
|
|
|
void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) override;
|
|
|
|
void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) override;
|
|
|
|
void postPaintScreen() override;
|
2011-10-19 23:04:52 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Gaussian (bumper) animation curve for QEasingCurve.
|
|
|
|
*
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2011-10-19 23:04:52 +00:00
|
|
|
static qreal qecGaussian(qreal progress)
|
|
|
|
{
|
|
|
|
progress = 2*progress - 1;
|
|
|
|
progress *= -5*progress;
|
|
|
|
return qExp(progress);
|
|
|
|
}
|
|
|
|
|
2019-01-08 18:08:15 +00:00
|
|
|
/**
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-11-03 20:33:34 +00:00
|
|
|
static inline qint64 clock() {
|
|
|
|
return s_clock.elapsed();
|
|
|
|
}
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
protected:
|
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Starts an animated transition of any supported attribute.
|
|
|
|
*
|
|
|
|
* @param w The animated window.
|
|
|
|
* @param a The animated attribute.
|
|
|
|
* @param meta Basically a wildcard to carry various extra information, e.g.
|
|
|
|
* the anchor, relativity or rotation axis. You will probably use it when
|
|
|
|
* performing Generic animations.
|
|
|
|
* @param ms How long the transition will last.
|
|
|
|
* @param to The target value. FPx2 is an agnostic two component float type
|
|
|
|
* (like QPointF or QSizeF, but without requiring to be either and supporting
|
|
|
|
* an invalid state).
|
2019-01-11 13:36:17 +00:00
|
|
|
* @param curve How the animation progresses, e.g. Linear progresses constantly
|
2019-01-08 18:08:15 +00:00
|
|
|
* while Exponential start slow and becomes very fast in the end.
|
|
|
|
* @param delay When the animation will start compared to "now" (the window will
|
|
|
|
* remain at the "from" position until then).
|
|
|
|
* @param from The starting value, the default is invalid, ie. the attribute for
|
|
|
|
* the window is not transformed in the beginning.
|
|
|
|
* @param fullScreen Sets this effect as the active full screen effect for the
|
|
|
|
* duration of the animation.
|
|
|
|
* @param keepAlive Whether closed windows should be kept alive during animation.
|
|
|
|
* @returns An ID that you can use to cancel a running animation.
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-10-29 22:04:15 +00:00
|
|
|
quint64 animate( EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const FPx2 &from = FPx2(), bool fullScreen = false, bool keepAlive = true)
|
[effects/dialogparent] Fix flickering of parent windows
Summary:
If a modal window is closed and some alternative effect that animates
the disappearing of windows is enabled(e.g. the Glide effect, or the
Scale effect), the Dialog Parent effect can cause flickering of the
parent window because its animation duration doesn't match duration of
those alternative effects.
Also, if the Fade effect, the Glide effect, and the Scale effect are
disabled, the Dialog Parent will keep the parent window alive for no
good reason.
This change addresses that problem by adding keepAlive property to
`animate` function so scripted effects have more control over lifetime
of animated windows.
If both a modal window and its parent window are closed at the same time
(and there is no effect that animates the disappearing of windows), the
Dialog Parent will stop immediately(because windowDeleted will be
emitted right after windowClosed signal).
If both a modal window and its parent window are closed at the same time
(and there is effect that animates the disappearing of windows), the
Dialog Parent won't reference the latter window. Thus, it won't cause
flickering. I.e. it will "passively" animate parent windows.
BUG: 355036
FIXED-IN: 5.15.0
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D14919
2018-10-10 07:36:45 +00:00
|
|
|
{ return p_animate(w, a, meta, ms, to, curve, delay, from, false, fullScreen, keepAlive); }
|
2013-02-28 18:51:00 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Starts a persistent animated transition of any supported attribute.
|
|
|
|
*
|
|
|
|
* This method is equal to animate() with one important difference:
|
|
|
|
* the target value for the attribute is kept until you call cancel().
|
|
|
|
*
|
|
|
|
* @param w The animated window.
|
|
|
|
* @param a The animated attribute.
|
|
|
|
* @param meta Basically a wildcard to carry various extra information, e.g.
|
|
|
|
* the anchor, relativity or rotation axis. You will probably use it when
|
|
|
|
* performing Generic animations.
|
|
|
|
* @param ms How long the transition will last.
|
|
|
|
* @param to The target value. FPx2 is an agnostic two component float type
|
|
|
|
* (like QPointF or QSizeF, but without requiring to be either and supporting
|
|
|
|
* an invalid state).
|
2019-01-11 13:36:17 +00:00
|
|
|
* @param curve How the animation progresses, e.g. Linear progresses constantly
|
2019-01-08 18:08:15 +00:00
|
|
|
* while Exponential start slow and becomes very fast in the end.
|
|
|
|
* @param delay When the animation will start compared to "now" (the window will
|
|
|
|
* remain at the "from" position until then).
|
|
|
|
* @param from The starting value, the default is invalid, ie. the attribute for
|
|
|
|
* the window is not transformed in the beginning.
|
|
|
|
* @param fullScreen Sets this effect as the active full screen effect for the
|
|
|
|
* duration of the animation.
|
|
|
|
* @param keepAlive Whether closed windows should be kept alive during animation.
|
|
|
|
* @returns An ID that you need to use to cancel this manipulation.
|
|
|
|
* @since 4.11
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-10-29 22:04:15 +00:00
|
|
|
quint64 set( EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const FPx2 &from = FPx2(), bool fullScreen = false, bool keepAlive = true)
|
[effects/dialogparent] Fix flickering of parent windows
Summary:
If a modal window is closed and some alternative effect that animates
the disappearing of windows is enabled(e.g. the Glide effect, or the
Scale effect), the Dialog Parent effect can cause flickering of the
parent window because its animation duration doesn't match duration of
those alternative effects.
Also, if the Fade effect, the Glide effect, and the Scale effect are
disabled, the Dialog Parent will keep the parent window alive for no
good reason.
This change addresses that problem by adding keepAlive property to
`animate` function so scripted effects have more control over lifetime
of animated windows.
If both a modal window and its parent window are closed at the same time
(and there is no effect that animates the disappearing of windows), the
Dialog Parent will stop immediately(because windowDeleted will be
emitted right after windowClosed signal).
If both a modal window and its parent window are closed at the same time
(and there is effect that animates the disappearing of windows), the
Dialog Parent won't reference the latter window. Thus, it won't cause
flickering. I.e. it will "passively" animate parent windows.
BUG: 355036
FIXED-IN: 5.15.0
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D14919
2018-10-10 07:36:45 +00:00
|
|
|
{ return p_animate(w, a, meta, ms, to, curve, delay, from, true, fullScreen, keepAlive); }
|
2013-02-28 18:51:00 +00:00
|
|
|
|
2016-02-03 16:36:48 +00:00
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Changes the target (but not type or curve) of a running animation.
|
|
|
|
*
|
|
|
|
* Please use cancel() to cancel an animation rather than altering it.
|
2016-02-03 16:36:48 +00:00
|
|
|
*
|
2019-01-08 18:08:15 +00:00
|
|
|
* @param animationId The id of the animation to be retargetted.
|
|
|
|
* @param newTarget The new target.
|
|
|
|
* @param newRemainingTime The new duration of the transition. By default (-1),
|
|
|
|
* the remaining time remains unchanged.
|
|
|
|
* @returns @c true if the animation was retargetted successfully, @c false otherwise.
|
|
|
|
* @note You can NOT retarget an animation that just has just ended!
|
|
|
|
* @since 5.6
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-03 16:36:48 +00:00
|
|
|
bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1);
|
|
|
|
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
/**
|
|
|
|
* Changes the direction of the animation.
|
|
|
|
*
|
|
|
|
* @param animationId The id of the animation.
|
|
|
|
* @param direction The new direction of the animation.
|
2019-01-11 13:36:17 +00:00
|
|
|
* @param terminationFlags Whether the animation should be terminated when it
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
* reaches the source position after its direction was changed to go backward.
|
|
|
|
* Currently, TerminationFlag::TerminateAtTarget has no effect.
|
|
|
|
* @returns @c true if the direction of the animation was changed successfully,
|
|
|
|
* otherwise @c false.
|
2019-01-08 18:08:15 +00:00
|
|
|
* @since 5.15
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
bool redirect(quint64 animationId,
|
|
|
|
Direction direction,
|
|
|
|
TerminationFlags terminationFlags = TerminateAtSource);
|
|
|
|
|
2018-10-25 18:02:36 +00:00
|
|
|
/**
|
|
|
|
* Fast-forwards the animation to the target position.
|
|
|
|
*
|
|
|
|
* @param animationId The id of the animation.
|
|
|
|
* @returns @c true if the animation was fast-forwarded successfully, otherwise
|
|
|
|
* @c false.
|
2019-01-08 18:08:15 +00:00
|
|
|
* @since 5.15
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-10-25 18:02:36 +00:00
|
|
|
bool complete(quint64 animationId);
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Called whenever an animation ends.
|
|
|
|
*
|
|
|
|
* You can reimplement this method to keep a constant transformation for the window
|
|
|
|
* (i.e. keep it at some opacity or position) or to start another animation.
|
|
|
|
*
|
|
|
|
* @param w The animated window.
|
|
|
|
* @param a The animated attribute.
|
|
|
|
* @param meta Originally supplied metadata to animate() or set().
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-01-08 18:08:15 +00:00
|
|
|
virtual void animationEnded(EffectWindow *w, Attribute a, uint meta)
|
|
|
|
{Q_UNUSED(w); Q_UNUSED(a); Q_UNUSED(meta);}
|
2013-02-28 18:51:00 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Cancels a running animation.
|
|
|
|
*
|
|
|
|
* @param animationId The id of the animation.
|
|
|
|
* @returns @c true if the animation was found (and canceled), @c false otherwise.
|
|
|
|
* @note There is NO animated reset of the original value. You'll have to provide
|
|
|
|
* that with a second animation.
|
|
|
|
* @note This will eventually release a Deleted window as well.
|
|
|
|
* @note If you intend to run another animation on the (Deleted) window, you have
|
|
|
|
* to do that before cancelling the old animation (to keep the window around).
|
|
|
|
* @since 4.11
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-02-28 18:51:00 +00:00
|
|
|
bool cancel(quint64 animationId);
|
2019-01-08 18:08:15 +00:00
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
/**
|
2019-01-08 18:08:15 +00:00
|
|
|
* Called whenever animation that transforms Generic attribute needs to be painted.
|
|
|
|
*
|
|
|
|
* You should reimplement this method if you transform Generic attribute. @p meta
|
|
|
|
* can be used to support more than one additional animations.
|
|
|
|
*
|
|
|
|
* @param w The animated window.
|
|
|
|
* @param data The paint data.
|
|
|
|
* @param progress Current progress value.
|
|
|
|
* @param meta The metadata.
|
|
|
|
* @since 4.8
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2011-10-19 23:04:52 +00:00
|
|
|
virtual void genericAnimation( EffectWindow *w, WindowPaintData &data, float progress, uint meta )
|
|
|
|
{Q_UNUSED(w); Q_UNUSED(data); Q_UNUSED(progress); Q_UNUSED(meta);}
|
|
|
|
|
2019-02-26 09:37:44 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-02-26 09:37:44 +00:00
|
|
|
typedef QMap<EffectWindow *, QPair<QList<AniData>, QRect> > AniMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-07-23 21:52:58 +00:00
|
|
|
AniMap state() const;
|
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
private:
|
2019-10-29 22:04:15 +00:00
|
|
|
quint64 p_animate(EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, const QEasingCurve &curve, int delay, FPx2 from, bool keepAtTarget, bool fullScreenEffect, bool keepAlive);
|
2012-03-28 21:13:37 +00:00
|
|
|
QRect clipRect(const QRect &windowRect, const AniData&) const;
|
|
|
|
void clipWindow(const EffectWindow *, const AniData &, WindowQuadList &) const;
|
2011-10-19 23:04:52 +00:00
|
|
|
float interpolated( const AniData&, int i = 0 ) const;
|
|
|
|
float progress( const AniData& ) const;
|
2013-03-18 16:08:58 +00:00
|
|
|
void disconnectGeometryChanges();
|
2012-03-24 21:42:29 +00:00
|
|
|
void updateLayerRepaints();
|
2016-02-03 16:36:48 +00:00
|
|
|
void validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, const EffectWindow *w) const;
|
2018-12-28 17:12:20 +00:00
|
|
|
|
2012-01-01 08:23:48 +00:00
|
|
|
private Q_SLOTS:
|
2011-10-19 23:04:52 +00:00
|
|
|
void init();
|
|
|
|
void triggerRepaint();
|
2012-01-29 11:29:24 +00:00
|
|
|
void _windowClosed( KWin::EffectWindow* w );
|
|
|
|
void _windowDeleted( KWin::EffectWindow* w );
|
2012-03-24 21:42:29 +00:00
|
|
|
void _expandedGeometryChanged(KWin::EffectWindow *w, const QRect &old);
|
2018-12-28 17:12:20 +00:00
|
|
|
|
2011-10-19 23:04:52 +00:00
|
|
|
private:
|
2012-11-03 20:33:34 +00:00
|
|
|
static QElapsedTimer s_clock;
|
2011-10-19 23:04:52 +00:00
|
|
|
AnimationEffectPrivate * const d_ptr;
|
|
|
|
Q_DECLARE_PRIVATE(AnimationEffect)
|
2018-12-28 17:19:13 +00:00
|
|
|
Q_DISABLE_COPY(AnimationEffect)
|
2011-10-19 23:04:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
2018-12-28 17:12:20 +00:00
|
|
|
|
2012-10-27 21:35:19 +00:00
|
|
|
QDebug operator<<(QDebug dbg, const KWin::FPx2 &fpx2);
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
|
2012-01-30 09:21:32 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::FPx2)
|
[scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".
A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.
This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:
redirect(<animation id(s)>, <direction>, [<termination policy>])
the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.
We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16449
2018-10-24 19:58:29 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AnimationEffect::TerminationFlags)
|
2011-10-19 23:04:52 +00:00
|
|
|
|
|
|
|
#endif // ANIMATION_EFFECT_H
|