1 /**
2 * This file is a part of the Cairo-Dock project
3 *
4 * Copyright : (C) see the 'copyright' file.
5 * E-mail    : see the 'copyright' file.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef __CD_APPLET_STRUCT__
22 #define  __CD_APPLET_STRUCT__
23 
24 #include <cairo-dock.h>
25 
26 #define CD_ANIMATIONS_SPOT_HEIGHT 12
27 
28 typedef enum {
29 	CD_SQUARE_MESH=0,
30 	CD_CUBE_MESH,
31 	CD_CAPSULE_MESH,
32 	CD_ANIMATIONS_NB_MESH
33 	} CDAnimationsMeshType;
34 
35 typedef enum {
36 	CD_HORIZONTAL_STRECTH=0,
37 	CD_VERTICAL_STRECTH,
38 	CD_CORNER_STRECTH,
39 	CD_ANIMATIONS_NB_STRECTH
40 	} CDAnimationsStretchType;
41 
42 // enumerations of the animations, which also corresponds to the list order in the conf file.
43 typedef enum {
44 	CD_ANIMATIONS_BOUNCE=0,
45 	CD_ANIMATIONS_ROTATE,
46 	CD_ANIMATIONS_BLINK,
47 	CD_ANIMATIONS_PULSE,
48 	CD_ANIMATIONS_WOBBLY,
49 	CD_ANIMATIONS_WAVE,
50 	CD_ANIMATIONS_SPOT,
51 	CD_ANIMATIONS_BUSY,
52 	CD_ANIMATIONS_NB_EFFECTS
53 	} CDAnimationsEffects;
54 
55 //\___________ structure containing the applet's configuration parameters.
56 struct _AppletConfig {
57 	gint iRotationDuration;
58 	gboolean bContinueRotation;
59 	CDAnimationsMeshType iMeshType;
60 	GLfloat pMeshColor[4];
61 
62 	gint iSpotDuration;
63 	gboolean bContinueSpot;
64 	GLfloat pSpotColor[3];
65 	gchar *cSpotImage;
66 	gchar *cSpotFrontImage;
67 	GLfloat pHaloColor[4];
68 	gdouble pRaysColor1[3];
69 	gdouble pRaysColor2[3];
70 	gboolean bMysticalRays;
71 	gint iNbRaysParticles;
72 	gint iRaysParticleSize;
73 	gdouble fRaysParticleSpeed;
74 
75 	gboolean bContinueWobbly;
76 	gint iNbGridNodes;
77 	CDAnimationsStretchType iInitialStrecth;
78 	gdouble fSpringConstant;
79 	gdouble fFriction;
80 
81 	gint iWaveDuration;
82 	gboolean bContinueWave;
83 	gdouble fWaveWidth;
84 	gdouble fWaveAmplitude;
85 
86 	gint iPulseDuration;
87 	gboolean bContinuePulse;
88 	gdouble fPulseZoom;
89 	gboolean bPulseSameShape;
90 
91 	gint iBounceDuration;
92 	gboolean bContinueBounce;
93 	gdouble fBounceResize;
94 	gdouble fBounceFlatten;
95 
96 	gint iBlinkDuration;
97 	gboolean bContinueBlink;
98 
99 	gint iBusyDuration;
100 	gboolean bContinueBusy;
101 	gchar *cBusyImage;
102 	gdouble fBusySize;
103 
104 	CDAnimationsEffects iEffectsOnMouseOver[CD_ANIMATIONS_NB_EFFECTS];
105 	CDAnimationsEffects iEffectsOnClick[CAIRO_DOCK_NB_GROUPS][CD_ANIMATIONS_NB_EFFECTS];
106 	gint iNbRoundsOnClick[CAIRO_DOCK_NB_GROUPS];
107 	gboolean bOpeningAnimation;
108 
109 	gboolean bContinue[CD_ANIMATIONS_NB_EFFECTS];
110 	} ;
111 
112 
113 typedef struct _CDAnimationData CDAnimationData;
114 
115 typedef struct _CDAnimation CDAnimation;
116 
117 typedef struct _CDCurrentAnimation CDCurrentAnimation;
118 
119 
120 typedef struct _CDAnimationGridNode {
121 	gdouble x, y;
122 	gdouble vx, vy;
123 	gdouble fx, fy;
124 	gdouble rk[5][4];
125 	} CDAnimationGridNode;
126 
127 #define CD_WAVE_NB_POINTS 9
128 
129 struct _CDAnimationData {
130 	gdouble fRotationSpeed;
131 	gdouble fRotationAngle;
132 	gdouble fRotationBrake;
133 	gdouble fAdjustFactor;
134 	gboolean bRotationBeginning;
135 	gdouble fRotateWidthFactor;
136 
137 	gdouble fIconOffsetY;
138 	gdouble fRadiusFactor;
139 	gdouble fHaloRotationAngle;
140 	CairoParticleSystem *pRaysSystem;
141 	gboolean bGrowingSpot;
142 
143 	CDAnimationGridNode gridNodes[4][4];
144 	GLfloat pCtrlPts[4][4][3];
145 	gint iWobblyCount;
146 	gdouble fWobblyWidthFactor, fWobblyHeightFactor;
147 
148 	gdouble fWavePosition;
149 	gint iNumActiveNodes;
150 	GLfloat pVertices[4*(CD_WAVE_NB_POINTS+2)];
151 	GLfloat pCoords[4*(CD_WAVE_NB_POINTS+2)];
152 
153 	gdouble fPulseSpeed;
154 	gdouble fPulseAlpha;
155 
156 	gint iNumRound;
157 
158 	gint iBounceCount;
159 	gdouble fElevation;
160 	gdouble fFlattenFactor;
161 	gdouble fResizeFactor;
162 
163 	gint iBlinkCount;
164 	gdouble fBlinkAlpha;
165 
166 	CairoDockImageBuffer *pBusyImage;
167 
168 	gboolean bIsUnfolding;
169 
170 	gint iReflectShadeCount;
171 	gboolean bHasBeenPulsed;
172 
173 	GList *pUsedAnimations;  // animations currently running on the icon, ordered by their rendering order.
174 	};
175 
176 
177 // generic Animation interface
178 struct _CDAnimation {
179 	// interface
180 	void (*init) (Icon *pIcon, CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bUseOpenGL);
181 	gboolean (*update) (Icon *pIcon, CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bUseOpenGL, gboolean bRepeat);  // returns TRUE if the round is still playing, FALSE if it has finished.
182 	void (*render) (Icon *pIcon, CairoDock *pDock, CDAnimationData *pData, cairo_t *pCairoContext);  // pCairoContext is NULL in OpenGL
183 	void (*post_render) (Icon *pIcon, CairoDock *pDock, CDAnimationData *pData, cairo_t *pCairoContext);  // pCairoContext is NULL in OpenGL
184 	// properties
185 	const gchar *cName;
186 	const gchar *cDisplayedName;
187 	gboolean bDrawIcon;  // whether the animation draws the icon itself (or just alter the drawing context).
188 	gboolean bDrawReflect;  // TRUE if the animation can draw the reflect itself.
189 	CDAnimationsEffects id;  // ID of the animation, the same as in the conf file.
190 	// internal
191 	guint iRenderingOrder;  // order in which it will be called during the rendering.
192 	guint iRegisteredId;  // registration ID in the core
193 	};
194 
195 
196 struct _CDCurrentAnimation {
197 	CDAnimation *pAnimation;
198 	gboolean bIsPlaying;  // TRUE if currently playing, FALSE if it has already finished.
199 	};
200 
201 
202 //\___________ structure containing the applet's data, like surfaces, dialogs, results of calculus, etc.
203 struct _AppletData {
204 	GLuint iChromeTexture;
205 	GLuint iCallList[CD_ANIMATIONS_NB_MESH];
206 	GLuint iSpotTexture;
207 	GLuint iHaloTexture;
208 	GLuint iSpotFrontTexture;
209 	GLuint iRaysTexture;
210 	CairoDockImageBuffer *pBusyImage;
211 	CDAnimation pAnimations[CD_ANIMATIONS_NB_EFFECTS];  // same order as in the conf file.
212 	} ;
213 
214 #endif
215