]> icculus.org git repositories - dana/openbox.git/blob - render2/render.h
pass expose events like i was before. cleanups in rendering to not render areas anymo...
[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 /*! Returns if an RrColor is non-opaque */
46 #define RrColorHasAlpha(c) ((c).a > 0.0000001)
47
48 /*! Sets the values of all components for an RrColor */
49 #define RrColorSet(c, w, x, y, z) (c)->r = (w), (c)->g = (x), \
50                                   (c)->b = (y), (c)->a = z
51
52
53 /*! Gets color values from a colorname.
54   @param inst An instance of the library
55   @param colorname The name of the color.
56   @param ret The RrColor to set the colorvalues in.
57   @return nonzero if the colorname could be parsed; on error, it returns zero.
58 */
59 int RrColorParse(struct RrInstance *inst, const char *colorname,
60                  struct RrColor *ret);
61
62 /* fonts */
63
64 struct RrFont;
65
66 struct RrFont *RrFontOpen(struct RrInstance *inst, const char *fontstring);
67 void RrFontClose(struct RrFont *font);
68
69 int RrFontMeasureString(struct RrFont *font, const char *string);
70 int RrFontHeight(struct RrFont *font);
71 int RrFontMaxCharWidth(struct RrFont *font);
72
73 /* surfaces */
74
75 struct RrSurface;
76
77 enum RrSurfaceType {
78     RR_SURFACE_NONE,
79     RR_SURFACE_PLANAR,
80     RR_SURFACE_NONPLANAR
81 };
82
83 /*! Create a new RrSurface prototype that can't render. A prototype can be
84  copied to a new RrSurface that can render. */
85 struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type,
86                                     int numtex);
87 /*! Create a new top-level RrSurface for a Window. The new RrSurface defaults
88   to a non-visible state.*/
89 struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
90                                enum RrSurfaceType type,
91                                Window win,
92                                int numtex);
93 /*! Create a new RrSurface which is a child of another. The new RrSurface
94   defaults to a visible state. */
95 struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
96                                     struct RrSurface *parent,
97                                     int numtex);
98 /*! Copy an RrSurface, creating a new top-level RrSurface for a Window. The
99   new RrSurface defaults to a non-visible state.*/
100 struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
101                                 struct RrSurface *sur,
102                                 Window win);
103 /*! Copy an RrSurface, creating a nwe RrSurface which is a child of another.
104   The new RrSurface defaults to a visible state.*/
105 struct RrSurface *RrSurfaceCopyChild(struct RrSurface *sur,
106                                      struct RrSurface *parent);
107 /*! Destroys an RrSurface. */
108 void RrSurfaceFree(struct RrSurface *sur);
109
110 void RrSurfaceSetArea(struct RrSurface *sur,
111                       int x,
112                       int y,
113                       int w,
114                       int h);
115 void RrSurfaceSetPos(struct RrSurface *sur,
116                      int x,
117                      int y);
118 void RrSurfaceSetSize(struct RrSurface *sur,
119                       int w,
120                       int h);
121
122 Window RrSurfaceWindow(struct RrSurface *sur);
123
124 void RrSurfaceShow(struct RrSurface *sur);
125 void RrSurfaceHide(struct RrSurface *sur);
126 int RrSurfaceVisible(struct RrSurface *sur);
127
128 void RrSurfaceMinSize(struct RrSurface *sur, int *w, int *h);
129
130 /* planar surfaces */
131
132 /*! The options available for the background of an RrSurface */
133 enum RrSurfaceColorType {
134     /*! No rendering on the surface background, its contents will be
135       undefined. */
136     RR_PLANAR_NONE,
137     /*! Solid color fill. */
138     RR_PLANAR_SOLID,
139     /*! Horizontal gradient. */
140     RR_PLANAR_HORIZONTAL,
141     /*! Vertical gradient. */
142     RR_PLANAR_VERTICAL,
143     /*! Diagonal (TL->BR) gradient. */
144     RR_PLANAR_DIAGONAL,
145     /*! Cross-Diagonal (TR->BL) gradient. */
146     RR_PLANAR_CROSSDIAGONAL,
147     /*! Pipecross gradient. */
148     RR_PLANAR_PIPECROSS,
149     /*! Rectangle gradient. */
150     RR_PLANAR_RECTANGLE,
151     /*! Pyramid gradient. */
152     RR_PLANAR_PYRAMID
153 };
154
155 void RrPlanarSet(struct RrSurface *sur,
156                  enum RrSurfaceColorType type,
157                  struct RrColor *primary,
158                  struct RrColor *secondary);
159
160 /* textures */
161
162 enum RrLayout {
163     RR_TOP_LEFT,
164     RR_TOP,
165     RR_TOP_RIGHT,
166     RR_LEFT,
167     RR_CENTER,
168     RR_RIGHT,
169     RR_BOTTOM_LEFT,
170     RR_BOTTOM,
171     RR_BOTTOM_RIGHT
172 };
173
174 #ifndef __LONG64
175 typedef long RrData32;
176 #else
177 typedef int RrData32;
178 #endif
179
180 void RrTextureSetRGBA(struct RrSurface *sur,
181                       int texnum,
182                       RrData32 *data,
183                       int x,
184                       int y,
185                       int w,
186                       int h);
187 void RrTextureSetText(struct RrSurface *sur,
188                       int texnum,
189                       struct RrFont *font,
190                       enum RrLayout layout,
191                       const char *text);
192 void RrTextureSetNone(struct RrSurface *sur,
193                       int texnum);
194
195 /* drawing */
196
197 /*! Paints the surface, and all its children */
198 void RrPaint(struct RrSurface *sur);
199
200 void RrExpose(struct RrInstance *inst, XExposeEvent *e);
201
202 #endif