1 /* Functions for default rendering of menus. Might become pluginnable */
5 #include "render/theme.h"
7 void menu_render_full(Menu
*self
);
9 void menu_render(Menu
*self
) {
14 menu_render_full(self
);
20 void menu_render_full(Menu
*self
) {
23 int nitems
= 0; /* each item, only one is used */
29 if (self
->a_title
== NULL
) {
30 XSetWindowBorderWidth(ob_display
, self
->frame
, ob_rr_theme
->bwidth
);
31 XSetWindowBackground(ob_display
, self
->frame
,
32 ob_rr_theme
->b_color
->pixel
);
33 XSetWindowBorderWidth(ob_display
, self
->title
, ob_rr_theme
->bwidth
);
34 XSetWindowBorder(ob_display
, self
->frame
, ob_rr_theme
->b_color
->pixel
);
35 XSetWindowBorder(ob_display
, self
->title
, ob_rr_theme
->b_color
->pixel
);
37 self
->a_title
= RrAppearanceCopy(ob_rr_theme
->a_menu_title
);
38 self
->a_items
= RrAppearanceCopy(ob_rr_theme
->a_menu
);
41 /* set texture data and size them mofos out */
43 self
->a_title
->texture
[0].data
.text
.string
= self
->label
;
44 RrMinsize(self
->a_title
, &self
->title_min_w
, &self
->title_h
);
45 self
->title_min_w
+= ob_rr_theme
->bevel
* 2;
46 self
->title_h
+= ob_rr_theme
->bevel
* 2;
47 self
->size
.width
= MAX(self
->size
.width
, self
->title_min_w
);
50 for (it
= self
->entries
; it
; it
= it
->next
) {
51 MenuEntry
*e
= it
->data
;
54 if (e
->a_item
== NULL
) {
55 e
->a_item
= RrAppearanceCopy(ob_rr_theme
->a_menu_item
);
56 e
->a_disabled
= RrAppearanceCopy(ob_rr_theme
->a_menu_disabled
);
57 e
->a_hilite
= RrAppearanceCopy(ob_rr_theme
->a_menu_hilite
);
60 e
->a_item
->texture
[0].data
.text
.string
= e
->label
;
61 RrMinsize(e
->a_item
, &e
->min_w
, &self
->item_h
);
62 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
64 e
->a_disabled
->texture
[0].data
.text
.string
= e
->label
;
65 RrMinsize(e
->a_disabled
, &e
->min_w
, &h
);
66 self
->item_h
= MAX(self
->item_h
, h
);
67 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
69 e
->a_hilite
->texture
[0].data
.text
.string
= e
->label
;
70 RrMinsize(e
->a_hilite
, &e
->min_w
, &h
);
71 self
->item_h
= MAX(self
->item_h
, h
);
72 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
74 e
->min_w
+= ob_rr_theme
->bevel
* 2;
77 self
->bullet_w
= self
->item_h
+ ob_rr_theme
->bevel
;
78 self
->size
.width
+= 2 * self
->bullet_w
+ 2 * ob_rr_theme
->bevel
;
79 self
->item_h
+= ob_rr_theme
->bevel
* 2;
80 items_h
= self
->item_h
* MAX(nitems
, 1);
82 self
->size
.height
= MAX(self
->title_h
+ items_h
+ ob_rr_theme
->bwidth
, 1);
83 XResizeWindow(ob_display
, self
->frame
, self
->size
.width
,self
->size
.height
);
85 XMoveResizeWindow(ob_display
, self
->title
, -ob_rr_theme
->bwidth
,
87 self
->size
.width
, self
->title_h
);
89 XMoveResizeWindow(ob_display
, self
->items
, 0,
90 self
->title_h
+ ob_rr_theme
->bwidth
, self
->size
.width
,
94 RrPaint(self
->a_title
, self
->title
, self
->size
.width
, self
->title_h
);
95 RrPaint(self
->a_items
, self
->items
, self
->size
.width
, items_h
);
98 for (it
= self
->entries
; it
; it
= it
->next
) {
99 ((MenuEntry
*)it
->data
)->y
= item_y
;
100 menu_entry_render(it
->data
);
101 item_y
+= self
->item_h
;
104 self
->invalid
= FALSE
;
107 void menu_entry_render(MenuEntry
*self
)
109 Menu
*menu
= self
->parent
;
112 switch (self
->render_type
) {
113 case MenuEntryRenderType_Submenu
:
114 /* TODO: submenu mask */
115 case MenuEntryRenderType_Boolean
:
116 /* TODO: boolean check */
117 a
= self
->enabled
? (self
->hilite
? self
->a_hilite
: self
->a_item
)
120 case MenuEntryRenderType_None
:
121 a
= self
->enabled
? (self
->hilite
? self
->a_hilite
: self
->a_item
)
124 case MenuEntryRenderType_Separator
:
129 g_message("unhandled render_type");
130 a
= !self
->enabled
? self
->a_disabled
:
132 (self
->action
|| self
->render_type
== MenuEntryRenderType_Submenu
) ?
133 self
->a_hilite
: self
->a_item
);
136 g_message ("%s %d", self
->label
, self
->hilite
);
138 XMoveResizeWindow(ob_display
, self
->item
, 0, self
->y
,
139 menu
->size
.width
, menu
->item_h
);
141 a
->surface
.parent
= menu
->a_items
;
142 a
->surface
.parentx
= 0;
143 a
->surface
.parenty
= self
->y
;
145 RrPaint(a
, self
->item
, menu
->size
.width
, menu
->item_h
);