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.
26 #include "obt/paths.h"
29 #include <X11/Xresource.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
);
49 static RrFont
*get_font(RrFont
*target
, RrFont
**default_font
,
50 const RrInstance
*inst
)
56 /* Only load the default font once */
58 RrFontRef(*default_font
);
60 *default_font
= RrFontOpenDefault(inst
);
66 RrTheme
* RrThemeNew(const RrInstance
*inst
, const gchar
*name
,
67 gboolean allow_fallback
,
68 RrFont
*active_window_font
, RrFont
*inactive_window_font
,
69 RrFont
*menu_title_font
, RrFont
*menu_item_font
,
70 RrFont
*active_osd_font
, RrFont
*inactive_osd_font
)
72 XrmDatabase db
= NULL
;
73 RrJustify winjust
, mtitlejust
;
76 RrFont
*default_font
= NULL
;
81 db
= loaddb(name
, &path
);
83 g_message("Unable to load the theme '%s'", name
);
85 g_message("Falling back to the default theme '%s'",
87 /* fallback to the default theme */
93 db
= loaddb(DEFAULT_THEME
, &path
);
95 g_message("Unable to load the theme '%s'", DEFAULT_THEME
);
102 theme
= g_new0(RrTheme
, 1);
105 theme
->name
= g_strdup(name
? name
: DEFAULT_THEME
);
107 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
108 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
109 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
110 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
111 theme
->a_toggled_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
112 theme
->a_toggled_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
113 theme
->a_toggled_hover_focused_max
= RrAppearanceNew(inst
, 1);
114 theme
->a_toggled_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
115 theme
->a_toggled_focused_pressed_max
= RrAppearanceNew(inst
, 1);
116 theme
->a_toggled_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
117 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
118 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
119 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
120 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
121 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
122 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
123 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
124 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
125 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
126 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
127 theme
->a_icon
= RrAppearanceNew(inst
, 1);
128 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
129 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
130 theme
->a_menu
= RrAppearanceNew(inst
, 0);
131 theme
->a_menu_title
= RrAppearanceNew(inst
, 0);
132 theme
->a_menu_text_title
= RrAppearanceNew(inst
, 1);
133 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
134 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
135 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
136 /* a_menu_disabled_selected is copied from a_menu_selected */
137 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
138 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
139 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
140 theme
->a_menu_text_disabled_selected
= RrAppearanceNew(inst
, 1);
141 theme
->a_menu_bullet_normal
= RrAppearanceNew(inst
, 1);
142 theme
->a_menu_bullet_selected
= RrAppearanceNew(inst
, 1);
143 theme
->a_clear
= RrAppearanceNew(inst
, 0);
144 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
145 theme
->osd_bg
= RrAppearanceNew(inst
, 0);
146 theme
->osd_hilite_label
= RrAppearanceNew(inst
, 1);
147 theme
->osd_hilite_bg
= RrAppearanceNew(inst
, 0);
148 theme
->osd_unhilite_label
= RrAppearanceNew(inst
, 1);
149 theme
->osd_unhilite_bg
= RrAppearanceNew(inst
, 0);
151 /* load the font stuff */
152 theme
->win_font_focused
= get_font(active_window_font
,
153 &default_font
, inst
);
154 theme
->win_font_unfocused
= get_font(inactive_window_font
,
155 &default_font
, inst
);
157 winjust
= RR_JUSTIFY_LEFT
;
158 if (read_string(db
, "window.label.text.justify", &str
)) {
159 if (!g_ascii_strcasecmp(str
, "right"))
160 winjust
= RR_JUSTIFY_RIGHT
;
161 else if (!g_ascii_strcasecmp(str
, "center"))
162 winjust
= RR_JUSTIFY_CENTER
;
165 theme
->menu_title_font
= get_font(menu_title_font
, &default_font
, inst
);
167 mtitlejust
= RR_JUSTIFY_LEFT
;
168 if (read_string(db
, "menu.title.text.justify", &str
)) {
169 if (!g_ascii_strcasecmp(str
, "right"))
170 mtitlejust
= RR_JUSTIFY_RIGHT
;
171 else if (!g_ascii_strcasecmp(str
, "center"))
172 mtitlejust
= RR_JUSTIFY_CENTER
;
175 theme
->menu_font
= get_font(menu_item_font
, &default_font
, inst
);
177 theme
->osd_font_hilite
= get_font(active_osd_font
, &default_font
, inst
);
178 theme
->osd_font_unhilite
= get_font(inactive_osd_font
, &default_font
,inst
);
180 /* load direct dimensions */
181 if ((!read_int(db
, "menu.overlap.x", &theme
->menu_overlap_x
) &&
182 !read_int(db
, "menu.overlap", &theme
->menu_overlap_x
)) ||
183 theme
->menu_overlap_x
< -100 || theme
->menu_overlap_x
> 100)
184 theme
->menu_overlap_x
= 0;
185 if ((!read_int(db
, "menu.overlap.y", &theme
->menu_overlap_y
) &&
186 !read_int(db
, "menu.overlap", &theme
->menu_overlap_y
)) ||
187 theme
->menu_overlap_y
< -100 || theme
->menu_overlap_y
> 100)
188 theme
->menu_overlap_y
= 0;
189 if (!read_int(db
, "window.handle.width", &theme
->handle_height
) ||
190 theme
->handle_height
< 0 || theme
->handle_height
> 100)
191 theme
->handle_height
= 6;
192 if (!read_int(db
, "padding.width", &theme
->paddingx
) ||
193 theme
->paddingx
< 0 || theme
->paddingx
> 100)
195 if (!read_int(db
, "padding.height", &theme
->paddingy
) ||
196 theme
->paddingy
< 0 || theme
->paddingy
> 100)
197 theme
->paddingy
= theme
->paddingx
;
198 if (!read_int(db
, "border.width", &theme
->fbwidth
) ||
199 theme
->fbwidth
< 0 || theme
->fbwidth
> 100)
201 /* menu border width inherits from the frame border width */
202 if (!read_int(db
, "menu.border.width", &theme
->mbwidth
) ||
203 theme
->mbwidth
< 0 || theme
->mbwidth
> 100)
204 theme
->mbwidth
= theme
->fbwidth
;
205 /* osd border width inherits from the frame border width */
206 if (!read_int(db
, "osd.border.width", &theme
->obwidth
) ||
207 theme
->obwidth
< 0 || theme
->obwidth
> 100)
208 theme
->obwidth
= theme
->fbwidth
;
209 if (!read_int(db
, "window.client.padding.width", &theme
->cbwidthx
) ||
210 theme
->cbwidthx
< 0 || theme
->cbwidthx
> 100)
211 theme
->cbwidthx
= theme
->paddingx
;
212 if (!read_int(db
, "window.client.padding.height", &theme
->cbwidthy
) ||
213 theme
->cbwidthy
< 0 || theme
->cbwidthy
> 100)
214 theme
->cbwidthy
= theme
->cbwidthx
;
215 if (!read_int(db
, "menu.separator.width", &theme
->menu_sep_width
) ||
216 theme
->menu_sep_width
< 1 || theme
->menu_sep_width
> 100)
217 theme
->menu_sep_width
= 1;
218 if (!read_int(db
, "menu.separator.padding.width",
219 &theme
->menu_sep_paddingx
) ||
220 theme
->menu_sep_paddingx
< 0 || theme
->menu_sep_paddingx
> 100)
221 theme
->menu_sep_paddingx
= 6;
222 if (!read_int(db
, "menu.separator.padding.height",
223 &theme
->menu_sep_paddingy
) ||
224 theme
->menu_sep_paddingy
< 0 || theme
->menu_sep_paddingy
> 100)
225 theme
->menu_sep_paddingy
= 3;
228 if (!read_color(db
, inst
,
229 "window.active.border.color",
230 &theme
->frame_focused_border_color
) &&
231 !read_color(db
, inst
,
233 &theme
->frame_focused_border_color
))
234 theme
->frame_focused_border_color
= RrColorNew(inst
, 0, 0, 0);
235 /* title separator focused color inherits from focused border color */
236 if (!read_color(db
, inst
,
237 "window.active.title.separator.color",
238 &theme
->title_separator_focused_color
))
239 theme
->title_separator_focused_color
=
241 theme
->frame_focused_border_color
->r
,
242 theme
->frame_focused_border_color
->g
,
243 theme
->frame_focused_border_color
->b
);
244 /* unfocused border color inherits from frame focused border color */
245 if (!read_color(db
, inst
,
246 "window.inactive.border.color",
247 &theme
->frame_unfocused_border_color
))
248 theme
->frame_unfocused_border_color
=
249 RrColorNew(inst
, theme
->frame_focused_border_color
->r
,
250 theme
->frame_focused_border_color
->g
,
251 theme
->frame_focused_border_color
->b
);
252 /* title separator unfocused color inherits from unfocused border color */
253 if (!read_color(db
, inst
,
254 "window.inactive.title.separator.color",
255 &theme
->title_separator_unfocused_color
))
256 theme
->title_separator_unfocused_color
=
258 theme
->frame_unfocused_border_color
->r
,
259 theme
->frame_unfocused_border_color
->g
,
260 theme
->frame_unfocused_border_color
->b
);
262 /* menu border color inherits from frame focused border color */
263 if (!read_color(db
, inst
, "menu.border.color", &theme
->menu_border_color
))
264 theme
->menu_border_color
=
266 theme
->frame_focused_border_color
->r
,
267 theme
->frame_focused_border_color
->g
,
268 theme
->frame_focused_border_color
->b
);
269 /* osd border color inherits from frame focused border color */
270 if (!read_color(db
, inst
, "osd.border.color", &theme
->osd_border_color
))
271 theme
->osd_border_color
=
273 theme
->frame_focused_border_color
->r
,
274 theme
->frame_focused_border_color
->g
,
275 theme
->frame_focused_border_color
->b
);
276 if (!read_color(db
, inst
,
277 "window.active.client.color",
278 &theme
->cb_focused_color
))
279 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
280 if (!read_color(db
, inst
,
281 "window.inactive.client.color",
282 &theme
->cb_unfocused_color
))
283 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
284 if (!read_color(db
, inst
,
285 "window.active.label.text.color",
286 &theme
->title_focused_color
))
287 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
288 if (!read_color(db
, inst
, "osd.active.label.text.color",
289 &theme
->osd_text_active_color
) &&
290 !read_color(db
, inst
, "osd.label.text.color",
291 &theme
->osd_text_active_color
))
292 theme
->osd_text_active_color
=
294 theme
->title_focused_color
->r
,
295 theme
->title_focused_color
->g
,
296 theme
->title_focused_color
->b
);
297 if (!read_color(db
, inst
,
298 "window.inactive.label.text.color",
299 &theme
->title_unfocused_color
))
300 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
301 if (!read_color(db
, inst
, "osd.inactive.label.text.color",
302 &theme
->osd_text_inactive_color
))
303 theme
->osd_text_inactive_color
=
305 theme
->title_unfocused_color
->r
,
306 theme
->title_unfocused_color
->g
,
307 theme
->title_unfocused_color
->b
);
308 if (!read_color(db
, inst
,
309 "window.active.button.unpressed.image.color",
310 &theme
->titlebut_focused_unpressed_color
))
311 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
312 if (!read_color(db
, inst
,
313 "window.inactive.button.unpressed.image.color",
314 &theme
->titlebut_unfocused_unpressed_color
))
315 theme
->titlebut_unfocused_unpressed_color
=
316 RrColorNew(inst
, 0xff, 0xff, 0xff);
317 if (!read_color(db
, inst
,
318 "window.active.button.pressed.image.color",
319 &theme
->titlebut_focused_pressed_color
))
320 theme
->titlebut_focused_pressed_color
=
322 theme
->titlebut_focused_unpressed_color
->r
,
323 theme
->titlebut_focused_unpressed_color
->g
,
324 theme
->titlebut_focused_unpressed_color
->b
);
325 if (!read_color(db
, inst
,
326 "window.inactive.button.pressed.image.color",
327 &theme
->titlebut_unfocused_pressed_color
))
328 theme
->titlebut_unfocused_pressed_color
=
330 theme
->titlebut_unfocused_unpressed_color
->r
,
331 theme
->titlebut_unfocused_unpressed_color
->g
,
332 theme
->titlebut_unfocused_unpressed_color
->b
);
333 if (!read_color(db
, inst
,
334 "window.active.button.disabled.image.color",
335 &theme
->titlebut_disabled_focused_color
))
336 theme
->titlebut_disabled_focused_color
=
337 RrColorNew(inst
, 0xff, 0xff, 0xff);
338 if (!read_color(db
, inst
,
339 "window.inactive.button.disabled.image.color",
340 &theme
->titlebut_disabled_unfocused_color
))
341 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
342 if (!read_color(db
, inst
,
343 "window.active.button.hover.image.color",
344 &theme
->titlebut_hover_focused_color
))
345 theme
->titlebut_hover_focused_color
=
347 theme
->titlebut_focused_unpressed_color
->r
,
348 theme
->titlebut_focused_unpressed_color
->g
,
349 theme
->titlebut_focused_unpressed_color
->b
);
350 if (!read_color(db
, inst
,
351 "window.inactive.button.hover.image.color",
352 &theme
->titlebut_hover_unfocused_color
))
353 theme
->titlebut_hover_unfocused_color
=
355 theme
->titlebut_unfocused_unpressed_color
->r
,
356 theme
->titlebut_unfocused_unpressed_color
->g
,
357 theme
->titlebut_unfocused_unpressed_color
->b
);
358 if (!read_color(db
, inst
,
359 "window.active.button.toggled.unpressed.image.color",
360 &theme
->titlebut_toggled_focused_unpressed_color
) &&
361 !read_color(db
, inst
,
362 "window.active.button.toggled.image.color",
363 &theme
->titlebut_toggled_focused_unpressed_color
))
364 theme
->titlebut_toggled_focused_unpressed_color
=
366 theme
->titlebut_focused_pressed_color
->r
,
367 theme
->titlebut_focused_pressed_color
->g
,
368 theme
->titlebut_focused_pressed_color
->b
);
369 if (!read_color(db
, inst
,
370 "window.inactive.button.toggled.unpressed.image.color",
371 &theme
->titlebut_toggled_unfocused_unpressed_color
) &&
372 !read_color(db
, inst
,
373 "window.inactive.button.toggled.image.color",
374 &theme
->titlebut_toggled_unfocused_unpressed_color
))
375 theme
->titlebut_toggled_unfocused_unpressed_color
=
377 theme
->titlebut_unfocused_pressed_color
->r
,
378 theme
->titlebut_unfocused_pressed_color
->g
,
379 theme
->titlebut_unfocused_pressed_color
->b
);
380 if (!read_color(db
, inst
,
381 "window.active.button.toggled.hover.image.color",
382 &theme
->titlebut_toggled_hover_focused_color
))
383 theme
->titlebut_toggled_hover_focused_color
=
385 theme
->titlebut_toggled_focused_unpressed_color
->r
,
386 theme
->titlebut_toggled_focused_unpressed_color
->g
,
387 theme
->titlebut_toggled_focused_unpressed_color
->b
);
388 if (!read_color(db
, inst
,
389 "window.inactive.button.toggled.hover.image.color",
390 &theme
->titlebut_toggled_hover_unfocused_color
))
391 theme
->titlebut_toggled_hover_unfocused_color
=
393 theme
->titlebut_toggled_unfocused_unpressed_color
->r
,
394 theme
->titlebut_toggled_unfocused_unpressed_color
->g
,
395 theme
->titlebut_toggled_unfocused_unpressed_color
->b
);
396 if (!read_color(db
, inst
,
397 "window.active.button.toggled.pressed.image.color",
398 &theme
->titlebut_toggled_focused_pressed_color
))
399 theme
->titlebut_toggled_focused_pressed_color
=
401 theme
->titlebut_focused_pressed_color
->r
,
402 theme
->titlebut_focused_pressed_color
->g
,
403 theme
->titlebut_focused_pressed_color
->b
);
404 if (!read_color(db
, inst
,
405 "window.inactive.button.toggled.pressed.image.color",
406 &theme
->titlebut_toggled_unfocused_pressed_color
))
407 theme
->titlebut_toggled_unfocused_pressed_color
=
409 theme
->titlebut_unfocused_pressed_color
->r
,
410 theme
->titlebut_unfocused_pressed_color
->g
,
411 theme
->titlebut_unfocused_pressed_color
->b
);
412 if (!read_color(db
, inst
,
413 "menu.title.text.color", &theme
->menu_title_color
))
414 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
415 if (!read_color(db
, inst
,
416 "menu.items.text.color", &theme
->menu_color
))
417 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
418 if (!read_color(db
, inst
,
419 "menu.items.disabled.text.color",
420 &theme
->menu_disabled_color
))
421 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
422 if (!read_color(db
, inst
,
423 "menu.items.active.disabled.text.color",
424 &theme
->menu_disabled_selected_color
))
425 theme
->menu_disabled_selected_color
=
427 theme
->menu_disabled_color
->r
,
428 theme
->menu_disabled_color
->g
,
429 theme
->menu_disabled_color
->b
);
430 if (!read_color(db
, inst
,
431 "menu.items.active.text.color",
432 &theme
->menu_selected_color
))
433 theme
->menu_selected_color
= RrColorNew(inst
, 0, 0, 0);
434 if (!read_color(db
, inst
,
435 "menu.separator.color", &theme
->menu_sep_color
))
436 theme
->menu_sep_color
= RrColorNew(inst
,
437 theme
->menu_color
->r
,
438 theme
->menu_color
->g
,
439 theme
->menu_color
->b
);
441 /* load the image masks */
443 /* maximize button masks */
445 if (!read_mask(inst
, path
, theme
, "max.xbm", &theme
->max_mask
)) {
446 guchar data
[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
447 theme
->max_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
450 if (!read_mask(inst
, path
, theme
, "max_toggled.xbm",
451 &theme
->max_toggled_mask
))
454 theme
->max_toggled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
456 guchar data
[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
457 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 6, 6,(gchar
*)data
);
460 if (!read_mask(inst
, path
, theme
, "max_pressed.xbm",
461 &theme
->max_pressed_mask
))
462 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
463 if (!read_mask(inst
,path
,theme
,"max_disabled.xbm",
464 &theme
->max_disabled_mask
))
465 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
466 if (!read_mask(inst
, path
, theme
, "max_hover.xbm", &theme
->max_hover_mask
))
467 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
468 if (!read_mask(inst
, path
, theme
, "max_toggled_pressed.xbm",
469 &theme
->max_toggled_pressed_mask
))
470 theme
->max_toggled_pressed_mask
=
471 RrPixmapMaskCopy(theme
->max_toggled_mask
);
472 if (!read_mask(inst
, path
, theme
, "max_toggled_hover.xbm",
473 &theme
->max_toggled_hover_mask
))
474 theme
->max_toggled_hover_mask
=
475 RrPixmapMaskCopy(theme
->max_toggled_mask
);
477 /* iconify button masks */
478 if (!read_mask(inst
, path
, theme
, "iconify.xbm", &theme
->iconify_mask
)) {
479 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
480 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
482 if (!read_mask(inst
, path
, theme
, "iconify_pressed.xbm",
483 &theme
->iconify_pressed_mask
))
484 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
485 if (!read_mask(inst
, path
, theme
, "iconify_disabled.xbm",
486 &theme
->iconify_disabled_mask
))
487 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
488 if (!read_mask(inst
, path
, theme
, "iconify_hover.xbm",
489 &theme
->iconify_hover_mask
))
490 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
492 /* all desktops button masks */
494 if (!read_mask(inst
, path
, theme
, "desk.xbm", &theme
->desk_mask
)) {
495 guchar data
[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
496 theme
->desk_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
499 if (!read_mask(inst
, path
, theme
, "desk_toggled.xbm",
500 &theme
->desk_toggled_mask
)) {
502 theme
->desk_toggled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
504 guchar data
[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
505 theme
->desk_toggled_mask
=
506 RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
509 if (!read_mask(inst
, path
, theme
, "desk_pressed.xbm",
510 &theme
->desk_pressed_mask
))
511 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
512 if (!read_mask(inst
, path
, theme
, "desk_disabled.xbm",
513 &theme
->desk_disabled_mask
))
514 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
515 if (!read_mask(inst
, path
, theme
, "desk_hover.xbm",
516 &theme
->desk_hover_mask
))
517 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
518 if (!read_mask(inst
, path
, theme
, "desk_toggled_pressed.xbm",
519 &theme
->desk_toggled_pressed_mask
))
520 theme
->desk_toggled_pressed_mask
=
521 RrPixmapMaskCopy(theme
->desk_toggled_mask
);
522 if (!read_mask(inst
, path
, theme
, "desk_toggled_hover.xbm",
523 &theme
->desk_toggled_hover_mask
))
524 theme
->desk_toggled_hover_mask
=
525 RrPixmapMaskCopy(theme
->desk_toggled_mask
);
527 /* shade button masks */
528 if (!read_mask(inst
, path
, theme
, "shade.xbm", &theme
->shade_mask
)) {
529 guchar data
[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
530 theme
->shade_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
532 if (!read_mask(inst
, path
, theme
, "shade_toggled.xbm",
533 &theme
->shade_toggled_mask
))
534 theme
->shade_toggled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
535 if (!read_mask(inst
, path
, theme
, "shade_pressed.xbm",
536 &theme
->shade_pressed_mask
))
537 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
538 if (!read_mask(inst
, path
, theme
, "shade_disabled.xbm",
539 &theme
->shade_disabled_mask
))
540 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
541 if (!read_mask(inst
, path
, theme
, "shade_hover.xbm",
542 &theme
->shade_hover_mask
))
543 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
544 if (!read_mask(inst
, path
, theme
, "shade_toggled_pressed.xbm",
545 &theme
->shade_toggled_pressed_mask
))
546 theme
->shade_toggled_pressed_mask
=
547 RrPixmapMaskCopy(theme
->shade_toggled_mask
);
548 if (!read_mask(inst
, path
, theme
, "shade_toggled_hover.xbm",
549 &theme
->shade_toggled_hover_mask
))
550 theme
->shade_toggled_hover_mask
=
551 RrPixmapMaskCopy(theme
->shade_toggled_mask
);
553 /* close button masks */
554 if (!read_mask(inst
, path
, theme
, "close.xbm", &theme
->close_mask
)) {
555 guchar data
[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
556 theme
->close_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
558 if (!read_mask(inst
, path
, theme
, "close_pressed.xbm",
559 &theme
->close_pressed_mask
))
560 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
561 if (!read_mask(inst
, path
, theme
, "close_disabled.xbm",
562 &theme
->close_disabled_mask
))
563 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
564 if (!read_mask(inst
, path
, theme
, "close_hover.xbm",
565 &theme
->close_hover_mask
))
566 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
568 /* submenu bullet mask */
569 if (!read_mask(inst
, path
, theme
, "bullet.xbm", &theme
->menu_bullet_mask
))
571 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
572 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (gchar
*)data
);
575 /* up and down arrows */
577 guchar data
[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
578 theme
->down_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
581 guchar data
[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
582 theme
->up_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
585 /* setup the default window icon */
586 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
587 OB_DEFAULT_ICON_HEIGHT
,
588 OB_DEFAULT_ICON_pixel_data
);
589 theme
->def_win_icon_w
= OB_DEFAULT_ICON_WIDTH
;
590 theme
->def_win_icon_h
= OB_DEFAULT_ICON_HEIGHT
;
592 /* read the decoration textures */
593 if (!read_appearance(db
, inst
,
594 "window.active.title.bg", theme
->a_focused_title
,
596 set_default_appearance(theme
->a_focused_title
);
597 if (!read_appearance(db
, inst
,
598 "window.inactive.title.bg", theme
->a_unfocused_title
,
600 set_default_appearance(theme
->a_unfocused_title
);
601 if (!read_appearance(db
, inst
,
602 "window.active.label.bg", theme
->a_focused_label
,
604 set_default_appearance(theme
->a_focused_label
);
605 if (!read_appearance(db
, inst
,
606 "window.inactive.label.bg", theme
->a_unfocused_label
,
608 set_default_appearance(theme
->a_unfocused_label
);
609 if (!read_appearance(db
, inst
,
610 "window.active.handle.bg", theme
->a_focused_handle
,
612 set_default_appearance(theme
->a_focused_handle
);
613 if (!read_appearance(db
, inst
,
614 "window.inactive.handle.bg",theme
->a_unfocused_handle
,
616 set_default_appearance(theme
->a_unfocused_handle
);
617 if (!read_appearance(db
, inst
,
618 "window.active.grip.bg", theme
->a_focused_grip
,
620 set_default_appearance(theme
->a_focused_grip
);
621 if (!read_appearance(db
, inst
,
622 "window.inactive.grip.bg", theme
->a_unfocused_grip
,
624 set_default_appearance(theme
->a_unfocused_grip
);
625 if (!read_appearance(db
, inst
,
626 "menu.items.bg", theme
->a_menu
,
628 set_default_appearance(theme
->a_menu
);
629 if (!read_appearance(db
, inst
,
630 "menu.title.bg", theme
->a_menu_title
,
632 set_default_appearance(theme
->a_menu_title
);
633 if (!read_appearance(db
, inst
,
634 "menu.items.active.bg", theme
->a_menu_selected
,
636 set_default_appearance(theme
->a_menu_selected
);
637 theme
->a_menu_disabled_selected
=
638 RrAppearanceCopy(theme
->a_menu_selected
);
640 /* read appearances for non-decorations (on-screen-display) */
641 if (!read_appearance(db
, inst
, "osd.bg", theme
->osd_bg
, FALSE
)) {
642 RrAppearanceFree(theme
->osd_bg
);
643 theme
->osd_bg
= RrAppearanceCopy(theme
->a_focused_title
);
645 if (!read_appearance(db
, inst
, "osd.active.label.bg",
646 theme
->osd_hilite_label
, TRUE
) &&
647 !read_appearance(db
, inst
, "osd.label.bg",
648 theme
->osd_hilite_label
, TRUE
)) {
649 RrAppearanceFree(theme
->osd_hilite_label
);
650 theme
->osd_hilite_label
= RrAppearanceCopy(theme
->a_focused_label
);
652 if (!read_appearance(db
, inst
, "osd.inactive.label.bg",
653 theme
->osd_unhilite_label
, TRUE
)) {
654 RrAppearanceFree(theme
->osd_unhilite_label
);
655 theme
->osd_unhilite_label
= RrAppearanceCopy(theme
->a_unfocused_label
);
657 /* osd_hilite_fg can't be parentrel */
658 if (!read_appearance(db
, inst
, "osd.hilight.bg",
659 theme
->osd_hilite_bg
, FALSE
)) {
660 RrAppearanceFree(theme
->osd_hilite_bg
);
661 if (theme
->a_focused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
662 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_label
);
664 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_title
);
666 /* osd_unhilite_fg can't be parentrel either */
667 if (!read_appearance(db
, inst
, "osd.unhilight.bg",
668 theme
->osd_unhilite_bg
, FALSE
)) {
669 RrAppearanceFree(theme
->osd_unhilite_bg
);
670 if (theme
->a_unfocused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
671 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_label
);
673 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_title
);
676 /* read buttons textures */
677 if (!read_appearance(db
, inst
,
678 "window.active.button.disabled.bg",
679 theme
->a_disabled_focused_max
,
681 set_default_appearance(theme
->a_disabled_focused_max
);
682 if (!read_appearance(db
, inst
,
683 "window.inactive.button.disabled.bg",
684 theme
->a_disabled_unfocused_max
,
686 set_default_appearance(theme
->a_disabled_unfocused_max
);
687 if (!read_appearance(db
, inst
,
688 "window.active.button.pressed.bg",
689 theme
->a_focused_pressed_max
,
691 set_default_appearance(theme
->a_focused_pressed_max
);
692 if (!read_appearance(db
, inst
,
693 "window.inactive.button.pressed.bg",
694 theme
->a_unfocused_pressed_max
,
696 set_default_appearance(theme
->a_unfocused_pressed_max
);
697 if (!read_appearance(db
, inst
,
698 "window.active.button.toggled.unpressed.bg",
699 theme
->a_toggled_focused_unpressed_max
,
701 !read_appearance(db
, inst
,
702 "window.active.button.toggled.bg",
703 theme
->a_toggled_focused_unpressed_max
,
706 RrAppearanceFree(theme
->a_toggled_focused_unpressed_max
);
707 theme
->a_toggled_focused_unpressed_max
=
708 RrAppearanceCopy(theme
->a_focused_pressed_max
);
710 if (!read_appearance(db
, inst
,
711 "window.inactive.button.toggled.unpressed.bg",
712 theme
->a_toggled_unfocused_unpressed_max
,
714 !read_appearance(db
, inst
,
715 "window.inactive.button.toggled.bg",
716 theme
->a_toggled_unfocused_unpressed_max
,
719 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_max
);
720 theme
->a_toggled_unfocused_unpressed_max
=
721 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
723 if (!read_appearance(db
, inst
,
724 "window.active.button.toggled.hover.bg",
725 theme
->a_toggled_hover_focused_max
,
728 RrAppearanceFree(theme
->a_toggled_hover_focused_max
);
729 theme
->a_toggled_hover_focused_max
=
730 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
732 if (!read_appearance(db
, inst
,
733 "window.inactive.button.toggled.hover.bg",
734 theme
->a_toggled_hover_unfocused_max
,
737 RrAppearanceFree(theme
->a_toggled_hover_unfocused_max
);
738 theme
->a_toggled_hover_unfocused_max
=
739 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
741 if (!read_appearance(db
, inst
,
742 "window.active.button.toggled.pressed.bg",
743 theme
->a_toggled_focused_pressed_max
,
746 RrAppearanceFree(theme
->a_toggled_focused_pressed_max
);
747 theme
->a_toggled_focused_pressed_max
=
748 RrAppearanceCopy(theme
->a_focused_pressed_max
);
750 if (!read_appearance(db
, inst
,
751 "window.inactive.button.toggled.pressed.bg",
752 theme
->a_toggled_unfocused_pressed_max
,
755 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_max
);
756 theme
->a_toggled_unfocused_pressed_max
=
757 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
759 if (!read_appearance(db
, inst
,
760 "window.active.button.unpressed.bg",
761 theme
->a_focused_unpressed_max
,
763 set_default_appearance(theme
->a_focused_unpressed_max
);
764 if (!read_appearance(db
, inst
,
765 "window.inactive.button.unpressed.bg",
766 theme
->a_unfocused_unpressed_max
,
768 set_default_appearance(theme
->a_unfocused_unpressed_max
);
769 if (!read_appearance(db
, inst
,
770 "window.active.button.hover.bg",
771 theme
->a_hover_focused_max
,
774 RrAppearanceFree(theme
->a_hover_focused_max
);
775 theme
->a_hover_focused_max
=
776 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
778 if (!read_appearance(db
, inst
,
779 "window.inactive.button.hover.bg",
780 theme
->a_hover_unfocused_max
,
783 RrAppearanceFree(theme
->a_hover_unfocused_max
);
784 theme
->a_hover_unfocused_max
=
785 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
788 theme
->a_disabled_focused_close
=
789 RrAppearanceCopy(theme
->a_disabled_focused_max
);
790 theme
->a_disabled_unfocused_close
=
791 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
792 theme
->a_hover_focused_close
=
793 RrAppearanceCopy(theme
->a_hover_focused_max
);
794 theme
->a_hover_unfocused_close
=
795 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
796 theme
->a_unfocused_unpressed_close
=
797 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
798 theme
->a_unfocused_pressed_close
=
799 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
800 theme
->a_focused_unpressed_close
=
801 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
802 theme
->a_focused_pressed_close
=
803 RrAppearanceCopy(theme
->a_focused_pressed_max
);
804 theme
->a_disabled_focused_desk
=
805 RrAppearanceCopy(theme
->a_disabled_focused_max
);
806 theme
->a_disabled_unfocused_desk
=
807 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
808 theme
->a_hover_focused_desk
=
809 RrAppearanceCopy(theme
->a_hover_focused_max
);
810 theme
->a_hover_unfocused_desk
=
811 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
812 theme
->a_toggled_hover_focused_desk
=
813 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
814 theme
->a_toggled_hover_unfocused_desk
=
815 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
816 theme
->a_toggled_focused_unpressed_desk
=
817 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
818 theme
->a_toggled_unfocused_unpressed_desk
=
819 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
820 theme
->a_toggled_focused_pressed_desk
=
821 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
822 theme
->a_toggled_unfocused_pressed_desk
=
823 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
824 theme
->a_unfocused_unpressed_desk
=
825 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
826 theme
->a_unfocused_pressed_desk
=
827 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
828 theme
->a_focused_unpressed_desk
=
829 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
830 theme
->a_focused_pressed_desk
=
831 RrAppearanceCopy(theme
->a_focused_pressed_max
);
832 theme
->a_disabled_focused_shade
=
833 RrAppearanceCopy(theme
->a_disabled_focused_max
);
834 theme
->a_disabled_unfocused_shade
=
835 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
836 theme
->a_hover_focused_shade
=
837 RrAppearanceCopy(theme
->a_hover_focused_max
);
838 theme
->a_hover_unfocused_shade
=
839 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
840 theme
->a_toggled_hover_focused_shade
=
841 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
842 theme
->a_toggled_hover_unfocused_shade
=
843 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
844 theme
->a_toggled_focused_unpressed_shade
=
845 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
846 theme
->a_toggled_unfocused_unpressed_shade
=
847 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
848 theme
->a_toggled_focused_pressed_shade
=
849 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
850 theme
->a_toggled_unfocused_pressed_shade
=
851 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
852 theme
->a_unfocused_unpressed_shade
=
853 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
854 theme
->a_unfocused_pressed_shade
=
855 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
856 theme
->a_focused_unpressed_shade
=
857 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
858 theme
->a_focused_pressed_shade
=
859 RrAppearanceCopy(theme
->a_focused_pressed_max
);
860 theme
->a_disabled_focused_iconify
=
861 RrAppearanceCopy(theme
->a_disabled_focused_max
);
862 theme
->a_disabled_unfocused_iconify
=
863 RrAppearanceCopy(theme
->a_disabled_focused_max
);
864 theme
->a_hover_focused_iconify
=
865 RrAppearanceCopy(theme
->a_hover_focused_max
);
866 theme
->a_hover_unfocused_iconify
=
867 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
868 theme
->a_unfocused_unpressed_iconify
=
869 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
870 theme
->a_unfocused_pressed_iconify
=
871 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
872 theme
->a_focused_unpressed_iconify
=
873 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
874 theme
->a_focused_pressed_iconify
=
875 RrAppearanceCopy(theme
->a_focused_pressed_max
);
877 theme
->a_icon
->surface
.grad
=
878 theme
->a_clear
->surface
.grad
=
879 theme
->a_clear_tex
->surface
.grad
=
880 theme
->a_menu_text_title
->surface
.grad
=
881 theme
->a_menu_normal
->surface
.grad
=
882 theme
->a_menu_disabled
->surface
.grad
=
883 theme
->a_menu_text_normal
->surface
.grad
=
884 theme
->a_menu_text_selected
->surface
.grad
=
885 theme
->a_menu_text_disabled
->surface
.grad
=
886 theme
->a_menu_text_disabled_selected
->surface
.grad
=
887 theme
->a_menu_bullet_normal
->surface
.grad
=
888 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
890 /* set up the textures */
891 theme
->a_focused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
892 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
893 theme
->a_focused_label
->texture
[0].data
.text
.font
=theme
->win_font_focused
;
894 theme
->a_focused_label
->texture
[0].data
.text
.color
=
895 theme
->title_focused_color
;
897 if (read_string(db
, "window.active.label.text.font", &str
)) {
901 if (strstr(str
, "shadow=y")) {
902 if ((p
= strstr(str
, "shadowoffset=")))
903 i
= parse_inline_number(p
+ strlen("shadowoffset="));
906 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
907 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
909 if ((p
= strstr(str
, "shadowtint=")))
911 i
= parse_inline_number(p
+ strlen("shadowtint="));
912 j
= (i
> 0 ? 0 : 255);
915 theme
->title_focused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
916 theme
->title_focused_shadow_alpha
= i
;
918 theme
->title_focused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
919 theme
->title_focused_shadow_alpha
= 50;
923 theme
->a_focused_label
->texture
[0].data
.text
.shadow_color
=
924 theme
->title_focused_shadow_color
;
925 theme
->a_focused_label
->texture
[0].data
.text
.shadow_alpha
=
926 theme
->title_focused_shadow_alpha
;
928 theme
->osd_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
929 theme
->osd_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
930 theme
->osd_hilite_label
->texture
[0].data
.text
.font
=
931 theme
->osd_font_hilite
;
932 theme
->osd_hilite_label
->texture
[0].data
.text
.color
=
933 theme
->osd_text_active_color
;
935 theme
->osd_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
936 theme
->osd_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
937 theme
->osd_unhilite_label
->texture
[0].data
.text
.font
=
938 theme
->osd_font_unhilite
;
939 theme
->osd_unhilite_label
->texture
[0].data
.text
.color
=
940 theme
->osd_text_inactive_color
;
942 if (read_string(db
, "osd.active.label.text.font", &str
) ||
943 read_string(db
, "osd.label.text.font", &str
))
948 if (strstr(str
, "shadow=y")) {
949 if ((p
= strstr(str
, "shadowoffset=")))
950 i
= parse_inline_number(p
+ strlen("shadowoffset="));
953 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
954 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
956 if ((p
= strstr(str
, "shadowtint=")))
958 i
= parse_inline_number(p
+ strlen("shadowtint="));
959 j
= (i
> 0 ? 0 : 255);
962 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, j
, j
, j
);
963 theme
->osd_text_active_shadow_alpha
= i
;
965 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
966 theme
->osd_text_active_shadow_alpha
= 50;
969 /* inherit the font settings from the focused label */
970 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
=
971 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
;
972 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
=
973 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
;
974 if (theme
->title_focused_shadow_color
)
975 theme
->osd_text_active_shadow_color
=
977 theme
->title_focused_shadow_color
->r
,
978 theme
->title_focused_shadow_color
->g
,
979 theme
->title_focused_shadow_color
->b
);
981 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
982 theme
->osd_text_active_shadow_alpha
=
983 theme
->title_focused_shadow_alpha
;
986 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_color
=
987 theme
->osd_text_active_shadow_color
;
988 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_alpha
=
989 theme
->osd_text_active_shadow_alpha
;
991 if (read_string(db
, "osd.inactive.label.text.font", &str
))
996 if (strstr(str
, "shadow=y")) {
997 if ((p
= strstr(str
, "shadowoffset=")))
998 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1001 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=i
;
1002 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=i
;
1004 if ((p
= strstr(str
, "shadowtint=")))
1006 i
= parse_inline_number(p
+ strlen("shadowtint="));
1007 j
= (i
> 0 ? 0 : 255);
1010 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1011 theme
->osd_text_inactive_shadow_alpha
= i
;
1013 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1014 theme
->osd_text_inactive_shadow_alpha
= 50;
1017 /* inherit the font settings from the focused label */
1018 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=
1019 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
;
1020 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=
1021 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
;
1022 if (theme
->title_unfocused_shadow_color
)
1023 theme
->osd_text_inactive_shadow_color
=
1025 theme
->title_unfocused_shadow_color
->r
,
1026 theme
->title_unfocused_shadow_color
->g
,
1027 theme
->title_unfocused_shadow_color
->b
);
1029 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1030 theme
->osd_text_inactive_shadow_alpha
=
1031 theme
->title_unfocused_shadow_alpha
;
1034 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_color
=
1035 theme
->osd_text_inactive_shadow_color
;
1036 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_alpha
=
1037 theme
->osd_text_inactive_shadow_alpha
;
1039 theme
->a_unfocused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
1040 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
1041 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
1042 theme
->win_font_unfocused
;
1043 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
1044 theme
->title_unfocused_color
;
1046 if (read_string(db
, "window.inactive.label.text.font", &str
)) {
1050 if (strstr(str
, "shadow=y")) {
1051 if ((p
= strstr(str
, "shadowoffset=")))
1052 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1055 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
1056 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
1058 if ((p
= strstr(str
, "shadowtint=")))
1060 i
= parse_inline_number(p
+ strlen("shadowtint="));
1061 j
= (i
> 0 ? 0 : 255);
1064 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1065 theme
->title_unfocused_shadow_alpha
= i
;
1067 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1068 theme
->title_unfocused_shadow_alpha
= 50;
1072 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_color
=
1073 theme
->title_unfocused_shadow_color
;
1074 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_alpha
=
1075 theme
->title_unfocused_shadow_alpha
;
1077 theme
->a_menu_text_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
1078 theme
->a_menu_text_title
->texture
[0].data
.text
.justify
= mtitlejust
;
1079 theme
->a_menu_text_title
->texture
[0].data
.text
.font
=
1080 theme
->menu_title_font
;
1081 theme
->a_menu_text_title
->texture
[0].data
.text
.color
=
1082 theme
->menu_title_color
;
1084 if (read_string(db
, "menu.title.text.font", &str
)) {
1088 if (strstr(str
, "shadow=y")) {
1089 if ((p
= strstr(str
, "shadowoffset=")))
1090 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1093 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_x
= i
;
1094 theme
->a_menu_text_title
->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);
1102 theme
->menu_title_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1103 theme
->menu_title_shadow_alpha
= i
;
1105 theme
->menu_title_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1106 theme
->menu_title_shadow_alpha
= 50;
1110 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_color
=
1111 theme
->menu_title_shadow_color
;
1112 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_alpha
=
1113 theme
->menu_title_shadow_alpha
;
1115 theme
->a_menu_text_normal
->texture
[0].type
=
1116 theme
->a_menu_text_selected
->texture
[0].type
=
1117 theme
->a_menu_text_disabled
->texture
[0].type
=
1118 theme
->a_menu_text_disabled_selected
->texture
[0].type
=
1120 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
1121 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
1122 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
1123 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.justify
=
1125 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
1126 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
=
1127 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
1128 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.font
=
1130 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
1131 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
1132 theme
->menu_selected_color
;
1133 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
1134 theme
->menu_disabled_color
;
1135 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.color
=
1136 theme
->menu_disabled_selected_color
;
1138 if (read_string(db
, "menu.items.font", &str
)) {
1142 if (strstr(str
, "shadow=y")) {
1143 if ((p
= strstr(str
, "shadowoffset=")))
1144 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1147 theme
->a_menu_text_normal
->
1148 texture
[0].data
.text
.shadow_offset_x
= i
;
1149 theme
->a_menu_text_normal
->
1150 texture
[0].data
.text
.shadow_offset_y
= i
;
1151 theme
->a_menu_text_selected
->
1152 texture
[0].data
.text
.shadow_offset_x
= i
;
1153 theme
->a_menu_text_selected
->
1154 texture
[0].data
.text
.shadow_offset_y
= i
;
1155 theme
->a_menu_text_disabled
->
1156 texture
[0].data
.text
.shadow_offset_x
= i
;
1157 theme
->a_menu_text_disabled
->
1158 texture
[0].data
.text
.shadow_offset_y
= i
;
1159 theme
->a_menu_text_disabled_selected
->
1160 texture
[0].data
.text
.shadow_offset_x
= i
;
1161 theme
->a_menu_text_disabled_selected
->
1162 texture
[0].data
.text
.shadow_offset_y
= i
;
1164 if ((p
= strstr(str
, "shadowtint=")))
1166 i
= parse_inline_number(p
+ strlen("shadowtint="));
1167 j
= (i
> 0 ? 0 : 255);
1170 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1171 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1172 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1173 theme
->menu_text_normal_shadow_alpha
= i
;
1174 theme
->menu_text_selected_shadow_alpha
= i
;
1175 theme
->menu_text_disabled_shadow_alpha
= i
;
1176 theme
->menu_text_disabled_selected_shadow_alpha
= i
;
1178 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1179 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1180 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1181 theme
->menu_text_normal_shadow_alpha
= 50;
1182 theme
->menu_text_selected_shadow_alpha
= 50;
1183 theme
->menu_text_disabled_selected_shadow_alpha
= 50;
1187 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_color
=
1188 theme
->menu_text_normal_shadow_color
;
1189 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_alpha
=
1190 theme
->menu_text_normal_shadow_alpha
;
1191 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_color
=
1192 theme
->menu_text_selected_shadow_color
;
1193 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_alpha
=
1194 theme
->menu_text_selected_shadow_alpha
;
1195 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_color
=
1196 theme
->menu_text_disabled_shadow_color
;
1197 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_alpha
=
1198 theme
->menu_text_disabled_shadow_alpha
;
1199 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_color
=
1200 theme
->menu_text_disabled_shadow_color
;
1201 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_alpha
=
1202 theme
->menu_text_disabled_shadow_alpha
;
1204 theme
->a_disabled_focused_max
->texture
[0].type
=
1205 theme
->a_disabled_unfocused_max
->texture
[0].type
=
1206 theme
->a_hover_focused_max
->texture
[0].type
=
1207 theme
->a_hover_unfocused_max
->texture
[0].type
=
1208 theme
->a_toggled_hover_focused_max
->texture
[0].type
=
1209 theme
->a_toggled_hover_unfocused_max
->texture
[0].type
=
1210 theme
->a_toggled_focused_unpressed_max
->texture
[0].type
=
1211 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].type
=
1212 theme
->a_toggled_focused_pressed_max
->texture
[0].type
=
1213 theme
->a_toggled_unfocused_pressed_max
->texture
[0].type
=
1214 theme
->a_focused_unpressed_max
->texture
[0].type
=
1215 theme
->a_focused_pressed_max
->texture
[0].type
=
1216 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
1217 theme
->a_unfocused_pressed_max
->texture
[0].type
=
1218 theme
->a_disabled_focused_close
->texture
[0].type
=
1219 theme
->a_disabled_unfocused_close
->texture
[0].type
=
1220 theme
->a_hover_focused_close
->texture
[0].type
=
1221 theme
->a_hover_unfocused_close
->texture
[0].type
=
1222 theme
->a_focused_unpressed_close
->texture
[0].type
=
1223 theme
->a_focused_pressed_close
->texture
[0].type
=
1224 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
1225 theme
->a_unfocused_pressed_close
->texture
[0].type
=
1226 theme
->a_disabled_focused_desk
->texture
[0].type
=
1227 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
1228 theme
->a_hover_focused_desk
->texture
[0].type
=
1229 theme
->a_hover_unfocused_desk
->texture
[0].type
=
1230 theme
->a_toggled_hover_focused_desk
->texture
[0].type
=
1231 theme
->a_toggled_hover_unfocused_desk
->texture
[0].type
=
1232 theme
->a_toggled_focused_unpressed_desk
->texture
[0].type
=
1233 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].type
=
1234 theme
->a_toggled_focused_pressed_desk
->texture
[0].type
=
1235 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].type
=
1236 theme
->a_focused_unpressed_desk
->texture
[0].type
=
1237 theme
->a_focused_pressed_desk
->texture
[0].type
=
1238 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
1239 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
1240 theme
->a_disabled_focused_shade
->texture
[0].type
=
1241 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
1242 theme
->a_hover_focused_shade
->texture
[0].type
=
1243 theme
->a_hover_unfocused_shade
->texture
[0].type
=
1244 theme
->a_toggled_hover_focused_shade
->texture
[0].type
=
1245 theme
->a_toggled_hover_unfocused_shade
->texture
[0].type
=
1246 theme
->a_toggled_focused_unpressed_shade
->texture
[0].type
=
1247 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].type
=
1248 theme
->a_toggled_focused_pressed_shade
->texture
[0].type
=
1249 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].type
=
1250 theme
->a_focused_unpressed_shade
->texture
[0].type
=
1251 theme
->a_focused_pressed_shade
->texture
[0].type
=
1252 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
1253 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
1254 theme
->a_disabled_focused_iconify
->texture
[0].type
=
1255 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
1256 theme
->a_hover_focused_iconify
->texture
[0].type
=
1257 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
1258 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
1259 theme
->a_focused_pressed_iconify
->texture
[0].type
=
1260 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
1261 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
1262 theme
->a_menu_bullet_normal
->texture
[0].type
=
1263 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
1265 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
1266 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
1267 theme
->max_disabled_mask
;
1268 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
1269 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1270 theme
->max_hover_mask
;
1271 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1272 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1273 theme
->max_pressed_mask
;
1274 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1275 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1277 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.mask
=
1278 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1279 theme
->max_toggled_hover_mask
;
1280 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1281 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1282 theme
->max_toggled_mask
;
1283 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1284 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1285 theme
->max_toggled_pressed_mask
;
1286 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
1287 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
1288 theme
->close_disabled_mask
;
1289 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
1290 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
1291 theme
->close_hover_mask
;
1292 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
1293 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
1294 theme
->close_pressed_mask
;
1295 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
1296 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
1298 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
1299 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
1300 theme
->desk_disabled_mask
;
1301 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1302 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1303 theme
->desk_hover_mask
;
1304 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1305 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1306 theme
->desk_pressed_mask
;
1307 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1308 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1310 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1311 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1312 theme
->desk_toggled_hover_mask
;
1313 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1314 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1315 theme
->desk_toggled_mask
;
1316 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1317 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1318 theme
->desk_toggled_pressed_mask
;
1319 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
1320 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
1321 theme
->shade_disabled_mask
;
1322 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1323 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1324 theme
->shade_hover_mask
;
1325 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1326 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1327 theme
->shade_pressed_mask
;
1328 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1329 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1331 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1332 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1333 theme
->shade_toggled_hover_mask
;
1334 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1335 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1336 theme
->shade_toggled_mask
;
1337 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1338 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1339 theme
->shade_toggled_pressed_mask
;
1340 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
1341 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1342 theme
->iconify_disabled_mask
;
1343 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
1344 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1345 theme
->iconify_hover_mask
;
1346 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1347 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1348 theme
->iconify_pressed_mask
;
1349 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1350 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1351 theme
->iconify_mask
;
1352 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
1353 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
1354 theme
->menu_bullet_mask
;
1355 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
1356 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
1357 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
1358 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
1359 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
1360 theme
->titlebut_disabled_focused_color
;
1361 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
1362 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
1363 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
1364 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
1365 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
1366 theme
->titlebut_disabled_unfocused_color
;
1367 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
1368 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
1369 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
1370 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
1371 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
1372 theme
->titlebut_hover_focused_color
;
1373 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1374 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
1375 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1376 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1377 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
1378 theme
->titlebut_hover_unfocused_color
;
1379 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.color
=
1380 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.color
=
1381 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.color
=
1382 theme
->titlebut_toggled_hover_focused_color
;
1383 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1384 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1385 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1386 theme
->titlebut_toggled_hover_unfocused_color
;
1387 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1388 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1389 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1390 theme
->titlebut_toggled_focused_unpressed_color
;
1391 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1392 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1393 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1394 theme
->titlebut_toggled_unfocused_unpressed_color
;
1395 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.color
=
1396 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1397 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1398 theme
->titlebut_toggled_focused_pressed_color
;
1399 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1400 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1401 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1402 theme
->titlebut_toggled_unfocused_pressed_color
;
1403 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1404 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
1405 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1406 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1407 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1408 theme
->titlebut_focused_unpressed_color
;
1409 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
1410 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
1411 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1412 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1413 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
1414 theme
->titlebut_focused_pressed_color
;
1415 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1416 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
1417 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1418 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1419 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1420 theme
->titlebut_unfocused_unpressed_color
;
1421 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1422 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
1423 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1424 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1425 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
1426 theme
->titlebut_unfocused_pressed_color
;
1427 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
1429 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
1430 theme
->menu_selected_color
;
1433 XrmDestroyDatabase(db
);
1435 /* set the font heights */
1436 theme
->win_font_height
= RrFontHeight
1437 (theme
->win_font_focused
,
1438 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
);
1439 theme
->win_font_height
=
1440 MAX(theme
->win_font_height
,
1442 (theme
->win_font_focused
,
1443 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
));
1444 theme
->menu_title_font_height
= RrFontHeight
1445 (theme
->menu_title_font
,
1446 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
);
1447 theme
->menu_font_height
= RrFontHeight
1449 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset_y
);
1451 /* calculate some last extents */
1453 gint ft
, fb
, fl
, fr
, ut
, ub
, ul
, ur
;
1455 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
1456 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
1457 theme
->label_height
= theme
->win_font_height
+ MAX(ft
+ fb
, ut
+ ub
);
1458 theme
->label_height
+= theme
->label_height
% 2;
1460 /* this would be nice I think, since padding.width can now be 0,
1461 but it breaks frame.c horribly and I don't feel like fixing that
1462 right now, so if anyone complains, here is how to keep text from
1463 going over the title's bevel/border with a padding.width of 0 and a
1464 bevelless/borderless label
1465 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1466 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1467 theme->title_height = theme->label_height +
1468 MAX(MAX(theme->padding * 2, ft + fb),
1469 MAX(theme->padding * 2, ut + ub));
1471 theme
->title_height
= theme
->label_height
+ theme
->paddingy
* 2;
1473 RrMargins(theme
->a_menu_title
, &ul
, &ut
, &ur
, &ub
);
1474 theme
->menu_title_label_height
= theme
->menu_title_font_height
+ut
+ub
;
1475 theme
->menu_title_height
= theme
->menu_title_label_height
+
1476 theme
->paddingy
* 2;
1478 theme
->button_size
= theme
->label_height
- 2;
1479 theme
->grip_width
= 25;
1484 void RrThemeFree(RrTheme
*theme
)
1487 g_free(theme
->name
);
1489 RrColorFree(theme
->menu_border_color
);
1490 RrColorFree(theme
->osd_border_color
);
1491 RrColorFree(theme
->frame_focused_border_color
);
1492 RrColorFree(theme
->frame_unfocused_border_color
);
1493 RrColorFree(theme
->title_separator_focused_color
);
1494 RrColorFree(theme
->title_separator_unfocused_color
);
1495 RrColorFree(theme
->cb_unfocused_color
);
1496 RrColorFree(theme
->cb_focused_color
);
1497 RrColorFree(theme
->title_focused_color
);
1498 RrColorFree(theme
->title_unfocused_color
);
1499 RrColorFree(theme
->titlebut_disabled_focused_color
);
1500 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
1501 RrColorFree(theme
->titlebut_hover_focused_color
);
1502 RrColorFree(theme
->titlebut_hover_unfocused_color
);
1503 RrColorFree(theme
->titlebut_toggled_hover_focused_color
);
1504 RrColorFree(theme
->titlebut_toggled_hover_unfocused_color
);
1505 RrColorFree(theme
->titlebut_toggled_focused_pressed_color
);
1506 RrColorFree(theme
->titlebut_toggled_unfocused_pressed_color
);
1507 RrColorFree(theme
->titlebut_toggled_focused_unpressed_color
);
1508 RrColorFree(theme
->titlebut_toggled_unfocused_unpressed_color
);
1509 RrColorFree(theme
->titlebut_focused_pressed_color
);
1510 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
1511 RrColorFree(theme
->titlebut_focused_unpressed_color
);
1512 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
1513 RrColorFree(theme
->menu_title_color
);
1514 RrColorFree(theme
->menu_sep_color
);
1515 RrColorFree(theme
->menu_color
);
1516 RrColorFree(theme
->menu_selected_color
);
1517 RrColorFree(theme
->menu_disabled_color
);
1518 RrColorFree(theme
->menu_disabled_selected_color
);
1519 RrColorFree(theme
->title_focused_shadow_color
);
1520 RrColorFree(theme
->title_unfocused_shadow_color
);
1521 RrColorFree(theme
->osd_text_active_color
);
1522 RrColorFree(theme
->osd_text_inactive_color
);
1523 RrColorFree(theme
->osd_text_active_shadow_color
);
1524 RrColorFree(theme
->osd_text_inactive_shadow_color
);
1525 RrColorFree(theme
->menu_title_shadow_color
);
1526 RrColorFree(theme
->menu_text_normal_shadow_color
);
1527 RrColorFree(theme
->menu_text_selected_shadow_color
);
1528 RrColorFree(theme
->menu_text_disabled_shadow_color
);
1529 RrColorFree(theme
->menu_text_disabled_selected_shadow_color
);
1531 g_free(theme
->def_win_icon
);
1533 RrPixmapMaskFree(theme
->max_mask
);
1534 RrPixmapMaskFree(theme
->max_toggled_mask
);
1535 RrPixmapMaskFree(theme
->max_toggled_hover_mask
);
1536 RrPixmapMaskFree(theme
->max_toggled_pressed_mask
);
1537 RrPixmapMaskFree(theme
->max_disabled_mask
);
1538 RrPixmapMaskFree(theme
->max_hover_mask
);
1539 RrPixmapMaskFree(theme
->max_pressed_mask
);
1540 RrPixmapMaskFree(theme
->desk_mask
);
1541 RrPixmapMaskFree(theme
->desk_toggled_mask
);
1542 RrPixmapMaskFree(theme
->desk_toggled_hover_mask
);
1543 RrPixmapMaskFree(theme
->desk_toggled_pressed_mask
);
1544 RrPixmapMaskFree(theme
->desk_disabled_mask
);
1545 RrPixmapMaskFree(theme
->desk_hover_mask
);
1546 RrPixmapMaskFree(theme
->desk_pressed_mask
);
1547 RrPixmapMaskFree(theme
->shade_mask
);
1548 RrPixmapMaskFree(theme
->shade_toggled_mask
);
1549 RrPixmapMaskFree(theme
->shade_toggled_hover_mask
);
1550 RrPixmapMaskFree(theme
->shade_toggled_pressed_mask
);
1551 RrPixmapMaskFree(theme
->shade_disabled_mask
);
1552 RrPixmapMaskFree(theme
->shade_hover_mask
);
1553 RrPixmapMaskFree(theme
->shade_pressed_mask
);
1554 RrPixmapMaskFree(theme
->iconify_mask
);
1555 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
1556 RrPixmapMaskFree(theme
->iconify_hover_mask
);
1557 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
1558 RrPixmapMaskFree(theme
->close_mask
);
1559 RrPixmapMaskFree(theme
->close_disabled_mask
);
1560 RrPixmapMaskFree(theme
->close_hover_mask
);
1561 RrPixmapMaskFree(theme
->close_pressed_mask
);
1562 RrPixmapMaskFree(theme
->menu_bullet_mask
);
1563 RrPixmapMaskFree(theme
->down_arrow_mask
);
1564 RrPixmapMaskFree(theme
->up_arrow_mask
);
1566 RrFontClose(theme
->win_font_focused
);
1567 RrFontClose(theme
->win_font_unfocused
);
1568 RrFontClose(theme
->menu_title_font
);
1569 RrFontClose(theme
->menu_font
);
1570 RrFontClose(theme
->osd_font_hilite
);
1571 RrFontClose(theme
->osd_font_unhilite
);
1573 RrAppearanceFree(theme
->a_disabled_focused_max
);
1574 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
1575 RrAppearanceFree(theme
->a_hover_focused_max
);
1576 RrAppearanceFree(theme
->a_hover_unfocused_max
);
1577 RrAppearanceFree(theme
->a_toggled_hover_focused_max
);
1578 RrAppearanceFree(theme
->a_toggled_hover_unfocused_max
);
1579 RrAppearanceFree(theme
->a_toggled_focused_unpressed_max
);
1580 RrAppearanceFree(theme
->a_toggled_focused_pressed_max
);
1581 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_max
);
1582 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_max
);
1583 RrAppearanceFree(theme
->a_focused_unpressed_max
);
1584 RrAppearanceFree(theme
->a_focused_pressed_max
);
1585 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
1586 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
1587 RrAppearanceFree(theme
->a_disabled_focused_close
);
1588 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
1589 RrAppearanceFree(theme
->a_hover_focused_close
);
1590 RrAppearanceFree(theme
->a_hover_unfocused_close
);
1591 RrAppearanceFree(theme
->a_focused_unpressed_close
);
1592 RrAppearanceFree(theme
->a_focused_pressed_close
);
1593 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1594 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1595 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1596 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1597 RrAppearanceFree(theme
->a_hover_focused_desk
);
1598 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1599 RrAppearanceFree(theme
->a_toggled_hover_focused_desk
);
1600 RrAppearanceFree(theme
->a_toggled_hover_unfocused_desk
);
1601 RrAppearanceFree(theme
->a_toggled_focused_unpressed_desk
);
1602 RrAppearanceFree(theme
->a_toggled_focused_pressed_desk
);
1603 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_desk
);
1604 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_desk
);
1605 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1606 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1607 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1608 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1609 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1610 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1611 RrAppearanceFree(theme
->a_hover_focused_shade
);
1612 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1613 RrAppearanceFree(theme
->a_toggled_hover_focused_shade
);
1614 RrAppearanceFree(theme
->a_toggled_hover_unfocused_shade
);
1615 RrAppearanceFree(theme
->a_toggled_focused_unpressed_shade
);
1616 RrAppearanceFree(theme
->a_toggled_focused_pressed_shade
);
1617 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_shade
);
1618 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_shade
);
1619 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1620 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1621 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1622 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1623 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1624 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1625 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1626 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1627 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1628 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1629 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1630 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1631 RrAppearanceFree(theme
->a_focused_grip
);
1632 RrAppearanceFree(theme
->a_unfocused_grip
);
1633 RrAppearanceFree(theme
->a_focused_title
);
1634 RrAppearanceFree(theme
->a_unfocused_title
);
1635 RrAppearanceFree(theme
->a_focused_label
);
1636 RrAppearanceFree(theme
->a_unfocused_label
);
1637 RrAppearanceFree(theme
->a_icon
);
1638 RrAppearanceFree(theme
->a_focused_handle
);
1639 RrAppearanceFree(theme
->a_unfocused_handle
);
1640 RrAppearanceFree(theme
->a_menu
);
1641 RrAppearanceFree(theme
->a_menu_title
);
1642 RrAppearanceFree(theme
->a_menu_text_title
);
1643 RrAppearanceFree(theme
->a_menu_normal
);
1644 RrAppearanceFree(theme
->a_menu_selected
);
1645 RrAppearanceFree(theme
->a_menu_disabled
);
1646 RrAppearanceFree(theme
->a_menu_disabled_selected
);
1647 RrAppearanceFree(theme
->a_menu_text_normal
);
1648 RrAppearanceFree(theme
->a_menu_text_selected
);
1649 RrAppearanceFree(theme
->a_menu_text_disabled
);
1650 RrAppearanceFree(theme
->a_menu_text_disabled_selected
);
1651 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1652 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1653 RrAppearanceFree(theme
->a_clear
);
1654 RrAppearanceFree(theme
->a_clear_tex
);
1655 RrAppearanceFree(theme
->osd_bg
);
1656 RrAppearanceFree(theme
->osd_hilite_bg
);
1657 RrAppearanceFree(theme
->osd_hilite_label
);
1658 RrAppearanceFree(theme
->osd_unhilite_bg
);
1659 RrAppearanceFree(theme
->osd_unhilite_label
);
1665 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
)
1668 XrmDatabase db
= NULL
;
1671 if (name
[0] == '/') {
1672 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1673 if ((db
= XrmGetFileDatabase(s
)))
1674 *path
= g_path_get_dirname(s
);
1679 p
= obt_paths_new();
1681 /* XXX backwards compatibility, remove me sometime later */
1682 s
= g_build_filename(g_get_home_dir(), ".themes", name
,
1683 "openbox-3", "themerc", NULL
);
1684 if ((db
= XrmGetFileDatabase(s
)))
1685 *path
= g_path_get_dirname(s
);
1688 for (it
= obt_paths_data_dirs(p
); !db
&& it
; it
= g_slist_next(it
))
1690 s
= g_build_filename(it
->data
, "themes", name
,
1691 "openbox-3", "themerc", NULL
);
1692 if ((db
= XrmGetFileDatabase(s
)))
1693 *path
= g_path_get_dirname(s
);
1701 s
= g_build_filename(name
, "themerc", NULL
);
1702 if ((db
= XrmGetFileDatabase(s
)))
1703 *path
= g_path_get_dirname(s
);
1710 static gchar
*create_class_name(const gchar
*rname
)
1712 gchar
*rclass
= g_strdup(rname
);
1717 p
= strchr(p
+1, '.');
1718 if (p
== NULL
) break;
1720 if (*p
== '\0') break;
1725 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
)
1727 gboolean ret
= FALSE
;
1728 gchar
*rclass
= create_class_name(rname
);
1729 gchar
*rettype
, *end
;
1732 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1733 retvalue
.addr
!= NULL
) {
1734 *value
= (gint
)strtol(retvalue
.addr
, &end
, 10);
1735 if (end
!= retvalue
.addr
)
1743 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
)
1745 gboolean ret
= FALSE
;
1746 gchar
*rclass
= create_class_name(rname
);
1750 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1751 retvalue
.addr
!= NULL
) {
1752 *value
= retvalue
.addr
;
1760 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1761 const gchar
*rname
, RrColor
**value
)
1763 gboolean ret
= FALSE
;
1764 gchar
*rclass
= create_class_name(rname
);
1768 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1769 retvalue
.addr
!= NULL
) {
1770 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1781 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
1782 RrTheme
*theme
, const gchar
*maskname
,
1783 RrPixmapMask
**value
)
1785 gboolean ret
= FALSE
;
1787 gint hx
, hy
; /* ignored */
1791 s
= g_build_filename(path
, maskname
, NULL
);
1792 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1794 *value
= RrPixmapMaskNew(inst
, w
, h
, (gchar
*)b
);
1802 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1803 RrReliefType
*relief
, RrBevelType
*bevel
,
1804 gboolean
*interlaced
, gboolean
*border
,
1805 gboolean allow_trans
)
1809 /* convert to all lowercase */
1810 for (t
= tex
; *t
!= '\0'; ++t
)
1811 *t
= g_ascii_tolower(*t
);
1813 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1814 *grad
= RR_SURFACE_PARENTREL
;
1816 if (strstr(tex
, "gradient") != NULL
) {
1817 if (strstr(tex
, "crossdiagonal") != NULL
)
1818 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1819 else if (strstr(tex
, "pyramid") != NULL
)
1820 *grad
= RR_SURFACE_PYRAMID
;
1821 else if (strstr(tex
, "mirrorhorizontal") != NULL
)
1822 *grad
= RR_SURFACE_MIRROR_HORIZONTAL
;
1823 else if (strstr(tex
, "horizontal") != NULL
)
1824 *grad
= RR_SURFACE_HORIZONTAL
;
1825 else if (strstr(tex
, "splitvertical") != NULL
)
1826 *grad
= RR_SURFACE_SPLIT_VERTICAL
;
1827 else if (strstr(tex
, "vertical") != NULL
)
1828 *grad
= RR_SURFACE_VERTICAL
;
1830 *grad
= RR_SURFACE_DIAGONAL
;
1832 *grad
= RR_SURFACE_SOLID
;
1836 if (strstr(tex
, "sunken") != NULL
)
1837 *relief
= RR_RELIEF_SUNKEN
;
1838 else if (strstr(tex
, "flat") != NULL
)
1839 *relief
= RR_RELIEF_FLAT
;
1840 else if (strstr(tex
, "raised") != NULL
)
1841 *relief
= RR_RELIEF_RAISED
;
1843 *relief
= (*grad
== RR_SURFACE_PARENTREL
) ?
1844 RR_RELIEF_FLAT
: RR_RELIEF_RAISED
;
1847 if (*relief
== RR_RELIEF_FLAT
) {
1848 if (strstr(tex
, "border") != NULL
)
1851 if (strstr(tex
, "bevel2") != NULL
)
1852 *bevel
= RR_BEVEL_2
;
1854 *bevel
= RR_BEVEL_1
;
1857 if (strstr(tex
, "interlaced") != NULL
)
1860 *interlaced
= FALSE
;
1863 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1864 const gchar
*rname
, RrAppearance
*value
,
1865 gboolean allow_trans
)
1867 gboolean ret
= FALSE
;
1868 gchar
*rclass
= create_class_name(rname
);
1869 gchar
*cname
, *ctoname
, *bcname
, *icname
, *hname
, *sname
;
1870 gchar
*csplitname
, *ctosplitname
;
1875 cname
= g_strconcat(rname
, ".color", NULL
);
1876 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1877 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1878 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1879 hname
= g_strconcat(rname
, ".highlight", NULL
);
1880 sname
= g_strconcat(rname
, ".shadow", NULL
);
1881 csplitname
= g_strconcat(rname
, ".color.splitTo", NULL
);
1882 ctosplitname
= g_strconcat(rname
, ".colorTo.splitTo", NULL
);
1884 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1885 retvalue
.addr
!= NULL
) {
1886 parse_appearance(retvalue
.addr
,
1887 &value
->surface
.grad
,
1888 &value
->surface
.relief
,
1889 &value
->surface
.bevel
,
1890 &value
->surface
.interlaced
,
1891 &value
->surface
.border
,
1893 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1894 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1895 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1896 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1897 if (value
->surface
.border
)
1898 if (!read_color(db
, inst
, bcname
,
1899 &value
->surface
.border_color
))
1900 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1901 if (value
->surface
.interlaced
)
1902 if (!read_color(db
, inst
, icname
,
1903 &value
->surface
.interlace_color
))
1904 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1905 if (read_int(db
, hname
, &i
) && i
>= 0)
1906 value
->surface
.bevel_light_adjust
= i
;
1907 if (read_int(db
, sname
, &i
) && i
>= 0 && i
<= 256)
1908 value
->surface
.bevel_dark_adjust
= i
;
1910 if (value
->surface
.grad
== RR_SURFACE_SPLIT_VERTICAL
) {
1913 if (!read_color(db
, inst
, csplitname
,
1914 &value
->surface
.split_primary
))
1916 r
= value
->surface
.primary
->r
;
1918 g
= value
->surface
.primary
->g
;
1920 b
= value
->surface
.primary
->b
;
1922 if (r
> 0xFF) r
= 0xFF;
1923 if (g
> 0xFF) g
= 0xFF;
1924 if (b
> 0xFF) b
= 0xFF;
1925 value
->surface
.split_primary
= RrColorNew(inst
, r
, g
, b
);
1928 if (!read_color(db
, inst
, ctosplitname
,
1929 &value
->surface
.split_secondary
))
1931 r
= value
->surface
.secondary
->r
;
1933 g
= value
->surface
.secondary
->g
;
1935 b
= value
->surface
.secondary
->b
;
1937 if (r
> 0xFF) r
= 0xFF;
1938 if (g
> 0xFF) g
= 0xFF;
1939 if (b
> 0xFF) b
= 0xFF;
1940 value
->surface
.split_secondary
= RrColorNew(inst
, r
, g
, b
);
1947 g_free(ctosplitname
);
1959 static int parse_inline_number(const char *p
)
1967 for (; isdigit(*p
); ++p
)
1968 res
= res
* 10 + *p
- '0';
1973 static void set_default_appearance(RrAppearance
*a
)
1975 a
->surface
.grad
= RR_SURFACE_SOLID
;
1976 a
->surface
.relief
= RR_RELIEF_FLAT
;
1977 a
->surface
.bevel
= RR_BEVEL_1
;
1978 a
->surface
.interlaced
= FALSE
;
1979 a
->surface
.border
= FALSE
;
1980 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1981 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1984 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1985 an RrTextureRGBA. */
1986 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1991 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1993 for (i
= 0; i
< width
* height
; ++i
) {
1994 guchar a
= ((*p
>> 24) & 0xff);
1995 guchar b
= ((*p
>> 16) & 0xff);
1996 guchar g
= ((*p
>> 8) & 0xff);
1997 guchar r
= ((*p
>> 0) & 0xff);
1999 *p
= ((r
<< RrDefaultRedOffset
) +
2000 (g
<< RrDefaultGreenOffset
) +
2001 (b
<< RrDefaultBlueOffset
) +
2002 (a
<< RrDefaultAlphaOffset
));