]> Dogcows Code - chaz/openbox/commitdiff
Add theme options for menu line separators.
authorDana Jansens <danakj@orodu.net>
Fri, 22 Feb 2008 17:12:20 +0000 (12:12 -0500)
committerDana Jansens <danakj@orodu.net>
Fri, 22 Feb 2008 17:13:02 +0000 (12:13 -0500)
Added:
 menu.separator.color
 menu.separator.width
 menu.separator.padding.width
 menu.separator.padding.height

openbox/menuframe.c
render/theme.c
render/theme.h

index 54f0cdbc525df36cfc52b27911316a2184af4b56..ac1d88d5f8dab9ff521863151158fb969800452d 100644 (file)
@@ -30,7 +30,6 @@
 #include "render/theme.h"
 
 #define PADDING 2
-#define SEPARATOR_HEIGHT 3
 #define MAX_MENU_WIDTH 400
 
 #define ITEM_HEIGHT (ob_rr_theme->menu_font_height + 2*PADDING)
@@ -41,6 +40,9 @@
                          ButtonPressMask | ButtonReleaseMask)
 
 GList *menu_frame_visible;
+GHashTable *menu_frame_map;
+
+static RrAppearance *a_sep;
 
 static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
                                               ObMenuFrame *frame);
@@ -57,10 +59,18 @@ static Window createWindow(Window parent, gulong mask,
                          RrVisual(ob_rr_inst), mask, attrib);
 }
 
-GHashTable *menu_frame_map;
-
 void menu_frame_startup(gboolean reconfig)
 {
+    gint i;
+
+    a_sep = RrAppearanceCopy(ob_rr_theme->a_clear);
+    RrAppearanceAddTextures(a_sep, ob_rr_theme->menu_sep_width);
+    for (i = 0; i < ob_rr_theme->menu_sep_width; ++i) {
+        a_sep->texture[i].type = RR_TEXTURE_LINE_ART;
+        a_sep->texture[i].data.lineart.color =
+            ob_rr_theme->menu_sep_color;
+    }
+
     if (reconfig) return;
 
     menu_frame_map = g_hash_table_new(g_int_hash, g_int_equal);
@@ -68,6 +78,8 @@ void menu_frame_startup(gboolean reconfig)
 
 void menu_frame_shutdown(gboolean reconfig)
 {
+    RrAppearanceFree(a_sep);
+
     if (reconfig) return;
 
     g_hash_table_destroy(menu_frame_map);
@@ -333,7 +345,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
             th = ob_rr_theme->menu_title_height;
         } else {
             item_a = ob_rr_theme->a_menu_normal;
-            th = SEPARATOR_HEIGHT + 2*PADDING;
+            th = ob_rr_theme->menu_sep_width +
+                2*ob_rr_theme->menu_sep_paddingy;
         }
         break;
     default:
@@ -437,26 +450,31 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
                     ob_rr_theme->menu_title_height -
                     2*ob_rr_theme->paddingy);
         } else {
-            RrAppearance *clear;
-
-            /* unlabeled separaator */
-            XMoveResizeWindow(ob_display, self->text, PADDING, PADDING,
-                              self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
-
-            clear = ob_rr_theme->a_clear_tex;
-            RrAppearanceClearTextures(clear);
-            clear->texture[0].type = RR_TEXTURE_LINE_ART;
-            clear->surface.parent = item_a;
-            clear->surface.parentx = PADDING;
-            clear->surface.parenty = PADDING;
-            clear->texture[0].data.lineart.color =
-                text_a->texture[0].data.text.color;
-            clear->texture[0].data.lineart.x1 = 2*PADDING;
-            clear->texture[0].data.lineart.y1 = SEPARATOR_HEIGHT/2;
-            clear->texture[0].data.lineart.x2 = self->area.width - 4*PADDING;
-            clear->texture[0].data.lineart.y2 = SEPARATOR_HEIGHT/2;
-            RrPaint(clear, self->text,
-                    self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
+            gint i;
+
+            /* unlabeled separator */
+            XMoveResizeWindow(ob_display, self->text, 0, 0,
+                              self->area.width,
+                              ob_rr_theme->menu_sep_width +
+                              2*ob_rr_theme->menu_sep_paddingy);
+
+            a_sep->surface.parent = item_a;
+            a_sep->surface.parentx = 0;
+            a_sep->surface.parenty = 0;
+            for (i = 0; i < ob_rr_theme->menu_sep_width; ++i) {
+                a_sep->texture[i].data.lineart.x1 =
+                    ob_rr_theme->menu_sep_paddingx;
+                a_sep->texture[i].data.lineart.y1 =
+                    ob_rr_theme->menu_sep_paddingy + i;
+                a_sep->texture[i].data.lineart.x2 =
+                    self->area.width - ob_rr_theme->menu_sep_paddingx - 1;
+                a_sep->texture[i].data.lineart.y2 =
+                    ob_rr_theme->menu_sep_paddingy + i;
+            }
+
+            RrPaint(a_sep, self->text, self->area.width,
+                    ob_rr_theme->menu_sep_width +
+                    2*ob_rr_theme->menu_sep_paddingy);
         }
         break;
     }
@@ -592,7 +610,8 @@ static gint menu_entry_frame_get_height(ObMenuEntryFrame *self,
             if (last_entry)
                 h -= ob_rr_theme->mbwidth;
         } else {
-            h += SEPARATOR_HEIGHT;
+            h += ob_rr_theme->menu_sep_width +
+                2*ob_rr_theme->menu_sep_paddingy - PADDING * 2;
         }
         break;
     }
