From: Dana Jansens Date: Sun, 6 Apr 2003 06:16:19 +0000 (+0000) Subject: add the ability to render and size text labels for non-window-decorations X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=6016ff8658c53fca30b1ee530bea9c469f2cce84;p=chaz%2Fopenbox add the ability to render and size text labels for non-window-decorations --- diff --git a/engines/openbox/obengine.c b/engines/openbox/obengine.c index bad7b51e..843a6988 100644 --- a/engines/openbox/obengine.c +++ b/engines/openbox/obengine.c @@ -82,6 +82,9 @@ Appearance *ob_a_icon; /* always parentrelative, so no focused/unfocused */ Appearance *ob_a_focused_handle; Appearance *ob_a_unfocused_handle; +Appearance *ob_app_hilite_label; +Appearance *ob_app_unhilite_label; + static void layout_title(ObFrame *self); static void mouse_event(const ObEvent *e, ObFrame *self); @@ -140,6 +143,8 @@ gboolean startup() ob_a_icon = appearance_new(Surface_Planar, 1); ob_a_focused_handle = appearance_new(Surface_Planar, 0); ob_a_unfocused_handle = appearance_new(Surface_Planar, 0); + ob_app_hilite_label = appearance_new(Surface_Planar, 1); + ob_app_unhilite_label = appearance_new(Surface_Planar, 1); if (obtheme_load()) { RECT_SET(ob_a_focused_pressed_desk->area, 0, 0, @@ -284,6 +289,8 @@ void shutdown() appearance_free(ob_a_icon); appearance_free(ob_a_focused_handle); appearance_free(ob_a_unfocused_handle); + appearance_free(ob_app_hilite_label); + appearance_free(ob_app_unhilite_label); } static Window createWindow(Window parent, unsigned long mask, diff --git a/engines/openbox/obengine.h b/engines/openbox/obengine.h index 2a879b70..b4cd7d48 100644 --- a/engines/openbox/obengine.h +++ b/engines/openbox/obengine.h @@ -75,6 +75,9 @@ extern Appearance *ob_a_icon; extern Appearance *ob_a_focused_handle; extern Appearance *ob_a_unfocused_handle; +extern Appearance *ob_app_hilite_label; +extern Appearance *ob_app_unhilite_label; + typedef struct ObFrame { Frame frame; diff --git a/engines/openbox/obrender.c b/engines/openbox/obrender.c index a609376f..c765ef76 100644 --- a/engines/openbox/obrender.c +++ b/engines/openbox/obrender.c @@ -202,3 +202,33 @@ static void obrender_close(ObFrame *self, Appearance *a) RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); paint(self->close, a); } + +void render_label(Window win, Rect *area, char *text, + gboolean hilight, gboolean toplevel) +{ + Appearance *a; + + a = hilight ? ob_app_hilite_label : ob_app_unhilite_label; + a->texture[0].data.text.string = text; + RECT_SET(a->area, 0, 0, area->width, area->height); + a->texture[0].position = a->area; + + if (toplevel) { + XSetWindowBorderWidth(ob_display, win, ob_s_bwidth); + XSetWindowBorder(ob_display, win, ob_s_b_color->pixel); + } + + paint(win, a); +} + +void size_label(char *text, gboolean hilight, gboolean toplevel, Size *s) +{ + Appearance *a; + + a = hilight ? ob_app_hilite_label : ob_app_unhilite_label; + a->texture[0].data.text.string = text; + + appearance_minsize(a, s); + s->width += ob_s_bevel * 2; + s->height += ob_s_bevel * 2; +} diff --git a/engines/openbox/obtheme.c b/engines/openbox/obtheme.c index 59c1b45a..a68d8248 100644 --- a/engines/openbox/obtheme.c +++ b/engines/openbox/obtheme.c @@ -401,6 +401,7 @@ gboolean obtheme_load() ob_s_close_mask = pixmap_mask_new(7, 7, data); } + /* read the decoration textures */ if (!read_appearance(db, "window.title.focus", ob_a_focused_title)) set_default_appearance(ob_a_focused_title); if (!read_appearance(db, "window.title.unfocus", ob_a_unfocused_title)) @@ -418,6 +419,26 @@ gboolean obtheme_load() if (!read_appearance(db, "window.grip.unfocus", ob_a_unfocused_grip)) set_default_appearance(ob_a_unfocused_grip); + /* read the appearances for rendering non-decorations. these cannot be + parent-relative */ + if (ob_a_focused_label->surface.data.planar.grad != + Background_ParentRelative) { + if (!read_appearance(db, "window.label.focus", ob_app_hilite_label)) + set_default_appearance(ob_app_hilite_label); + } else { + if (!read_appearance(db, "window.title.focus", ob_app_hilite_label)) + set_default_appearance(ob_app_hilite_label); + } + if (ob_a_unfocused_label->surface.data.planar.grad != + Background_ParentRelative) { + if (!read_appearance(db, "window.label.unfocus",ob_app_unhilite_label)) + set_default_appearance(ob_app_unhilite_label); + } else { + if (!read_appearance(db, "window.title.unfocus",ob_app_unhilite_label)) + set_default_appearance(ob_app_unhilite_label); + } + + /* read buttons textures */ if (!read_appearance(db, "window.button.pressed.focus", ob_a_focused_pressed_max)) if (!read_appearance(db, "window.button.pressed", @@ -477,6 +498,13 @@ gboolean obtheme_load() ob_a_focused_label->texture[0].data.text.offset = engine_shadow_offset; ob_a_focused_label->texture[0].data.text.tint = engine_shadow_tint; ob_a_focused_label->texture[0].data.text.color = ob_s_title_focused_color; + ob_app_hilite_label->texture[0].type = Text; + ob_app_hilite_label->texture[0].data.text.justify = winjust; + ob_app_hilite_label->texture[0].data.text.font = ob_s_winfont; + ob_app_hilite_label->texture[0].data.text.shadow = engine_shadow; + ob_app_hilite_label->texture[0].data.text.offset = engine_shadow_offset; + ob_app_hilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_hilite_label->texture[0].data.text.color = ob_s_title_focused_color; ob_a_unfocused_label->texture[0].type = Text; ob_a_unfocused_label->texture[0].data.text.justify = winjust; @@ -486,6 +514,14 @@ gboolean obtheme_load() ob_a_unfocused_label->texture[0].data.text.tint = engine_shadow_tint; ob_a_unfocused_label->texture[0].data.text.color = ob_s_title_unfocused_color; + ob_app_unhilite_label->texture[0].type = Text; + ob_app_unhilite_label->texture[0].data.text.justify = winjust; + ob_app_unhilite_label->texture[0].data.text.font = ob_s_winfont; + ob_app_unhilite_label->texture[0].data.text.shadow = engine_shadow; + ob_app_unhilite_label->texture[0].data.text.offset = engine_shadow_offset; + ob_app_unhilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_unhilite_label->texture[0].data.text.color = + ob_s_title_unfocused_color; ob_a_focused_unpressed_max->texture[0].type = ob_a_focused_pressed_max->texture[0].type = diff --git a/openbox/engine.c b/openbox/engine.c index 5012fecf..34d72918 100644 --- a/openbox/engine.c +++ b/openbox/engine.c @@ -15,6 +15,21 @@ gboolean engine_shadow; int engine_shadow_offset; int engine_shadow_tint; +EngineFrameNew *engine_frame_new; +EngineFrameGrabClient *engine_frame_grab_client; +EngineFrameReleaseClient *engine_frame_release_client; +EngineFrameAdjustArea *engine_frame_adjust_area; +EngineFrameAdjustShape *engine_frame_adjust_shape; +EngineFrameAdjustState *engine_frame_adjust_state; +EngineFrameAdjustFocus *engine_frame_adjust_focus; +EngineFrameAdjustTitle *engine_frame_adjust_title; +EngineFrameAdjustIcon *engine_frame_adjust_icon; +EngineFrameShow *engine_frame_show; +EngineFrameHide *engine_frame_hide; +EngineGetContext *engine_get_context; +EngineRenderLabel *engine_render_label; +EngineSizeLabel *engine_size_label; + static GModule *module = NULL; static EngineStartup *estartup = NULL; static EngineShutdown *eshutdown = NULL; @@ -60,6 +75,8 @@ static gboolean load(char *name) LOADSYM(frame_show, engine_frame_show); LOADSYM(frame_hide, engine_frame_hide); LOADSYM(get_context, engine_get_context); + LOADSYM(render_label, engine_render_label); + LOADSYM(size_label, engine_size_label); if (!estartup()) return FALSE; diff --git a/openbox/engine.h b/openbox/engine.h index 76bb1495..0180e3e5 100644 --- a/openbox/engine.h +++ b/openbox/engine.h @@ -22,21 +22,24 @@ void engine_startup(); void engine_load(); void engine_shutdown(); -EngineFrameNew *engine_frame_new; +extern EngineFrameNew *engine_frame_new; -EngineFrameGrabClient *engine_frame_grab_client; -EngineFrameReleaseClient *engine_frame_release_client; +extern EngineFrameGrabClient *engine_frame_grab_client; +extern EngineFrameReleaseClient *engine_frame_release_client; -EngineFrameAdjustArea *engine_frame_adjust_area; -EngineFrameAdjustShape *engine_frame_adjust_shape; -EngineFrameAdjustState *engine_frame_adjust_state; -EngineFrameAdjustFocus *engine_frame_adjust_focus; -EngineFrameAdjustTitle *engine_frame_adjust_title; -EngineFrameAdjustIcon *engine_frame_adjust_icon; +extern EngineFrameAdjustArea *engine_frame_adjust_area; +extern EngineFrameAdjustShape *engine_frame_adjust_shape; +extern EngineFrameAdjustState *engine_frame_adjust_state; +extern EngineFrameAdjustFocus *engine_frame_adjust_focus; +extern EngineFrameAdjustTitle *engine_frame_adjust_title; +extern EngineFrameAdjustIcon *engine_frame_adjust_icon; -EngineFrameShow *engine_frame_show; -EngineFrameHide *engine_frame_hide; +extern EngineFrameShow *engine_frame_show; +extern EngineFrameHide *engine_frame_hide; -EngineGetContext *engine_get_context; +extern EngineGetContext *engine_get_context; + +extern EngineRenderLabel *engine_render_label; +extern EngineSizeLabel *engine_size_label; #endif