X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Ftheme.c;h=8ba7a9dcda3104dc6dd0254aa5f569bd9b3307f2;hb=d6652d0a90bd6c93084b0b9e6cf36123e0ec15d1;hp=d6f248ce9b2c7a99ed739c610045b8c4e224f78c;hpb=5cf61ee02354c1c9f80c11f3796afc4b948055d6;p=chaz%2Fopenbox diff --git a/render/theme.c b/render/theme.c index d6f248ce..8ba7a9dc 100644 --- a/render/theme.c +++ b/render/theme.c @@ -19,12 +19,26 @@ color_rgb *theme_title_focused_color; color_rgb *theme_title_unfocused_color; color_rgb *theme_titlebut_focused_color; color_rgb *theme_titlebut_unfocused_color; +color_rgb *theme_menu_title_color; +color_rgb *theme_menu_color; +color_rgb *theme_menu_disabled_color; +color_rgb *theme_menu_hilite_color; /* style settings - fonts */ int theme_winfont_height; ObFont *theme_winfont; gboolean theme_winfont_shadow; int theme_winfont_shadow_offset; int theme_winfont_shadow_tint; +int theme_mtitlefont_height; +ObFont *theme_mtitlefont; +gboolean theme_mtitlefont_shadow; +int theme_mtitlefont_shadow_offset; +int theme_mtitlefont_shadow_tint; +int theme_mfont_height; +ObFont *theme_mfont; +gboolean theme_mfont_shadow; +int theme_mfont_shadow_offset; +int theme_mfont_shadow_tint; /* style settings - title layout */ char *theme_title_layout; /* style settings - masks */ @@ -73,16 +87,26 @@ Appearance *theme_a_unfocused_label; Appearance *theme_a_icon; /* always parentrelative, so no focused/unfocused */ Appearance *theme_a_focused_handle; Appearance *theme_a_unfocused_handle; - +Appearance *theme_a_menu_title; +Appearance *theme_a_menu; +Appearance *theme_a_menu_item; +Appearance *theme_a_menu_disabled; +Appearance *theme_a_menu_hilite; + +Appearance *theme_app_hilite_bg; +Appearance *theme_app_unhilite_bg; Appearance *theme_app_hilite_label; Appearance *theme_app_unhilite_label; +Appearance *theme_app_icon; void theme_startup() { theme_b_color = theme_cb_unfocused_color = theme_cb_focused_color = theme_title_unfocused_color = theme_title_focused_color = - theme_titlebut_unfocused_color = theme_titlebut_focused_color = NULL; - theme_winfont = NULL; + theme_titlebut_unfocused_color = theme_titlebut_focused_color = + theme_menu_color = theme_menu_title_color = theme_menu_disabled_color = + theme_menu_hilite_color = NULL; + theme_winfont = theme_mtitlefont = theme_mfont = NULL; theme_title_layout = NULL; theme_max_set_mask = theme_max_unset_mask = NULL; theme_desk_set_mask = theme_desk_unset_mask = NULL; @@ -124,8 +148,17 @@ void theme_startup() theme_a_icon = appearance_new(Surface_Planar, 1); theme_a_focused_handle = appearance_new(Surface_Planar, 0); theme_a_unfocused_handle = appearance_new(Surface_Planar, 0); + theme_a_menu = appearance_new(Surface_Planar, 0); + theme_a_menu_title = appearance_new(Surface_Planar, 1); + theme_a_menu_item = appearance_new(Surface_Planar, 1); + theme_a_menu_disabled = appearance_new(Surface_Planar, 1); + theme_a_menu_hilite = appearance_new(Surface_Planar, 1); + + theme_app_hilite_bg = appearance_new(Surface_Planar, 0); + theme_app_unhilite_bg = appearance_new(Surface_Planar, 0); theme_app_hilite_label = appearance_new(Surface_Planar, 1); theme_app_unhilite_label = appearance_new(Surface_Planar, 1); + theme_app_icon = appearance_new(Surface_Planar, 1); } @@ -138,6 +171,10 @@ void theme_shutdown() color_free(theme_title_focused_color); color_free(theme_titlebut_unfocused_color); color_free(theme_titlebut_focused_color); + color_free(theme_menu_color); + color_free(theme_menu_title_color); + color_free(theme_menu_disabled_color); + color_free(theme_menu_hilite_color); pixmap_mask_free(theme_max_set_mask); pixmap_mask_free(theme_max_unset_mask); @@ -149,6 +186,9 @@ void theme_shutdown() pixmap_mask_free(theme_close_mask); font_close(theme_winfont); + font_close(theme_mtitlefont); + font_close(theme_mfont); + g_free(theme_title_layout); appearance_free(theme_a_focused_unpressed_max); @@ -182,8 +222,16 @@ void theme_shutdown() appearance_free(theme_a_icon); appearance_free(theme_a_focused_handle); appearance_free(theme_a_unfocused_handle); + appearance_free(theme_a_menu); + appearance_free(theme_a_menu_title); + appearance_free(theme_a_menu_item); + appearance_free(theme_a_menu_disabled); + appearance_free(theme_a_menu_hilite); + appearance_free(theme_app_hilite_bg); + appearance_free(theme_app_unhilite_bg); appearance_free(theme_app_hilite_label); appearance_free(theme_app_unhilite_label); + appearance_free(theme_app_icon); } static XrmDatabase loaddb(char *theme) @@ -291,7 +339,7 @@ static gboolean read_mask(XrmDatabase db, char *rname, char *theme, if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { - button_dir = g_strdup_printf("%s_buttons", theme); + button_dir = g_strdup_printf("%s_data", theme); s = g_build_filename(g_get_home_dir(), ".openbox", "themes", button_dir, retvalue.addr, NULL); @@ -309,7 +357,7 @@ static gboolean read_mask(XrmDatabase db, char *rname, char *theme, g_free(s); themename = g_path_get_basename(theme); - s = g_strdup_printf("%s/%s_buttons/%s", theme, + s = g_strdup_printf("%s/%s_data/%s", theme, themename, retvalue.addr); g_free(themename); if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == @@ -356,7 +404,7 @@ static void parse_appearance(char *tex, SurfaceColorType *grad, else if (strstr(tex, "pipecross") != NULL) *grad = Background_PipeCross; else if (strstr(tex, "elliptic") != NULL) - *grad = Background_Elliptic; + *grad = Background_Rectangle; else if (strstr(tex, "horizontal") != NULL) *grad = Background_Horizontal; else if (strstr(tex, "vertical") != NULL) @@ -445,9 +493,9 @@ char *theme_load(char *theme) { XrmDatabase db = NULL; char *loaded = NULL; - Justify winjust; - char *winjust_str; - char *winfont_str; + Justify winjust, mtitlejust, mjust; + char *str; + char *font_str; if (theme) { db = loaddb(theme); @@ -467,22 +515,97 @@ char *theme_load(char *theme) } /* load the font stuff */ - winfont_str = "arial-8:bold"; - theme_winfont_shadow = FALSE; - theme_winfont_shadow_offset = 1; - theme_winfont_shadow_tint = 25; + font_str = "arial-8:bold"; - theme_winfont = font_open(winfont_str); + theme_winfont_shadow = FALSE; + if (read_string(db, "window.xft.flags", &str)) { + if (g_strrstr(str, "shadow")) + theme_winfont_shadow = TRUE; + g_free(str); + } + + if (!read_int(db, "window.xft.shadow.offset", + &theme_winfont_shadow_offset)) + theme_winfont_shadow_offset = 1; + if (!read_int(db, "window.xft.shadow.tint", + &theme_winfont_shadow_tint) || + theme_winfont_shadow_tint < 100 || theme_winfont_shadow_tint > 100) + theme_winfont_shadow_tint = 25; + + theme_winfont = font_open(font_str); theme_winfont_height = font_height(theme_winfont, theme_winfont_shadow, - theme_winfont_shadow_offset); + theme_winfont_shadow_offset); winjust = Justify_Left; - if (read_string(db, "window.justify", &winjust_str)) { - if (!g_ascii_strcasecmp(winjust_str, "right")) + if (read_string(db, "window.justify", &str)) { + if (!g_ascii_strcasecmp(str, "right")) winjust = Justify_Right; - else if (!g_ascii_strcasecmp(winjust_str, "center")) + else if (!g_ascii_strcasecmp(str, "center")) winjust = Justify_Center; - g_free(winjust_str); + g_free(str); + } + + font_str = "arial-10:bold"; + + theme_mtitlefont_shadow = FALSE; + if (read_string(db, "menu.title.xft.flags", &str)) { + if (g_strrstr(str, "shadow")) + theme_mtitlefont_shadow = TRUE; + g_free(str); + } + + if (!read_int(db, "menu.title.xft.shadow.offset", + &theme_mtitlefont_shadow_offset)) + theme_mtitlefont_shadow_offset = 1; + if (!read_int(db, "menu.title.xft.shadow.tint", + &theme_mtitlefont_shadow_tint) || + theme_mtitlefont_shadow_tint < 100 || + theme_mtitlefont_shadow_tint > 100) + theme_mtitlefont_shadow_tint = 25; + + theme_mtitlefont = font_open(font_str); + theme_mtitlefont_height = font_height(theme_mtitlefont, + theme_mtitlefont_shadow, + theme_mtitlefont_shadow_offset); + + mtitlejust = Justify_Left; + if (read_string(db, "menu.title.justify", &str)) { + if (!g_ascii_strcasecmp(str, "right")) + mtitlejust = Justify_Right; + else if (!g_ascii_strcasecmp(str, "center")) + mtitlejust = Justify_Center; + g_free(str); + } + + font_str = "arial-8"; + + theme_mfont_shadow = FALSE; + if (read_string(db, "menu.frame.xft.flags", &str)) { + if (g_strrstr(str, "shadow")) + theme_mfont_shadow = TRUE; + g_free(str); + } + + if (!read_int(db, "menu.frame.xft.shadow.offset", + &theme_mfont_shadow_offset)) + theme_mfont_shadow_offset = 1; + if (!read_int(db, "menu.frame.xft.shadow.tint", + &theme_mfont_shadow_tint) || + theme_mfont_shadow_tint < 100 || + theme_mfont_shadow_tint > 100) + theme_mfont_shadow_tint = 25; + + theme_mfont = font_open(font_str); + theme_mfont_height = font_height(theme_mfont, theme_mfont_shadow, + theme_mfont_shadow_offset); + + mjust = Justify_Left; + if (read_string(db, "menu.frame.justify", &str)) { + if (!g_ascii_strcasecmp(str, "right")) + mjust = Justify_Right; + else if (!g_ascii_strcasecmp(str, "center")) + mjust = Justify_Center; + g_free(str); } /* load the title layout */ @@ -498,11 +621,12 @@ char *theme_load(char *theme) if (!read_int(db, "frameWidth", &theme_cbwidth) || theme_cbwidth < 0 || theme_cbwidth > 100) theme_cbwidth = theme_bevel; + /* load colors */ if (!read_color(db, "borderColor", &theme_b_color)) theme_b_color = color_new(0, 0, 0); if (!read_color(db, "window.frame.focusColor", &theme_cb_focused_color)) theme_cb_focused_color = color_new(0xff, 0xff, 0xff); - if (!read_color(db, "window.frame.unfocusColor", &theme_cb_unfocused_color)) + if (!read_color(db, "window.frame.unfocusColor",&theme_cb_unfocused_color)) theme_cb_unfocused_color = color_new(0xff, 0xff, 0xff); if (!read_color(db, "window.label.focus.textColor", &theme_title_focused_color)) @@ -516,6 +640,14 @@ char *theme_load(char *theme) if (!read_color(db, "window.button.unfocus.picColor", &theme_titlebut_unfocused_color)) theme_titlebut_unfocused_color = color_new(0xff, 0xff, 0xff); + if (!read_color(db, "menu.title.textColor", &theme_menu_title_color)) + theme_menu_title_color = color_new(0, 0, 0); + if (!read_color(db, "menu.frame.textColor", &theme_menu_color)) + theme_menu_color = color_new(0xff, 0xff, 0xff); + if (!read_color(db, "menu.frame.disableColor", &theme_menu_disabled_color)) + theme_menu_disabled_color = color_new(0, 0, 0); + if (!read_color(db, "menu.hilite.textColor", &theme_menu_hilite_color)) + theme_menu_hilite_color = color_new(0, 0, 0); if (read_mask(db, "window.button.max.mask", theme, &theme_max_unset_mask)){ if (!read_mask(db, "window.button.max.toggled.mask", theme, @@ -592,33 +724,28 @@ char *theme_load(char *theme) set_default_appearance(theme_a_unfocused_label); if (!read_appearance(db, "window.handle.focus", theme_a_focused_handle)) set_default_appearance(theme_a_focused_handle); - if (!read_appearance(db, "window.handle.unfocus", theme_a_unfocused_handle)) + if (!read_appearance(db, "window.handle.unfocus",theme_a_unfocused_handle)) set_default_appearance(theme_a_unfocused_handle); if (!read_appearance(db, "window.grip.focus", theme_a_focused_grip)) set_default_appearance(theme_a_focused_grip); if (!read_appearance(db, "window.grip.unfocus", theme_a_unfocused_grip)) set_default_appearance(theme_a_unfocused_grip); - - /* read the appearances for rendering non-decorations. these cannot be - parent-relative */ - if (theme_a_focused_label->surface.data.planar.grad != - Background_ParentRelative) { - if (!read_appearance(db, "window.label.focus", theme_app_hilite_label)) - set_default_appearance(theme_app_hilite_label); - } else { - if (!read_appearance(db, "window.title.focus", theme_app_hilite_label)) - set_default_appearance(theme_app_hilite_label); - } - if (theme_a_unfocused_label->surface.data.planar.grad != - Background_ParentRelative) { - if (!read_appearance(db, "window.label.unfocus", - theme_app_unhilite_label)) - set_default_appearance(theme_app_unhilite_label); - } else { - if (!read_appearance(db, "window.title.unfocus", - theme_app_unhilite_label)) - set_default_appearance(theme_app_unhilite_label); - } + if (!read_appearance(db, "menu.frame", theme_a_menu)) + set_default_appearance(theme_a_menu); + if (!read_appearance(db, "menu.title", theme_a_menu_title)) + set_default_appearance(theme_a_menu_title); + if (!read_appearance(db, "menu.hilite", theme_a_menu_hilite)) + set_default_appearance(theme_a_menu_hilite); + + /* read the appearances for rendering non-decorations */ + if (!read_appearance(db, "window.title.focus", theme_app_hilite_bg)) + set_default_appearance(theme_app_hilite_bg); + if (!read_appearance(db, "window.label.focus", theme_app_hilite_label)) + set_default_appearance(theme_app_hilite_label); + if (!read_appearance(db, "window.title.unfocus", theme_app_unhilite_bg)) + set_default_appearance(theme_app_unhilite_bg); + if (!read_appearance(db, "window.label.unfocus", theme_app_unhilite_label)) + set_default_appearance(theme_app_unhilite_label); /* read buttons textures */ if (!read_appearance(db, "window.button.pressed.focus", @@ -688,8 +815,8 @@ char *theme_load(char *theme) /* set up the textures */ theme_a_focused_label->texture[0].type = theme_app_hilite_label->texture[0].type = Text; - theme_a_focused_label->texture[0].data.text.justify = - theme_app_hilite_label->texture[0].data.text.justify = winjust; + theme_a_focused_label->texture[0].data.text.justify = winjust; + theme_app_hilite_label->texture[0].data.text.justify = Justify_Left; theme_a_focused_label->texture[0].data.text.font = theme_app_hilite_label->texture[0].data.text.font = theme_winfont; theme_a_focused_label->texture[0].data.text.shadow = @@ -707,8 +834,8 @@ char *theme_load(char *theme) theme_a_unfocused_label->texture[0].type = theme_app_unhilite_label->texture[0].type = Text; - theme_a_unfocused_label->texture[0].data.text.justify = - theme_app_unhilite_label->texture[0].data.text.justify = winjust; + theme_a_unfocused_label->texture[0].data.text.justify = winjust; + theme_app_unhilite_label->texture[0].data.text.justify = Justify_Left; theme_a_unfocused_label->texture[0].data.text.font = theme_app_unhilite_label->texture[0].data.text.font = theme_winfont; theme_a_unfocused_label->texture[0].data.text.shadow = @@ -724,6 +851,46 @@ char *theme_load(char *theme) theme_app_unhilite_label->texture[0].data.text.color = theme_title_unfocused_color; + theme_a_menu_title->texture[0].type = Text; + theme_a_menu_title->texture[0].data.text.justify = mtitlejust; + theme_a_menu_title->texture[0].data.text.font = theme_mtitlefont; + theme_a_menu_title->texture[0].data.text.shadow = theme_mtitlefont_shadow; + theme_a_menu_title->texture[0].data.text.offset = + theme_mtitlefont_shadow_offset; + theme_a_menu_title->texture[0].data.text.tint = + theme_mtitlefont_shadow_tint; + theme_a_menu_title->texture[0].data.text.color = theme_menu_title_color; + + theme_a_menu_item->surface.data.planar.grad = + theme_a_menu_disabled->surface.data.planar.grad = + theme_app_icon->surface.data.planar.grad = + Background_ParentRelative; + + theme_a_menu_item->texture[0].type = + theme_a_menu_disabled->texture[0].type = + theme_a_menu_hilite->texture[0].type = Text; + theme_a_menu_item->texture[0].data.text.justify = + theme_a_menu_disabled->texture[0].data.text.justify = + theme_a_menu_hilite->texture[0].data.text.justify = mjust; + theme_a_menu_item->texture[0].data.text.font = + theme_a_menu_disabled->texture[0].data.text.font = + theme_a_menu_hilite->texture[0].data.text.font = theme_mfont; + theme_a_menu_item->texture[0].data.text.shadow = + theme_a_menu_disabled->texture[0].data.text.shadow = + theme_a_menu_hilite->texture[0].data.text.shadow = theme_mfont_shadow; + theme_a_menu_item->texture[0].data.text.offset = + theme_a_menu_disabled->texture[0].data.text.offset = + theme_a_menu_hilite->texture[0].data.text.offset = + theme_mfont_shadow_offset; + theme_a_menu_item->texture[0].data.text.tint = + theme_a_menu_disabled->texture[0].data.text.tint = + theme_a_menu_hilite->texture[0].data.text.tint = + theme_mfont_shadow_tint; + theme_a_menu_item->texture[0].data.text.color = theme_menu_color; + theme_a_menu_disabled->texture[0].data.text.color = + theme_menu_disabled_color; + theme_a_menu_hilite->texture[0].data.text.color = theme_menu_hilite_color; + theme_a_focused_unpressed_max->texture[0].type = theme_a_focused_pressed_max->texture[0].type = theme_a_focused_pressed_set_max->texture[0].type =