]> icculus.org git repositories - dana/openbox.git/blob - render2/render.h
can render.. only it doesnt work yet
[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 /* initialization */
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 *RrInit(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 RrDestroy(struct RrInstance *inst);
24
25
26 /* colors */
27
28 /*! A Color (including alpha component) for the Render library. This should be
29   treated as an opaque data type, and be accessed only via the available
30   functions. */
31 struct RrColor {
32     /*! The red component. */
33     float r;
34     /*! The green component. */
35     float g;
36     /*! The blue component. */
37     float b;
38     /*! The alpha component. */
39     float a;
40 };
41
42 /*! Returns if an RrColor is non-opaque */
43 #define RrColorHasAlpha(c) ((c).a > 0.0000001)
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_PLANAR,
76     RR_SURFACE_NONPLANAR
77 };
78
79 /*! Create a new RrSurface prototype that can't render. A prototype can be
80  copied to a new RrSurface that can render. */
81 struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type,
82                                     int numtex);
83 /*! Create a new top-level RrSurface for a Window. */
84 struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
85                                enum RrSurfaceType type,
86                                Window win,
87                                int numtex);
88 /*! Create a new RrSurface which is a child of another. */
89 struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
90                                     struct RrSurface *parent,
91                                     int numtex);
92 /*! Copy an RrSurface, creating a new top-level RrSurface for a Window. */
93 struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
94                                 struct RrSurface *sur,
95                                 Window win);
96 /*! Copy an RrSurface, creating a nwe RrSurface which is a child of another. */
97 struct RrSurface *RrSurfaceCopyChild(struct RrSurface *sur,
98                                      struct RrSurface *parent);
99 void RrSurfaceFree(struct RrSurface *sur);
100
101 void RrSurfaceSetArea(struct RrSurface *sur,
102                       int x,
103                       int y,
104                       int w,
105                       int h);
106
107 Window RrSurfaceWindow(struct RrSurface *sur);
108
109 /* planar surfaces */
110
111 /*! The options available for the background of an RrSurface */
112 enum RrSurfaceColorType {
113     /*! No rendering on the surface background, its contents will be
114       undefined. */
115     RR_PLANAR_NONE,
116     /*! Solid color fill. */
117     RR_PLANAR_SOLID,
118     /*! Horizontal gradient. */
119     RR_PLANAR_HORIZONTAL,
120     /*! Vertical gradient. */
121     RR_PLANAR_VERTICAL,
122     /*! Diagonal (TL->BR) gradient. */
123     RR_PLANAR_DIAGONAL,
124     /*! Cross-Diagonal (TR->BL) gradient. */
125     RR_PLANAR_CROSSDIAGONAL,
126     /*! Pipecross gradient. */
127     RR_PLANAR_PIPECROSS,
128     /*! Rectangle gradient. */
129     RR_PLANAR_RECTANGLE,
130     /*! Pyramid gradient. */
131     RR_PLANAR_PYRAMID
132 };
133
134 void RrPlanarSet(struct RrSurface *sur,
135                  enum RrSurfaceColorType type,
136                  struct RrColor *primary,
137                  struct RrColor *secondary);
138
139 /* textures */
140
141 enum RrLayout {
142     RR_TOP_LEFT,
143     RR_TOP,
144     RR_TOP_RIGHT,
145     RR_LEFT,
146     RR_CENTER,
147     RR_RIGHT,
148     RR_BOTTOM_LEFT,
149     RR_BOTTOM,
150     RR_BOTTOM_RIGHT
151 };
152
153 #ifndef __LONG64
154 typedef long RrData32;
155 #else
156 typedef int RrData32;
157 #endif
158
159 void RrTextureSetRGBA(struct RrSurface *sur,
160                       int texnum,
161                       RrData32 *data,
162                       int x,
163                       int y,
164                       int w,
165                       int h);
166 void RrTextureSetText(struct RrSurface *sur,
167                       int texnum,
168                       struct RrFont *font,
169                       enum RrLayout layout,
170                       const char *text);
171
172 /* drawing */
173
174 /*! Paints the surface, and all its children */
175 void RrPaint(struct RrSurface *sur);
176 /*! Paints the surface, and all its children, but only in the given area. */
177 void RrPaintArea(struct RrSurface *sur,
178                  int x,
179                  int y,
180                  int w,
181                  int h);
182
183 #endif