summaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-04-06 06:16:19 +0000
committerDana Jansens <danakj@orodu.net>2003-04-06 06:16:19 +0000
commit6016ff8658c53fca30b1ee530bea9c469f2cce84 (patch)
tree05d6c7189681dd0e908d93d47ffd34493e56927a /engines
parentaf21cb131a784b3d76e9930421a3595f5819dc71 (diff)
add the ability to render and size text labels for non-window-decorations
Diffstat (limited to 'engines')
-rw-r--r--engines/openbox/obengine.c7
-rw-r--r--engines/openbox/obengine.h3
-rw-r--r--engines/openbox/obrender.c30
-rw-r--r--engines/openbox/obtheme.c36
4 files changed, 76 insertions, 0 deletions
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 =