Infobar: Add option to move layout button before of after tags list (Feature #20 requested by Erus.)

This commit is contained in:
Martin Duquesnoy 2010-02-07 17:27:42 +01:00
parent 881ac9f68f
commit 56079ebdfe
4 changed files with 38 additions and 8 deletions

View File

@ -318,6 +318,9 @@ conf_layout_section(char *src)
if((tmp = get_opt(src, "menu", "system").str) && !strcmp(tmp, "menu")) if((tmp = get_opt(src, "menu", "system").str) && !strcmp(tmp, "menu"))
conf.layout_system = True; conf.layout_system = True;
if((tmp = get_opt(src, "right", "placement").str) && !strcmp(tmp, "left"))
conf.layout_placement = True;
conf.nlayout = get_size_sec(src, "layout"); conf.nlayout = get_size_sec(src, "layout");
if(conf.nlayout > NUM_OF_LAYOUT || !(conf.nlayout)) if(conf.nlayout > NUM_OF_LAYOUT || !(conf.nlayout))

View File

@ -37,7 +37,7 @@
void void
infobar_init(void) infobar_init(void)
{ {
int s, sc, i, j; int s, sc, i, j = 0;
s = screen_count(); s = screen_count();
@ -72,29 +72,44 @@ infobar_init(void)
sgeo[sc].width, infobar[sc].geo.height, sgeo[sc].width, infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, conf.border.bar); conf.colors.bar, conf.colors.text, False, False, conf.border.bar);
infobar[sc].tags_board = barwin_create(infobar[sc].bar->win,
((conf.layout_placement) ? textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5: 0), 0,
textw(tags[sc][0].name) + PAD, /* Base size, will change */
infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, False);
/* Create tags window */ /* Create tags window */
for(i = 1; i < conf.ntag[sc] + 1; ++i) for(i = 1; i < conf.ntag[sc] + 1; ++i)
{ {
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0, infobar[sc].tags[i] = barwin_create(infobar[sc].tags_board->win, j, 0,
textw(tags[sc][i].name) + PAD, textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height, infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, conf.border.tag); conf.colors.bar, conf.colors.text, False, False, conf.border.tag);
j += textw(tags[sc][i].name) + PAD; j += textw(tags[sc][i].name) + PAD;
barwin_resize(infobar[sc].tags_board, j, infobar[sc].geo.height);
barwin_map_subwin(infobar[sc].tags[i]); barwin_map_subwin(infobar[sc].tags[i]);
} }
/* Create layout switch barwindow */ /* Create layout switch barwindow */
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, j + PAD / 2, 0, infobar[sc].layout_button = barwin_create(infobar[sc].bar->win,
textw(tags[sc][seltag[sc]].layout.symbol) + PAD, ((conf.layout_placement) ? 0 : (j + PAD / 2)), 0,
infobar[sc].geo.height, textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
conf.colors.layout_bg, conf.colors.layout_fg, infobar[sc].geo.height,
False, False, conf.border.layout); conf.colors.layout_bg, conf.colors.layout_fg,
False, False, conf.border.layout);
/* Map/Refresh all */ /* Map/Refresh all */
barwin_map(infobar[sc].bar); barwin_map(infobar[sc].bar);
barwin_map_subwin(infobar[sc].bar); barwin_map_subwin(infobar[sc].bar);
barwin_map(infobar[sc].tags_board);
barwin_map_subwin(infobar[sc].tags_board);
if(conf.border.layout) if(conf.border.layout)
barwin_map_subwin(infobar[sc].layout_button); barwin_map_subwin(infobar[sc].layout_button);
barwin_refresh_color(infobar[sc].bar); barwin_refresh_color(infobar[sc].bar);
barwin_refresh(infobar[sc].bar); barwin_refresh(infobar[sc].bar);
@ -129,6 +144,7 @@ infobar_draw_layout(int sc)
{ {
barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height); barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button); barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol) if(tags[sc][seltag[sc]].layout.symbol)
barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol); barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
@ -144,6 +160,9 @@ infobar_draw_taglist(int sc)
int i; int i;
Client *c; Client *c;
if(conf.layout_placement)
barwin_move(infobar[sc].tags_board, textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5, 0);
for(i = 1; i < conf.ntag[sc] + 1; ++i) for(i = 1; i < conf.ntag[sc] + 1; ++i)
{ {
infobar[sc].tags[i]->bg = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar); infobar[sc].tags[i]->bg = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar);
@ -177,11 +196,15 @@ infobar_destroy(void)
{ {
barwin_delete(infobar[sc].layout_button); barwin_delete(infobar[sc].layout_button);
barwin_delete_subwin(infobar[sc].layout_button); barwin_delete_subwin(infobar[sc].layout_button);
for(i = 1; i < conf.ntag[sc] + 1; ++i) for(i = 1; i < conf.ntag[sc] + 1; ++i)
{ {
barwin_delete_subwin(infobar[sc].tags[i]); barwin_delete_subwin(infobar[sc].tags[i]);
barwin_delete(infobar[sc].tags[i]); barwin_delete(infobar[sc].tags[i]);
} }
barwin_delete_subwin(infobar[sc].tags_board);
barwin_delete(infobar[sc].tags_board);
barwin_delete_subwin(infobar[sc].bar); barwin_delete_subwin(infobar[sc].bar);
barwin_delete(infobar[sc].bar); barwin_delete(infobar[sc].bar);
} }

View File

@ -226,7 +226,7 @@ typedef struct
{ {
BarWindow *bar; BarWindow *bar;
BarWindow *layout_button; BarWindow *layout_button;
BarWindow *tags[MAXTAG]; BarWindow *tags_board, *tags[MAXTAG];
XRectangle geo; XRectangle geo;
int position; int position;
char *statustext; char *statustext;
@ -392,6 +392,7 @@ typedef struct
int *ntag; int *ntag;
Bool tag_round; Bool tag_round;
Bool layout_system; /* Switch: False, Menu: True. */ Bool layout_system; /* Switch: False, Menu: True. */
Bool layout_placement; /* Right (normal): False, Left: True. */
/* Number of... */ /* Number of... */
int nkeybind; int nkeybind;
int nlayout; int nlayout;

View File

@ -26,6 +26,9 @@
# Value menu or switch. # Value menu or switch.
system = "menu" system = "menu"
# Value left or right.
placement = "right"
# Tiling layouts. # Tiling layouts.
[layout] type = "tile_right" symbol = "RIGHT" [/layout] [layout] type = "tile_right" symbol = "RIGHT" [/layout]
[layout] type = "tile_left" symbol = "LEFT" [/layout] [layout] type = "tile_left" symbol = "LEFT" [/layout]