Bugfix: Menu get out of the screen view area. Feature: New menu option 'align'.
This commit is contained in:
parent
a0258c13d0
commit
590acffb62
@ -533,6 +533,15 @@ conf_menu_section(char *src)
|
||||
conf.menu[i].y = get_opt(tmp, "0", "y").num;
|
||||
}
|
||||
|
||||
tmp2 = _strdup(get_opt(tmp, "center", "align").str);
|
||||
|
||||
if(!strcmp(tmp2 ,"left"))
|
||||
conf.menu[i].align = MA_Left;
|
||||
else if(!strcmp(tmp2, "right"))
|
||||
conf.menu[i].align = MA_Right;
|
||||
else
|
||||
conf.menu[i].align = MA_Center;
|
||||
|
||||
conf.menu[i].colors.focus.bg = getcolor(get_opt(tmp, "#000000", "bg_focus").str);
|
||||
conf.menu[i].colors.focus.fg = get_opt(tmp, "#ffffff", "fg_focus").str;
|
||||
conf.menu[i].colors.normal.bg = getcolor(get_opt(tmp, "#000000", "bg_normal").str);
|
||||
|
||||
29
src/menu.c
29
src/menu.c
@ -63,15 +63,21 @@ menu_new_item(MenuItem *mi, char *name, void *func, char *cmd)
|
||||
void
|
||||
menu_draw(Menu menu, int x, int y)
|
||||
{
|
||||
int i, width;
|
||||
int i, width, height, out;
|
||||
XEvent ev;
|
||||
BarWindow *item[menu.nitem];
|
||||
BarWindow *frame;
|
||||
|
||||
width = menu_get_longer_string(menu.item, menu.nitem) + PAD;
|
||||
height = menu.nitem * (INFOBARH - SHADH);
|
||||
|
||||
/* Frame barwin */
|
||||
frame = barwin_create(ROOT, x, y, width + SHADH, menu.nitem * (INFOBARH - SHADH) + SHADH * 2,
|
||||
screen_get_sel();
|
||||
|
||||
if((out = x + width - spgeo[selscreen].width) > 0) x -= out;
|
||||
if((out = y + height - spgeo[selscreen].height) > 0) y -= out;
|
||||
|
||||
frame = barwin_create(ROOT, x, y, width + SHADH, height + SHADH * 2,
|
||||
menu.colors.normal.bg, menu.colors.normal.fg, False, False, True);
|
||||
|
||||
barwin_map(frame);
|
||||
@ -219,12 +225,23 @@ menu_focus_item(Menu *menu, int item, BarWindow *winitem[])
|
||||
void
|
||||
menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[])
|
||||
{
|
||||
int x;
|
||||
int width = menu_get_longer_string(menu->item, menu->nitem) + PAD;
|
||||
|
||||
barwin_draw_text(winitem[item],
|
||||
((width / 2) - (textw(menu->item[item].name) / 2)),
|
||||
FHINFOBAR,
|
||||
menu->item[item].name);
|
||||
switch(menu->align)
|
||||
{
|
||||
case MA_Left:
|
||||
x = PAD / 2;
|
||||
break;
|
||||
case MA_Right:
|
||||
x = width - textw(menu->item[item].name) + PAD / 2;
|
||||
break;
|
||||
default:
|
||||
case MA_Center:
|
||||
x = width / 2 - textw(menu->item[item].name) / 2 + PAD / 2;
|
||||
break;
|
||||
}
|
||||
barwin_draw_text(winitem[item], x, FHINFOBAR, menu->item[item].name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -87,6 +87,9 @@ typedef unsigned char uchar;
|
||||
enum { CurNormal, CurResize, CurRightResize, CurLeftResize, CurMove, CurLast };
|
||||
enum { TagSel, TagTransfert, TagAdd, TagNext, TagPrev, TagActionLast };
|
||||
|
||||
/* Menu align */
|
||||
enum { MA_Center = 0, MA_Left = 1, MA_Right = 2 };
|
||||
|
||||
/* Infobar position */
|
||||
enum { IB_Hide = 0, IB_Bottom = 1, IB_Top = 2 };
|
||||
|
||||
@ -283,6 +286,7 @@ typedef struct
|
||||
char *name;
|
||||
/* Placement */
|
||||
Bool place_at_mouse;
|
||||
int align;
|
||||
int x, y;
|
||||
/* Color */
|
||||
struct
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user