1 /* Insert copyright */
2 #ifndef _COMPIZ_ELEMENTS_H
3 #define _COMPIZ_ELEMENTS_H
4 
5 #include <compiz-core.h>
6 
7 /* This is the number used to make sure that elements don't get all
8    created in one place. Bigger number, more distance.
9    Possibly fixable later. -> s->width? */
10 #define BIG_NUMBER		20000
11 
12 #define ELEMENTS_ABIVERSION     20081215
13 
14 typedef struct _ElementTypeInfo  ElementTypeInfo;
15 typedef struct _Element          Element;
16 typedef struct _ElementAnimation ElementAnimation;
17 typedef struct _ElementTexture   ElementTexture;
18 
19 typedef void (*ElementInitiateProc) (CompScreen *s,
20 				     Element    *e);
21 
22 typedef void (*ElementMoveProc) (CompScreen       *s,
23 				 ElementAnimation *anim,
24 				 Element          *e,
25 				 int              updateDelay);
26 
27 typedef void (*ElementFiniProc) (CompScreen *s,
28 				 Element    *e);
29 
30 /* Element Type management, extension plugins should call this to create
31    a new 'type' of element in the core of elements on initDisplay.
32    What is provided:
33    * CompDisplay *
34    * Element Name
35    * Function pointer to element initialization function
36    * Function pointer to element movement function
37    * Fuction  pointer to fini function
38  */
39 
40 typedef struct _ElementsBaseFunctions
41 {
42     Bool (*newElementType) (CompDisplay         *d,
43 			    char                *name,
44 			    char                *desc,
45 			    ElementInitiateProc initiate,
46 			    ElementMoveProc	move,
47 			    ElementFiniProc     fini);
48 
49     void (*removeElementType) (CompScreen *s,
50 			       char       *name);
51 
52     int (*getRand) (int min, int max);
53     float (*mmRand) (int min, int max, float divisor);
54 
55     int (*boxing) (CompScreen *s);
56     int (*depth) (CompScreen *s);
57 } ElementsBaseFunctions;
58 
59 struct _ElementTypeInfo
60 {
61     char *name;
62     char *desc;
63 
64     ElementInitiateProc initiate;
65     ElementMoveProc     move;
66     ElementFiniProc     fini;
67 
68     struct _ElementTypeInfo *next;
69 };
70 
71 struct _ElementTexture
72 {
73     CompTexture tex;
74 
75     unsigned int width;
76     unsigned int height;
77 
78     Bool   loaded;
79     GLuint dList;
80 };
81 
82 struct _Element
83 {
84     float x, y, z;
85     float dx, dy, dz;
86     float rSpeed;
87     int   rDirection;
88     int   rAngle;
89 
90     float opacity;
91     float glowAlpha;	/* Needs to be painted */
92     int   nTexture;
93 
94     void *ptr;		/* Extensions latch on to this */
95 };
96 
97 struct _ElementAnimation
98 {
99     char *type;
100     char *desc;
101 
102     int nElement;
103     int size;
104     int speed;
105     int id;		/* Uniquely idenitifies this animation */
106 
107     Bool rotate;
108 
109     Bool active;
110 
111     ElementTexture *texture;
112     int            nTextures;
113 
114     Element         *elements;
115     ElementTypeInfo *properties;
116 
117     struct _ElementAnimation *next;
118 };
119 
120 /* Resets an animation to defaults */
121 void initiateElement (CompScreen       *s,
122 		      ElementAnimation *anim,
123 		      Element          *ele,
124 		      Bool             rotate);
125 
126 /* Calls the movement function pointer for an element in an element animation */
127 void elementMove (CompScreen       *s,
128 		  Element          *e,
129 		  ElementAnimation *anim,
130 		  int              updateDelay);
131 
132 /* Used to update all element textures and settings */
133 void updateElementTextures (CompScreen *s,
134 			    Bool       changeTextures);
135 
136 /* Utility Functions */
137 int elementsGetRand (int min, int max);
138 float elementsMmRand(int  min, int max, float divisor);
139 int elementsGetEBoxing (CompScreen *s);
140 int elementsGetEDepth (CompScreen *s);
141 
142 /* Management of ElementAnimations */
143 ElementAnimation* elementsCreateAnimation (CompScreen *s,
144 					   char       *name);
145 void elementsDeleteAnimation (CompScreen       *s,
146 			      ElementAnimation *anim);
147 
148 #endif
149