be a bit more explicit about what is being copied from one texture to another
[openbox.git] / obrender / theme.c
blob85cdf4abfb3d5dea1edb5dae340221ab70f94d33
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
20 #include "render.h"
21 #include "color.h"
22 #include "font.h"
23 #include "mask.h"
24 #include "theme.h"
25 #include "icon.h"
26 #include "obt/paths.h"
28 #include <X11/Xlib.h>
29 #include <X11/Xresource.h>
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <string.h>
34 static XrmDatabase loaddb(const gchar *name, gchar **path);
35 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
36 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
37 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
38 const gchar *rname, RrColor **value);
39 static gboolean read_mask(const RrInstance *inst, const gchar *path,
40 RrTheme *theme, const gchar *maskname,
41 RrPixmapMask **value);
42 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
43 const gchar *rname, RrAppearance *value,
44 gboolean allow_trans);
45 static int parse_inline_number(const char *p);
46 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
47 static void set_default_appearance(RrAppearance *a);
48 static void read_button_colors(XrmDatabase db, const RrInstance *inst,
49 const RrTheme *theme, RrButton *btn,
50 const gchar *btnname);
52 static RrFont *get_font(RrFont *target, RrFont **default_font,
53 const RrInstance *inst)
55 if (target) {
56 RrFontRef(target);
57 return target;
58 } else {
59 /* Only load the default font once */
60 if (*default_font) {
61 RrFontRef(*default_font);
62 } else {
63 *default_font = RrFontOpenDefault(inst);
65 return *default_font;
69 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
70 if (!read_int(db, x_resstr, & x_var) || \
71 x_var < x_min || x_var > x_max) \
72 x_var = x_def;
74 #define READ_COLOR(x_resstr, x_var, x_def) \
75 if (!read_color(db, inst, x_resstr, & x_var)) \
76 x_var = x_def;
78 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
79 if (!read_color(db, inst, x_res1, & x_var) && \
80 !read_color(db, inst, x_res2, & x_var)) \
81 x_var = x_def;
83 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
84 if (!read_mask(inst, path, theme, x_file, & x_var)) \
85 x_var = RrPixmapMaskCopy(x_copysrc);
87 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
88 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
89 set_default_appearance(x_var);
91 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
92 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
93 RrAppearanceFree(x_var); \
94 x_var = RrAppearanceCopy(x_defval); }
96 #define READ_APPEARANCE_COPY_TEXTURES(x_resstr, x_var, x_parrel, x_defval, n_tex) \
97 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
98 RrAppearanceFree(x_var); \
99 x_var = RrAppearanceCopy(x_defval); \
100 RrAppearanceRemoveTextures(x_var); \
101 RrAppearanceAddTextures(x_var, 5); }
103 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
104 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
105 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
106 RrAppearanceFree(x_var); \
107 x_var = RrAppearanceCopy(x_defval); }
109 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
110 gboolean allow_fallback,
111 RrFont *active_window_font, RrFont *inactive_window_font,
112 RrFont *menu_title_font, RrFont *menu_item_font,
113 RrFont *active_osd_font, RrFont *inactive_osd_font)
115 XrmDatabase db = NULL;
116 RrJustify winjust, mtitlejust;
117 gchar *str;
118 RrTheme *theme;
119 RrFont *default_font = NULL;
120 gchar *path;
121 gboolean userdef;
122 gint menu_overlap = 0;
123 RrAppearance *a_disabled_focused_tmp;
124 RrAppearance *a_disabled_unfocused_tmp;
125 RrAppearance *a_hover_focused_tmp;
126 RrAppearance *a_hover_unfocused_tmp;
127 RrAppearance *a_focused_unpressed_tmp;
128 RrAppearance *a_focused_pressed_tmp;
129 RrAppearance *a_unfocused_unpressed_tmp;
130 RrAppearance *a_unfocused_pressed_tmp;
131 RrAppearance *a_toggled_hover_focused_tmp;
132 RrAppearance *a_toggled_hover_unfocused_tmp;
133 RrAppearance *a_toggled_focused_unpressed_tmp;
134 RrAppearance *a_toggled_focused_pressed_tmp;
135 RrAppearance *a_toggled_unfocused_unpressed_tmp;
136 RrAppearance *a_toggled_unfocused_pressed_tmp;
138 if (name) {
139 db = loaddb(name, &path);
140 if (db == NULL) {
141 g_message("Unable to load the theme '%s'", name);
142 if (allow_fallback)
143 g_message("Falling back to the default theme '%s'",
144 DEFAULT_THEME);
145 /* fallback to the default theme */
146 name = NULL;
149 if (name == NULL) {
150 if (allow_fallback) {
151 db = loaddb(DEFAULT_THEME, &path);
152 if (db == NULL) {
153 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
154 return NULL;
156 } else
157 return NULL;
160 /* initialize temp reading textures */
161 a_disabled_focused_tmp = RrAppearanceNew(inst, 1);
162 a_disabled_unfocused_tmp = RrAppearanceNew(inst, 1);
163 a_hover_focused_tmp = RrAppearanceNew(inst, 1);
164 a_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
165 a_toggled_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
166 a_toggled_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
167 a_toggled_hover_focused_tmp = RrAppearanceNew(inst, 1);
168 a_toggled_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
169 a_toggled_focused_pressed_tmp = RrAppearanceNew(inst, 1);
170 a_toggled_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
171 a_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
172 a_focused_pressed_tmp = RrAppearanceNew(inst, 1);
173 a_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
174 a_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
176 /* initialize theme */
177 theme = g_slice_new0(RrTheme);
179 theme->inst = inst;
180 theme->name = g_strdup(name ? name : DEFAULT_THEME);
182 /* init buttons */
183 theme->btn_max = RrButtonNew(inst);
184 theme->btn_close = RrButtonNew(inst);
185 theme->btn_desk = RrButtonNew(inst);
186 theme->btn_shade = RrButtonNew(inst);
187 theme->btn_iconify = RrButtonNew(inst);
189 /* init appearances */
190 theme->a_focused_grip = RrAppearanceNew(inst, 0);
191 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
192 theme->a_focused_title = RrAppearanceNew(inst, 0);
193 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
194 theme->a_focused_label = RrAppearanceNew(inst, 1);
195 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
196 theme->a_icon = RrAppearanceNew(inst, 1);
197 theme->a_focused_handle = RrAppearanceNew(inst, 0);
198 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
199 theme->a_menu = RrAppearanceNew(inst, 0);
200 theme->a_menu_title = RrAppearanceNew(inst, 0);
201 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
202 theme->a_menu_normal = RrAppearanceNew(inst, 0);
203 theme->a_menu_selected = RrAppearanceNew(inst, 0);
204 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
205 /* a_menu_disabled_selected is copied from a_menu_selected */
206 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
207 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
208 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
209 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
210 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
211 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
212 theme->a_clear = RrAppearanceNew(inst, 0);
213 theme->a_clear_tex = RrAppearanceNew(inst, 1);
214 theme->osd_bg = RrAppearanceNew(inst, 0);
215 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
216 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
217 theme->osd_unhilite_label = RrAppearanceNew(inst, 1);
218 theme->osd_unhilite_bg = RrAppearanceNew(inst, 0);
219 theme->osd_unpressed_button = RrAppearanceNew(inst, 1);
220 theme->osd_pressed_button = RrAppearanceNew(inst, 5);
221 theme->osd_focused_button = RrAppearanceNew(inst, 5);
223 /* load the font stuff */
224 theme->win_font_focused = get_font(active_window_font,
225 &default_font, inst);
226 theme->win_font_unfocused = get_font(inactive_window_font,
227 &default_font, inst);
229 winjust = RR_JUSTIFY_LEFT;
230 if (read_string(db, "window.label.text.justify", &str)) {
231 if (!g_ascii_strcasecmp(str, "right"))
232 winjust = RR_JUSTIFY_RIGHT;
233 else if (!g_ascii_strcasecmp(str, "center"))
234 winjust = RR_JUSTIFY_CENTER;
237 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
239 mtitlejust = RR_JUSTIFY_LEFT;
240 if (read_string(db, "menu.title.text.justify", &str)) {
241 if (!g_ascii_strcasecmp(str, "right"))
242 mtitlejust = RR_JUSTIFY_RIGHT;
243 else if (!g_ascii_strcasecmp(str, "center"))
244 mtitlejust = RR_JUSTIFY_CENTER;
247 theme->menu_font = get_font(menu_item_font, &default_font, inst);
249 theme->osd_font_hilite = get_font(active_osd_font, &default_font, inst);
250 theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst);
252 /* load direct dimensions */
253 READ_INT("menu.overlap", menu_overlap, -100, 100, 0);
254 READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, menu_overlap);
255 READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, menu_overlap);
256 READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
257 READ_INT("padding.width", theme->paddingx, 0, 100, 3);
258 READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
259 READ_INT("border.width", theme->fbwidth, 0, 100, 1);
260 READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
261 READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
262 READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
263 READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
264 READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
265 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
266 theme->paddingx);
267 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
268 theme->cbwidthx);
270 /* load colors */
271 READ_COLOR_("window.active.border.color", "border.color",
272 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
274 /* title separator focused color inherits from focused border color */
275 READ_COLOR("window.active.title.separator.color",
276 theme->title_separator_focused_color,
277 RrColorCopy(theme->frame_focused_border_color));
279 /* unfocused border color inherits from frame focused border color */
280 READ_COLOR("window.inactive.border.color",
281 theme->frame_unfocused_border_color,
282 RrColorCopy(theme->frame_focused_border_color));
284 /* title separator unfocused color inherits from unfocused border color */
285 READ_COLOR("window.inactive.title.separator.color",
286 theme->title_separator_unfocused_color,
287 RrColorCopy(theme->frame_unfocused_border_color));
289 /* menu border color inherits from frame focused border color */
290 READ_COLOR("menu.border.color", theme->menu_border_color,
291 RrColorCopy(theme->frame_focused_border_color));
293 /* osd border color inherits from frame focused border color */
294 READ_COLOR("osd.border.color", theme->osd_border_color,
295 RrColorCopy(theme->frame_focused_border_color));
297 READ_COLOR("window.active.client.color", theme->cb_focused_color,
298 RrColorNew(inst, 0xff, 0xff, 0xff));
300 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
301 RrColorNew(inst, 0xff, 0xff, 0xff));
303 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
304 RrColorNew(inst, 0x0, 0x0, 0x0));
306 READ_COLOR_("osd.active.label.text.color",
307 "osd.label.text.color",
308 theme->osd_text_active_color, RrColorCopy(theme->title_focused_color));
310 READ_COLOR("window.inactive.label.text.color", theme->title_unfocused_color,
311 RrColorCopy(theme->title_unfocused_color));
313 READ_COLOR("osd.inactive.label.text.color", theme->osd_text_inactive_color,
314 RrColorNew(inst, 0xff, 0xff, 0xff));
316 READ_COLOR("window.inactive.label.text.color",
317 theme->title_unfocused_color,
318 RrColorNew(inst, 0xff, 0xff, 0xff));
320 READ_COLOR("window.active.button.unpressed.image.color",
321 theme->titlebut_focused_unpressed_color,
322 RrColorNew(inst, 0, 0, 0));
324 READ_COLOR("window.inactive.button.unpressed.image.color",
325 theme->titlebut_unfocused_unpressed_color,
326 RrColorNew(inst, 0xff, 0xff, 0xff));
328 READ_COLOR("window.active.button.pressed.image.color",
329 theme->titlebut_focused_pressed_color,
330 RrColorCopy(theme->titlebut_focused_unpressed_color));
332 READ_COLOR("window.inactive.button.pressed.image.color",
333 theme->titlebut_unfocused_pressed_color,
334 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
336 READ_COLOR("window.active.button.disabled.image.color",
337 theme->titlebut_disabled_focused_color,
338 RrColorNew(inst, 0xff, 0xff, 0xff));
340 READ_COLOR("window.inactive.button.disabled.image.color",
341 theme->titlebut_disabled_unfocused_color,
342 RrColorNew(inst, 0, 0, 0));
344 READ_COLOR("window.active.button.hover.image.color",
345 theme->titlebut_hover_focused_color,
346 RrColorCopy(theme->titlebut_focused_unpressed_color));
348 READ_COLOR("window.inactive.button.hover.image.color",
349 theme->titlebut_hover_unfocused_color,
350 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
352 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
353 "window.active.button.toggled.image.color",
354 theme->titlebut_toggled_focused_unpressed_color,
355 RrColorCopy(theme->titlebut_focused_pressed_color));
357 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
358 "window.inactive.button.toggled.image.color",
359 theme->titlebut_toggled_unfocused_unpressed_color,
360 RrColorCopy(theme->titlebut_unfocused_pressed_color));
362 READ_COLOR("window.active.button.toggled.hover.image.color",
363 theme->titlebut_toggled_hover_focused_color,
364 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
366 READ_COLOR("window.inactive.button.toggled.hover.image.color",
367 theme->titlebut_toggled_hover_unfocused_color,
368 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
370 READ_COLOR("window.active.button.toggled.pressed.image.color",
371 theme->titlebut_toggled_focused_pressed_color,
372 RrColorCopy(theme->titlebut_focused_pressed_color));
374 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
375 theme->titlebut_toggled_unfocused_pressed_color,
376 RrColorCopy(theme->titlebut_unfocused_pressed_color));
378 READ_COLOR("menu.title.text.color", theme->menu_title_color,
379 RrColorNew(inst, 0, 0, 0));
381 READ_COLOR("menu.items.text.color", theme->menu_color,
382 RrColorNew(inst, 0xff, 0xff, 0xff));
384 READ_COLOR("menu.bullet.image.color", theme->menu_bullet_color,
385 RrColorCopy(theme->menu_color));
387 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
388 RrColorNew(inst, 0, 0, 0));
390 READ_COLOR("menu.items.active.disabled.text.color",
391 theme->menu_disabled_selected_color,
392 RrColorCopy(theme->menu_disabled_color));
394 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
395 RrColorNew(inst, 0, 0, 0));
397 READ_COLOR("menu.separator.color", theme->menu_sep_color,
398 RrColorCopy(theme->menu_color));
400 READ_COLOR("menu.bullet.selected.image.color",
401 theme->menu_bullet_selected_color,
402 RrColorCopy(theme->menu_selected_color));
404 READ_COLOR("osd.button.unpressed.text.color", theme->osd_unpressed_color,
405 RrColorCopy(theme->osd_text_active_color));
406 READ_COLOR("osd.button.pressed.text.color", theme->osd_pressed_color,
407 RrColorCopy(theme->osd_text_active_color));
408 READ_COLOR("osd.button.focused.text.color", theme->osd_focused_color,
409 RrColorCopy(theme->osd_text_active_color));
410 READ_COLOR("osd.button.pressed.box.color", theme->osd_pressed_lineart,
411 RrColorCopy(theme->titlebut_focused_pressed_color));
412 READ_COLOR("osd.button.focused.box.color", theme->osd_focused_lineart,
413 RrColorCopy(theme->titlebut_hover_focused_color));
415 /* load the image masks */
417 /* maximize button masks */
418 userdef = TRUE;
419 if (!read_mask(inst, path, theme, "max.xbm", &theme->btn_max->mask)) {
420 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
421 theme->btn_max->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
422 userdef = FALSE;
424 if (!read_mask(inst, path, theme, "max_toggled.xbm",
425 &theme->btn_max->toggled_mask))
427 if (userdef)
428 theme->btn_max->toggled_mask = RrPixmapMaskCopy(theme->btn_max->mask);
429 else {
430 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
431 theme->btn_max->toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
434 READ_MASK_COPY("max_pressed.xbm", theme->btn_max->pressed_mask,
435 theme->btn_max->mask);
436 READ_MASK_COPY("max_disabled.xbm", theme->btn_max->disabled_mask,
437 theme->btn_max->mask);
438 READ_MASK_COPY("max_hover.xbm", theme->btn_max->hover_mask,
439 theme->btn_max->mask);
440 READ_MASK_COPY("max_toggled_pressed.xbm",
441 theme->btn_max->toggled_pressed_mask,
442 theme->btn_max->toggled_mask);
443 READ_MASK_COPY("max_toggled_hover.xbm",
444 theme->btn_max->toggled_hover_mask,
445 theme->btn_max->toggled_mask);
447 /* iconify button masks */
448 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->btn_iconify->mask)) {
449 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
450 theme->btn_iconify->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
452 READ_MASK_COPY("iconify_pressed.xbm", theme->btn_iconify->pressed_mask,
453 theme->btn_iconify->mask);
454 READ_MASK_COPY("iconify_disabled.xbm", theme->btn_iconify->disabled_mask,
455 theme->btn_iconify->mask);
456 READ_MASK_COPY("iconify_hover.xbm", theme->btn_iconify->hover_mask,
457 theme->btn_iconify->mask);
459 /* all desktops button masks */
460 userdef = TRUE;
461 if (!read_mask(inst, path, theme, "desk.xbm", &theme->btn_desk->mask)) {
462 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
463 theme->btn_desk->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
464 userdef = FALSE;
466 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
467 &theme->btn_desk->toggled_mask)) {
468 if (userdef)
469 theme->btn_desk->toggled_mask = RrPixmapMaskCopy(theme->btn_desk->mask);
470 else {
471 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
472 theme->btn_desk->toggled_mask =
473 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
476 READ_MASK_COPY("desk_pressed.xbm", theme->btn_desk->pressed_mask,
477 theme->btn_desk->mask);
478 READ_MASK_COPY("desk_disabled.xbm", theme->btn_desk->disabled_mask,
479 theme->btn_desk->mask);
480 READ_MASK_COPY("desk_hover.xbm", theme->btn_desk->hover_mask, theme->btn_desk->mask);
481 READ_MASK_COPY("desk_toggled_pressed.xbm",
482 theme->btn_desk->toggled_pressed_mask, theme->btn_desk->toggled_mask);
483 READ_MASK_COPY("desk_toggled_hover.xbm", theme->btn_desk->toggled_hover_mask,
484 theme->btn_desk->toggled_mask);
486 /* shade button masks */
487 if (!read_mask(inst, path, theme, "shade.xbm", &theme->btn_shade->mask)) {
488 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
489 theme->btn_shade->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
491 READ_MASK_COPY("shade_toggled.xbm", theme->btn_shade->toggled_mask,
492 theme->btn_shade->mask);
493 READ_MASK_COPY("shade_pressed.xbm", theme->btn_shade->pressed_mask,
494 theme->btn_shade->mask);
495 READ_MASK_COPY("shade_disabled.xbm", theme->btn_shade->disabled_mask,
496 theme->btn_shade->mask);
497 READ_MASK_COPY("shade_hover.xbm", theme->btn_shade->hover_mask,
498 theme->btn_shade->mask);
499 READ_MASK_COPY("shade_toggled_pressed.xbm",
500 theme->btn_shade->toggled_pressed_mask,
501 theme->btn_shade->toggled_mask);
502 READ_MASK_COPY("shade_toggled_hover.xbm",
503 theme->btn_shade->toggled_hover_mask,
504 theme->btn_shade->toggled_mask);
506 /* close button masks */
507 if (!read_mask(inst, path, theme, "close.xbm", &theme->btn_close->mask)) {
508 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
509 theme->btn_close->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
511 READ_MASK_COPY("close_pressed.xbm", theme->btn_close->pressed_mask,
512 theme->btn_close->mask);
513 READ_MASK_COPY("close_disabled.xbm", theme->btn_close->disabled_mask,
514 theme->btn_close->mask);
515 READ_MASK_COPY("close_hover.xbm", theme->btn_close->hover_mask,
516 theme->btn_close->mask);
518 /* submenu bullet mask */
519 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
521 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
522 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
525 /* up and down arrows */
527 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
528 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
531 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
532 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
535 /* setup the default window icon */
536 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
537 OB_DEFAULT_ICON_HEIGHT,
538 OB_DEFAULT_ICON_pixel_data);
539 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
540 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
542 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
543 theme->btn_max->toggled_hover_mask =
544 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
545 theme->btn_desk->toggled_hover_mask =
546 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
547 theme->btn_shade->toggled_hover_mask =
548 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
549 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
550 theme->btn_max->toggled_pressed_mask =
551 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
552 theme->btn_desk->toggled_pressed_mask =
553 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
554 theme->btn_shade->toggled_pressed_mask =
555 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
557 /* read the decoration textures */
558 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
559 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
560 FALSE);
561 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
562 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
563 TRUE);
564 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
565 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
566 FALSE);
567 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
568 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
569 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
570 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
571 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
573 theme->a_menu_disabled_selected =
574 RrAppearanceCopy(theme->a_menu_selected);
576 /* read appearances for non-decorations (on-screen-display) */
577 if (!read_appearance(db, inst, "osd.bg", theme->osd_bg, FALSE)) {
578 RrAppearanceFree(theme->osd_bg);
579 theme->osd_bg = RrAppearanceCopy(theme->a_focused_title);
581 if (!read_appearance(db, inst, "osd.active.label.bg",
582 theme->osd_hilite_label, TRUE) &&
583 !read_appearance(db, inst, "osd.label.bg",
584 theme->osd_hilite_label, TRUE)) {
585 RrAppearanceFree(theme->osd_hilite_label);
586 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
588 if (!read_appearance(db, inst, "osd.inactive.label.bg",
589 theme->osd_unhilite_label, TRUE)) {
590 RrAppearanceFree(theme->osd_unhilite_label);
591 theme->osd_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
593 /* osd_hilite_fg can't be parentrel */
594 if (!read_appearance(db, inst, "osd.hilight.bg",
595 theme->osd_hilite_bg, FALSE)) {
596 RrAppearanceFree(theme->osd_hilite_bg);
597 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
598 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_label);
599 else
600 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
602 /* osd_unhilite_fg can't be parentrel either */
603 if (!read_appearance(db, inst, "osd.unhilight.bg",
604 theme->osd_unhilite_bg, FALSE)) {
605 RrAppearanceFree(theme->osd_unhilite_bg);
606 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
607 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_label);
608 else
609 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_title);
612 /* read buttons textures */
614 /* bases: unpressed, pressed, disabled */
615 READ_APPEARANCE("window.active.button.unpressed.bg",
616 a_focused_unpressed_tmp, TRUE);
617 READ_APPEARANCE("window.inactive.button.unpressed.bg",
618 a_unfocused_unpressed_tmp, TRUE);
619 READ_APPEARANCE("window.active.button.pressed.bg",
620 a_focused_pressed_tmp, TRUE);
621 READ_APPEARANCE("window.inactive.button.pressed.bg",
622 a_unfocused_pressed_tmp, TRUE);
623 READ_APPEARANCE("window.active.button.disabled.bg",
624 a_disabled_focused_tmp, TRUE);
625 READ_APPEARANCE("window.inactive.button.disabled.bg",
626 a_disabled_unfocused_tmp, TRUE);
628 /* hover */
629 READ_APPEARANCE_COPY("window.active.button.hover.bg",
630 a_hover_focused_tmp, TRUE,
631 a_focused_unpressed_tmp);
632 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
633 a_hover_unfocused_tmp, TRUE,
634 a_unfocused_unpressed_tmp);
636 /* toggled unpressed */
637 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
638 "window.active.button.toggled.bg",
639 a_toggled_focused_unpressed_tmp, TRUE,
640 a_focused_pressed_tmp);
641 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
642 "window.inactive.button.toggled.bg",
643 a_toggled_unfocused_unpressed_tmp, TRUE,
644 a_unfocused_pressed_tmp);
646 /* toggled pressed */
647 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
648 a_toggled_focused_pressed_tmp, TRUE,
649 a_focused_pressed_tmp);
650 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
651 a_toggled_unfocused_pressed_tmp, TRUE,
652 a_unfocused_pressed_tmp);
654 /* toggled hover */
655 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
656 a_toggled_hover_focused_tmp, TRUE,
657 a_toggled_focused_unpressed_tmp);
658 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
659 a_toggled_hover_unfocused_tmp, TRUE,
660 a_toggled_unfocused_unpressed_tmp);
663 /* now do individual buttons, if specified */
665 /* max button */
666 read_button_colors(db, inst, theme, theme->btn_max, "max");
668 /* bases: unpressed, pressed, disabled */
669 READ_APPEARANCE_COPY("window.active.button.max.unpressed.bg",
670 theme->btn_max->a_focused_unpressed, TRUE,
671 a_focused_unpressed_tmp);
672 READ_APPEARANCE_COPY("window.inactive.button.max.unpressed.bg",
673 theme->btn_max->a_unfocused_unpressed, TRUE,
674 a_unfocused_unpressed_tmp);
675 READ_APPEARANCE_COPY("window.active.button.max.pressed.bg",
676 theme->btn_max->a_focused_pressed, TRUE,
677 a_focused_pressed_tmp);
678 READ_APPEARANCE_COPY("window.inactive.button.max.pressed.bg",
679 theme->btn_max->a_unfocused_pressed, TRUE,
680 a_unfocused_pressed_tmp);
681 READ_APPEARANCE_COPY("window.active.button.max.disabled.bg",
682 theme->btn_max->a_disabled_focused, TRUE,
683 a_disabled_focused_tmp);
684 READ_APPEARANCE_COPY("window.inactive.button.max.disabled.bg",
685 theme->btn_max->a_disabled_unfocused, TRUE,
686 a_disabled_unfocused_tmp);
688 /* hover */
689 READ_APPEARANCE_COPY("window.active.button.max.hover.bg",
690 theme->btn_max->a_hover_focused, TRUE,
691 theme->btn_max->a_focused_unpressed);
692 READ_APPEARANCE_COPY("window.inactive.button.max.hover.bg",
693 theme->btn_max->a_hover_unfocused, TRUE,
694 theme->btn_max->a_unfocused_unpressed);
696 /* toggled unpressed */
697 READ_APPEARANCE_("window.active.button.max.toggled.unpressed.bg",
698 "window.active.button.max.toggled.bg",
699 theme->btn_max->a_toggled_focused_unpressed, TRUE,
700 theme->btn_max->a_focused_pressed);
701 READ_APPEARANCE_("window.inactive.button.max.toggled.unpressed.bg",
702 "window.inactive.button.max.toggled.bg",
703 theme->btn_max->a_toggled_unfocused_unpressed, TRUE,
704 theme->btn_max->a_unfocused_pressed);
706 /* toggled pressed */
707 READ_APPEARANCE_COPY("window.active.button.max.toggled.pressed.bg",
708 theme->btn_max->a_toggled_focused_pressed, TRUE,
709 theme->btn_max->a_focused_pressed);
710 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.pressed.bg",
711 theme->btn_max->a_toggled_unfocused_pressed, TRUE,
712 theme->btn_max->a_unfocused_pressed);
714 /* toggled hover */
715 READ_APPEARANCE_COPY("window.active.button.max.toggled.hover.bg",
716 theme->btn_max->a_toggled_hover_focused, TRUE,
717 theme->btn_max->a_toggled_focused_unpressed);
718 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.hover.bg",
719 theme->btn_max->a_toggled_hover_unfocused, TRUE,
720 theme->btn_max->a_toggled_unfocused_unpressed);
722 /* close button */
723 read_button_colors(db, inst, theme, theme->btn_close, "close");
725 READ_APPEARANCE_COPY("window.active.button.close.unpressed.bg",
726 theme->btn_close->a_focused_unpressed, TRUE,
727 a_focused_unpressed_tmp);
728 READ_APPEARANCE_COPY("window.inactive.button.close.unpressed.bg",
729 theme->btn_close->a_unfocused_unpressed, TRUE,
730 a_unfocused_unpressed_tmp);
731 READ_APPEARANCE_COPY("window.active.button.close.pressed.bg",
732 theme->btn_close->a_focused_pressed, TRUE,
733 a_focused_pressed_tmp);
734 READ_APPEARANCE_COPY("window.inactive.button.close.pressed.bg",
735 theme->btn_close->a_unfocused_pressed, TRUE,
736 a_unfocused_pressed_tmp);
737 READ_APPEARANCE_COPY("window.active.button.close.disabled.bg",
738 theme->btn_close->a_disabled_focused, TRUE,
739 a_disabled_focused_tmp);
740 READ_APPEARANCE_COPY("window.inactive.button.close.disabled.bg",
741 theme->btn_close->a_disabled_unfocused, TRUE,
742 a_disabled_unfocused_tmp);
743 READ_APPEARANCE_COPY("window.active.button.close.hover.bg",
744 theme->btn_close->a_hover_focused, TRUE,
745 theme->btn_close->a_focused_unpressed);
746 READ_APPEARANCE_COPY("window.inactive.button.close.hover.bg",
747 theme->btn_close->a_hover_unfocused, TRUE,
748 theme->btn_close->a_unfocused_unpressed);
750 /* desk button */
751 read_button_colors(db, inst, theme, theme->btn_desk, "desk");
753 /* bases: unpressed, pressed, disabled */
754 READ_APPEARANCE_COPY("window.active.button.desk.unpressed.bg",
755 theme->btn_desk->a_focused_unpressed, TRUE,
756 a_focused_unpressed_tmp);
757 READ_APPEARANCE_COPY("window.inactive.button.desk.unpressed.bg",
758 theme->btn_desk->a_unfocused_unpressed, TRUE,
759 a_unfocused_unpressed_tmp);
760 READ_APPEARANCE_COPY("window.active.button.desk.pressed.bg",
761 theme->btn_desk->a_focused_pressed, TRUE,
762 a_focused_pressed_tmp);
763 READ_APPEARANCE_COPY("window.inactive.button.desk.pressed.bg",
764 theme->btn_desk->a_unfocused_pressed, TRUE,
765 a_unfocused_pressed_tmp);
766 READ_APPEARANCE_COPY("window.active.button.desk.disabled.bg",
767 theme->btn_desk->a_disabled_focused, TRUE,
768 a_disabled_focused_tmp);
769 READ_APPEARANCE_COPY("window.inactive.button.desk.disabled.bg",
770 theme->btn_desk->a_disabled_unfocused, TRUE,
771 a_disabled_unfocused_tmp);
773 /* hover */
774 READ_APPEARANCE_COPY("window.active.button.desk.hover.bg",
775 theme->btn_desk->a_hover_focused, TRUE,
776 theme->btn_desk->a_focused_unpressed);
777 READ_APPEARANCE_COPY("window.inactive.button.desk.hover.bg",
778 theme->btn_desk->a_hover_unfocused, TRUE,
779 theme->btn_desk->a_unfocused_unpressed);
781 /* toggled unpressed */
782 READ_APPEARANCE_("window.active.button.desk.toggled.unpressed.bg",
783 "window.active.button.desk.toggled.bg",
784 theme->btn_desk->a_toggled_focused_unpressed, TRUE,
785 theme->btn_desk->a_focused_pressed);
786 READ_APPEARANCE_("window.inactive.button.desk.toggled.unpressed.bg",
787 "window.inactive.button.desk.toggled.bg",
788 theme->btn_desk->a_toggled_unfocused_unpressed, TRUE,
789 theme->btn_desk->a_unfocused_pressed);
791 /* toggled pressed */
792 READ_APPEARANCE_COPY("window.active.button.desk.toggled.pressed.bg",
793 theme->btn_desk->a_toggled_focused_pressed, TRUE,
794 theme->btn_desk->a_focused_pressed);
795 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.pressed.bg",
796 theme->btn_desk->a_toggled_unfocused_pressed, TRUE,
797 theme->btn_desk->a_unfocused_pressed);
799 /* toggled hover */
800 READ_APPEARANCE_COPY("window.active.button.desk.toggled.hover.bg",
801 theme->btn_desk->a_toggled_hover_focused, TRUE,
802 theme->btn_desk->a_toggled_focused_unpressed);
803 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.hover.bg",
804 theme->btn_desk->a_toggled_hover_unfocused, TRUE,
805 theme->btn_desk->a_toggled_unfocused_unpressed);
807 /* shade button */
808 read_button_colors(db, inst, theme, theme->btn_shade, "shade");
810 /* bases: unpressed, pressed, disabled */
811 READ_APPEARANCE_COPY("window.active.button.shade.unpressed.bg",
812 theme->btn_shade->a_focused_unpressed, TRUE,
813 a_focused_unpressed_tmp);
814 READ_APPEARANCE_COPY("window.inactive.button.shade.unpressed.bg",
815 theme->btn_shade->a_unfocused_unpressed, TRUE,
816 a_unfocused_unpressed_tmp);
817 READ_APPEARANCE_COPY("window.active.button.shade.pressed.bg",
818 theme->btn_shade->a_focused_pressed, TRUE,
819 a_focused_pressed_tmp);
820 READ_APPEARANCE_COPY("window.inactive.button.shade.pressed.bg",
821 theme->btn_shade->a_unfocused_pressed, TRUE,
822 a_unfocused_pressed_tmp);
823 READ_APPEARANCE_COPY("window.active.button.shade.disabled.bg",
824 theme->btn_shade->a_disabled_focused, TRUE,
825 a_disabled_focused_tmp);
826 READ_APPEARANCE_COPY("window.inactive.button.shade.disabled.bg",
827 theme->btn_shade->a_disabled_unfocused, TRUE,
828 a_disabled_unfocused_tmp);
830 /* hover */
831 READ_APPEARANCE_COPY("window.active.button.shade.hover.bg",
832 theme->btn_shade->a_hover_focused, TRUE,
833 theme->btn_shade->a_focused_unpressed);
834 READ_APPEARANCE_COPY("window.inactive.button.shade.hover.bg",
835 theme->btn_shade->a_hover_unfocused, TRUE,
836 theme->btn_shade->a_unfocused_unpressed);
838 /* toggled unpressed */
839 READ_APPEARANCE_("window.active.button.shade.toggled.unpressed.bg",
840 "window.active.button.shade.toggled.bg",
841 theme->btn_shade->a_toggled_focused_unpressed, TRUE,
842 theme->btn_shade->a_focused_pressed);
843 READ_APPEARANCE_("window.inactive.button.shade.toggled.unpressed.bg",
844 "window.inactive.button.shade.toggled.bg",
845 theme->btn_shade->a_toggled_unfocused_unpressed, TRUE,
846 theme->btn_shade->a_unfocused_pressed);
848 /* toggled pressed */
849 READ_APPEARANCE_COPY("window.active.button.shade.toggled.pressed.bg",
850 theme->btn_shade->a_toggled_focused_pressed, TRUE,
851 theme->btn_shade->a_focused_pressed);
852 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.pressed.bg",
853 theme->btn_shade->a_toggled_unfocused_pressed, TRUE,
854 theme->btn_shade->a_unfocused_pressed);
856 /* toggled hover */
857 READ_APPEARANCE_COPY("window.active.button.shade.toggled.hover.bg",
858 theme->btn_shade->a_toggled_hover_focused, TRUE,
859 theme->btn_shade->a_toggled_focused_unpressed);
860 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.hover.bg",
861 theme->btn_shade->a_toggled_hover_unfocused, TRUE,
862 theme->btn_shade->a_toggled_unfocused_unpressed);
864 /* iconify button */
865 read_button_colors(db, inst, theme, theme->btn_iconify, "iconify");
867 READ_APPEARANCE_COPY("window.active.button.iconify.unpressed.bg",
868 theme->btn_iconify->a_focused_unpressed, TRUE,
869 a_focused_unpressed_tmp);
870 READ_APPEARANCE_COPY("window.inactive.button.iconify.unpressed.bg",
871 theme->btn_iconify->a_unfocused_unpressed, TRUE,
872 a_unfocused_unpressed_tmp);
873 READ_APPEARANCE_COPY("window.active.button.iconify.pressed.bg",
874 theme->btn_iconify->a_focused_pressed, TRUE,
875 a_focused_pressed_tmp);
876 READ_APPEARANCE_COPY("window.inactive.button.iconify.pressed.bg",
877 theme->btn_iconify->a_unfocused_pressed, TRUE,
878 a_unfocused_pressed_tmp);
879 READ_APPEARANCE_COPY("window.active.button.iconify.disabled.bg",
880 theme->btn_iconify->a_disabled_focused, TRUE,
881 a_disabled_focused_tmp);
882 READ_APPEARANCE_COPY("window.inactive.button.iconify.disabled.bg",
883 theme->btn_iconify->a_disabled_unfocused, TRUE,
884 a_disabled_unfocused_tmp);
885 READ_APPEARANCE_COPY("window.active.button.iconify.hover.bg",
886 theme->btn_iconify->a_hover_focused, TRUE,
887 theme->btn_iconify->a_focused_unpressed);
888 READ_APPEARANCE_COPY("window.inactive.button.iconify.hover.bg",
889 theme->btn_iconify->a_hover_unfocused, TRUE,
890 theme->btn_iconify->a_unfocused_unpressed);
892 /* osd buttons */
893 READ_APPEARANCE_COPY("osd.button.unpressed.bg", theme->osd_unpressed_button, TRUE, a_focused_unpressed_tmp);
894 READ_APPEARANCE_COPY_TEXTURES("osd.button.pressed.bg", theme->osd_pressed_button, TRUE, a_focused_pressed_tmp, 5);
895 READ_APPEARANCE_COPY_TEXTURES("osd.button.focused.bg", theme->osd_focused_button, TRUE, a_focused_unpressed_tmp, 5);
897 theme->a_icon->surface.grad =
898 theme->a_clear->surface.grad =
899 theme->a_clear_tex->surface.grad =
900 theme->a_menu_text_title->surface.grad =
901 theme->a_menu_normal->surface.grad =
902 theme->a_menu_disabled->surface.grad =
903 theme->a_menu_text_normal->surface.grad =
904 theme->a_menu_text_selected->surface.grad =
905 theme->a_menu_text_disabled->surface.grad =
906 theme->a_menu_text_disabled_selected->surface.grad =
907 theme->a_menu_bullet_normal->surface.grad =
908 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
910 /* set up the textures */
911 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
912 theme->a_focused_label->texture[0].data.text.justify = winjust;
913 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
914 theme->a_focused_label->texture[0].data.text.color =
915 theme->title_focused_color;
917 if (read_string(db, "window.active.label.text.font", &str)) {
918 char *p;
919 gint i = 0;
920 gint j;
921 if (strstr(str, "shadow=y")) {
922 if ((p = strstr(str, "shadowoffset=")))
923 i = parse_inline_number(p + strlen("shadowoffset="));
924 else
925 i = 1;
926 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
927 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
929 if ((p = strstr(str, "shadowtint=")))
931 i = parse_inline_number(p + strlen("shadowtint="));
932 j = (i > 0 ? 0 : 255);
933 i = ABS(i*255/100);
935 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
936 theme->title_focused_shadow_alpha = i;
937 } else {
938 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
939 theme->title_focused_shadow_alpha = 50;
943 theme->a_focused_label->texture[0].data.text.shadow_color =
944 theme->title_focused_shadow_color;
945 theme->a_focused_label->texture[0].data.text.shadow_alpha =
946 theme->title_focused_shadow_alpha;
948 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
949 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
950 theme->osd_hilite_label->texture[0].data.text.font =
951 theme->osd_font_hilite;
952 theme->osd_hilite_label->texture[0].data.text.color =
953 theme->osd_text_active_color;
955 if (read_string(db, "osd.active.label.text.font", &str) ||
956 read_string(db, "osd.label.text.font", &str))
958 char *p;
959 gint i = 0;
960 gint j;
961 if (strstr(str, "shadow=y")) {
962 if ((p = strstr(str, "shadowoffset=")))
963 i = parse_inline_number(p + strlen("shadowoffset="));
964 else
965 i = 1;
966 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
967 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
969 if ((p = strstr(str, "shadowtint=")))
971 i = parse_inline_number(p + strlen("shadowtint="));
972 j = (i > 0 ? 0 : 255);
973 i = ABS(i*255/100);
975 theme->osd_text_active_shadow_color = RrColorNew(inst, j, j, j);
976 theme->osd_text_active_shadow_alpha = i;
977 } else {
978 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
979 theme->osd_text_active_shadow_alpha = 50;
981 } else {
982 /* inherit the font settings from the focused label */
983 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
984 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
985 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
986 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
987 if (theme->title_focused_shadow_color)
988 theme->osd_text_active_shadow_color =
989 RrColorNew(inst,
990 theme->title_focused_shadow_color->r,
991 theme->title_focused_shadow_color->g,
992 theme->title_focused_shadow_color->b);
993 else
994 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
995 theme->osd_text_active_shadow_alpha =
996 theme->title_focused_shadow_alpha;
999 theme->osd_hilite_label->texture[0].data.text.shadow_color =
1000 theme->osd_text_active_shadow_color;
1001 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
1002 theme->osd_text_active_shadow_alpha;
1004 theme->osd_unpressed_button->texture[0].type =
1005 theme->osd_pressed_button->texture[0].type =
1006 theme->osd_focused_button->texture[0].type =
1007 RR_TEXTURE_TEXT;
1009 theme->osd_unpressed_button->texture[0].data.text.justify =
1010 theme->osd_pressed_button->texture[0].data.text.justify =
1011 theme->osd_focused_button->texture[0].data.text.justify =
1012 RR_JUSTIFY_CENTER;
1014 theme->osd_unpressed_button->texture[0].data.text.font =
1015 theme->osd_pressed_button->texture[0].data.text.font =
1016 theme->osd_focused_button->texture[0].data.text.font =
1017 theme->osd_font_hilite;
1019 theme->osd_unpressed_button->texture[0].data.text.color =
1020 theme->osd_unpressed_color;
1021 theme->osd_pressed_button->texture[0].data.text.color =
1022 theme->osd_pressed_color;
1023 theme->osd_focused_button->texture[0].data.text.color =
1024 theme->osd_focused_color;
1026 theme->osd_pressed_button->texture[1].data.lineart.color =
1027 theme->osd_pressed_button->texture[2].data.lineart.color =
1028 theme->osd_pressed_button->texture[3].data.lineart.color =
1029 theme->osd_pressed_button->texture[4].data.lineart.color =
1030 theme->osd_pressed_lineart;
1032 theme->osd_focused_button->texture[1].data.lineart.color =
1033 theme->osd_focused_button->texture[2].data.lineart.color =
1034 theme->osd_focused_button->texture[3].data.lineart.color =
1035 theme->osd_focused_button->texture[4].data.lineart.color =
1036 theme->osd_focused_lineart;
1038 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
1039 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
1040 theme->a_unfocused_label->texture[0].data.text.font =
1041 theme->win_font_unfocused;
1042 theme->a_unfocused_label->texture[0].data.text.color =
1043 theme->title_unfocused_color;
1045 if (read_string(db, "window.inactive.label.text.font", &str)) {
1046 char *p;
1047 gint i = 0;
1048 gint j;
1049 if (strstr(str, "shadow=y")) {
1050 if ((p = strstr(str, "shadowoffset=")))
1051 i = parse_inline_number(p + strlen("shadowoffset="));
1052 else
1053 i = 1;
1054 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
1055 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
1057 if ((p = strstr(str, "shadowtint=")))
1059 i = parse_inline_number(p + strlen("shadowtint="));
1060 j = (i > 0 ? 0 : 255);
1061 i = ABS(i*255/100);
1063 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
1064 theme->title_unfocused_shadow_alpha = i;
1065 } else {
1066 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
1067 theme->title_unfocused_shadow_alpha = 50;
1071 theme->a_unfocused_label->texture[0].data.text.shadow_color =
1072 theme->title_unfocused_shadow_color;
1073 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
1074 theme->title_unfocused_shadow_alpha;
1076 theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
1077 theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
1078 theme->osd_unhilite_label->texture[0].data.text.font =
1079 theme->osd_font_unhilite;
1080 theme->osd_unhilite_label->texture[0].data.text.color =
1081 theme->osd_text_inactive_color;
1083 if (read_string(db, "osd.inactive.label.text.font", &str))
1085 char *p;
1086 gint i = 0;
1087 gint j;
1088 if (strstr(str, "shadow=y")) {
1089 if ((p = strstr(str, "shadowoffset=")))
1090 i = parse_inline_number(p + strlen("shadowoffset="));
1091 else
1092 i = 1;
1093 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x=i;
1094 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y=i;
1096 if ((p = strstr(str, "shadowtint=")))
1098 i = parse_inline_number(p + strlen("shadowtint="));
1099 j = (i > 0 ? 0 : 255);
1100 i = ABS(i*255/100);
1102 theme->osd_text_inactive_shadow_color = RrColorNew(inst, j, j, j);
1103 theme->osd_text_inactive_shadow_alpha = i;
1104 } else {
1105 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1106 theme->osd_text_inactive_shadow_alpha = 50;
1108 } else {
1109 /* inherit the font settings from the unfocused label */
1110 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x =
1111 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x;
1112 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y =
1113 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y;
1114 if (theme->title_unfocused_shadow_color)
1115 theme->osd_text_inactive_shadow_color =
1116 RrColorNew(inst,
1117 theme->title_unfocused_shadow_color->r,
1118 theme->title_unfocused_shadow_color->g,
1119 theme->title_unfocused_shadow_color->b);
1120 else
1121 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1122 theme->osd_text_inactive_shadow_alpha =
1123 theme->title_unfocused_shadow_alpha;
1126 theme->osd_unhilite_label->texture[0].data.text.shadow_color =
1127 theme->osd_text_inactive_shadow_color;
1128 theme->osd_unhilite_label->texture[0].data.text.shadow_alpha =
1129 theme->osd_text_inactive_shadow_alpha;
1131 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
1132 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
1133 theme->a_menu_text_title->texture[0].data.text.font =
1134 theme->menu_title_font;
1135 theme->a_menu_text_title->texture[0].data.text.color =
1136 theme->menu_title_color;
1138 if (read_string(db, "menu.title.text.font", &str)) {
1139 char *p;
1140 gint i = 0;
1141 gint j;
1142 if (strstr(str, "shadow=y")) {
1143 if ((p = strstr(str, "shadowoffset=")))
1144 i = parse_inline_number(p + strlen("shadowoffset="));
1145 else
1146 i = 1;
1147 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1148 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1150 if ((p = strstr(str, "shadowtint=")))
1152 i = parse_inline_number(p + strlen("shadowtint="));
1153 j = (i > 0 ? 0 : 255);
1154 i = ABS(i*255/100);
1156 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1157 theme->menu_title_shadow_alpha = i;
1158 } else {
1159 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1160 theme->menu_title_shadow_alpha = 50;
1164 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1165 theme->menu_title_shadow_color;
1166 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1167 theme->menu_title_shadow_alpha;
1169 theme->a_menu_text_normal->texture[0].type =
1170 theme->a_menu_text_selected->texture[0].type =
1171 theme->a_menu_text_disabled->texture[0].type =
1172 theme->a_menu_text_disabled_selected->texture[0].type =
1173 RR_TEXTURE_TEXT;
1174 theme->a_menu_text_normal->texture[0].data.text.justify =
1175 theme->a_menu_text_selected->texture[0].data.text.justify =
1176 theme->a_menu_text_disabled->texture[0].data.text.justify =
1177 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1178 RR_JUSTIFY_LEFT;
1179 theme->a_menu_text_normal->texture[0].data.text.font =
1180 theme->a_menu_text_selected->texture[0].data.text.font =
1181 theme->a_menu_text_disabled->texture[0].data.text.font =
1182 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1183 theme->menu_font;
1184 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1185 theme->a_menu_text_selected->texture[0].data.text.color =
1186 theme->menu_selected_color;
1187 theme->a_menu_text_disabled->texture[0].data.text.color =
1188 theme->menu_disabled_color;
1189 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1190 theme->menu_disabled_selected_color;
1192 if (read_string(db, "menu.items.font", &str)) {
1193 char *p;
1194 gint i = 0;
1195 gint j;
1196 if (strstr(str, "shadow=y")) {
1197 if ((p = strstr(str, "shadowoffset=")))
1198 i = parse_inline_number(p + strlen("shadowoffset="));
1199 else
1200 i = 1;
1201 theme->a_menu_text_normal->
1202 texture[0].data.text.shadow_offset_x = i;
1203 theme->a_menu_text_normal->
1204 texture[0].data.text.shadow_offset_y = i;
1205 theme->a_menu_text_selected->
1206 texture[0].data.text.shadow_offset_x = i;
1207 theme->a_menu_text_selected->
1208 texture[0].data.text.shadow_offset_y = i;
1209 theme->a_menu_text_disabled->
1210 texture[0].data.text.shadow_offset_x = i;
1211 theme->a_menu_text_disabled->
1212 texture[0].data.text.shadow_offset_y = i;
1213 theme->a_menu_text_disabled_selected->
1214 texture[0].data.text.shadow_offset_x = i;
1215 theme->a_menu_text_disabled_selected->
1216 texture[0].data.text.shadow_offset_y = i;
1218 if ((p = strstr(str, "shadowtint=")))
1220 i = parse_inline_number(p + strlen("shadowtint="));
1221 j = (i > 0 ? 0 : 255);
1222 i = ABS(i*255/100);
1224 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1225 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1226 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1227 theme->menu_text_normal_shadow_alpha = i;
1228 theme->menu_text_selected_shadow_alpha = i;
1229 theme->menu_text_disabled_shadow_alpha = i;
1230 theme->menu_text_disabled_selected_shadow_alpha = i;
1231 } else {
1232 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1233 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1234 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1235 theme->menu_text_normal_shadow_alpha = 50;
1236 theme->menu_text_selected_shadow_alpha = 50;
1237 theme->menu_text_disabled_selected_shadow_alpha = 50;
1241 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1242 theme->menu_text_normal_shadow_color;
1243 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1244 theme->menu_text_normal_shadow_alpha;
1245 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1246 theme->menu_text_selected_shadow_color;
1247 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1248 theme->menu_text_selected_shadow_alpha;
1249 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1250 theme->menu_text_disabled_shadow_color;
1251 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1252 theme->menu_text_disabled_shadow_alpha;
1253 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1254 theme->menu_text_disabled_shadow_color;
1255 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1256 theme->menu_text_disabled_shadow_alpha;
1258 theme->btn_max->a_disabled_focused->texture[0].type =
1259 theme->btn_max->a_disabled_unfocused->texture[0].type =
1260 theme->btn_max->a_hover_focused->texture[0].type =
1261 theme->btn_max->a_hover_unfocused->texture[0].type =
1262 theme->btn_max->a_toggled_hover_focused->texture[0].type =
1263 theme->btn_max->a_toggled_hover_unfocused->texture[0].type =
1264 theme->btn_max->a_toggled_focused_unpressed->texture[0].type =
1265 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].type =
1266 theme->btn_max->a_toggled_focused_pressed->texture[0].type =
1267 theme->btn_max->a_toggled_unfocused_pressed->texture[0].type =
1268 theme->btn_max->a_focused_unpressed->texture[0].type =
1269 theme->btn_max->a_focused_pressed->texture[0].type =
1270 theme->btn_max->a_unfocused_unpressed->texture[0].type =
1271 theme->btn_max->a_unfocused_pressed->texture[0].type =
1272 theme->btn_close->a_disabled_focused->texture[0].type =
1273 theme->btn_close->a_disabled_unfocused->texture[0].type =
1274 theme->btn_close->a_hover_focused->texture[0].type =
1275 theme->btn_close->a_hover_unfocused->texture[0].type =
1276 theme->btn_close->a_focused_unpressed->texture[0].type =
1277 theme->btn_close->a_focused_pressed->texture[0].type =
1278 theme->btn_close->a_unfocused_unpressed->texture[0].type =
1279 theme->btn_close->a_unfocused_pressed->texture[0].type =
1280 theme->btn_desk->a_disabled_focused->texture[0].type =
1281 theme->btn_desk->a_disabled_unfocused->texture[0].type =
1282 theme->btn_desk->a_hover_focused->texture[0].type =
1283 theme->btn_desk->a_hover_unfocused->texture[0].type =
1284 theme->btn_desk->a_toggled_hover_focused->texture[0].type =
1285 theme->btn_desk->a_toggled_hover_unfocused->texture[0].type =
1286 theme->btn_desk->a_toggled_focused_unpressed->texture[0].type =
1287 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].type =
1288 theme->btn_desk->a_toggled_focused_pressed->texture[0].type =
1289 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].type =
1290 theme->btn_desk->a_focused_unpressed->texture[0].type =
1291 theme->btn_desk->a_focused_pressed->texture[0].type =
1292 theme->btn_desk->a_unfocused_unpressed->texture[0].type =
1293 theme->btn_desk->a_unfocused_pressed->texture[0].type =
1294 theme->btn_shade->a_disabled_focused->texture[0].type =
1295 theme->btn_shade->a_disabled_unfocused->texture[0].type =
1296 theme->btn_shade->a_hover_focused->texture[0].type =
1297 theme->btn_shade->a_hover_unfocused->texture[0].type =
1298 theme->btn_shade->a_toggled_hover_focused->texture[0].type =
1299 theme->btn_shade->a_toggled_hover_unfocused->texture[0].type =
1300 theme->btn_shade->a_toggled_focused_unpressed->texture[0].type =
1301 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].type =
1302 theme->btn_shade->a_toggled_focused_pressed->texture[0].type =
1303 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].type =
1304 theme->btn_shade->a_focused_unpressed->texture[0].type =
1305 theme->btn_shade->a_focused_pressed->texture[0].type =
1306 theme->btn_shade->a_unfocused_unpressed->texture[0].type =
1307 theme->btn_shade->a_unfocused_pressed->texture[0].type =
1308 theme->btn_iconify->a_disabled_focused->texture[0].type =
1309 theme->btn_iconify->a_disabled_unfocused->texture[0].type =
1310 theme->btn_iconify->a_hover_focused->texture[0].type =
1311 theme->btn_iconify->a_hover_unfocused->texture[0].type =
1312 theme->btn_iconify->a_focused_unpressed->texture[0].type =
1313 theme->btn_iconify->a_focused_pressed->texture[0].type =
1314 theme->btn_iconify->a_unfocused_unpressed->texture[0].type =
1315 theme->btn_iconify->a_unfocused_pressed->texture[0].type =
1316 theme->a_menu_bullet_normal->texture[0].type =
1317 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1319 theme->btn_max->a_disabled_focused->texture[0].data.mask.mask =
1320 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.mask =
1321 theme->btn_max->disabled_mask;
1322 theme->btn_max->a_hover_focused->texture[0].data.mask.mask =
1323 theme->btn_max->a_hover_unfocused->texture[0].data.mask.mask =
1324 theme->btn_max->hover_mask;
1325 theme->btn_max->a_focused_pressed->texture[0].data.mask.mask =
1326 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.mask =
1327 theme->btn_max->pressed_mask;
1328 theme->btn_max->a_focused_unpressed->texture[0].data.mask.mask =
1329 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.mask =
1330 theme->btn_max->mask;
1331 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.mask =
1332 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1333 theme->btn_max->toggled_hover_mask;
1334 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1335 theme->btn_max->a_toggled_unfocused_unpressed->
1336 texture[0].data.mask.mask = theme->btn_max->toggled_mask;
1337 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.mask =
1338 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1339 = theme->btn_max->toggled_pressed_mask;
1340 theme->btn_close->a_disabled_focused->texture[0].data.mask.mask =
1341 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.mask =
1342 theme->btn_close->disabled_mask;
1343 theme->btn_close->a_hover_focused->texture[0].data.mask.mask =
1344 theme->btn_close->a_hover_unfocused->texture[0].data.mask.mask =
1345 theme->btn_close->hover_mask;
1346 theme->btn_close->a_focused_pressed->texture[0].data.mask.mask =
1347 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.mask =
1348 theme->btn_close->pressed_mask;
1349 theme->btn_close->a_focused_unpressed->texture[0].data.mask.mask =
1350 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.mask =
1351 theme->btn_close->mask;
1352 theme->btn_desk->a_disabled_focused->texture[0].data.mask.mask =
1353 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.mask =
1354 theme->btn_desk->disabled_mask;
1355 theme->btn_desk->a_hover_focused->texture[0].data.mask.mask =
1356 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.mask =
1357 theme->btn_desk->hover_mask;
1358 theme->btn_desk->a_focused_pressed->texture[0].data.mask.mask =
1359 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.mask =
1360 theme->btn_desk->pressed_mask;
1361 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.mask =
1362 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.mask =
1363 theme->btn_desk->mask;
1364 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.mask =
1365 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1366 theme->btn_desk->toggled_hover_mask;
1367 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1368 theme->btn_desk->a_toggled_unfocused_unpressed->
1369 texture[0].data.mask.mask = theme->btn_desk->toggled_mask;
1370 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.mask =
1371 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1372 = theme->btn_desk->toggled_pressed_mask;
1373 theme->btn_shade->a_disabled_focused->texture[0].data.mask.mask =
1374 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.mask =
1375 theme->btn_shade->disabled_mask;
1376 theme->btn_shade->a_hover_focused->texture[0].data.mask.mask =
1377 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.mask =
1378 theme->btn_shade->hover_mask;
1379 theme->btn_shade->a_focused_pressed->texture[0].data.mask.mask =
1380 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.mask =
1381 theme->btn_shade->pressed_mask;
1382 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.mask =
1383 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.mask =
1384 theme->btn_shade->mask;
1385 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.mask =
1386 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.mask
1387 = theme->btn_shade->toggled_hover_mask;
1388 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1389 theme->btn_shade->a_toggled_unfocused_unpressed->
1390 texture[0].data.mask.mask = theme->btn_shade->toggled_mask;
1391 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.mask =
1392 theme->btn_shade->a_toggled_unfocused_pressed->
1393 texture[0].data.mask.mask = theme->btn_shade->toggled_pressed_mask;
1394 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.mask =
1395 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.mask =
1396 theme->btn_iconify->disabled_mask;
1397 theme->btn_iconify->a_hover_focused->texture[0].data.mask.mask =
1398 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.mask =
1399 theme->btn_iconify->hover_mask;
1400 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.mask =
1401 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.mask =
1402 theme->btn_iconify->pressed_mask;
1403 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.mask =
1404 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.mask =
1405 theme->btn_iconify->mask;
1406 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1407 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1408 theme->menu_bullet_mask;
1409 theme->btn_max->a_disabled_focused->texture[0].data.mask.color =
1410 theme->btn_max->disabled_focused_color;
1411 theme->btn_close->a_disabled_focused->texture[0].data.mask.color =
1412 theme->btn_close->disabled_focused_color;
1413 theme->btn_desk->a_disabled_focused->texture[0].data.mask.color =
1414 theme->btn_desk->disabled_focused_color;
1415 theme->btn_shade->a_disabled_focused->texture[0].data.mask.color =
1416 theme->btn_shade->disabled_focused_color;
1417 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.color =
1418 theme->btn_iconify->disabled_focused_color;
1419 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.color =
1420 theme->btn_max->disabled_unfocused_color;
1421 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.color =
1422 theme->btn_close->disabled_unfocused_color;
1423 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.color =
1424 theme->btn_desk->disabled_unfocused_color;
1425 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.color =
1426 theme->btn_shade->disabled_unfocused_color;
1427 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.color =
1428 theme->btn_iconify->disabled_unfocused_color;
1429 theme->btn_max->a_hover_focused->texture[0].data.mask.color =
1430 theme->btn_max->hover_focused_color;
1431 theme->btn_close->a_hover_focused->texture[0].data.mask.color =
1432 theme->btn_close->hover_focused_color;
1433 theme->btn_desk->a_hover_focused->texture[0].data.mask.color =
1434 theme->btn_desk->hover_focused_color;
1435 theme->btn_shade->a_hover_focused->texture[0].data.mask.color =
1436 theme->btn_shade->hover_focused_color;
1437 theme->btn_iconify->a_hover_focused->texture[0].data.mask.color =
1438 theme->btn_iconify->hover_focused_color;
1439 theme->btn_max->a_hover_unfocused->texture[0].data.mask.color =
1440 theme->btn_max->hover_unfocused_color;
1441 theme->btn_close->a_hover_unfocused->texture[0].data.mask.color =
1442 theme->btn_close->hover_unfocused_color;
1443 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.color =
1444 theme->btn_desk->hover_unfocused_color;
1445 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.color =
1446 theme->btn_shade->hover_unfocused_color;
1447 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.color =
1448 theme->btn_iconify->hover_unfocused_color;
1449 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.color =
1450 theme->btn_max->toggled_hover_focused_color;
1451 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.color =
1452 theme->btn_desk->toggled_hover_focused_color;
1453 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.color =
1454 theme->btn_shade->toggled_hover_focused_color;
1455 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.color =
1456 theme->btn_max->toggled_hover_unfocused_color;
1457 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.color =
1458 theme->btn_desk->toggled_hover_unfocused_color;
1459 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.color =
1460 theme->btn_shade->toggled_hover_unfocused_color;
1461 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.color =
1462 theme->btn_max->toggled_focused_unpressed_color;
1463 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.color =
1464 theme->btn_desk->toggled_focused_unpressed_color;
1465 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.color =
1466 theme->btn_shade->toggled_focused_unpressed_color;
1467 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].data.mask.color =
1468 theme->btn_max->toggled_unfocused_unpressed_color;
1469 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1470 = theme->btn_desk->toggled_unfocused_unpressed_color;
1471 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1472 = theme->btn_shade->toggled_unfocused_unpressed_color;
1473 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.color =
1474 theme->btn_max->toggled_focused_pressed_color;
1475 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.color =
1476 theme->btn_desk->toggled_focused_pressed_color;
1477 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.color =
1478 theme->btn_shade->toggled_focused_pressed_color;
1479 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1480 theme->btn_max->toggled_unfocused_pressed_color;
1481 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1482 theme->btn_desk->toggled_unfocused_pressed_color;
1483 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1484 theme->btn_shade->toggled_unfocused_pressed_color;
1485 theme->btn_max->a_focused_unpressed->texture[0].data.mask.color =
1486 theme->btn_max->focused_unpressed_color;
1487 theme->btn_close->a_focused_unpressed->texture[0].data.mask.color =
1488 theme->btn_close->focused_unpressed_color;
1489 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.color =
1490 theme->btn_desk->focused_unpressed_color;
1491 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.color =
1492 theme->btn_shade->focused_unpressed_color;
1493 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.color =
1494 theme->btn_iconify->focused_unpressed_color;
1495 theme->btn_max->a_focused_pressed->texture[0].data.mask.color =
1496 theme->btn_max->focused_pressed_color;
1497 theme->btn_close->a_focused_pressed->texture[0].data.mask.color =
1498 theme->btn_close->focused_pressed_color;
1499 theme->btn_desk->a_focused_pressed->texture[0].data.mask.color =
1500 theme->btn_desk->focused_pressed_color;
1501 theme->btn_shade->a_focused_pressed->texture[0].data.mask.color =
1502 theme->btn_shade->focused_pressed_color;
1503 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.color =
1504 theme->btn_iconify->focused_pressed_color;
1505 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.color =
1506 theme->btn_max->unfocused_unpressed_color;
1507 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.color =
1508 theme->btn_close->unfocused_unpressed_color;
1509 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.color =
1510 theme->btn_desk->unfocused_unpressed_color;
1511 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.color =
1512 theme->btn_shade->unfocused_unpressed_color;
1513 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.color =
1514 theme->btn_iconify->unfocused_unpressed_color;
1515 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.color =
1516 theme->btn_max->unfocused_pressed_color;
1517 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.color =
1518 theme->btn_close->unfocused_pressed_color;
1519 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.color =
1520 theme->btn_desk->unfocused_pressed_color;
1521 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.color =
1522 theme->btn_shade->unfocused_pressed_color;
1523 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.color =
1524 theme->btn_iconify->unfocused_pressed_color;
1525 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1526 theme->menu_bullet_color;
1527 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1528 theme->menu_bullet_selected_color;
1530 g_free(path);
1531 XrmDestroyDatabase(db);
1533 /* set the font heights */
1534 theme->win_font_height = RrFontHeight
1535 (theme->win_font_focused,
1536 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1537 theme->win_font_height =
1538 MAX(theme->win_font_height,
1539 RrFontHeight
1540 (theme->win_font_focused,
1541 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1542 theme->menu_title_font_height = RrFontHeight
1543 (theme->menu_title_font,
1544 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1545 theme->menu_font_height = RrFontHeight
1546 (theme->menu_font,
1547 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1549 /* calculate some last extents */
1551 gint ft, fb, fl, fr, ut, ub, ul, ur;
1553 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1554 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1555 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1556 theme->label_height += theme->label_height % 2;
1558 /* this would be nice I think, since padding.width can now be 0,
1559 but it breaks frame.c horribly and I don't feel like fixing that
1560 right now, so if anyone complains, here is how to keep text from
1561 going over the title's bevel/border with a padding.width of 0 and a
1562 bevelless/borderless label
1563 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1564 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1565 theme->title_height = theme->label_height +
1566 MAX(MAX(theme->padding * 2, ft + fb),
1567 MAX(theme->padding * 2, ut + ub));
1569 theme->title_height = theme->label_height + theme->paddingy * 2;
1571 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1572 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1573 theme->menu_title_height = theme->menu_title_label_height +
1574 theme->paddingy * 2;
1576 theme->button_size = theme->label_height - 2;
1577 theme->grip_width = 25;
1579 RrAppearanceFree(a_disabled_focused_tmp);
1580 RrAppearanceFree(a_disabled_unfocused_tmp);
1581 RrAppearanceFree(a_hover_focused_tmp);
1582 RrAppearanceFree(a_hover_unfocused_tmp);
1583 RrAppearanceFree(a_focused_unpressed_tmp);
1584 RrAppearanceFree(a_focused_pressed_tmp);
1585 RrAppearanceFree(a_unfocused_unpressed_tmp);
1586 RrAppearanceFree(a_unfocused_pressed_tmp);
1587 RrAppearanceFree(a_toggled_hover_focused_tmp);
1588 RrAppearanceFree(a_toggled_hover_unfocused_tmp);
1589 RrAppearanceFree(a_toggled_focused_unpressed_tmp);
1590 RrAppearanceFree(a_toggled_focused_pressed_tmp);
1591 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp);
1592 RrAppearanceFree(a_toggled_unfocused_pressed_tmp);
1594 return theme;
1597 void RrThemeFree(RrTheme *theme)
1599 if (theme) {
1600 g_free(theme->name);
1602 RrButtonFree(theme->btn_max);
1603 RrButtonFree(theme->btn_close);
1604 RrButtonFree(theme->btn_desk);
1605 RrButtonFree(theme->btn_shade);
1606 RrButtonFree(theme->btn_iconify);
1608 RrColorFree(theme->menu_border_color);
1609 RrColorFree(theme->osd_border_color);
1610 RrColorFree(theme->frame_focused_border_color);
1611 RrColorFree(theme->frame_unfocused_border_color);
1612 RrColorFree(theme->title_separator_focused_color);
1613 RrColorFree(theme->title_separator_unfocused_color);
1614 RrColorFree(theme->cb_unfocused_color);
1615 RrColorFree(theme->cb_focused_color);
1616 RrColorFree(theme->title_focused_color);
1617 RrColorFree(theme->title_unfocused_color);
1618 RrColorFree(theme->titlebut_disabled_focused_color);
1619 RrColorFree(theme->titlebut_disabled_unfocused_color);
1620 RrColorFree(theme->titlebut_hover_focused_color);
1621 RrColorFree(theme->titlebut_hover_unfocused_color);
1622 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1623 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1624 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1625 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1626 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1627 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1628 RrColorFree(theme->titlebut_focused_pressed_color);
1629 RrColorFree(theme->titlebut_unfocused_pressed_color);
1630 RrColorFree(theme->titlebut_focused_unpressed_color);
1631 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1632 RrColorFree(theme->menu_title_color);
1633 RrColorFree(theme->menu_sep_color);
1634 RrColorFree(theme->menu_color);
1635 RrColorFree(theme->menu_bullet_color);
1636 RrColorFree(theme->menu_bullet_selected_color);
1637 RrColorFree(theme->menu_selected_color);
1638 RrColorFree(theme->menu_disabled_color);
1639 RrColorFree(theme->menu_disabled_selected_color);
1640 RrColorFree(theme->title_focused_shadow_color);
1641 RrColorFree(theme->title_unfocused_shadow_color);
1642 RrColorFree(theme->osd_text_active_color);
1643 RrColorFree(theme->osd_text_inactive_color);
1644 RrColorFree(theme->osd_text_active_shadow_color);
1645 RrColorFree(theme->osd_text_inactive_shadow_color);
1646 RrColorFree(theme->osd_pressed_color);
1647 RrColorFree(theme->osd_unpressed_color);
1648 RrColorFree(theme->osd_focused_color);
1649 RrColorFree(theme->osd_pressed_lineart);
1650 RrColorFree(theme->osd_focused_lineart);
1651 RrColorFree(theme->menu_title_shadow_color);
1652 RrColorFree(theme->menu_text_normal_shadow_color);
1653 RrColorFree(theme->menu_text_selected_shadow_color);
1654 RrColorFree(theme->menu_text_disabled_shadow_color);
1655 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1657 g_free(theme->def_win_icon);
1659 RrPixmapMaskFree(theme->menu_bullet_mask);
1660 RrPixmapMaskFree(theme->down_arrow_mask);
1661 RrPixmapMaskFree(theme->up_arrow_mask);
1663 RrFontClose(theme->win_font_focused);
1664 RrFontClose(theme->win_font_unfocused);
1665 RrFontClose(theme->menu_title_font);
1666 RrFontClose(theme->menu_font);
1667 RrFontClose(theme->osd_font_hilite);
1668 RrFontClose(theme->osd_font_unhilite);
1670 RrAppearanceFree(theme->a_focused_grip);
1671 RrAppearanceFree(theme->a_unfocused_grip);
1672 RrAppearanceFree(theme->a_focused_title);
1673 RrAppearanceFree(theme->a_unfocused_title);
1674 RrAppearanceFree(theme->a_focused_label);
1675 RrAppearanceFree(theme->a_unfocused_label);
1676 RrAppearanceFree(theme->a_icon);
1677 RrAppearanceFree(theme->a_focused_handle);
1678 RrAppearanceFree(theme->a_unfocused_handle);
1679 RrAppearanceFree(theme->a_menu);
1680 RrAppearanceFree(theme->a_menu_title);
1681 RrAppearanceFree(theme->a_menu_text_title);
1682 RrAppearanceFree(theme->a_menu_normal);
1683 RrAppearanceFree(theme->a_menu_selected);
1684 RrAppearanceFree(theme->a_menu_disabled);
1685 RrAppearanceFree(theme->a_menu_disabled_selected);
1686 RrAppearanceFree(theme->a_menu_text_normal);
1687 RrAppearanceFree(theme->a_menu_text_selected);
1688 RrAppearanceFree(theme->a_menu_text_disabled);
1689 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1690 RrAppearanceFree(theme->a_menu_bullet_normal);
1691 RrAppearanceFree(theme->a_menu_bullet_selected);
1692 RrAppearanceFree(theme->a_clear);
1693 RrAppearanceFree(theme->a_clear_tex);
1694 RrAppearanceFree(theme->osd_bg);
1695 RrAppearanceFree(theme->osd_hilite_bg);
1696 RrAppearanceFree(theme->osd_hilite_label);
1697 RrAppearanceFree(theme->osd_unhilite_bg);
1698 RrAppearanceFree(theme->osd_unhilite_label);
1699 RrAppearanceFree(theme->osd_pressed_button);
1700 RrAppearanceFree(theme->osd_unpressed_button);
1701 RrAppearanceFree(theme->osd_focused_button);
1703 g_slice_free(RrTheme, theme);
1707 static XrmDatabase loaddb(const gchar *name, gchar **path)
1709 GSList *it;
1710 XrmDatabase db = NULL;
1711 gchar *s;
1713 if (name[0] == '/') {
1714 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1715 if ((db = XrmGetFileDatabase(s)))
1716 *path = g_path_get_dirname(s);
1717 g_free(s);
1718 } else {
1719 ObtPaths *p;
1721 p = obt_paths_new();
1723 /* XXX backwards compatibility, remove me sometime later */
1724 s = g_build_filename(g_get_home_dir(), ".themes", name,
1725 "openbox-3", "themerc", NULL);
1726 if ((db = XrmGetFileDatabase(s)))
1727 *path = g_path_get_dirname(s);
1728 g_free(s);
1730 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1732 s = g_build_filename(it->data, "themes", name,
1733 "openbox-3", "themerc", NULL);
1734 if ((db = XrmGetFileDatabase(s)))
1735 *path = g_path_get_dirname(s);
1736 g_free(s);
1739 obt_paths_unref(p);
1742 if (db == NULL) {
1743 s = g_build_filename(name, "themerc", NULL);
1744 if ((db = XrmGetFileDatabase(s)))
1745 *path = g_path_get_dirname(s);
1746 g_free(s);
1749 return db;
1752 static gchar *create_class_name(const gchar *rname)
1754 gchar *rclass = g_strdup(rname);
1755 gchar *p = rclass;
1757 while (TRUE) {
1758 *p = toupper(*p);
1759 p = strchr(p+1, '.');
1760 if (p == NULL) break;
1761 ++p;
1762 if (*p == '\0') break;
1764 return rclass;
1767 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1769 gboolean ret = FALSE;
1770 gchar *rclass = create_class_name(rname);
1771 gchar *rettype, *end;
1772 XrmValue retvalue;
1774 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1775 retvalue.addr != NULL) {
1776 *value = (gint)strtol(retvalue.addr, &end, 10);
1777 if (end != retvalue.addr)
1778 ret = TRUE;
1781 g_free(rclass);
1782 return ret;
1785 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1787 gboolean ret = FALSE;
1788 gchar *rclass = create_class_name(rname);
1789 gchar *rettype;
1790 XrmValue retvalue;
1792 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1793 retvalue.addr != NULL) {
1794 *value = retvalue.addr;
1795 ret = TRUE;
1798 g_free(rclass);
1799 return ret;
1802 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1803 const gchar *rname, RrColor **value)
1805 gboolean ret = FALSE;
1806 gchar *rclass = create_class_name(rname);
1807 gchar *rettype;
1808 XrmValue retvalue;
1810 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1811 retvalue.addr != NULL) {
1812 RrColor *c = RrColorParse(inst, retvalue.addr);
1813 if (c != NULL) {
1814 *value = c;
1815 ret = TRUE;
1819 g_free(rclass);
1820 return ret;
1823 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1824 RrTheme *theme, const gchar *maskname,
1825 RrPixmapMask **value)
1827 gboolean ret = FALSE;
1828 gchar *s;
1829 gint hx, hy; /* ignored */
1830 guint w, h;
1831 guchar *b;
1833 s = g_build_filename(path, maskname, NULL);
1834 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1835 ret = TRUE;
1836 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1837 XFree(b);
1839 g_free(s);
1841 return ret;
1844 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1845 RrReliefType *relief, RrBevelType *bevel,
1846 gboolean *interlaced, gboolean *border,
1847 gboolean allow_trans)
1849 gchar *t;
1851 /* convert to all lowercase */
1852 for (t = tex; *t != '\0'; ++t)
1853 *t = g_ascii_tolower(*t);
1855 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1856 *grad = RR_SURFACE_PARENTREL;
1857 } else {
1858 if (strstr(tex, "gradient") != NULL) {
1859 if (strstr(tex, "crossdiagonal") != NULL)
1860 *grad = RR_SURFACE_CROSS_DIAGONAL;
1861 else if (strstr(tex, "pyramid") != NULL)
1862 *grad = RR_SURFACE_PYRAMID;
1863 else if (strstr(tex, "mirrorhorizontal") != NULL)
1864 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1865 else if (strstr(tex, "horizontal") != NULL)
1866 *grad = RR_SURFACE_HORIZONTAL;
1867 else if (strstr(tex, "splitvertical") != NULL)
1868 *grad = RR_SURFACE_SPLIT_VERTICAL;
1869 else if (strstr(tex, "vertical") != NULL)
1870 *grad = RR_SURFACE_VERTICAL;
1871 else
1872 *grad = RR_SURFACE_DIAGONAL;
1873 } else {
1874 *grad = RR_SURFACE_SOLID;
1878 if (strstr(tex, "sunken") != NULL)
1879 *relief = RR_RELIEF_SUNKEN;
1880 else if (strstr(tex, "flat") != NULL)
1881 *relief = RR_RELIEF_FLAT;
1882 else if (strstr(tex, "raised") != NULL)
1883 *relief = RR_RELIEF_RAISED;
1884 else
1885 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1886 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1888 *border = FALSE;
1889 if (*relief == RR_RELIEF_FLAT) {
1890 if (strstr(tex, "border") != NULL)
1891 *border = TRUE;
1892 } else {
1893 if (strstr(tex, "bevel2") != NULL)
1894 *bevel = RR_BEVEL_2;
1895 else
1896 *bevel = RR_BEVEL_1;
1899 if (strstr(tex, "interlaced") != NULL)
1900 *interlaced = TRUE;
1901 else
1902 *interlaced = FALSE;
1905 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1906 const gchar *rname, RrAppearance *value,
1907 gboolean allow_trans)
1909 gboolean ret = FALSE;
1910 gchar *rclass = create_class_name(rname);
1911 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1912 gchar *csplitname, *ctosplitname;
1913 gchar *rettype;
1914 XrmValue retvalue;
1915 gint i;
1917 cname = g_strconcat(rname, ".color", NULL);
1918 ctoname = g_strconcat(rname, ".colorTo", NULL);
1919 bcname = g_strconcat(rname, ".border.color", NULL);
1920 icname = g_strconcat(rname, ".interlace.color", NULL);
1921 hname = g_strconcat(rname, ".highlight", NULL);
1922 sname = g_strconcat(rname, ".shadow", NULL);
1923 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1924 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1926 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1927 retvalue.addr != NULL) {
1928 parse_appearance(retvalue.addr,
1929 &value->surface.grad,
1930 &value->surface.relief,
1931 &value->surface.bevel,
1932 &value->surface.interlaced,
1933 &value->surface.border,
1934 allow_trans);
1935 if (!read_color(db, inst, cname, &value->surface.primary))
1936 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1937 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1938 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1939 if (value->surface.border)
1940 if (!read_color(db, inst, bcname,
1941 &value->surface.border_color))
1942 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1943 if (value->surface.interlaced)
1944 if (!read_color(db, inst, icname,
1945 &value->surface.interlace_color))
1946 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1947 if (read_int(db, hname, &i) && i >= 0)
1948 value->surface.bevel_light_adjust = i;
1949 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1950 value->surface.bevel_dark_adjust = i;
1952 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1953 gint r, g, b;
1955 if (!read_color(db, inst, csplitname,
1956 &value->surface.split_primary))
1958 r = value->surface.primary->r;
1959 r += r >> 2;
1960 g = value->surface.primary->g;
1961 g += g >> 2;
1962 b = value->surface.primary->b;
1963 b += b >> 2;
1964 if (r > 0xFF) r = 0xFF;
1965 if (g > 0xFF) g = 0xFF;
1966 if (b > 0xFF) b = 0xFF;
1967 value->surface.split_primary = RrColorNew(inst, r, g, b);
1970 if (!read_color(db, inst, ctosplitname,
1971 &value->surface.split_secondary))
1973 r = value->surface.secondary->r;
1974 r += r >> 4;
1975 g = value->surface.secondary->g;
1976 g += g >> 4;
1977 b = value->surface.secondary->b;
1978 b += b >> 4;
1979 if (r > 0xFF) r = 0xFF;
1980 if (g > 0xFF) g = 0xFF;
1981 if (b > 0xFF) b = 0xFF;
1982 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1986 ret = TRUE;
1989 g_free(ctosplitname);
1990 g_free(csplitname);
1991 g_free(sname);
1992 g_free(hname);
1993 g_free(icname);
1994 g_free(bcname);
1995 g_free(ctoname);
1996 g_free(cname);
1997 g_free(rclass);
1998 return ret;
2001 static int parse_inline_number(const char *p)
2003 int neg = 1;
2004 int res = 0;
2005 if (*p == '-') {
2006 neg = -1;
2007 ++p;
2009 for (; isdigit(*p); ++p)
2010 res = res * 10 + *p - '0';
2011 res *= neg;
2012 return res;
2015 static void set_default_appearance(RrAppearance *a)
2017 a->surface.grad = RR_SURFACE_SOLID;
2018 a->surface.relief = RR_RELIEF_FLAT;
2019 a->surface.bevel = RR_BEVEL_1;
2020 a->surface.interlaced = FALSE;
2021 a->surface.border = FALSE;
2022 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
2023 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
2026 /* Reads the output from gimp's C-Source file format into valid RGBA data for
2027 an RrTextureRGBA. */
2028 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
2030 RrPixel32 *im, *p;
2031 gint i;
2033 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
2035 for (i = 0; i < width * height; ++i) {
2036 guchar a = ((*p >> 24) & 0xff);
2037 guchar b = ((*p >> 16) & 0xff);
2038 guchar g = ((*p >> 8) & 0xff);
2039 guchar r = ((*p >> 0) & 0xff);
2041 *p = ((r << RrDefaultRedOffset) +
2042 (g << RrDefaultGreenOffset) +
2043 (b << RrDefaultBlueOffset) +
2044 (a << RrDefaultAlphaOffset));
2045 p++;
2048 return im;
2051 static void read_button_colors(XrmDatabase db, const RrInstance *inst,
2052 const RrTheme *theme, RrButton *btn,
2053 const gchar *btnname)
2055 gchar *name;
2057 /* active unpressed */
2058 name = g_strdup_printf("window.active.button.%s.unpressed.image.color",
2059 btnname);
2060 READ_COLOR(name, btn->focused_unpressed_color,
2061 RrColorCopy(theme->titlebut_focused_unpressed_color));
2062 g_free(name);
2064 /* inactive unpressed */
2065 name = g_strdup_printf("window.inactive.button.%s.unpressed.image.color",
2066 btnname);
2067 READ_COLOR(name, btn->unfocused_unpressed_color,
2068 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
2069 g_free(name);
2071 /* active pressed */
2072 name = g_strdup_printf("window.active.button.%s.pressed.image.color",
2073 btnname);
2074 READ_COLOR(name, btn->focused_pressed_color,
2075 RrColorCopy(theme->titlebut_focused_pressed_color));
2076 g_free(name);
2078 /* inactive pressed */
2079 name = g_strdup_printf("window.inactive.button.%s.pressed.image.color",
2080 btnname);
2081 READ_COLOR(name, btn->unfocused_pressed_color,
2082 RrColorCopy(theme->titlebut_unfocused_pressed_color));
2083 g_free(name);
2085 /* active disabled */
2086 name = g_strdup_printf("window.active.button.%s.disabled.image.color",
2087 btnname);
2088 READ_COLOR(name, btn->disabled_focused_color,
2089 RrColorCopy(theme->titlebut_disabled_focused_color));
2090 g_free(name);
2092 /* inactive disabled */
2093 name = g_strdup_printf("window.inactive.button.%s.disabled.image.color",
2094 btnname);
2095 READ_COLOR(name, btn->disabled_unfocused_color,
2096 RrColorCopy(theme->titlebut_disabled_unfocused_color));
2097 g_free(name);
2099 /* active hover */
2100 name = g_strdup_printf("window.active.button.%s.hover.image.color",
2101 btnname);
2102 READ_COLOR(name, btn->hover_focused_color,
2103 RrColorCopy(theme->titlebut_hover_focused_color));
2104 g_free(name);
2106 /* inactive hover */
2107 name = g_strdup_printf("window.inactive.button.%s.hover.image.color",
2108 btnname);
2109 READ_COLOR(name, btn->hover_unfocused_color,
2110 RrColorCopy(theme->titlebut_hover_unfocused_color));
2111 g_free(name);
2113 /* active toggled unpressed */
2114 name = g_strdup_printf("window.active.button.%s.toggled."
2115 "unpressed.image.color", btnname);
2116 READ_COLOR(name, btn->toggled_focused_unpressed_color,
2117 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
2118 g_free(name);
2120 /* inactive toggled unpressed */
2121 name = g_strdup_printf("window.inactive.button.%s.toggled."
2122 "unpressed.image.color", btnname);
2123 READ_COLOR(name, btn->toggled_unfocused_unpressed_color,
2124 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
2125 g_free(name);
2127 /* active toggled hover */
2128 name = g_strdup_printf("window.active.button.%s.toggled.hover.image.color",
2129 btnname);
2130 READ_COLOR(name, btn->toggled_hover_focused_color,
2131 RrColorCopy(theme->titlebut_toggled_hover_focused_color));
2133 g_free(name);
2135 /* inactive toggled hover */
2136 name = g_strdup_printf("window.inactive.button.%s.toggled.hover."
2137 "image.color", btnname);
2138 READ_COLOR(name, btn->toggled_hover_unfocused_color,
2139 RrColorCopy(theme->titlebut_toggled_hover_unfocused_color));
2140 g_free(name);
2142 /* active toggled pressed */
2143 name = g_strdup_printf("window.active.button.%s.toggled.pressed."
2144 "image.color", btnname);
2145 READ_COLOR(name, btn->toggled_focused_pressed_color,
2146 RrColorCopy(theme->titlebut_toggled_focused_pressed_color));
2147 g_free(name);
2149 /* inactive toggled pressed */
2150 name = g_strdup_printf("window.inactive.button.%s.toggled.pressed."
2151 "image.color", btnname);
2152 READ_COLOR(name, btn->toggled_unfocused_pressed_color,
2153 RrColorCopy(theme->titlebut_toggled_unfocused_pressed_color));
2154 g_free(name);