1
#ifndef ANIMATION_ANIMEFFECT_H
2
#define ANIMATION_ANIMEFFECT_H
5
typedef Animation *(*CreateAnimFunc) (CompWindow *w,
6
WindowEvent curWindowEvent,
11
/// Animation info class that holds the name, the list of supported events, and
12
/// the creator function for a subclass of Animation.
13
/// A pointer to this class is used as an identifier for each implemented
18
AnimEffectInfo (const char *name,
19
bool usedO, bool usedC, bool usedM, bool usedS, bool usedF,
20
CreateAnimFunc create, bool isRestackAnim = false);
23
bool matchesEffectName (const CompString &animName);
25
bool matchesPluginName (const CompString &pluginName);
27
const char *name; ///< Name of the animation effect, e.g. "animationpack:Implode".
29
/// To be set to true for the window event animation list(s) that
30
/// the new animation (value) should be added to
31
/// (0: open, 1: close, 2: minimize, 3: shade, 4: focus)
32
bool usedForEvents[AnimEventNum];
34
/// Creates an instance of the Animation subclass and returns it as an
35
/// Animation instance.
36
CreateAnimFunc create;
38
/// Is it a complex focus animation? (i.e. restacking-related,
39
/// like FocusFade/Dodge)
44
Animation *createAnimation (CompWindow *w,
45
WindowEvent curWindowEvent,
47
const AnimEffect info,
50
return new T (w, curWindowEvent, duration, info, icon);
54
/** The base class for all animations.
55
A n*imations should derive from the closest animation class
56
to override as few methods as possible. Also, an animation
57
method should call ancestors' methods instead of duplicating
68
float mTimestep; ///< to store anim. timestep at anim. start
69
float mTimeElapsedWithinTimeStep;
71
int mTimeSinceLastPaint; ///< in milliseconds
73
int mOverrideProgressDir; ///< 0: default dir, 1: forward, 2: backward
75
GLFragment::Attrib mCurPaintAttrib;
76
GLushort mStoredOpacity;
77
WindowEvent mCurWindowEvent;
78
bool mInitialized; ///< whether the animation is initialized (in preparePaint)
80
AnimEffect mInfo; ///< information about the animation class
85
int mDecorBottomHeight;
87
GLTexture::List *texturesCache;
89
CompOption::Value &optVal (unsigned int optionId);
91
inline bool optValB (unsigned int optionId) { return optVal (optionId).b (); }
92
inline int optValI (unsigned int optionId) { return optVal (optionId).i (); }
93
inline float optValF (unsigned int optionId) { return optVal (optionId).f (); }
94
inline CompString optValS (unsigned int optionId) { return optVal (optionId).s (); }
95
inline unsigned short *optValC (unsigned int optionId) { return optVal (optionId).c (); }
99
Animation (CompWindow *w,
100
WindowEvent curWindowEvent,
102
const AnimEffect info,
103
const CompRect &icon);
104
virtual ~Animation ();
106
inline AnimEffect info () { return mInfo; }
108
// Overridable animation methods.
110
/// Needed since virtual method calls can't be done in the constructor.
111
virtual void init () {}
113
/// To be called during post-animation clean up.
114
virtual void cleanUp (bool closing,
117
/// Returns true if frame should be skipped (e.g. due to
118
/// higher timestep values). In that case no drawing is
119
/// needed for that window in current frame.
120
virtual bool shouldSkipFrame (int msSinceLastPaintActual);
122
/// Advances the animation time by the given time amount.
123
/// Returns true if more animation time is left.
124
virtual bool advanceTime (int msSinceLastPaint);
126
/// Computes new animation state based on remaining time.
127
virtual void step () {}
128
virtual void updateAttrib (GLWindowPaintAttrib &) {}
129
virtual void updateTransform (GLMatrix &) {}
130
virtual void prePaintWindow () {}
131
virtual void postPaintWindow () {}
132
virtual bool postPaintWindowUsed () { return false; }
134
/// Returns true if the animation is still in progress.
135
virtual bool prePreparePaint (int msSinceLastPaint) { return false; }
136
virtual void postPreparePaint () {}
138
/// Updates the bounding box of damaged region. Should be implemented for
139
/// any animation that doesn't update the whole screen.
140
virtual void updateBB (CompOutput &) {}
141
virtual bool updateBBUsed () { return false; }
143
/// Should return true for effects that make use of a region
144
/// instead of just a bounding box for damaged area.
145
virtual bool stepRegionUsed () { return false; }
147
virtual bool shouldDamageWindowOnStart ();
148
virtual bool shouldDamageWindowOnEnd ();
150
/// Should return false if the animation should be stopped on move
151
virtual bool moveUpdate (int dx, int dy) { return true; }
153
/// Should return false if the animation should be stopped on resize
154
virtual bool resizeUpdate (int dx, int dy,
155
int dwidth, int dheight) { return true; }
157
virtual void adjustPointerIconSize () {}
158
virtual void addGeometry (const GLTexture::MatrixList &matrix,
159
const CompRegion ®ion,
160
const CompRegion &clip,
161
unsigned int maxGridWidth,
162
unsigned int maxGridHeight);
163
virtual void drawGeometry ();
165
virtual bool paintWindowUsed () { return false; }
166
virtual bool paintWindow (GLWindow *gWindow,
167
const GLWindowPaintAttrib &attrib,
168
const GLMatrix &transform,
169
const CompRegion ®ion,
172
return gWindow->glPaint (attrib, transform, region, mask);
175
/// Gets info about the (extension) plugin that implements this animation.
176
/// Should be overriden by a base animation class in every extension plugin.
177
virtual ExtensionPluginInfo *getExtensionPluginInfo ();
179
void drawTexture (GLTexture *texture,
180
GLFragment::Attrib &attrib,
186
inline bool inProgress () { return (mRemainingTime > 0); }
188
inline WindowEvent curWindowEvent () { return mCurWindowEvent; }
189
inline float totalTime () { return mTotalTime; }
190
inline float remainingTime () { return mRemainingTime; }
192
float progressLinear ();
193
float progressEaseInEaseOut ();
194
float progressDecelerateCustom (float progress,
195
float minx, float maxx);
196
float progressDecelerate (float progress);
197
AnimDirection getActualAnimDirection (AnimDirection dir,
199
void perspectiveDistortAndResetZ (GLMatrix &transform);
201
static void prepareTransform (CompOutput &output,
202
GLMatrix &resultTransform,
203
GLMatrix &transform);
204
void setInitialized () { mInitialized = true; }
205
inline bool initialized () { return mInitialized; }
206
inline void setCurPaintAttrib (GLFragment::Attrib &newAttrib)
207
{ mCurPaintAttrib = newAttrib; }