]> Dogcows Code - chaz/openbox/commitdiff
better matching of the menu titles/separators to the theme
authorDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 03:54:43 +0000 (03:54 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 03:54:43 +0000 (03:54 +0000)
openbox/menuframe.c
openbox/menuframe.h
render/theme.c
render/theme.h

index d065881d303e70a74a8d3984de03fa5c9335215f..6a8b2c4e83e3e92fb29750f9decf97861f3da53b 100644 (file)
@@ -163,6 +163,8 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
         RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled);
     self->a_text_selected =
         RrAppearanceCopy(ob_rr_theme->a_menu_text_selected);
+    self->a_text_title =
+        RrAppearanceCopy(ob_rr_theme->a_menu_text_title);
 
     return self;
 }
@@ -193,6 +195,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
         RrAppearanceFree(self->a_text_normal);
         RrAppearanceFree(self->a_text_disabled);
         RrAppearanceFree(self->a_text_selected);
+        RrAppearanceFree(self->a_text_title);
         RrAppearanceFree(self->a_bullet_normal);
         RrAppearanceFree(self->a_bullet_selected);
 
@@ -290,9 +293,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
     case OB_MENU_ENTRY_TYPE_SEPARATOR:
         if (self->entry->data.separator.label) {
             item_a = self->frame->a_title;
-            item_a->texture[0].data.text.string =
-                self->entry->data.separator.label;
-            th = self->frame->title_h;
+            th = ob_rr_theme->menu_title_height;
         } else {
             item_a = self->a_normal;
             th = SEPARATOR_HEIGHT + 2*PADDING;
@@ -326,7 +327,10 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         text_a->texture[0].data.text.string = sub ? sub->title : "";
         break;
     case OB_MENU_ENTRY_TYPE_SEPARATOR:
-        text_a = self->a_text_normal;
+        if (self->entry->data.separator.label != NULL)
+            text_a = self->a_text_title;
+        else
+            text_a = self->a_text_normal;
         break;
     }
 
@@ -354,7 +358,22 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
                 self->frame->item_h - 2*PADDING);
         break;
     case OB_MENU_ENTRY_TYPE_SEPARATOR:
-        if (self->entry->data.separator.label == NULL) {
+        if (self->entry->data.separator.label != NULL) {
+            /* labeled separator */
+            XMoveResizeWindow(ob_display, self->text,
+                              ob_rr_theme->paddingx, ob_rr_theme->paddingy,
+                              self->area.width - 2*ob_rr_theme->paddingx,
+                              ob_rr_theme->menu_title_height -
+                              2*ob_rr_theme->paddingy);
+            text_a->surface.parent = item_a;
+            text_a->surface.parentx = ob_rr_theme->paddingx;
+            text_a->surface.parenty = ob_rr_theme->paddingy;
+            RrPaint(text_a, self->text,
+                    self->area.width - 2*ob_rr_theme->paddingx,
+                    ob_rr_theme->menu_title_height -
+                    2*ob_rr_theme->paddingy);
+        } else {
+            /* unlabeled separaator */
             XMoveResizeWindow(ob_display, self->text, PADDING, PADDING,
                               self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
             self->a_separator->surface.parent = item_a;
@@ -483,12 +502,6 @@ static void menu_frame_render(ObMenuFrame *self)
         th += 2*PADDING;
         self->item_h = th;
 
-        self->a_title->texture[0].data.text.string = "";
-        RrMinsize(self->a_title, &tw, &th);
-        tw += 2*PADDING;
-        th += 2*PADDING;
-        self->title_h = th;
-
         RrMargins(e->a_normal, &l, &t, &r, &b);
         STRUT_SET(self->item_margin,
                   MAX(self->item_margin.left, l),
@@ -567,11 +580,12 @@ static void menu_frame_render(ObMenuFrame *self)
             break;
         case OB_MENU_ENTRY_TYPE_SEPARATOR:
             if (e->entry->data.separator.label != NULL) {
-                self->a_title->texture[0].data.text.string =
+                e->a_text_title->texture[0].data.text.string =
                     e->entry->data.separator.label;
-                RrMinsize(self->a_title, &tw, &th);
+                RrMinsize(e->a_text_title, &tw, &th);
                 tw = MIN(tw, MAX_MENU_WIDTH);
-                th += ob_rr_theme->mbwidth * 2;
+                th = ob_rr_theme->menu_title_height +
+                    (ob_rr_theme->mbwidth - PADDING) *2;
             } else {
                 tw = 0;
                 th = SEPARATOR_HEIGHT;
index 26f44b1bee25973c78ef28a53dab6baeec7546d0..016700a74ae7e6fad32967f1916cf05aa2eab939 100644 (file)
@@ -99,6 +99,7 @@ struct _ObMenuEntryFrame
     RrAppearance *a_text_normal;
     RrAppearance *a_text_disabled;
     RrAppearance *a_text_selected;
+    RrAppearance *a_text_title;
 };
 
 extern GHashTable *menu_frame_map;
index cf4839776cc19af9a663a64212514713413b6aad..ade6f6c566f158f81272953ef309faf863c277eb 100644 (file)
@@ -115,7 +115,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
     theme->a_focused_handle = RrAppearanceNew(inst, 0);
     theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
     theme->a_menu = RrAppearanceNew(inst, 0);
-    theme->a_menu_title = RrAppearanceNew(inst, 1);
+    theme->a_menu_title = RrAppearanceNew(inst, 0);
+    theme->a_menu_text_title = RrAppearanceNew(inst, 1);
     theme->a_menu_normal = RrAppearanceNew(inst, 0);
     theme->a_menu_disabled = RrAppearanceNew(inst, 0);
     theme->a_menu_selected = RrAppearanceNew(inst, 0);
@@ -567,7 +568,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
         set_default_appearance(theme->a_unfocused_grip);
     if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE))
         set_default_appearance(theme->a_menu);
-    if (!FIND(appearance, L("menu","title"), theme->a_menu_title, FALSE))
+    if (!FIND(appearance, L("menu","title"), theme->a_menu_title, TRUE))
         set_default_appearance(theme->a_menu_title);
     if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE))
         set_default_appearance(theme->a_menu_selected);
