11 void RrPlanarSet(struct RrSurface *sur,
12 enum RrSurfaceColorType type,
13 enum RrBevelType bevel,
14 struct RrColor *primary,
15 struct RrColor *secondary,
17 struct RrColor *border)
19 sur->data.planar.colortype = type;
20 sur->data.planar.bevel = bevel;
21 sur->data.planar.primary = *primary;
22 if (!(type == RR_PLANAR_NONE || type == RR_PLANAR_SOLID))
23 sur->data.planar.secondary = *secondary;
24 assert(borderwidth >= 0);
25 sur->data.planar.borderwidth = borderwidth >= 0 ? borderwidth : 0;
27 sur->data.planar.border = *border;
30 int RrPlanarHasAlpha(struct RrSurface *sur)
32 if (RrColorHasAlpha(RrPlanarPrimaryColor(sur))) return 1;
33 if (!(RrPlanarColorType(sur) == RR_PLANAR_NONE ||
34 RrPlanarColorType(sur) == RR_PLANAR_SOLID))
35 if (RrColorHasAlpha(RrPlanarSecondaryColor(sur))) return 1;
39 static void copy_parent(struct RrSurface *sur)
44 switch (RrPlanarColorType(sur)) {
50 case RR_PLANAR_HORIZONTAL:
53 case RR_PLANAR_VERTICAL:
56 case RR_PLANAR_DIAGONAL:
59 case RR_PLANAR_CROSSDIAGONAL:
62 case RR_PLANAR_PYRAMID:
65 case RR_PLANAR_PIPECROSS:
68 case RR_PLANAR_RECTANGLE:
74 if (ncols >= 1 && RrColorHasAlpha(RrPlanarPrimaryColor(sur)))
76 if (ncols >= 1 && RrColorHasAlpha(RrPlanarSecondaryColor(sur)))
80 struct RrSurface *parent = RrSurfaceParent(sur);
84 RrDebug("copy parent here pls\n");
88 static void RrBevelPaint(int x, int y, int w, int h, int bwidth,
91 int offset = bwidth + inset;
95 glColor4f(1.0, 1.0, 1.0, 0.25);
97 glColor4f(0.0, 0.0, 0.0, 0.25);
100 glVertex2i(x + offset, y + offset);
101 glVertex2i(x + offset, y + h - offset);
103 glVertex2i(x + offset, y + h - offset);
104 glVertex2i(x + w - offset, y + h - offset);
107 glColor4f(1.0, 1.0, 1.0, 0.25);
109 glColor4f(0.0, 0.0, 0.0, 0.25);
111 glVertex2i(x + w - offset, y + h - offset);
112 glVertex2i(x + w - offset, y + offset);
114 glVertex2i(x + w - offset, y + offset);
115 glVertex2i(x + offset, y + offset);
119 static void RrBorderPaint(int x, int y, int w, int h, int bwidth,
120 struct RrColor *color)
122 int offset = bwidth / 2;
127 glBegin(GL_LINE_LOOP);
129 glVertex2i(x + offset, y + offset);
130 glVertex2i(x + offset, y + h - offset);
131 glVertex2i(x + w - offset, y + h - offset);
132 glVertex2i(x + w - offset, y + offset);
133 glLineWidth(1.0); /* XXX is this needed? */
137 void RrPlanarPaint(struct RrSurface *sur, int absx, int absy)
139 struct RrColor *pri, *sec, avg;
144 pri = &RrPlanarPrimaryColor(sur);
145 sec = &RrPlanarSecondaryColor(sur);
149 w = RrSurfaceWidth(sur);
150 h = RrSurfaceHeight(sur);
152 switch (RrPlanarColorType(sur)) {
155 case RR_PLANAR_SOLID:
156 glBegin(GL_TRIANGLES);
160 glVertex2i(x+w, y+h);
162 glVertex2i(x+w, y+h);
167 case RR_PLANAR_HORIZONTAL:
168 glBegin(GL_TRIANGLES);
173 glVertex2i(x+w, y+h);
175 glVertex2i(x+w, y+h);
181 case RR_PLANAR_VERTICAL:
182 glBegin(GL_TRIANGLES);
187 glVertex2i(x+w, y+h);
189 glVertex2i(x+w, y+h);
195 case RR_PLANAR_DIAGONAL:
196 RrColorAvg(&avg, pri, sec);
197 glBegin(GL_TRIANGLES);
203 glVertex2i(x+w, y+h);
206 glVertex2i(x+w, y+h);
213 case RR_PLANAR_CROSSDIAGONAL:
214 RrColorAvg(&avg, pri, sec);
215 glBegin(GL_TRIANGLES);
221 glVertex2i(x+w, y+h);
224 glVertex2i(x+w, y+h);
231 case RR_PLANAR_PYRAMID:
232 RrColorAvg(&avg, pri, sec);
233 glBegin(GL_TRIANGLES);
237 glVertex2i(x+w/2, y+h/2);
239 glVertex2i(x, y+h/2);
241 glVertex2i(x, y+h/2);
243 glVertex2i(x+w/2, y+h/2);
249 glVertex2i(x+w/2, y+h/2);
251 glVertex2i(x+w/2, y+h);
253 glVertex2i(x+w/2, y+h);
255 glVertex2i(x+w/2, y+h/2);
257 glVertex2i(x+w, y+h);
259 glVertex2i(x+w, y+h);
261 glVertex2i(x+w/2, y+h/2);
263 glVertex2i(x+w, y+h/2);
265 glVertex2i(x+w, y+h/2);
267 glVertex2i(x+w/2, y+h/2);
273 glVertex2i(x+w/2, y+h/2);
275 glVertex2i(x+w/2, y);
277 glVertex2i(x+w/2, y);
279 glVertex2i(x+w/2, y+h/2);
284 case RR_PLANAR_PIPECROSS:
285 glBegin(GL_TRIANGLES);
289 glVertex2i(x+w/2, y+h/2);
290 glVertex2i(x, y+h/2);
292 glVertex2i(x, y+h/2);
293 glVertex2i(x+w/2, y+h/2);
299 glVertex2i(x+w/2, y+h/2);
300 glVertex2i(x+w/2, y+h);
302 glVertex2i(x+w/2, y+h);
303 glVertex2i(x+w/2, y+h/2);
305 glVertex2i(x+w, y+h);
307 glVertex2i(x+w, y+h);
309 glVertex2i(x+w/2, y+h/2);
310 glVertex2i(x+w, y+h/2);
312 glVertex2i(x+w, y+h/2);
313 glVertex2i(x+w/2, y+h/2);
319 glVertex2i(x+w/2, y+h/2);
320 glVertex2i(x+w/2, y);
322 glVertex2i(x+w/2, y);
323 glVertex2i(x+w/2, y+h/2);
328 case RR_PLANAR_RECTANGLE:
329 glBegin(GL_TRIANGLES);
333 glVertex2i(x+w/2, y+h/2);
339 glVertex2i(x+w/2, y+h/2);
341 glVertex2i(x+w, y+h);
343 glVertex2i(x+w, y+h);
345 glVertex2i(x+w/2, y+h/2);
351 glVertex2i(x+w/2, y+h/2);
359 switch (RrPlanarBevelType(sur)) {
360 case RR_SUNKEN_OUTER:
361 RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur),
362 RrSurfaceWidth(sur), RrSurfaceHeight(sur),
363 RrPlanarBorderWidth(sur), 0, 0);
365 case RR_SUNKEN_INNER:
366 RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur),
367 RrSurfaceWidth(sur), RrSurfaceHeight(sur),
368 RrPlanarBorderWidth(sur), 1, 0);
370 case RR_RAISED_OUTER:
371 RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur),
372 RrSurfaceWidth(sur), RrSurfaceHeight(sur),
373 RrPlanarBorderWidth(sur), 0, 1);
375 case RR_RAISED_INNER:
376 RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur),
377 RrSurfaceWidth(sur), RrSurfaceHeight(sur),
378 RrPlanarBorderWidth(sur), 1, 1);
384 if (RrPlanarBorderWidth(sur))
385 RrBorderPaint(RrSurfaceX(sur), RrSurfaceY(sur),
386 RrSurfaceWidth(sur), RrSurfaceHeight(sur),
387 RrPlanarBorderWidth(sur), &RrPlanarBorderColor(sur));
390 void RrPlanarMinSize(struct RrSurface *sur, int *w, int *h)
392 *w = *h = RrPlanarBorderWidth(sur);
393 switch (RrPlanarBevelType(sur)) {
394 case RR_SUNKEN_OUTER:
398 case RR_SUNKEN_INNER:
402 case RR_RAISED_OUTER:
406 case RR_RAISED_INNER: