]>
Dogcows Code - chaz/openbox/blob - menu_render.c
cf961f24c8acdc1f471845d65c35020d1dc2b59d
1 /* Functions for default rendering of menus. Might become pluginnable */
5 #include "render/theme.h"
7 void menu_render(Menu
*self
) {
10 int nitems
= 0; /* each item, only one is used */
16 /* set texture data and size them mofos out */
17 self
->a_title
->texture
[0].data
.text
.string
= self
->label
;
18 appearance_minsize(self
->a_title
, &self
->title_min_w
, &self
->title_h
);
19 self
->title_min_w
+= theme_bevel
* 2;
20 self
->title_h
+= theme_bevel
* 2;
21 self
->width
= MAX(self
->width
, self
->title_min_w
);
23 for (it
= self
->entries
; it
; it
= it
->next
) {
24 MenuEntry
*e
= it
->data
;
27 e
->a_item
->texture
[0].data
.text
.string
= e
->label
;
28 appearance_minsize(e
->a_item
, &e
->min_w
, &self
->item_h
);
29 self
->width
= MAX(self
->width
, e
->min_w
);
31 e
->a_disabled
->texture
[0].data
.text
.string
= e
->label
;
32 appearance_minsize(e
->a_disabled
, &e
->min_w
, &h
);
33 self
->item_h
= MAX(self
->item_h
, h
);
34 self
->width
= MAX(self
->width
, e
->min_w
);
36 e
->a_hilite
->texture
[0].data
.text
.string
= e
->label
;
37 appearance_minsize(e
->a_hilite
, &e
->min_w
, &h
);
38 self
->item_h
= MAX(self
->item_h
, h
);
39 self
->width
= MAX(self
->width
, e
->min_w
);
41 e
->min_w
+= theme_bevel
* 2;
44 self
->bullet_w
= self
->item_h
+ theme_bevel
;
45 self
->width
+= 2 * self
->bullet_w
;
46 self
->item_h
+= theme_bevel
* 2;
47 items_h
= self
->item_h
* nitems
;
49 RECT_SET(self
->a_title
->area
, 0, 0, self
->width
, self
->title_h
);
50 RECT_SET(self
->a_title
->texture
[0].position
, 0, 0, self
->width
,
52 RECT_SET(self
->a_items
->area
, 0, 0, self
->width
, items_h
);
54 XResizeWindow(ob_display
, self
->frame
, self
->width
,
55 self
->title_h
+ items_h
);
56 XMoveResizeWindow(ob_display
, self
->title
, -theme_bwidth
, -theme_bwidth
,
57 self
->width
, self
->title_h
);
58 XMoveResizeWindow(ob_display
, self
->items
, 0, self
->title_h
+ theme_bwidth
,
59 self
->width
, items_h
);
61 paint(self
->title
, self
->a_title
);
62 paint(self
->items
, self
->a_items
);
65 for (it
= self
->entries
; it
; it
= it
->next
) {
66 ((MenuEntry
*)it
->data
)->y
= item_y
;
67 menu_entry_render(it
->data
);
68 item_y
+= self
->item_h
;
71 self
->invalid
= FALSE
;
This page took 0.0357960000000001 seconds and 3 git commands to generate.