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 when the animation should be terminated. | ||||
124 | * | ||||
125 | * @value DontTerminate Don't terminate the animation when it reaches the source | ||||
126 | * or the target position. | ||||
127 | * | ||||
128 | * @value TerminateAtSource Terminate the animation when it reaches the source | ||||
129 | * position. An animation can reach the source position if its direction was | ||||
130 | * changed to go backward (from target to source). | ||||
131 | * | ||||
132 | * @value TerminateAtTarget Terminate the animation when it reaches the target | ||||
133 | * position. If this flag is not set, then the animation will be persistent. | ||||
134 | **/ | ||||
135 | enum TerminationFlag { | ||||
136 | DontTerminate = 0x00, | ||||
137 | TerminateAtSource = 0x01, | ||||
138 | TerminateAtTarget = 0x02 | ||||
139 | }; | ||||
140 | Q_FLAGS(TerminationFlag) | ||||
141 | Q_DECLARE_FLAGS(TerminationFlags, TerminationFlag) | ||||
142 | | ||||
111 | /** | 143 | /** | ||
112 | * Whenever you intend to connect to the EffectsHandler::windowClosed() signal, do so when reimplementing the constructor. | 144 | * 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 ) !! | 145 | * Do *not* add private slots named _windowClosed( EffectWindow* w ) or _windowDeleted( EffectWindow* w ) !! | ||
114 | * The AnimationEffect connects them right *after* the construction. | 146 | * 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. | 147 | * 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. | 148 | * If you shadow _windowClosed() or connect your slot to EffectsHandler::windowClosed() after _windowClosed() was connected, animations for closing windows will fail. | ||
117 | */ | 149 | */ | ||
118 | AnimationEffect(); | 150 | AnimationEffect(); | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 185 | protected: | |||
185 | * | 217 | * | ||
186 | * Please use @function cancel to cancel an animation rather than altering it. | 218 | * 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 ! | 219 | * 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 | 220 | * @return whether there was such animation and it could be altered | ||
189 | */ | 221 | */ | ||
190 | bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1); | 222 | bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1); | ||
191 | 223 | | |||
192 | /** | 224 | /** | ||
225 | * Changes the direction of the animation. | ||||
226 | * | ||||
227 | * @param animationId The id of the animation. | ||||
228 | * @param direction The new direction of the animation. | ||||
229 | * @param terminationPolicy Whether the animation should be terminated when it | ||||
230 | * reaches the source position after its direction was changed to go backward. | ||||
231 | * Currently, TerminationFlag::TerminateAtTarget has no effect. | ||||
232 | * @returns @c true if the direction of the animation was changed successfully, | ||||
233 | * otherwise @c false. | ||||
234 | **/ | ||||
235 | bool redirect(quint64 animationId, | ||||
236 | Direction direction, | ||||
237 | TerminationFlags terminationFlags = TerminateAtSource); | ||||
238 | | ||||
239 | /** | ||||
193 | * Called whenever an animation end, passes the transformed @class EffectWindow @enum Attribute and originally supplied @param meta | 240 | * 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 | 241 | * 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 | */ | 242 | */ | ||
196 | virtual void animationEnded( EffectWindow *, Attribute, uint meta ) {Q_UNUSED(meta);} | 243 | virtual void animationEnded( EffectWindow *, Attribute, uint meta ) {Q_UNUSED(meta);} | ||
197 | 244 | | |||
198 | /** | 245 | /** | ||
199 | * Cancel a running animation. @return true if an animation for @p animationId was found (and canceled) | 246 | * 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 | 247 | * NOTICE that there is NO animated reset of the original value. You'll have to provide that with a second animation | ||
Show All 30 Lines | 277 | private: | |||
231 | static QElapsedTimer s_clock; | 278 | static QElapsedTimer s_clock; | ||
232 | AnimationEffectPrivate * const d_ptr; | 279 | AnimationEffectPrivate * const d_ptr; | ||
233 | Q_DECLARE_PRIVATE(AnimationEffect) | 280 | Q_DECLARE_PRIVATE(AnimationEffect) | ||
234 | }; | 281 | }; | ||
235 | 282 | | |||
236 | 283 | | |||
237 | } // namespace | 284 | } // namespace | ||
238 | QDebug operator<<(QDebug dbg, const KWin::FPx2 &fpx2); | 285 | QDebug operator<<(QDebug dbg, const KWin::FPx2 &fpx2); | ||
286 | | ||||
239 | Q_DECLARE_METATYPE(KWin::FPx2) | 287 | Q_DECLARE_METATYPE(KWin::FPx2) | ||
288 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AnimationEffect::TerminationFlags) | ||||
240 | 289 | | |||
241 | #endif // ANIMATION_EFFECT_H | 290 | #endif // ANIMATION_EFFECT_H |