Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwinanimationeffect.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2011 Thomas Lübking <thomas.luebking@web.de> | 5 | Copyright (C) 2011 Thomas Lübking <thomas.luebking@web.de> | ||
6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 103 | enum Anchor { Left = 1<<0, Top = 1<<1, Right = 1<<2, Bottom = 1<<3, | |||
103 | Horizontal = Left|Right, Vertical = Top|Bottom, Mouse = 1<<4 }; | 104 | Horizontal = Left|Right, Vertical = Top|Bottom, Mouse = 1<<4 }; | ||
104 | enum Attribute { | 105 | enum Attribute { | ||
105 | Opacity = 0, Brightness, Saturation, Scale, Rotation, | 106 | Opacity = 0, Brightness, Saturation, Scale, Rotation, | ||
106 | Position, Size, Translation, Clip, Generic, CrossFadePrevious, | 107 | Position, Size, Translation, Clip, Generic, CrossFadePrevious, | ||
107 | NonFloatBase = Position | 108 | NonFloatBase = Position | ||
108 | }; | 109 | }; | ||
109 | enum MetaType { SourceAnchor, TargetAnchor, | 110 | enum MetaType { SourceAnchor, TargetAnchor, | ||
110 | RelativeSourceX, RelativeSourceY, RelativeTargetX, RelativeTargetY, Axis }; | 111 | RelativeSourceX, RelativeSourceY, RelativeTargetX, RelativeTargetY, Axis }; | ||
112 | | ||||
113 | /** | ||||
114 | * This enum type is used to specify the direction of the animation. | ||||
115 | **/ | ||||
116 | enum Direction { | ||||
117 | Forward, ///< The animation goes from source to target. | ||||
118 | Backward ///< The animation goes from target to source. | ||||
119 | }; | ||||
120 | Q_ENUM(Direction) | ||||
121 | | ||||
122 | /** | ||||
123 | * This enum type is used to specify whether the animation should be terminated | ||||
124 | * when it reaches the source position after its direction was changed to go | ||||
125 | * backward (from target to source). | ||||
126 | **/ | ||||
127 | enum TerminationPolicy { | ||||
128 | DontTerminateAtSource, ///< The animation should not be terminated. | ||||
129 | TerminateAtSource ///< The animation should be terminated. | ||||
130 | }; | ||||
131 | Q_ENUM(TerminationPolicy) | ||||
132 | | ||||
111 | /** | 133 | /** | ||
112 | * Whenever you intend to connect to the EffectsHandler::windowClosed() signal, do so when reimplementing the constructor. | 134 | * Whenever you intend to connect to the EffectsHandler::windowClosed() signal, do so when reimplementing the constructor. | ||
113 | * Do *not* add private slots named _windowClosed( EffectWindow* w ) or _windowDeleted( EffectWindow* w ) !! | 135 | * Do *not* add private slots named _windowClosed( EffectWindow* w ) or _windowDeleted( EffectWindow* w ) !! | ||
114 | * The AnimationEffect connects them right *after* the construction. | 136 | * The AnimationEffect connects them right *after* the construction. | ||
115 | * If you shadow the _windowDeleted slot (it doesn't matter that it's a private slot!), this will lead to segfaults. | 137 | * If you shadow the _windowDeleted slot (it doesn't matter that it's a private slot!), this will lead to segfaults. | ||
116 | * If you shadow _windowClosed() or connect your slot to EffectsHandler::windowClosed() after _windowClosed() was connected, animations for closing windows will fail. | 138 | * If you shadow _windowClosed() or connect your slot to EffectsHandler::windowClosed() after _windowClosed() was connected, animations for closing windows will fail. | ||
117 | */ | 139 | */ | ||
118 | AnimationEffect(); | 140 | AnimationEffect(); | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 175 | protected: | |||
185 | * | 207 | * | ||
186 | * Please use @function cancel to cancel an animation rather than altering it. | 208 | * Please use @function cancel to cancel an animation rather than altering it. | ||
187 | * NOTICE that you can NOT retarget an animation that just has just @function animationEnded ! | 209 | * NOTICE that you can NOT retarget an animation that just has just @function animationEnded ! | ||
188 | * @return whether there was such animation and it could be altered | 210 | * @return whether there was such animation and it could be altered | ||
189 | */ | 211 | */ | ||
190 | bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1); | 212 | bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1); | ||
191 | 213 | | |||
192 | /** | 214 | /** | ||
215 | * Changes the direction of the animation. | ||||
216 | * | ||||
217 | * @param animationId The id of the animation. | ||||
218 | * @param direction The new direction of the animation. | ||||
219 | * @param terminationPolicy Whether the animation should be terminated when it | ||||
220 | * reaches the source position after its direction was changed to go backward. | ||||
221 | * Please notice that this flag only relevant for persistent animations, i.e. | ||||
222 | * for animations created with AnimationEffect::set. | ||||
223 | * @returns @c true if the direction of the animation was changed successfully, | ||||
224 | * otherwise @c false. | ||||
225 | **/ | ||||
226 | bool redirect(quint64 animationId, | ||||
227 | Direction direction, | ||||
228 | TerminationPolicy terminationPolicy = TerminationPolicy::TerminateAtSource); | ||||
229 | | ||||
230 | /** | ||||
193 | * Called whenever an animation end, passes the transformed @class EffectWindow @enum Attribute and originally supplied @param meta | 231 | * Called whenever an animation end, passes the transformed @class EffectWindow @enum Attribute and originally supplied @param meta | ||
194 | * You can reimplement it to keep a constant transformation for the window (ie. keep it a this opacity or position) or to start another animation | 232 | * You can reimplement it to keep a constant transformation for the window (ie. keep it a this opacity or position) or to start another animation | ||
195 | */ | 233 | */ | ||
196 | virtual void animationEnded( EffectWindow *, Attribute, uint meta ) {Q_UNUSED(meta);} | 234 | virtual void animationEnded( EffectWindow *, Attribute, uint meta ) {Q_UNUSED(meta);} | ||
197 | 235 | | |||
198 | /** | 236 | /** | ||
199 | * Cancel a running animation. @return true if an animation for @p animationId was found (and canceled) | 237 | * Cancel a running animation. @return true if an animation for @p animationId was found (and canceled) | ||
200 | * NOTICE that there is NO animated reset of the original value. You'll have to provide that with a second animation | 238 | * NOTICE that there is NO animated reset of the original value. You'll have to provide that with a second animation | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |