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 /* set texture data and size them mofos out */
31 self
->a_title
->texture
[0].data
.text
.string
= self
->label
;
32 appearance_minsize(self
->a_title
, &self
->title_min_w
, &self
->title_h
);
33 self
->title_min_w
+= theme_bevel
* 2;
34 self
->title_h
+= theme_bevel
* 2;
35 self
->size
.width
= MAX(self
->size
.width
, self
->title_min_w
);
38 for (it
= self
->entries
; it
; it
= it
->next
) {
39 MenuEntry
*e
= it
->data
;
42 e
->a_item
->texture
[0].data
.text
.string
= e
->label
;
43 appearance_minsize(e
->a_item
, &e
->min_w
, &self
->item_h
);
44 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
46 e
->a_disabled
->texture
[0].data
.text
.string
= e
->label
;
47 appearance_minsize(e
->a_disabled
, &e
->min_w
, &h
);
48 self
->item_h
= MAX(self
->item_h
, h
);
49 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
51 e
->a_hilite
->texture
[0].data
.text
.string
= e
->label
;
52 appearance_minsize(e
->a_hilite
, &e
->min_w
, &h
);
53 self
->item_h
= MAX(self
->item_h
, h
);
54 self
->size
.width
= MAX(self
->size
.width
, e
->min_w
);
56 e
->min_w
+= theme_bevel
* 2;
59 self
->bullet_w
= self
->item_h
+ theme_bevel
;
60 self
->size
.width
+= 2 * self
->bullet_w
+ 2 * theme_bevel
;
61 self
->item_h
+= theme_bevel
* 2;
62 items_h
= self
->item_h
* MAX(nitems
, 1);
65 RECT_SET(self
->a_title
->area
, 0, 0, self
->size
.width
,
67 RECT_SET(self
->a_title
->texture
[0].position
, 0, 0, self
->size
.width
,
71 RECT_SET(self
->a_items
->area
, 0, 0, self
->size
.width
, items_h
);
73 XResizeWindow(ob_display
, self
->frame
, self
->size
.width
,
74 MAX(self
->title_h
+ items_h
, 1));
76 XMoveResizeWindow(ob_display
, self
->title
, -theme_bwidth
,
77 -theme_bwidth
, self
->size
.width
, self
->title_h
);
79 XMoveResizeWindow(ob_display
, self
->items
, 0,
80 self
->title_h
+ theme_bwidth
, self
->size
.width
,
84 paint(self
->title
, self
->a_title
);
85 paint(self
->items
, self
->a_items
);
88 for (it
= self
->entries
; it
; it
= it
->next
) {
89 ((MenuEntry
*)it
->data
)->y
= item_y
;
90 menu_entry_render(it
->data
);
91 item_y
+= self
->item_h
;
94 self
->size
.height
= item_y
;
95 self
->invalid
= FALSE
;
98 void menu_entry_render(MenuEntry
*self
)
100 Menu
*menu
= self
->parent
;
103 switch (self
->render_type
) {
104 case MenuEntryRenderType_Submenu
:
105 /* TODO: submenu mask */
106 case MenuEntryRenderType_Boolean
:
107 /* TODO: boolean check */
108 a
= self
->enabled
? (self
->hilite
? self
->a_hilite
: self
->a_item
)
111 case MenuEntryRenderType_None
:
112 a
= self
->enabled
? (self
->hilite
? self
->a_hilite
: self
->a_item
)
115 case MenuEntryRenderType_Separator
:
120 g_message("unhandled render_type");
121 a
= !self
->enabled
? self
->a_disabled
:
123 (self
->action
|| self
->render_type
== MenuEntryRenderType_Submenu
) ?
124 self
->a_hilite
: self
->a_item
);
128 RECT_SET(a
->area
, 0, 0, menu
->size
.width
,
130 RECT_SET(a
->texture
[0].position
, menu
->bullet_w
,
131 0, menu
->size
.width
- 2 * menu
->bullet_w
,
134 XMoveResizeWindow(ob_display
, self
->item
, 0, self
->y
,
135 menu
->size
.width
, menu
->item_h
);
136 a
->surface
.data
.planar
.parent
= menu
->a_items
;
137 a
->surface
.data
.planar
.parentx
= 0;
138 a
->surface
.data
.planar
.parenty
= self
->y
;
140 paint(self
->item
, a
);