@@ -723,7 +742,8 @@ void menu_frame_render(ObMenuFrame *self)
                     (ob_rr_theme->mbwidth - PADDING) *2;
             } else {
                 tw = 0;
-                th = SEPARATOR_HEIGHT;
+                th = ob_rr_theme->menu_sep_width +
+                    2*ob_rr_theme->menu_sep_paddingy - 2*PADDING;
             }
             break;
         }
index 8428f1d9180e7ff26c5e25558ca9d6f926d94ddd..8c7393b5e9ed561cab0f82f8b35712639167a6fc 100644 (file)
@@ -211,6 +211,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
         theme->cbwidthy < 0 || theme->cbwidthy > 100)
         theme->cbwidthy = theme->cbwidthx;
+    if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
+        theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
+        theme->menu_sep_width = 1;
+    if (!read_int(db, "menu.separator.padding.width",
+                  &theme->menu_sep_paddingx) ||
+        theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
+        theme->menu_sep_paddingx = 6;
+    if (!read_int(db, "menu.separator.padding.height",
+                  &theme->menu_sep_paddingy) ||
+        theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
+        theme->menu_sep_paddingy = 3;
 
     /* load colors */
     if (!read_color(db, inst,
@@ -408,6 +419,12 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                     "menu.items.active.text.color",
                     &theme->menu_selected_color))
         theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
+    if (!read_color(db, inst,
+                    "menu.separator.color", &theme->menu_sep_color))
+        theme->menu_sep_color = RrColorNew(inst,
+                                           theme->menu_color->r,
+                                           theme->menu_color->g,
+                                           theme->menu_color->b);
 
     /* load the image masks */
 
@@ -1408,6 +1425,7 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->titlebut_focused_unpressed_color);
         RrColorFree(theme->titlebut_unfocused_unpressed_color);
         RrColorFree(theme->menu_title_color);
+        RrColorFree(theme->menu_sep_color);
         RrColorFree(theme->menu_color);
         RrColorFree(theme->menu_selected_color);
         RrColorFree(theme->menu_disabled_color);
index 1940970a121fbfa6dc09b2d0a8e4d6cbc3db50f0..a14dac29625881e29076f15fe7982ab4a0e525c5 100644 (file)
@@ -47,6 +47,9 @@ struct _RrTheme {
     gint cbwidthy;
     gint menu_overlap_x;
     gint menu_overlap_y;
+    gint menu_sep_width;
+    gint menu_sep_paddingx;
+    gint menu_sep_paddingy;
     /* these ones are calculated, not set directly by the theme file */
     gint win_font_height;
     gint menu_title_font_height;
@@ -84,6 +87,7 @@ struct _RrTheme {
     RrColor *titlebut_focused_unpressed_color;
     RrColor *titlebut_unfocused_unpressed_color;
     RrColor *menu_title_color;
+    RrColor *menu_sep_color;
     RrColor *menu_color;
     RrColor *menu_selected_color;
     RrColor *menu_disabled_color;
This page took 0.049952 seconds and 4 git commands to generate.