@@ -752,6 +753,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
     theme->a_icon->surface.grad =
         theme->a_clear->surface.grad =
         theme->a_clear_tex->surface.grad =
+        theme->a_menu_text_title->surface.grad =
         theme->a_menu_normal->surface.grad =
         theme->a_menu_disabled->surface.grad =
         theme->a_menu_text_normal->surface.grad =
@@ -811,18 +813,20 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
     theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
         theme->title_unfocused_shadow_alpha;
 
-    theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
-    theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
-    theme->a_menu_title->texture[0].data.text.font = theme->menu_title_font;
-    theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color;
+    theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
+    theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
+    theme->a_menu_text_title->texture[0].data.text.font =
+        theme->menu_title_font;
+    theme->a_menu_text_title->texture[0].data.text.color =
+        theme->menu_title_color;
 
     if (!FIND(shadow, L("menu","title","text","shadow","offset"),
-              theme->a_menu_title))
-        theme->a_menu_title->texture[0].data.text.shadow_offset_x =
-            theme->a_menu_title->texture[0].data.text.shadow_offset_y = 0;
-    theme->a_menu_title->texture[0].data.text.shadow_color =
+              theme->a_menu_text_title))
+        theme->a_menu_text_title->texture[0].data.text.shadow_offset_x =
+            theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = 0;
+    theme->a_menu_text_title->texture[0].data.text.shadow_color =
         theme->menu_title_shadow_color;
-    theme->a_menu_title->texture[0].data.text.shadow_alpha =
+    theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
         theme->menu_title_shadow_alpha;
 
     theme->a_menu_text_normal->texture[0].type =
@@ -1117,7 +1121,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
             MAX(theme->win_font_height,
                 RrFontHeight(theme->win_font_unfocused,
                              a->texture[0].data.text.shadow_offset_y));
-        a = theme->a_menu_title;
+        a = theme->a_menu_text_title;
         theme->menu_title_font_height =
             RrFontHeight(theme->menu_title_font,
                          a->texture[0].data.text.shadow_offset_y);
@@ -1294,6 +1298,7 @@ void RrThemeFree(RrTheme *theme)
         RrAppearanceFree(theme->a_unfocused_handle);
         RrAppearanceFree(theme->a_menu);
         RrAppearanceFree(theme->a_menu_title);
+        RrAppearanceFree(theme->a_menu_text_title);
         RrAppearanceFree(theme->a_menu_normal);
         RrAppearanceFree(theme->a_menu_disabled);
         RrAppearanceFree(theme->a_menu_selected);
index c3b375c66a7c3744ea6127dc33ecf54cda4db058..62ff87dd5643aa9d145e8c980c796850f9101b2c 100644 (file)
@@ -201,6 +201,7 @@ struct _RrTheme {
     RrAppearance *a_icon;
     RrAppearance *a_focused_handle;
     RrAppearance *a_unfocused_handle;
+    RrAppearance *a_menu_text_title;
     RrAppearance *a_menu_title;
     RrAppearance *a_menu;
     RrAppearance *a_menu_normal;
This page took 0.034528 seconds and 4 git commands to generate.