X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Ftheme.c;h=ac80d19ba52d7d58c2700e6c974b0f09a1bd0867;hb=be15e8c01c49327ff328e44bced78b220e16f132;hp=25a610865d18c6b52dadb965420e10c6c9cd0238;hpb=a72371b41f48a2d6a1e55099456d30d3b678b66c;p=chaz%2Fopenbox diff --git a/render/theme.c b/render/theme.c index 25a61086..ac80d19b 100644 --- a/render/theme.c +++ b/render/theme.c @@ -3,6 +3,7 @@ #include "font.h" #include "mask.h" #include "theme.h" +#include "icon.h" #include #include @@ -21,6 +22,7 @@ static gboolean read_mask(const RrInstance *inst, static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, gchar *rname, RrAppearance *value, gboolean allow_trans); +static RrPixel32* read_c_image(gint width, gint height, const guint8 *data); static void set_default_appearance(RrAppearance *a); RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) @@ -71,6 +73,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) theme->app_hilite_bg = RrAppearanceNew(inst, 0); theme->app_unhilite_bg = RrAppearanceNew(inst, 0); + theme->app_hilite_fg = RrAppearanceNew(inst, 0); + theme->app_unhilite_fg = RrAppearanceNew(inst, 0); theme->app_hilite_label = RrAppearanceNew(inst, 1); theme->app_unhilite_label = RrAppearanceNew(inst, 1); @@ -157,7 +161,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) if (theme->handle_height <= 0 || theme->handle_height > 100) theme->handle_height = 6; if (!read_int(db, "padding.width", &theme->padding) || - theme->padding <= 0 || theme->padding > 100) + theme->padding < 0 || theme->padding > 100) theme->padding = 3; if (!read_int(db, "border.width", &theme->bwidth) || theme->bwidth < 0 || theme->bwidth > 100) @@ -323,6 +327,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask); } + theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH, + OB_DEFAULT_ICON_HEIGHT, + OB_DEFAULT_ICON_pixel_data); + if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) { if (!read_mask(inst, "desk_pressed.xbm", theme, &theme->desk_pressed_mask)) { @@ -472,6 +480,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) "window.active.label.bg", theme->app_hilite_label, TRUE)) set_default_appearance(theme->app_hilite_label); + if (!read_appearance(db, inst, + "window.active.label.bg", theme->app_hilite_fg, + TRUE)) + set_default_appearance(theme->app_hilite_fg); + else if (theme->app_hilite_label->surface.grad == RR_SURFACE_PARENTREL) { + if (!read_appearance(db, inst, + "window.active.title.bg", + theme->app_hilite_fg, + FALSE)) + set_default_appearance(theme->app_hilite_fg); + } if (!read_appearance(db, inst, "window.inactive.title.bg", theme->app_unhilite_bg, FALSE)) @@ -480,6 +499,18 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) "window.inactive.label.bg", theme->app_unhilite_label, TRUE)) set_default_appearance(theme->app_unhilite_label); + if (!read_appearance(db, inst, + "window.inactive.label.bg", theme->app_unhilite_fg, + TRUE)) + set_default_appearance(theme->app_unhilite_fg); + else if (theme->app_unhilite_label->surface.grad == RR_SURFACE_PARENTREL) { + if (!read_appearance(db, inst, + "window.inactive.title.bg", + theme->app_unhilite_fg, + FALSE)) + set_default_appearance(theme->app_unhilite_fg); + } + /* read buttons textures */ if (!read_appearance(db, inst, @@ -870,8 +901,20 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub); theme->label_height = theme->winfont_height + MAX(ft + fb, ut + ub); + + /* 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 + right now, so if anyone complains, here is how to keep text from + going over the title's bevel/border with a padding.width of 0 and a + bevelless/borderless label + RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb); + RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub); + theme->title_height = theme->label_height + + MAX(MAX(theme->padding * 2, ft + fb), + MAX(theme->padding * 2, ut + ub)); + */ + theme->title_height = theme->label_height + theme->padding * 2; } - theme->title_height = theme->label_height + theme->padding * 2; theme->button_size = theme->label_height - 2; theme->grip_width = theme->title_height * 1.5; @@ -903,6 +946,8 @@ void RrThemeFree(RrTheme *theme) RrColorFree(theme->menu_disabled_color); RrColorFree(theme->menu_selected_color); + g_free(theme->def_win_icon); + RrPixmapMaskFree(theme->max_mask); RrPixmapMaskFree(theme->max_toggled_mask); RrPixmapMaskFree(theme->max_disabled_mask); @@ -1002,6 +1047,8 @@ void RrThemeFree(RrTheme *theme) RrAppearanceFree(theme->a_clear_tex); RrAppearanceFree(theme->app_hilite_bg); RrAppearanceFree(theme->app_unhilite_bg); + RrAppearanceFree(theme->app_hilite_fg); + RrAppearanceFree(theme->app_unhilite_fg); RrAppearanceFree(theme->app_hilite_label); RrAppearanceFree(theme->app_unhilite_label); } @@ -1236,3 +1283,28 @@ static void set_default_appearance(RrAppearance *a) a->surface.primary = RrColorNew(a->inst, 0, 0, 0); a->surface.secondary = RrColorNew(a->inst, 0, 0, 0); } + +/* Reads the output from gimp's C-Source file format into valid RGBA data for + an RrTextureRGBA. */ +static RrPixel32* read_c_image(gint width, gint height, const guint8 *data) +{ + RrPixel32 *im, *p; + gint i; + + p = im = g_memdup(data, width * height * sizeof(RrPixel32)); + + for (i = 0; i < width * height; ++i) { + guchar a = ((*p >> 24) & 0xff); + guchar b = ((*p >> 16) & 0xff); + guchar g = ((*p >> 8) & 0xff); + guchar r = ((*p >> 0) & 0xff); + + *p = ((r << RrDefaultRedOffset) + + (g << RrDefaultGreenOffset) + + (b << RrDefaultBlueOffset) + + (a << RrDefaultAlphaOffset)); + p++; + } + + return im; +}