]> icculus.org git repositories - dana/openbox.git/blob - render2/theme.c
now cborder in merry's theme
[dana/openbox.git] / render2 / theme.c
1 #include "render.h"
2 #include "theme.h"
3 #include <stdlib.h>
4
5 struct RrTheme *RrThemeLoad(struct RrInstance *inst, const char *name)
6 {
7     struct RrTheme *theme;
8     struct RrColor pri, sec, bor;
9
10     theme = malloc(sizeof(struct RrTheme));
11     theme->inst = inst;
12
13 #define MERRY
14 #ifdef MERRY
15
16     theme->bevel = 1;
17     theme->bwidth = 1;
18     theme->cbwidth = 0;
19     theme->handle_height = 4;
20
21     theme->title_layout = "NLIMC";
22
23     theme->title_font = RrFontOpen(inst,
24                                   "arial:bold:pixelsize=10:"
25                                   "shadow:shadowoffset=1:shadowtint=0.1");
26     theme->title_justify = RR_CENTER;
27
28     RrColorSet(&theme->b_color, 0, 0, 0, 1);
29     RrColorSet(&theme->cb_color, 0, 0, 0, 1);
30     RrColorSet(&theme->cb_color_f, 0, 0, 0, 1);
31     RrColorSet(&theme->title_color, 1, 1, 1, 1);
32     RrColorSet(&theme->title_color_f, 1, 1, 1, 1);
33     RrColorSet(&theme->button_color, 0.3, 0.3, 0.3, 1);
34     RrColorSet(&theme->button_color_f, 0.12, 0.12, 0.12, 1);
35     RrColorSet(&theme->menu_title_color, 1, 1, 1, 1);
36     RrColorSet(&theme->menu_item_color, 1, 1, 1, 1);
37     RrColorSet(&theme->menu_disabled_color, 1, 1, 1, 1);
38     RrColorSet(&theme->menu_hilite_color, 1, 1, 1, 1);
39
40     theme->max = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
41     theme->max_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
42     theme->max_p = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
43     theme->max_p_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
44     theme->iconify = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
45     theme->iconify_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
46     theme->iconify_p = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
47     theme->iconify_p_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
48     theme->close = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
49     theme->close_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
50     theme->close_p = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
51     theme->close_p_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
52     theme->desk = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
53     theme->desk_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
54     theme->desk_p = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
55     theme->desk_p_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
56     theme->shade = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
57     theme->shade_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
58     theme->shade_p = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
59     theme->shade_p_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
60
61     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
62     RrPlanarSet(theme->max, RR_PLANAR_SOLID, RR_BEVEL_NONE,
63                 &pri, NULL, 0, NULL);
64     RrPlanarSet(theme->max_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
65                 &pri, NULL, 0, NULL);
66
67     RrColorSet(&pri, 0.71, 0.7, 0.68, 1);
68     RrPlanarSet(theme->max_p, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
69                 &pri, NULL, 0, NULL);
70     RrPlanarSet(theme->max_p_f, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
71                 &pri, NULL, 0, NULL);
72
73     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
74     RrPlanarSet(theme->iconify, RR_PLANAR_SOLID, RR_BEVEL_NONE,
75                 &pri, NULL, 0, NULL);
76     RrPlanarSet(theme->iconify_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
77                 &pri, NULL, 0, NULL);
78
79     RrColorSet(&pri, 0.71, 0.7, 0.68, 1);
80     RrPlanarSet(theme->iconify_p, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
81                 &pri, NULL, 0, NULL);
82     RrPlanarSet(theme->iconify_p_f, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
83                 &pri, NULL, 0, NULL);
84
85     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
86     RrPlanarSet(theme->close, RR_PLANAR_SOLID, RR_BEVEL_NONE,
87                 &pri, NULL, 0, NULL);
88     RrPlanarSet(theme->close_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
89                 &pri, NULL, 0, NULL);
90
91     RrColorSet(&pri, 0.71, 0.7, 0.68, 1);
92     RrPlanarSet(theme->close_p, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
93                 &pri, NULL, 0, NULL);
94     RrPlanarSet(theme->close_p_f, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
95                 &pri, NULL, 0, NULL);
96
97     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
98     RrPlanarSet(theme->desk, RR_PLANAR_SOLID, RR_BEVEL_NONE,
99                 &pri, NULL, 0, NULL);
100     RrPlanarSet(theme->desk_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
101                 &pri, NULL, 0, NULL);
102
103     RrColorSet(&pri, 0.71, 0.7, 0.68, 1);
104     RrPlanarSet(theme->desk_p, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
105                 &pri, NULL, 0, NULL);
106     RrPlanarSet(theme->desk_p_f, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
107                 &pri, NULL, 0, NULL);
108
109     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
110     RrPlanarSet(theme->shade, RR_PLANAR_SOLID, RR_BEVEL_NONE,
111                 &pri, NULL, 0, NULL);
112     RrPlanarSet(theme->shade_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
113                 &pri, NULL, 0, NULL);
114
115     RrColorSet(&pri, 0.71, 0.7, 0.68, 1);
116     RrPlanarSet(theme->shade_p, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
117                 &pri, NULL, 0, NULL);
118     RrPlanarSet(theme->shade_p_f, RR_PLANAR_SOLID, RR_SUNKEN_OUTER,
119                 &pri, NULL, 0, NULL);
120
121     theme->frame = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
122
123     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
124     RrColorSet(&bor, 0, 0, 0, 1);
125     RrPlanarSet(theme->frame, RR_PLANAR_SOLID, RR_BEVEL_NONE,
126                 &pri, NULL, 1, &bor);
127
128     theme->title = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
129     theme->title_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
130
131     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
132     RrColorSet(&bor, 0, 0, 0, 1);
133     RrPlanarSet(theme->title, RR_PLANAR_SOLID, RR_BEVEL_NONE,
134                 &pri, NULL, 1, &bor);
135     RrPlanarSet(theme->title_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
136                 &pri, NULL, 1, &bor);
137
138     theme->label = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
139     theme->label_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
140
141     RrColorSet(&pri, 0.70, 0.70, 0.68, 1);
142     RrColorSet(&sec, 0.75, 0.73, 0.71, 1);
143     RrColorSet(&bor, 0.42, 0.41, 0.42, 1);
144     RrPlanarSet(theme->label, RR_PLANAR_VERTICAL, RR_BEVEL_NONE,
145                 &pri, &sec, 1, &bor);
146     RrColorSet(&pri, 0.30, 0.34, 0.65, 1);
147     RrColorSet(&sec, 0.35, 0.43, 0.75, 1);
148     RrColorSet(&bor, 0, 0, 0, 1);
149     RrPlanarSet(theme->label_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
150                 &pri, &sec, 1, &bor);
151
152
153     theme->grip = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
154     theme->grip_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
155
156     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
157     RrColorSet(&bor, 0, 0, 0, 1);
158     RrPlanarSet(theme->grip, RR_PLANAR_SOLID, RR_BEVEL_NONE,
159                 &pri, NULL, 1, &bor);
160     RrPlanarSet(theme->grip_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
161                 &pri, NULL, 1, &bor);
162
163     theme->handle = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
164     theme->handle_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
165
166     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
167     RrColorSet(&bor, 0, 0, 0, 1);
168     RrPlanarSet(theme->handle, RR_PLANAR_SOLID, RR_BEVEL_NONE,
169                 &pri, NULL, 1, &bor);
170     RrPlanarSet(theme->handle_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
171                 &pri, NULL, 1, &bor);
172
173     theme->menu_title = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
174
175     RrColorSet(&pri, 0.29, 0.35, 0.65, 1);
176     RrColorSet(&bor, 0, 0, 0, 1);
177     RrPlanarSet(theme->menu_title, RR_PLANAR_SOLID, RR_BEVEL_NONE,
178                 &pri, NULL, 1, &bor);
179
180     theme->menu_item = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
181
182     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
183     RrPlanarSet(theme->menu_item, RR_PLANAR_SOLID, RR_BEVEL_NONE,
184                 &pri, NULL, 0, NULL);
185
186     theme->menu_disabled = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
187
188     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
189     RrPlanarSet(theme->menu_item, RR_PLANAR_SOLID, RR_BEVEL_NONE,
190                 &pri, NULL, 0, NULL);
191
192     theme->menu_hilite = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
193
194     /* app stuff */
195
196     RrColorSet(&theme->app_label_color, 1, 1, 1, 1);
197     RrColorSet(&theme->app_label_color_h, 1, 1, 1, 1);
198
199     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
200     RrPlanarSet(theme->menu_item, RR_PLANAR_SOLID, RR_BEVEL_NONE,
201                 &pri, NULL, 0, NULL);
202
203     theme->app_bg = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
204     theme->app_bg_h = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
205
206     RrColorSet(&pri, 0.9, 0.91, 0.9, 1);
207     RrColorSet(&bor, 0, 0, 0, 1);
208     RrPlanarSet(theme->app_bg, RR_PLANAR_SOLID, RR_BEVEL_NONE,
209                 &pri, NULL, 1, &bor);
210     RrPlanarSet(theme->app_bg_h, RR_PLANAR_SOLID, RR_BEVEL_NONE,
211                 &pri, NULL, 1, &bor);
212
213     theme->app_label = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
214     theme->app_label_h = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
215
216     RrColorSet(&pri, 0.70, 0.70, 0.68, 1);
217     RrColorSet(&sec, 0.75, 0.73, 0.71, 1);
218     RrColorSet(&bor, 0.42, 0.41, 0.42, 1);
219     RrPlanarSet(theme->app_label, RR_PLANAR_VERTICAL, RR_BEVEL_NONE,
220                 &pri, &sec, 1, &bor); 
221     RrColorSet(&pri, 0.30, 0.34, 0.65, 1);
222     RrColorSet(&sec, 0.35, 0.43, 0.75, 1);
223     RrColorSet(&bor, 0, 0, 0, 1);
224     RrPlanarSet(theme->app_label_h, RR_PLANAR_SOLID, RR_BEVEL_NONE,
225                 &pri, &sec, 1, &bor);
226
227 #endif
228
229     RrColorSet(&pri, 0, 0, 0, 0); /* clear */
230
231     theme->icon = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
232     RrPlanarSet(theme->icon, RR_PLANAR_SOLID, RR_BEVEL_NONE,
233                 &pri, NULL, 0, NULL);
234
235     theme->app_icon = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
236     RrPlanarSet(theme->app_icon, RR_PLANAR_SOLID, RR_BEVEL_NONE,
237                 &pri, NULL, 0, NULL);
238
239     return theme;
240 }
241
242 void RrThemeDestroy(struct RrTheme *theme)
243 {
244     if (theme) {
245         RrFontClose(theme->title_font);
246
247         RrSurfaceFree(theme->max);
248         RrSurfaceFree(theme->max_f);
249         RrSurfaceFree(theme->max_p);
250         RrSurfaceFree(theme->max_p_f);
251
252         RrSurfaceFree(theme->iconify);
253         RrSurfaceFree(theme->iconify_f);
254         RrSurfaceFree(theme->iconify_p);
255         RrSurfaceFree(theme->iconify_p_f);
256
257         RrSurfaceFree(theme->close);
258         RrSurfaceFree(theme->close_f);
259         RrSurfaceFree(theme->close_p);
260         RrSurfaceFree(theme->close_p_f);
261
262         RrSurfaceFree(theme->desk);
263         RrSurfaceFree(theme->desk_f);
264         RrSurfaceFree(theme->desk_p);
265         RrSurfaceFree(theme->desk_p_f);
266
267         RrSurfaceFree(theme->shade);
268         RrSurfaceFree(theme->shade_f);
269         RrSurfaceFree(theme->shade_p);
270         RrSurfaceFree(theme->shade_p_f);
271
272         RrSurfaceFree(theme->icon);
273
274         RrSurfaceFree(theme->frame);
275
276         RrSurfaceFree(theme->title);
277         RrSurfaceFree(theme->title_f);
278
279         RrSurfaceFree(theme->label);
280         RrSurfaceFree(theme->label_f);
281
282         RrSurfaceFree(theme->grip);
283         RrSurfaceFree(theme->grip_f);
284
285         RrSurfaceFree(theme->handle);
286         RrSurfaceFree(theme->handle_f);
287
288         RrSurfaceFree(theme->menu_title);
289         RrSurfaceFree(theme->menu_item);
290         RrSurfaceFree(theme->menu_disabled);
291         RrSurfaceFree(theme->menu_hilite);
292
293         RrSurfaceFree(theme->app_bg);
294         RrSurfaceFree(theme->app_bg_h);
295         RrSurfaceFree(theme->app_label);
296         RrSurfaceFree(theme->app_label_h);
297         RrSurfaceFree(theme->app_icon);
298
299         free(theme);
300     }
301 }