X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Ftheme.c;h=1dd49caf4a3462d846d36d2f756336376a69d7a9;hb=770360278c9acd563149b3d6bb2bbcc2f4f1b99b;hp=28a682b5f22b2a49bfcf431c40128619c23f0f19;hpb=526560b8a0871cd93f27c32442b3e470ec42ecb3;p=chaz%2Fopenbox diff --git a/render/theme.c b/render/theme.c index 28a682b5..1dd49caf 100644 --- a/render/theme.c +++ b/render/theme.c @@ -48,7 +48,7 @@ static xmlNodePtr find_node(xmlNodePtr n, const gchar *names[]); static gboolean find_int(ParseState *ps, xmlNodePtr n, const gchar *names[], gint *integer, gint lower, gint upper); static gboolean find_string(ParseState *ps, xmlNodePtr n, const gchar *names[], - const gchar **string); + gchar **string); static gboolean find_color(ParseState *ps, xmlNodePtr n, const gchar *names[], RrColor **color, gchar *alpha); static gboolean find_point(ParseState *ps, xmlNodePtr n, const gchar *names[], @@ -72,7 +72,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, ParseState ps; xmlNodePtr root; RrJustify winjust, mtitlejust; - const gchar *str; + gchar *str; RrTheme *theme; if (name) { @@ -154,6 +154,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, winjust = RR_JUSTIFY_RIGHT; else if (strcmp(str, "center") == 0) winjust = RR_JUSTIFY_CENTER; + g_free(str); } if (menu_title_font) { @@ -168,6 +169,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, mtitlejust = RR_JUSTIFY_RIGHT; else if (strcmp(str, "center") == 0) mtitlejust = RR_JUSTIFY_CENTER; + g_free(str); } if (menu_item_font) { @@ -194,31 +196,40 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, &theme->paddingx, &theme->paddingy, 0, 100, 0, 100)) theme->paddingx = theme->paddingy = 3; - if (!FIND(int, L("window","border","width"), + if (!FIND(int, L("dimensions","window","border"), &theme->fbwidth, 0, 100)) theme->fbwidth = 1; /* menu border width inherits from frame border width */ - if (!FIND(int, L("menu","border","width"), + if (!FIND(int, L("dimensions","menu","border"), &theme->mbwidth, 0, 100)) theme->mbwidth = theme->fbwidth; - if (!FIND(point, L("window","clientpadding"), &theme->cbwidthx, - &theme->cbwidthy, 0, 100, 0, 100)) + if (!FIND(point, L("dimensions","window","clientpadding"), + &theme->cbwidthx, &theme->cbwidthy, 0, 100, 0, 100)) theme->cbwidthx = theme->cbwidthy = 1; /* load colors */ - if (!FIND(color, L("window","border","primary"), - &theme->frame_b_color, NULL)) - theme->frame_b_color = RrColorNew(inst, 0, 0, 0); - - /* menu border color inherits from frame border color */ - if (!FIND(color, L("menu","border","primary"), - &theme->menu_b_color, NULL)) - theme->menu_b_color = RrColorNew(inst, - theme->frame_b_color->r, - theme->frame_b_color->g, - theme->frame_b_color->b); + if (!FIND(color, L("window","active","border"), + &theme->frame_focused_border_color, NULL)) + theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0); + /* frame unfocused border color inherits from frame focused border color */ + if (!FIND(color, L("window","inactive","border"), + &theme->frame_unfocused_border_color, NULL)) + theme->frame_unfocused_border_color = + RrColorNew(inst, + theme->frame_focused_border_color->r, + theme->frame_focused_border_color->g, + theme->frame_focused_border_color->b); + + /* menu border color inherits from frame focused border color */ + if (!FIND(color, L("menu","border"), + &theme->menu_border_color, NULL)) + theme->menu_border_color = + RrColorNew(inst, + theme->frame_focused_border_color->r, + theme->frame_focused_border_color->g, + theme->frame_focused_border_color->b); if (!FIND(color, L("window","active","clientpadding"), &theme->cb_focused_color, NULL)) theme->cb_focused_color = RrColorNew(inst, 255, 255, 255); @@ -685,14 +696,14 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, { RrAppearanceFree(theme->a_toggled_hover_focused_max); theme->a_toggled_hover_focused_max = - RrAppearanceCopy(theme->a_toggled_focused_pressed_max); + RrAppearanceCopy(theme->a_toggled_focused_unpressed_max); } if (!FIND(appearance, L("window","inactive","buttons","toggled-hover"), theme->a_toggled_hover_unfocused_max, TRUE)) { RrAppearanceFree(theme->a_toggled_hover_unfocused_max); theme->a_toggled_hover_unfocused_max = - RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max); + RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max); } theme->a_disabled_focused_close = @@ -1121,10 +1132,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color = theme->titlebut_toggled_focused_unpressed_color; theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color = - theme->a_toggled_unfocused_unpressed_desk-> - texture[0].data.mask.color = - theme->a_toggled_unfocused_unpressed_shade-> - texture[0].data.mask.color = + theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color = + theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color= theme->titlebut_toggled_unfocused_unpressed_color; theme->a_focused_unpressed_max->texture[0].data.mask.color = theme->a_focused_unpressed_close->texture[0].data.mask.color = @@ -1191,6 +1200,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb); RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub); theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub); + theme->label_height += theme->label_height % 2; /* this would be nice I think, since padding.width can now be 0, but it breaks frame.c horribly and I don't feel like fixing that @@ -1204,9 +1214,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, MAX(theme->padding * 2, ut + ub)); */ theme->title_height = theme->label_height + theme->paddingy * 2; - /* this should match the above title_height given the same font size - for both. */ - theme->menu_title_height = theme->menu_title_font_height + + + RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub); + theme->menu_title_label_height = theme->menu_title_font_height+ut+ub; + theme->menu_title_height = theme->menu_title_label_height + theme->paddingy * 2; } theme->button_size = theme->label_height - 2; @@ -1218,8 +1229,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, void RrThemeFree(RrTheme *theme) { if (theme) { - RrColorFree(theme->menu_b_color); - RrColorFree(theme->frame_b_color); + RrColorFree(theme->menu_border_color); + RrColorFree(theme->frame_focused_border_color); + RrColorFree(theme->frame_unfocused_border_color); RrColorFree(theme->cb_unfocused_color); RrColorFree(theme->cb_focused_color); RrColorFree(theme->title_focused_color); @@ -1257,16 +1269,22 @@ void RrThemeFree(RrTheme *theme) RrPixmapMaskFree(theme->max_mask); RrPixmapMaskFree(theme->max_toggled_mask); + RrPixmapMaskFree(theme->max_toggled_hover_mask); + RrPixmapMaskFree(theme->max_toggled_pressed_mask); RrPixmapMaskFree(theme->max_disabled_mask); RrPixmapMaskFree(theme->max_hover_mask); RrPixmapMaskFree(theme->max_pressed_mask); RrPixmapMaskFree(theme->desk_mask); RrPixmapMaskFree(theme->desk_toggled_mask); + RrPixmapMaskFree(theme->desk_toggled_hover_mask); + RrPixmapMaskFree(theme->desk_toggled_pressed_mask); RrPixmapMaskFree(theme->desk_disabled_mask); RrPixmapMaskFree(theme->desk_hover_mask); RrPixmapMaskFree(theme->desk_pressed_mask); RrPixmapMaskFree(theme->shade_mask); RrPixmapMaskFree(theme->shade_toggled_mask); + RrPixmapMaskFree(theme->shade_toggled_hover_mask); + RrPixmapMaskFree(theme->shade_toggled_pressed_mask); RrPixmapMaskFree(theme->shade_disabled_mask); RrPixmapMaskFree(theme->shade_hover_mask); RrPixmapMaskFree(theme->shade_pressed_mask); @@ -1515,7 +1533,7 @@ static gboolean find_int(ParseState *ps, xmlNodePtr n, const gchar *names[], } static gboolean find_string(ParseState *ps, xmlNodePtr n, const gchar *names[], - const gchar **string) + gchar **string) { if ((n = find_node(n, names))) { *string = parse_string(ps->doc, n);