add align option to widget to specify their alignment
This commit is contained in:
parent
4970e57048
commit
0bfa880b0f
|
@ -141,6 +141,8 @@ This widget shows the tag list.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
layoutinfo
|
layoutinfo
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
@ -152,6 +154,8 @@ This widget shows a icon for the selected layout.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
focusicon
|
focusicon
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
@ -163,6 +167,8 @@ This widget shows a icon for the focused window using NET_WM_ICON or icon file
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
tasklist
|
tasklist
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
@ -213,6 +219,8 @@ This widget shows a text.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
iconbox
|
iconbox
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -228,6 +236,8 @@ This widget shows an icon.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
progressbar
|
progressbar
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
@ -257,6 +267,8 @@ This widget shows one or more progress-bars.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
graph
|
graph
|
||||||
~~~~~
|
~~~~~
|
||||||
|
@ -292,6 +304,8 @@ This widget shows a graph.
|
||||||
Horizontal offset (auto-alignment if not set).
|
Horizontal offset (auto-alignment if not set).
|
||||||
*y*::
|
*y*::
|
||||||
Vertical offset (auto-alignment if not set).
|
Vertical offset (auto-alignment if not set).
|
||||||
|
*align*::
|
||||||
|
Widget alignment.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
--------
|
--------
|
||||||
|
@ -379,6 +393,7 @@ screen <integer> [MULTI]
|
||||||
taglist <identifier> [MULTI]
|
taglist <identifier> [MULTI]
|
||||||
{
|
{
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -388,6 +403,7 @@ screen <integer> [MULTI]
|
||||||
layoutinfo <identifier>
|
layoutinfo <identifier>
|
||||||
{
|
{
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -397,6 +413,7 @@ screen <integer> [MULTI]
|
||||||
focusicon <identifier>
|
focusicon <identifier>
|
||||||
{
|
{
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -412,7 +429,7 @@ screen <integer> [MULTI]
|
||||||
font = <font>
|
font = <font>
|
||||||
show_icons = <boolean>
|
show_icons = <boolean>
|
||||||
show = <{all,tags,focus}>
|
show = <{all,tags,focus}>
|
||||||
align = <{center,left,right}>
|
text_align = <{center,left,right}>
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
|
@ -427,8 +444,9 @@ screen <integer> [MULTI]
|
||||||
fg = <color>
|
fg = <color>
|
||||||
font = <font>
|
font = <font>
|
||||||
width = <integer>
|
width = <integer>
|
||||||
align = <{center,left,right}>
|
text_align = <{center,left,right}>
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -440,6 +458,7 @@ screen <integer> [MULTI]
|
||||||
image = <image>
|
image = <image>
|
||||||
resize = <boolean>
|
resize = <boolean>
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -458,6 +477,7 @@ screen <integer> [MULTI]
|
||||||
height = <float>
|
height = <float>
|
||||||
padding = <integer>
|
padding = <integer>
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
@ -477,6 +497,7 @@ screen <integer> [MULTI]
|
||||||
bg = <color>
|
bg = <color>
|
||||||
bordercolor = <color>
|
bordercolor = <color>
|
||||||
x = <integer> y = <integer>
|
x = <integer> y = <integer>
|
||||||
|
align = <{auto,right,left}>
|
||||||
mouse [MULTI]
|
mouse [MULTI]
|
||||||
{
|
{
|
||||||
button = <integer> modkey = {<mod>, ...}
|
button = <integer> modkey = {<mod>, ...}
|
||||||
|
|
|
@ -71,6 +71,7 @@ cfg_opt_t widget_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
@ -78,6 +79,7 @@ cfg_opt_t widget_taglist_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_taglist_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_taglist_opts, CFGF_MULTI),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
@ -85,6 +87,7 @@ cfg_opt_t widget_iconbox_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
||||||
CFG_BOOL((char *) "resize", cfg_true, CFGF_NONE),
|
CFG_BOOL((char *) "resize", cfg_true, CFGF_NONE),
|
||||||
|
@ -94,6 +97,7 @@ cfg_opt_t widget_textbox_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_INT((char *) "width", 0, CFGF_NONE),
|
CFG_INT((char *) "width", 0, CFGF_NONE),
|
||||||
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
||||||
|
@ -132,6 +136,7 @@ cfg_opt_t widget_graph_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_SEC((char *) "data", widget_graph_data_opts, CFGF_MULTI),
|
CFG_SEC((char *) "data", widget_graph_data_opts, CFGF_MULTI),
|
||||||
CFG_INT((char *) "width", 100, CFGF_NONE),
|
CFG_INT((char *) "width", 100, CFGF_NONE),
|
||||||
|
@ -154,6 +159,7 @@ cfg_opt_t widget_progressbar_opts[] =
|
||||||
{
|
{
|
||||||
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
|
CFG_STR((char *) "align", (char *) "auto", CFGF_NONE),
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_SEC((char *) "bar", widget_progressbar_bar_opts, CFGF_MULTI),
|
CFG_SEC((char *) "bar", widget_progressbar_bar_opts, CFGF_MULTI),
|
||||||
CFG_INT((char *) "width", 100, CFGF_NONE),
|
CFG_INT((char *) "width", 100, CFGF_NONE),
|
||||||
|
|
|
@ -535,12 +535,14 @@ draw_textwidth(Display *disp, XftFont *font, char *text)
|
||||||
Alignment
|
Alignment
|
||||||
draw_get_align(const char *align)
|
draw_get_align(const char *align)
|
||||||
{
|
{
|
||||||
if(!a_strncmp(align, "center", 6))
|
if(!a_strncmp(align, "left", 4))
|
||||||
|
return AlignLeft;
|
||||||
|
else if(!a_strncmp(align, "center", 6))
|
||||||
return AlignCenter;
|
return AlignCenter;
|
||||||
else if(!a_strncmp(align, "right", 5))
|
else if(!a_strncmp(align, "right", 5))
|
||||||
return AlignRight;
|
return AlignRight;
|
||||||
|
|
||||||
return AlignLeft;
|
return AlignAuto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize an X color
|
/** Initialize an X color
|
||||||
|
|
|
@ -33,8 +33,9 @@ typedef enum
|
||||||
{
|
{
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
AlignRight,
|
AlignRight,
|
||||||
|
AlignCenter,
|
||||||
AlignFlex,
|
AlignFlex,
|
||||||
AlignCenter
|
AlignAuto
|
||||||
} Alignment;
|
} Alignment;
|
||||||
|
|
||||||
typedef struct Area Area;
|
typedef struct Area Area;
|
||||||
|
|
10
statusbar.c
10
statusbar.c
|
@ -72,7 +72,7 @@ static void
|
||||||
statusbar_draw(Statusbar *statusbar)
|
statusbar_draw(Statusbar *statusbar)
|
||||||
{
|
{
|
||||||
int phys_screen = get_phys_screen(statusbar->screen);
|
int phys_screen = get_phys_screen(statusbar->screen);
|
||||||
Widget *widget, *last_drawn = NULL;
|
Widget *widget;
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
Area rectangle = { 0, 0, 0, 0, NULL };
|
Area rectangle = { 0, 0, 0, 0, NULL };
|
||||||
Drawable d;
|
Drawable d;
|
||||||
|
@ -116,13 +116,13 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* renders right widget from last to first */
|
/* renders right widget from last to first */
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = *widget_list_last(&statusbar->widgets);
|
||||||
if (widget->alignment == AlignRight && last_drawn == widget->next)
|
widget;
|
||||||
|
widget = widget_list_prev(&statusbar->widgets, widget))
|
||||||
|
if (widget->alignment == AlignRight)
|
||||||
{
|
{
|
||||||
widget->cache.needs_update = False;
|
widget->cache.needs_update = False;
|
||||||
right += widget->draw(widget, ctx, right, (left + right));
|
right += widget->draw(widget, ctx, right, (left + right));
|
||||||
last_drawn = widget;
|
|
||||||
widget = statusbar->widgets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
|
|
19
widget.c
19
widget.c
|
@ -31,23 +31,18 @@ extern AwesomeConf globalconf;
|
||||||
void
|
void
|
||||||
widget_calculate_alignments(Widget *widget)
|
widget_calculate_alignments(Widget *widget)
|
||||||
{
|
{
|
||||||
for(; widget; widget = widget->next)
|
for(; widget && widget->alignment != AlignFlex; widget = widget->next)
|
||||||
{
|
if(widget->alignment == AlignAuto)
|
||||||
if(widget->alignment == AlignFlex)
|
widget->alignment = AlignLeft;
|
||||||
{
|
|
||||||
widget = widget->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
widget->alignment = AlignLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(widget)
|
if(widget)
|
||||||
for(; widget; widget = widget->next)
|
for(widget = widget->next; widget; widget = widget->next)
|
||||||
{
|
{
|
||||||
if (widget->alignment == AlignFlex)
|
if(widget->alignment == AlignFlex)
|
||||||
warn("Multiple flex widgets in panel -"
|
warn("Multiple flex widgets in panel -"
|
||||||
" ignoring flex for all but the first.");
|
" ignoring flex for all but the first.");
|
||||||
widget->alignment = AlignRight;
|
if(widget->alignment == AlignAuto)
|
||||||
|
widget->alignment = AlignRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ focusicon_new(Statusbar *statusbar, cfg_t *config)
|
||||||
w = p_new(Widget, 1);
|
w = p_new(Widget, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
w->draw = focusicon_draw;
|
w->draw = focusicon_draw;
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_CLIENTS;
|
w->cache.flags = WIDGET_CACHE_CLIENTS;
|
||||||
|
|
|
@ -81,6 +81,7 @@ iconbox_new(Statusbar *statusbar, cfg_t *config)
|
||||||
|
|
||||||
w = p_new(Widget, 1);
|
w = p_new(Widget, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
w->draw = iconbox_draw;
|
w->draw = iconbox_draw;
|
||||||
w->tell = iconbox_tell;
|
w->tell = iconbox_tell;
|
||||||
w->data = d = p_new(Data, 1);
|
w->data = d = p_new(Data, 1);
|
||||||
|
|
|
@ -64,6 +64,7 @@ layoutinfo_new(Statusbar *statusbar, cfg_t* config)
|
||||||
w = p_new(Widget, 1);
|
w = p_new(Widget, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
w->draw = layoutinfo_draw;
|
w->draw = layoutinfo_draw;
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_LAYOUTS;
|
w->cache.flags = WIDGET_CACHE_LAYOUTS;
|
||||||
|
|
|
@ -149,6 +149,7 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
|
||||||
w->tell = progressbar_tell;
|
w->tell = progressbar_tell;
|
||||||
d = w->data = p_new(Data, 1);
|
d = w->data = p_new(Data, 1);
|
||||||
d->width = cfg_getint(config, "width");
|
d->width = cfg_getint(config, "width");
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
|
||||||
if(!(d->bars = cfg_size(config, "bar")))
|
if(!(d->bars = cfg_size(config, "bar")))
|
||||||
{
|
{
|
||||||
|
|
|
@ -193,6 +193,7 @@ taglist_new(Statusbar *statusbar, cfg_t *config)
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
w->draw = taglist_draw;
|
w->draw = taglist_draw;
|
||||||
w->button_press = taglist_button_press;
|
w->button_press = taglist_button_press;
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS;
|
w->cache.flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS;
|
||||||
|
|
|
@ -104,6 +104,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
w->draw = textbox_draw;
|
w->draw = textbox_draw;
|
||||||
w->tell = textbox_tell;
|
w->tell = textbox_tell;
|
||||||
|
w->alignment = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
|
||||||
w->data = d = p_new(Data, 1);
|
w->data = d = p_new(Data, 1);
|
||||||
|
|
||||||
|
@ -127,6 +128,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
|
||||||
w->font = globalconf.screens[statusbar->screen].font;
|
w->font = globalconf.screens[statusbar->screen].font;
|
||||||
|
|
||||||
d->text = a_strdup(cfg_getstr(config, "text"));
|
d->text = a_strdup(cfg_getstr(config, "text"));
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue