summaryrefslogtreecommitdiff
path: root/animationsim.h
blob: 39fdc7738a737c6d1ae640f9c3ce13420111345a (plain)
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
#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <math.h>

#include <compiz-core.h>
#include <compiz-animation.h>

extern int animDisplayPrivateIndex;
extern CompMetadata animMetadata;

extern AnimEffect AnimEffectFlyIn;
extern AnimEffect AnimEffectBounce;
extern AnimEffect AnimEffectRotateIn;
extern AnimEffect AnimEffectSheets;
extern AnimEffect AnimEffectExpand;

#define NUM_EFFECTS 5

typedef enum
{
    // Effect settings
    ANIMSIM_SCREEN_OPTION_BOUNCE_MAX_SIZE,
    ANIMSIM_SCREEN_OPTION_BOUNCE_MIN_SIZE,
    ANIMSIM_SCREEN_OPTION_BOUNCE_NUMBER,
    ANIMSIM_SCREEN_OPTION_BOUNCE_FADE,
    ANIMSIM_SCREEN_OPTION_FLYIN_DIRECTION,
    ANIMSIM_SCREEN_OPTION_FLYIN_FADE,
    ANIMSIM_SCREEN_OPTION_FLYIN_DISTANCE,
    ANIMSIM_SCREEN_OPTION_ROTATEIN_ANGLE,
    ANIMSIM_SCREEN_OPTION_ROTATEIN_DIRECTION,
    ANIMSIM_SCREEN_OPTION_SHEET_START_PERCENT,

    ANIMSIM_SCREEN_OPTION_NUM
} AnimSimScreenOptions;

// This must have the value of the first "effect setting" above
// in AnimSimScreenOptions
#define NUM_NONEFFECT_OPTIONS 0

typedef enum _AnimSimDisplayOptions
{
    ANIMSIM_DISPLAY_OPTION_ABI = 0,
    ANIMSIM_DISPLAY_OPTION_INDEX,
    ANIMSIM_DISPLAY_OPTION_NUM
} AnimSimDisplayOptions;

typedef struct _WaveParam
{
    float halfWidth;
    float amp;
    float pos;
} WaveParam;

typedef struct _AnimSimDisplay
{
    int screenPrivateIndex;
    AnimBaseFunctions *animBaseFunc;

    CompOption opt[ANIMSIM_DISPLAY_OPTION_NUM];
} AnimSimDisplay;

typedef struct _AnimSimScreen
{
    int windowPrivateIndex;

    CompOutput *output;

    CompOption opt[ANIMSIM_SCREEN_OPTION_NUM];
} AnimSimScreen;

typedef struct _AnimSimWindow
{
    AnimWindowCommon *com;
    /* bounce props */
    int bounceCount;
    int nBounce;
    float currBounceProgress;
    float targetScale;
    float currentScale;
    float lastProgressMax;
    Bool bounceNeg;
    /* rotatein props */
    int rotatinModAngle;
    int currentCull;
    /* sheets props */
    int sheetsWaveCount;
    WaveParam *sheetsWaves;

} AnimSimWindow;

#define GET_ANIMSIM_DISPLAY(d)						\
    ((AnimSimDisplay *) (d)->base.privates[animDisplayPrivateIndex].ptr)

#define ANIMSIM_DISPLAY(d)				\
    AnimSimDisplay *ad = GET_ANIMSIM_DISPLAY (d)

#define GET_ANIMSIM_SCREEN(s, ad)						\
    ((AnimSimScreen *) (s)->base.privates[(ad)->screenPrivateIndex].ptr)

#define ANIMSIM_SCREEN(s)							\
    AnimSimScreen *as = GET_ANIMSIM_SCREEN (s, GET_ANIMSIM_DISPLAY (s->display))

#define GET_ANIMSIM_WINDOW(w, as)						\
    ((AnimSimWindow *) (w)->base.privates[(as)->windowPrivateIndex].ptr)

#define ANIMSIM_WINDOW(w)					     \
    AnimSimWindow *aw = GET_ANIMSIM_WINDOW (w,                     \
		     GET_ANIMSIM_SCREEN (w->screen,             \
		     GET_ANIMSIM_DISPLAY (w->screen->display)))

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

#define EXPLODE_PERCEIVED_T 0.7f

/*
 * Function prototypes
 *
 */

OPTION_GETTERS_HDR

/* flyin.c */

Bool
fxFlyinInit (CompWindow *w);

void
fxFlyinUpdateWindowAttrib (CompWindow * w,
			   WindowPaintAttrib *wAttrib);

void
fxFlyinAnimStep (CompWindow *w,
		 float time);

float
fxFlyinAnimProgress (CompWindow *w);

void
fxFlyinUpdateWindowTransform (CompWindow *w,
			      CompTransform *wTransform);

/* rotatein.c */

Bool
fxRotateinInit (CompWindow *w);

void
fxRotateinUpdateWindowAttrib (CompWindow * w,
			   WindowPaintAttrib *wAttrib);

void
fxRotateinAnimStep (CompWindow *w,
		 float time);

float
fxRotateinAnimProgress (CompWindow *w);

void
fxRotateinUpdateWindowTransform (CompWindow *w,
			      CompTransform *wTransform);

void
fxRotateinPrePaintWindow (CompWindow * w);

void
fxRotateinPostPaintWindow (CompWindow * w);

Bool
fxRotateinZoomToIcon (CompWindow *w);

/* bounce.c */

Bool
fxBounceInit (CompWindow *w);

void
fxBounceUpdateWindowAttrib (CompWindow * w,
			   WindowPaintAttrib *wAttrib);

void
fxBounceAnimStep (CompWindow *w,
		 float time);

float
fxBounceAnimProgress (CompWindow *w);

void
fxBounceUpdateWindowTransform (CompWindow *w,
			      CompTransform *wTransform);

/* sheets.c */

void
fxSheetsInitGrid (CompWindow *w,
		     int *gridWidth, 
		     int *gridHeight);

Bool
fxSheetsInit (CompWindow * w);

void
fxSheetsModelStep (CompWindow * w,
		      float time);

/* expand.c */

Bool
fxExpandInit (CompWindow *w);

void
fxExpandUpdateWindowAttrib (CompWindow * w,
			   WindowPaintAttrib *wAttrib);

void
fxExpandAnimStep (CompWindow *w,
		 float time);

float
fxExpandAnimProgress (CompWindow *w);

void
fxExpandUpdateWindowTransform (CompWindow *w,
			      CompTransform *wTransform);