KWin
|
#include <animationeffect.h>
Public Member Functions | |
AnimationEffect () | |
~AnimationEffect () override | |
bool | isActive () const override |
QString | debug (const QString ¶meter) const override |
void | prePaintWindow (EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override |
void | paintWindow (const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override |
void | postPaintScreen () override |
![]() | |
CrossFadeEffect (QObject *parent=nullptr) | |
~CrossFadeEffect () override | |
void | drawWindow (const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *window, int mask, const QRegion ®ion, WindowPaintData &data) override |
void | redirect (EffectWindow *window) |
void | unredirect (EffectWindow *window) |
void | setShader (EffectWindow *window, GLShader *shader) |
![]() | |
Effect (QObject *parent=nullptr) | |
~Effect () override | |
virtual void | reconfigure (ReconfigureFlags flags) |
virtual void | prePaintScreen (ScreenPrePaintData &data, std::chrono::milliseconds presentTime) |
virtual void | paintScreen (const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) |
virtual void | postPaintWindow (EffectWindow *w) |
virtual bool | provides (Feature) |
virtual bool | perform (Feature feature, const QVariantList &arguments) |
virtual void | windowInputMouseEvent (QEvent *e) |
virtual void | grabbedKeyboardEvent (QKeyEvent *e) |
virtual int | requestedEffectChainPosition () const |
virtual bool | touchDown (qint32 id, const QPointF &pos, std::chrono::microseconds time) |
virtual bool | touchMotion (qint32 id, const QPointF &pos, std::chrono::microseconds time) |
virtual bool | touchUp (qint32 id, std::chrono::microseconds time) |
virtual bool | tabletToolEvent (QTabletEvent *event) |
virtual bool | tabletToolButtonEvent (uint button, bool pressed, quint64 tabletToolId) |
virtual bool | tabletPadButtonEvent (uint button, bool pressed, void *tabletPadId) |
virtual bool | tabletPadStripEvent (int number, int position, bool isFinger, void *tabletPadId) |
virtual bool | tabletPadRingEvent (int number, int position, bool isFinger, void *tabletPadId) |
template<typename T > | |
int | animationTime (int defaultDuration) |
virtual bool | blocksDirectScanout () const |
Static Public Member Functions | |
static int | metaData (MetaType type, uint meta) |
static void | setMetaData (MetaType type, uint value, uint &meta) |
static qreal | qecGaussian (qreal progress) |
static qint64 | clock () |
![]() | |
static bool | supported () |
![]() | |
static QPointF | cursorPos () |
static double | animationTime (const KConfigGroup &cfg, const QString &key, int defaultTime) |
static double | animationTime (int defaultTime) |
static double | interpolate (double x, double y, double a) |
static void | setPositionTransformations (WindowPaintData &data, QRect ®ion, EffectWindow *w, const QRect &r, Qt::AspectRatioMode aspect) |
Protected Types | |
typedef QMap< EffectWindow *, QPair< QList< AniData >, QRect > > | AniMap |
Protected Member Functions | |
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, GLShader *shader=nullptr) |
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, GLShader *shader=nullptr) |
bool | retarget (quint64 animationId, FPx2 newTarget, int newRemainingTime=-1) |
bool | freezeInTime (quint64 animationId, qint64 frozenTime) |
bool | redirect (quint64 animationId, Direction direction, TerminationFlags terminationFlags=TerminateAtSource) |
bool | complete (quint64 animationId) |
virtual void | animationEnded (EffectWindow *w, Attribute a, uint meta) |
bool | cancel (quint64 animationId) |
virtual void | genericAnimation (EffectWindow *w, WindowPaintData &data, float progress, uint meta) |
AniMap | state () const |
Additional Inherited Members | |
![]() | |
virtual bool | borderActivated (ElectricBorder border) |
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.
Definition at line 194 of file animationeffect.h.
|
protected |
Definition at line 501 of file animationeffect.h.
Enumerator | |
---|---|
Left | |
Top | |
Right | |
Bottom | |
Horizontal | |
Vertical | |
Mouse |
Definition at line 199 of file animationeffect.h.
Definition at line 208 of file animationeffect.h.
This enum type is used to specify the direction of the animation.
Enumerator | |
---|---|
Forward | The animation goes from source to target. |
Backward | The animation goes from target to source. |
Definition at line 248 of file animationeffect.h.
Enumerator | |
---|---|
SourceAnchor | |
TargetAnchor | |
RelativeSourceX | |
RelativeSourceY | |
RelativeTargetX | |
RelativeTargetY | |
Axis |
Definition at line 234 of file animationeffect.h.
This enum type is used to specify when the animation should be terminated.
Definition at line 259 of file animationeffect.h.
KWin::AnimationEffect::AnimationEffect | ( | ) |
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.
Definition at line 50 of file animationeffect.cpp.
|
override |
Definition at line 62 of file animationeffect.cpp.
|
inlineprotected |
Starts an animated transition of any supported attribute.
w | The animated window. |
a | The animated attribute. |
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. |
ms | How long the transition will last. |
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). |
curve | How the animation progresses, e.g. Linear progresses constantly while Exponential start slow and becomes very fast in the end. |
delay | When the animation will start compared to "now" (the window will remain at the "from" position until then). |
from | The starting value, the default is invalid, ie. the attribute for the window is not transformed in the beginning. |
fullScreen | Sets this effect as the active full screen effect for the duration of the animation. |
keepAlive | Whether closed windows should be kept alive during animation. |
shader | Optional shader to use to render the window. |
Definition at line 376 of file animationeffect.h.
|
protectedvirtual |
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.
w | The animated window. |
a | The animated attribute. |
meta | Originally supplied metadata to animate() or set(). |
Reimplemented in KWin::ScriptedEffect.
Definition at line 436 of file animationeffect.cpp.
|
protected |
Cancels a running animation.
animationId | The id of the animation. |
true
if the animation was found (and canceled), false
otherwise. Definition at line 407 of file animationeffect.cpp.
|
inlinestatic |
Definition at line 345 of file animationeffect.h.
|
protected |
Fast-forwards the animation to the target position.
animationId | The id of the animation. |
true
if the animation was fast-forwarded successfully, otherwise false
. Definition at line 381 of file animationeffect.cpp.
|
overridevirtual |
Reimplement this method to provide online debugging. This could be as trivial as printing specific detail information about the effect state but could also be used to move the effect in and out of a special debug modes, clear bogus data, etc. Notice that the functions is const by intent! Whenever you alter the state of the object due to random user input, you should do so with greatest care, hence const_cast<> your object - signalling "let me alone, i know what i'm doing"
parameter | A freeform string user input for your effect to interpret. |
Reimplemented from KWin::Effect.
Definition at line 997 of file animationeffect.cpp.
|
protected |
Definition at line 322 of file animationeffect.cpp.
|
protectedvirtual |
Called whenever animation that transforms Generic attribute needs to be painted.
You should reimplement this method if you transform Generic attribute. meta
can be used to support more than one additional animations.
w | The animated window. |
data | The paint data. |
progress | Current progress value. |
meta | The metadata. |
Definition at line 440 of file animationeffect.cpp.
|
overridevirtual |
Overwrite this method to indicate whether your effect will be doing something in the next frame to be rendered. If the method returns false
the effect will be excluded from the chained methods in the next rendered frame.
This method is called always directly before the paint loop begins. So it is totally fine to e.g. react on a window event, issue a repaint to trigger an animation and change a flag to indicate that this method returns true
.
As the method is called each frame, you should not perform complex calculations. Best use just a boolean flag.
The default implementation of this method returns true
.
Reimplemented from KWin::Effect.
Definition at line 86 of file animationeffect.cpp.
|
static |
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.
type | The type of the metadata. |
meta | Where the metadata is stored. |
Definition at line 756 of file animationeffect.cpp.
|
overridevirtual |
This is the main method for painting windows. In this method you can:
In OpenGL based compositing, the frameworks ensures that the context is current when this method is invoked.
Reimplemented from KWin::Effect.
Definition at line 522 of file animationeffect.cpp.
|
overridevirtual |
Called after all the painting has been finished. In this method you can:
In OpenGL based compositing, the frameworks ensures that the context is current when this method is invoked.
Reimplemented from KWin::Effect.
Definition at line 652 of file animationeffect.cpp.
|
overridevirtual |
Called for every window before the actual paint pass In this method you can:
In OpenGL based compositing, the frameworks ensures that the context is current when this method is invoked.
presentTime specifies the expected monotonic time when the rendered frame will be displayed on the screen.
Reimplemented from KWin::Effect.
Definition at line 487 of file animationeffect.cpp.
|
inlinestatic |
Gaussian (bumper) animation curve for QEasingCurve.
Definition at line 335 of file animationeffect.h.
|
protected |
Changes the direction of the animation.
animationId | The id of the animation. |
direction | The new direction of the animation. |
terminationFlags | Whether the animation should be terminated when it reaches the source position after its direction was changed to go backward. Currently, TerminationFlag::TerminateAtTarget has no effect. |
true
if the direction of the animation was changed successfully, otherwise false
. Definition at line 347 of file animationeffect.cpp.
|
protected |
Changes the target (but not type or curve) of a running animation.
Please use cancel() to cancel an animation rather than altering it.
animationId | The id of the animation to be retargetted. |
newTarget | The new target. |
newRemainingTime | The new duration of the transition. By default (-1), the remaining time remains unchanged. |
true
if the animation was retargetted successfully, false
otherwise. Definition at line 291 of file animationeffect.cpp.
|
inlineprotected |
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().
w | The animated window. |
a | The animated attribute. |
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. |
ms | How long the transition will last. |
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). |
curve | How the animation progresses, e.g. Linear progresses constantly while Exponential start slow and becomes very fast in the end. |
delay | When the animation will start compared to "now" (the window will remain at the "from" position until then). |
from | The starting value, the default is invalid, ie. the attribute for the window is not transformed in the beginning. |
fullScreen | Sets this effect as the active full screen effect for the duration of the animation. |
keepAlive | Whether closed windows should be kept alive during animation. |
shader | Optional shader to use to render the window. |
Definition at line 409 of file animationeffect.h.
|
static |
Sets metadata.
type | The type of the metadata. |
value | The data to be stored. |
meta | Where the metadata will be stored. |
Definition at line 777 of file animationeffect.cpp.
|
protected |
Definition at line 1020 of file animationeffect.cpp.