File: compiz-animation.h

package info (click to toggle)
compiz-fusion-plugins-main 0.8.4-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,912 kB
  • ctags: 2,567
  • sloc: ansic: 29,387; makefile: 738; sh: 9
file content (311 lines) | stat: -rw-r--r-- 8,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#ifndef _COMPIZ_ANIMATION_H
#define _COMPIZ_ANIMATION_H

#define ANIMATION_ABIVERSION 20081221

typedef enum
{
    WindowEventOpen = 0,
    WindowEventClose,
    WindowEventMinimize,
    WindowEventUnminimize,
    WindowEventShade,
    WindowEventUnshade,
    WindowEventFocus,
    WindowEventNum,
    WindowEventNone
} WindowEvent;

typedef enum
{
    AnimEventOpen = 0,
    AnimEventClose,
    AnimEventMinimize,
    AnimEventShade,
    AnimEventFocus,
    AnimEventNum
} AnimEvent;

typedef struct _AnimEffectProperties
{
    void (*updateWindowAttribFunc) (CompWindow *,
				    WindowPaintAttrib *);
    void (*prePaintWindowFunc) (CompWindow *);
    void (*postPaintWindowFunc) (CompWindow *);
    void (*animStepFunc) (CompWindow *, float time);
    Bool (*initFunc) (CompWindow *);
    void (*initGridFunc) (CompWindow *, int *, int *);
    void (*addCustomGeometryFunc) (CompWindow *, int, Box *,
				   int, CompMatrix *);
    void (*drawCustomGeometryFunc) (CompWindow *);
    Bool (*letOthersDrawGeomsFunc) (CompWindow *);
    void (*updateWinTransformFunc) (CompWindow *,
				    CompTransform *);
    Bool (*prePrepPaintScreenFunc) (CompWindow *, int msSinceLastPaint);
    void (*postPrepPaintScreenFunc) (CompWindow *);
    void (*updateBBFunc) (CompOutput *, CompWindow *, Box *);
    void (*cleanupFunc) (CompWindow *);
    void (*refreshFunc) (CompWindow *, Bool animInitialized);
    Bool (*zoomToIconFunc) (CompWindow *);
    Bool modelAnimIs3D;		// TRUE if anim uses model and 3d coords
    Bool useQTexCoord;		// TRUE if effect needs Q texture coordinates
    void *extraProperties;
} AnimEffectProperties;

typedef struct _AnimEffectInfo
{
    char *name; // name of the animation effect, e.g. "animationpack:Implode"

    // to be set to TRUE for the window event animation list(s) that
    // the new animation (value) should be added to
    // (0: open, 1: close, 2: minimize, 3: shade, 4: focus)
    Bool usedForEvents[AnimEventNum];

    AnimEffectProperties properties;
} AnimEffectInfo;

typedef const AnimEffectInfo * AnimEffect;

typedef struct _ExtensionPluginInfo
{
    unsigned int nEffects;
    AnimEffect *effects;

    // Plugin options to be used in "effect options" strings
    unsigned int nEffectOptions;
    CompOption *effectOptions;

    // Non-window functions
    void (*prePaintOutputFunc) (CompScreen *s, CompOutput *output);
} ExtensionPluginInfo;

typedef struct _xy_pair
{
    float x, y;
} Point, Vector;

typedef struct
{
    float x1, x2, y1, y2;
} Boxf;

typedef struct _xyz_tuple
{
    float x, y, z;
} Point3d, Vector3d;

typedef struct _Object
{
    Point gridPosition;		// position on window in [0,1] range
    Point3d position;		// position on screen

    // Texture x, y coordinates will be offset by given amounts
    // for quads that fall after and before this object in x and y directions.
    // Currently only y offset can be used.
    Point offsetTexCoordForQuadBefore;
    Point offsetTexCoordForQuadAfter;
} Object;

typedef struct _Model
{
    Object *objects;
    int numObjects;
    int gridWidth;
    int gridHeight;

    int winWidth;		// keeps win. size when model was created
    int winHeight;

    Vector scale;
    Point scaleOrigin;

    WindowEvent forWindowEvent;
    float topHeight;
    float bottomHeight;
} Model;

// Window properties common to multiple animation effects
typedef struct _AnimWindowCommon
{
    float animTotalTime;
    float animRemainingTime;
    float timestep;		// to be used in updateWindowAttribFunc

    int animOverrideProgressDir; // 0: default dir, 1: forward, 2: backward

    WindowEvent curWindowEvent;
    AnimEffect curAnimEffect;

    FragmentAttrib curPaintAttrib;

    Region drawRegion;
    Bool useDrawRegion;

    XRectangle icon;

    GLushort storedOpacity;

    CompTransform transform;
    Bool usingTransform;     // whether transform matrix is used for the current effect

    float transformStartProgress;
    float transformProgress;

    Model *model;   // for grid engine
} AnimWindowCommon;

typedef enum
{
    AnimDirectionDown = 0,
    AnimDirectionUp,
    AnimDirectionLeft,
    AnimDirectionRight,
    AnimDirectionRandom,
    AnimDirectionAuto
} AnimDirection;
#define LAST_ANIM_DIRECTION 5

typedef void
(*UpdateBBProc) (CompOutput *output,
		 CompWindow * w,
		 Box *BB);

// Base functions for extension plugins to call
typedef struct _AnimBaseFunctions {
    void (*addExtension) (CompScreen *s,
			  ExtensionPluginInfo *extensionPluginInfo);
    void (*removeExtension) (CompScreen *s,
			     ExtensionPluginInfo *extensionPluginInfo);
    CompOptionValue * (*getPluginOptVal)
	(CompWindow *w, ExtensionPluginInfo *extensionPluginInfo, int optionId);
    Bool (*getMousePointerXY) (CompScreen *s, short *x, short *y);
    UpdateBBProc	updateBBScreen;
    UpdateBBProc	updateBBWindow;
    UpdateBBProc	modelUpdateBB;
    UpdateBBProc	compTransformUpdateBB;
    Bool (*defaultAnimInit) (CompWindow * w);
    void (*defaultAnimStep) (CompWindow * w, float time);
    void (*defaultUpdateWindowTransform) (CompWindow *w,
					  CompTransform *wTransform);
    float (*getProgressAndCenter) (CompWindow *w,
				   Point *center);

    float (*defaultAnimProgress) (CompWindow *w);
    float (*sigmoidAnimProgress) (CompWindow *w);
    float (*decelerateProgressCustom) (float progress,
				       float minx,
				       float maxx);
    float (*decelerateProgress) (float progress);
    AnimDirection (*getActualAnimDirection) (CompWindow * w,
					     AnimDirection dir,
					     Bool openDir);
    void (*expandBoxWithBox) (Box *target, Box *source);
    void (*expandBoxWithPoint) (Box *target, float fx, float fy);
    void (*prepareTransform) (CompScreen *s,
			      CompOutput *output,
			      CompTransform *resultTransform,
			      CompTransform *transform);
    AnimWindowCommon * (*getAnimWindowCommon) (CompWindow *w);
    Bool (*returnTrue) (CompWindow *w);
    void (*postAnimationCleanup) (CompWindow *w);
    void (*fxZoomUpdateWindowAttrib) (CompWindow * w,
				      WindowPaintAttrib * wAttrib);
} AnimBaseFunctions;


#define OPTION_GETTERS(extensionBaseFunctions,				\
		       extensionPluginInfo, firstEffectOption)		\
static inline CompOptionValue *						\
animGetOptVal (CompWindow *w,						\
	       int optionId)						\
{									\
    return (extensionBaseFunctions)->getPluginOptVal			\
    	(w, (extensionPluginInfo), optionId - (firstEffectOption));	\
}						\
						\
inline Bool					\
animGetB (CompWindow *w,			\
	  int optionId)				\
{						\
    return animGetOptVal (w, optionId)->b;	\
}						\
						\
inline int					\
animGetI (CompWindow *w,			\
	  int optionId)				\
{						\
    return animGetOptVal (w, optionId)->i;	\
}						\
						\
inline float					\
animGetF (CompWindow *w,			\
	  int optionId)				\
{						\
    return animGetOptVal (w, optionId)->f;	\
}						\
						\
inline char *					\
animGetS (CompWindow *w,			\
	  int optionId)				\
{						\
    return animGetOptVal (w, optionId)->s;	\
}						\
						\
inline unsigned short *				\
animGetC (CompWindow *w,			\
	  int optionId)				\
{						\
    return animGetOptVal (w, optionId)->c;	\
}

#define OPTION_GETTERS_HDR			\
						\
inline Bool					\
animGetB (CompWindow *w,			\
	  int optionId);			\
						\
inline int					\
animGetI (CompWindow *w,			\
	  int optionId);			\
						\
inline float					\
animGetF (CompWindow *w,			\
	  int optionId);			\
						\
inline char *					\
animGetS (CompWindow *w,			\
	  int optionId);			\
						\
inline unsigned short *				\
animGetC (CompWindow *w,			\
	  int optionId);


#define WIN_X(w) ((w)->attrib.x - (w)->output.left)
#define WIN_Y(w) ((w)->attrib.y - (w)->output.top)
#define WIN_W(w) ((w)->width + (w)->output.left + (w)->output.right)
#define WIN_H(w) ((w)->height + (w)->output.top + (w)->output.bottom)

#define BORDER_X(w) ((w)->attrib.x - (w)->input.left)
#define BORDER_Y(w) ((w)->attrib.y - (w)->input.top)
#define BORDER_W(w) ((w)->width + (w)->input.left + (w)->input.right)
#define BORDER_H(w) ((w)->height + (w)->input.top + (w)->input.bottom)

#define RAND_FLOAT() ((float)rand() / RAND_MAX)

#define sigmoid(fx) (1.0f/(1.0f+exp(-5.0f*2*((fx)-0.5))))
#define sigmoid2(fx, s) (1.0f/(1.0f+exp(-(s)*2*((fx)-0.5))))

#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))


// ratio of perceived length of animation compared to real duration
// to make it appear to have the same speed with other animation effects

#define SPRINGY_ZOOM_PERCEIVED_T 0.55f
#define NONSPRINGY_ZOOM_PERCEIVED_T 0.6f
#define ZOOM_PERCEIVED_T 0.75f


#endif