]> Dogcows Code - chaz/openbox/commitdiff
add suppot for showing pixmap masks in menus where the rgba icons go too
authorDana Jansens <danakj@orodu.net>
Sat, 30 Aug 2003 19:03:06 +0000 (19:03 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 30 Aug 2003 19:03:06 +0000 (19:03 +0000)
openbox/menu.h
openbox/menuframe.c
openbox/menuframe.h

index b0f39b7b53b9b4258bc615e355e10cb6d15bd12e..a3620e75a7101f3f8c9312c117ef1b4a8626b855 100644 (file)
@@ -64,6 +64,10 @@ struct _ObNormalMenuEntry {
     gint icon_width;
     gint icon_height;
     RrPixel32 *icon_data;
+
+    /* Mask icon */
+    RrPixmapMask *mask;
+    RrColor *mask_color;
 };
 
 struct _ObSubmenuMenuEntry {
index df45b873e93e2e7fad57dbcab0d9099585d89b6b..2b64aaa8b0ceba028a29434d8886c73fcb6864f6 100644 (file)
@@ -107,8 +107,9 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
 
     self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
     self->a_icon->texture[0].type = RR_TEXTURE_RGBA;
+    self->a_mask = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
+    self->a_mask->texture[0].type = RR_TEXTURE_MASK;
     self->a_bullet = RrAppearanceCopy(ob_rr_theme->a_menu_bullet);
-    self->a_bullet->texture[0].type = RR_TEXTURE_MASK;
 
     self->a_text_normal =
         RrAppearanceCopy(ob_rr_theme->a_menu_text_item);
@@ -133,6 +134,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
         RrAppearanceFree(self->a_selected);
 
         RrAppearanceFree(self->a_icon);
+        RrAppearanceFree(self->a_mask);
         RrAppearanceFree(self->a_text_normal);
         RrAppearanceFree(self->a_text_disabled);
         RrAppearanceFree(self->a_text_selected);
@@ -254,7 +256,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         break;
     }
 
-    if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
+    if (self->entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR &&
         self->entry->data.normal.icon_data)
     {
         XMoveResizeWindow(ob_display, self->icon, PADDING, 0,
@@ -272,6 +274,22 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         RrPaint(self->a_icon, self->icon,
                 self->frame->item_h, self->frame->item_h);
         XMapWindow(ob_display, self->icon);
+    } else if (self->entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR &&
+               self->entry->data.normal.mask)
+    {
+        XMoveResizeWindow(ob_display, self->icon, PADDING, 0,
+                          self->frame->item_h,
+                          self->frame->item_h);
+        self->a_mask->texture[0].data.mask.mask =
+            self->entry->data.normal.mask;
+        self->a_mask->texture[0].data.mask.color =
+            self->entry->data.normal.mask_color;
+        self->a_mask->surface.parent = item_a;
+        self->a_mask->surface.parentx = PADDING;
+        self->a_mask->surface.parenty = 0;
+        RrPaint(self->a_mask, self->icon,
+                self->frame->item_h, self->frame->item_h);
+        XMapWindow(ob_display, self->icon);
     } else
         XUnmapWindow(ob_display, self->icon);
 
@@ -353,7 +371,8 @@ static void menu_frame_render(ObMenuFrame *self)
             text_a->texture[0].data.text.string = e->entry->data.normal.label;
             RrMinsize(text_a, &tw, &th);
 
-            if (e->entry->data.normal.icon_data)
+            if (e->entry->data.normal.icon_data ||
+                e->entry->data.normal.mask)
                 has_icon = TRUE;
             break;
         case OB_MENU_ENTRY_TYPE_SUBMENU:
@@ -361,6 +380,10 @@ static void menu_frame_render(ObMenuFrame *self)
             text_a->texture[0].data.text.string = sub ? sub->title : "";
             RrMinsize(text_a, &tw, &th);
 
+            if (e->entry->data.normal.icon_data ||
+                e->entry->data.normal.mask)
+                has_icon = TRUE;
+
             tw += self->item_h - PADDING;
             break;
         case OB_MENU_ENTRY_TYPE_SEPARATOR:
index 40b9f84415e1b7f8595f462e1a334b6827cfe353..7d2c1f067b549908125d8b81243a3fc9dcbfb5c2 100644 (file)
@@ -69,6 +69,7 @@ struct _ObMenuEntryFrame
     RrAppearance *a_selected;
 
     RrAppearance *a_icon;
+    RrAppearance *a_mask;
     RrAppearance *a_bullet;
     RrAppearance *a_text_normal;
     RrAppearance *a_text_disabled;
This page took 0.029203 seconds and 4 git commands to generate.