]> Dogcows Code - chaz/openbox/commitdiff
add the ability to render and size text labels for non-window-decorations
authorDana Jansens <danakj@orodu.net>
Sun, 6 Apr 2003 06:16:19 +0000 (06:16 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 6 Apr 2003 06:16:19 +0000 (06:16 +0000)
engines/openbox/obengine.c
engines/openbox/obengine.h
engines/openbox/obrender.c
engines/openbox/obtheme.c
openbox/engine.c
openbox/engine.h

index bad7b51e1beacaac39ccb8c6c5f8167dafd453ad..843a69887185aca30eba88a7dc877374c52e7384 100644 (file)
@@ -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,
index 2a879b70d9846df30dc71e3601a0e9016352cb50..b4cd7d48f6a38d660ea55181f7d81d28411f81de 100644 (file)
@@ -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;
 
index a609376f68ce9a0cbdb6b2d78dc47a1505f173f5..c765ef761e2fdde8d73b345d94e936629d39ad53 100644 (file)
@@ -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;
+}
index 59c1b45ac2e4294072d041d07a54b6e207e190cb..a68d8248523fbcf16152120560f7859fffeca2ca 100644 (file)
@@ -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 = 
index 5012fecf872bb49bece7b00c186834361122ec3e..34d7291801aa105be3a3d00ea80e606ad5452be6 100644 (file)
@@ -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;
index 76bb149578a60049f6bef499e84bec8cf241f388..0180e3e56182f54fe720a0acd3ba6a713a2a1588 100644 (file)
@@ -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
This page took 0.035657 seconds and 4 git commands to generate.