]> icculus.org git repositories - dana/openbox.git/blob - render2/render.h
use RrPlanarHasAlpha to determine if parent should be copied
[dana/openbox.git] / render2 / render.h
1 #ifndef __render_h__
2 #define __render_h__
3
4 #include <glib.h>
5 #include <X11/Xlib.h>
6
7 /* instances */
8
9 struct RrInstance;
10
11 /*! Returns a struct to be used when calling members of the library.
12   If the library fails to initialize, NULL is returned.
13   @param display The X Display to use.
14   @param screen The number of the screen to use.
15 */
16 struct RrInstance *RrInstanceNew(Display *display,
17                                  int screen);
18
19 /*! Destroys an instance of the library. The instance should not be used after
20   calling this function.
21   @param inst The instance to destroy.
22 */
23 void RrInstanceFree(struct RrInstance *inst);
24
25 int RrInstanceDepth(struct RrInstance *inst);
26 Colormap RrInstanceColormap(struct RrInstance *inst);
27 Visual *RrInstanceVisual(struct RrInstance *inst);
28
29 /* colors */
30
31 /*! A Color (including alpha component) for the Render library. This should be
32   treated as an opaque data type, and be accessed only via the available
33   functions. */
34 struct RrColor {
35     /*! The red component. */
36     float r;
37     /*! The green component. */
38     float g;
39     /*! The blue component. */
40     float b;
41     /*! The alpha component. */
42     float a;
43 };
44
45 /*! Sets the values of all components for an RrColor */
46 #define RrColorSet(c, w, x, y, z) (c)->r = (w), (c)->g = (x), \
47                                   (c)->b = (y), (c)->a = z
48
49
50 /*! Gets color values from a colorname.
51   @param inst An instance of the library
52   @param colorname The name of the color.
53   @param ret The RrColor to set the colorvalues in.
54   @return nonzero if the colorname could be parsed; on error, it returns zero.
55 */
56 int RrColorParse(struct RrInstance *inst, const char *colorname,
57                  struct RrColor *ret);
58
59 /* fonts */
60
61 struct RrFont;
62
63 struct RrFont *RrFontOpen(struct RrInstance *inst, const char *fontstring);
64 void RrFontClose(struct RrFont *font);
65
66 int RrFontMeasureString(struct RrFont *font, const char *string);
67 int RrFontHeight(struct RrFont *font);
68 int RrFontMaxCharWidth(struct RrFont *font);
69
70 /* surfaces */
71
72 struct RrSurface;
73
74 enum RrSurfaceType {
75     RR_SURFACE_NONE,
76     RR_SURFACE_PLANAR,
77     RR_SURFACE_NONPLANAR
78 };
79
80 /*! Create a new RrSurface prototype that can't render. A prototype can be
81  copied to a new RrSurface that can render. */
82 struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type,
83                                     int numtex);
84 /*! Create a new top-level RrSurface for a Window. The new RrSurface defaults
85   to a non-visible state.*/
86 struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
87                                enum RrSurfaceType type,
88                                Window win,
89                                int numtex);
90 /*! Create a new RrSurface which is a child of another. The new RrSurface
91   defaults to a visible state. */
92 struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
93                                     struct RrSurface *parent,
94                                     int numtex);
95 /*! Destroys an RrSurface. */
96 void RrSurfaceFree(struct RrSurface *sur);
97
98 /*! Copy an RrSurface, setting the dest surface to be identical to the source
99  surface. */
100 void RrSurfaceCopy(struct RrSurface *dest,
101                    struct RrSurface *src);
102
103 void RrSurfaceSetArea(struct RrSurface *sur,
104                       int x,
105                       int y,
106                       int w,
107                       int h);
108 void RrSurfaceSetPos(struct RrSurface *sur,
109                      int x,
110                      int y);
111 void RrSurfaceSetSize(struct RrSurface *sur,
112                       int w,
113                       int h);
114
115 Window RrSurfaceWindow(struct RrSurface *sur);
116
117 void RrSurfaceShow(struct RrSurface *sur);
118 void RrSurfaceHide(struct RrSurface *sur);
119 int RrSurfaceVisible(struct RrSurface *sur);
120
121 void RrSurfaceMinSize(struct RrSurface *sur,
122                       int *w,
123                       int *h);
124
125 /*! Shape a surface to its children. This is not done implicitly inside the
126   library at *any* time. You must call this for each surface you want to
127   shape, when you want to update it. This means when you resize the surface
128   or change its base shape, or move/resize any of its children, you will need
129   to call this explicitly. Also, please note that you must call it on the
130   children surfaces first and work your way up to the top level surface for it
131   to function properly.
132 */
133 void RrSurfaceShape(struct RrSurface *sur);
134
135 /*! Set the base shape for a surface. To clear the base, pass 0 for all
136   of the arguments (except for the surface of course!)
137 */
138 void RrSurfaceShapeSetBase(struct RrSurface *sur,
139                            Window base,
140                            int x,
141                            int y);
142
143 /* planar surfaces */
144
145 /*! The options available for the background of an RrSurface */
146 enum RrSurfaceColorType {
147     /*! No rendering on the surface background, its contents will be
148       undefined. */
149     RR_PLANAR_NONE,
150     /*! Solid color fill. */
151     RR_PLANAR_SOLID,
152     /*! Horizontal gradient. */
153     RR_PLANAR_HORIZONTAL,
154     /*! Vertical gradient. */
155     RR_PLANAR_VERTICAL,
156     /*! Diagonal (TL->BR) gradient. */
157     RR_PLANAR_DIAGONAL,
158     /*! Cross-Diagonal (TR->BL) gradient. */
159     RR_PLANAR_CROSSDIAGONAL,
160     /*! Pipecross gradient. */
161     RR_PLANAR_PIPECROSS,
162     /*! Rectangle gradient. */
163     RR_PLANAR_RECTANGLE,
164     /*! Pyramid gradient. */
165     RR_PLANAR_PYRAMID
166 };
167
168 enum RrBevelType {
169     RR_SUNKEN_OUTER = -2,
170     RR_SUNKEN_INNER = -1,
171     RR_BEVEL_NONE   =  0,
172     RR_RAISED_INNER =  1,
173     RR_RAISED_OUTER =  2
174 };
175
176 void RrPlanarSet(struct RrSurface *sur,
177                  enum RrSurfaceColorType type,
178                  enum RrBevelType bevel,
179                  struct RrColor *primary,
180                  struct RrColor *secondary,
181                  int borderwidth,
182                  struct RrColor *border);
183
184 /* textures */
185
186 enum RrLayout {
187     RR_TOP_LEFT,
188     RR_TOP,
189     RR_TOP_RIGHT,
190     RR_LEFT,
191     RR_CENTER,
192     RR_RIGHT,
193     RR_BOTTOM_LEFT,
194     RR_BOTTOM,
195     RR_BOTTOM_RIGHT
196 };
197
198 #ifndef __LONG64
199 typedef long RrData32;
200 #else
201 typedef int RrData32;
202 #endif
203
204 void RrTextureSetRGBA(struct RrSurface *sur,
205                       int texnum,
206                       RrData32 *data,
207                       int x,
208                       int y,
209                       int w,
210                       int h);
211 void RrTextureSetText(struct RrSurface *sur,
212                       int texnum,
213                       struct RrFont *font,
214                       enum RrLayout layout,
215                       struct RrColor *color,
216                       const char *text);
217 void RrTextureSetNone(struct RrSurface *sur,
218                       int texnum);
219
220 /* drawing */
221
222 /*! Paints the surface, and optionally all its children */
223 void RrPaint(struct RrSurface *sur, int recurse_always);
224
225 void RrExpose(struct RrInstance *inst, XExposeEvent *e);
226
227 #endif