add support for x,y coords supplying in widgets
This commit is contained in:
parent
6ca7d7b2db
commit
a4c09d142c
14
config.c
14
config.c
|
@ -514,16 +514,22 @@ config_parse(const char *confpatharg)
|
|||
};
|
||||
static cfg_opt_t widget_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_END()
|
||||
};
|
||||
static cfg_opt_t widget_taglist_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_taglist_opts, CFGF_MULTI),
|
||||
CFG_END()
|
||||
};
|
||||
static cfg_opt_t widget_iconbox_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
||||
CFG_BOOL((char *) "resize", cfg_true, CFGF_NONE),
|
||||
|
@ -531,6 +537,8 @@ config_parse(const char *confpatharg)
|
|||
};
|
||||
static cfg_opt_t widget_textbox_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_INT((char *) "width", 0, CFGF_NONE),
|
||||
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
||||
|
@ -542,6 +550,8 @@ config_parse(const char *confpatharg)
|
|||
};
|
||||
static cfg_opt_t widget_focustitle_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
||||
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
||||
|
@ -551,6 +561,8 @@ config_parse(const char *confpatharg)
|
|||
};
|
||||
static cfg_opt_t widget_tasklist_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
||||
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
||||
|
@ -569,6 +581,8 @@ config_parse(const char *confpatharg)
|
|||
};
|
||||
static cfg_opt_t widget_progressbar_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "x", -1, CFGF_NONE),
|
||||
CFG_INT((char *) "y", -1, CFGF_NONE),
|
||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||
CFG_SEC((char *) "bar", widget_progressbar_bar_opts, CFGF_MULTI),
|
||||
CFG_INT((char *) "width", 100, CFGF_NONE),
|
||||
|
|
2
widget.c
2
widget.c
|
@ -115,6 +115,8 @@ widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
|||
widget->name = a_strdup(name);
|
||||
widget->tell = widget_common_tell;
|
||||
widget->button_press = widget_common_button_press;
|
||||
widget->area.x = cfg_getint(config, "x");
|
||||
widget->area.y = cfg_getint(config, "y");
|
||||
}
|
||||
|
||||
/** Send command to widget
|
||||
|
|
|
@ -44,26 +44,30 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
Data *d = widget->data;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
if(sel)
|
||||
{
|
||||
draw_text(ctx, widget->area.x, 0,
|
||||
draw_text(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->width - used,
|
||||
widget->statusbar->height,
|
||||
d->align,
|
||||
widget->font->height / 2, widget->font, sel->name,
|
||||
d->fg, d->bg);
|
||||
if(sel->isfloating)
|
||||
draw_circle(ctx, widget->area.x, 0,
|
||||
draw_circle(ctx, widget->area.x, widget->area.y,
|
||||
(widget->font->height + 2) / 4,
|
||||
sel->ismax, d->fg);
|
||||
}
|
||||
else
|
||||
draw_rectangle(ctx, widget->area.x, 0,
|
||||
draw_rectangle(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->width - used, widget->statusbar->height, True, d->bg);
|
||||
|
||||
widget->area.width = widget->statusbar->width - used;
|
||||
|
|
|
@ -42,12 +42,17 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
else
|
||||
widget->area.width = area.width;
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
draw_image(ctx, widget->area.x, 0, d->resize ? widget->statusbar->height : 0, d->image);
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
d->resize ? widget->statusbar->height : 0, d->image);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
|
|
|
@ -34,14 +34,20 @@ layoutinfo_draw(Widget *widget,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Tag **curtags = get_current_tags(widget->statusbar->screen);
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->statusbar->height,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->statusbar->height,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
widget->area.width = widget->statusbar->height;
|
||||
|
||||
draw_image(ctx, widget->area.x, 0, widget->statusbar->height,
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height,
|
||||
curtags[0]->layout->image);
|
||||
|
||||
p_delete(&curtags);
|
||||
|
|
|
@ -51,11 +51,16 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
area = draw_get_image_size(r->icon);
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||
* area.width;
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
draw_image(ctx, widget->area.x, 0, widget->statusbar->height, r->icon);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height, r->icon);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
|
@ -69,13 +74,17 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) icon->height) * icon->width;
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_image_from_argb_data(ctx,
|
||||
widget->area.x, 0,
|
||||
widget->area.x, widget->area.y,
|
||||
icon->width, icon->height,
|
||||
widget->statusbar->height, icon->image);
|
||||
|
||||
|
|
|
@ -61,19 +61,22 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
if (!(d->bars))
|
||||
return 0;
|
||||
|
||||
margin_top = (int) (widget->statusbar->height * (1 - d->height)) / 2 + 0.5;
|
||||
pb_height = (int) (widget->statusbar->height * d->height - (d->gap * (d->bars - 1))) / d->bars + 0.5;
|
||||
|
||||
width = d->width - d->lpadding;
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
d->width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
d->width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
margin_top = (int) (widget->statusbar->height * (1 - d->height)) / 2 + 0.5 + widget->area.y;
|
||||
pb_height = (int) (widget->statusbar->height * d->height - (d->gap * (d->bars - 1))) / d->bars + 0.5;
|
||||
left_offset = widget->area.x + d->lpadding;
|
||||
|
||||
for (i = 0; i < d->bars; i++)
|
||||
for(i = 0; i < d->bars; i++)
|
||||
{
|
||||
pwidth = (int) d->percent[i] ? ((width - 2) * d->percent[i]) / 100 : 0;
|
||||
|
||||
|
|
|
@ -75,10 +75,14 @@ taglist_draw(Widget *widget,
|
|||
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||
widget->area.width += textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
widget->area.width = 0;
|
||||
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||
|
@ -91,7 +95,7 @@ taglist_draw(Widget *widget,
|
|||
else
|
||||
colors = vscreen.colors_normal;
|
||||
draw_text(ctx,
|
||||
widget->area.x + widget->area.width, 0,
|
||||
widget->area.x + widget->area.width, widget->area.y,
|
||||
w, widget->statusbar->height,
|
||||
AlignCenter,
|
||||
vscreen.font->height / 2,
|
||||
|
@ -100,7 +104,9 @@ taglist_draw(Widget *widget,
|
|||
colors[ColFG],
|
||||
colors[ColBG]);
|
||||
if(isoccupied(tag))
|
||||
draw_rectangle(ctx, widget->area.x + widget->area.width, 0, flagsize, flagsize,
|
||||
draw_rectangle(ctx,
|
||||
widget->area.x + widget->area.width, widget->area.y,
|
||||
flagsize, flagsize,
|
||||
sel && is_client_tagged(sel, tag), colors[ColFG]);
|
||||
widget->area.width += w;
|
||||
}
|
||||
|
|
|
@ -67,10 +67,14 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
|
||||
box_width = (widget->statusbar->width - used) / n;
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
|
||||
for(c = globalconf.clients; c; c = c->next)
|
||||
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
|
||||
|
@ -86,7 +90,8 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||
draw_image(ctx,
|
||||
widget->area.x + box_width * i,
|
||||
0, widget->statusbar->height,
|
||||
widget->area.y,
|
||||
widget->statusbar->height,
|
||||
r->icon);
|
||||
}
|
||||
|
||||
|
@ -95,7 +100,8 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
icon_width = ((double) widget->statusbar->height / (double) icon->height)
|
||||
* icon->width;
|
||||
draw_image_from_argb_data(ctx,
|
||||
widget->area.x + box_width * i, 0,
|
||||
widget->area.x + box_width * i,
|
||||
widget->area.y,
|
||||
icon->width, icon->height,
|
||||
widget->statusbar->height, icon->image);
|
||||
p_delete(&icon->image);
|
||||
|
@ -105,7 +111,8 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
|
||||
if(sel == c)
|
||||
{
|
||||
draw_text(ctx, widget->area.x + icon_width + box_width * i, 0,
|
||||
draw_text(ctx, widget->area.x + icon_width + box_width * i,
|
||||
widget->area.y,
|
||||
box_width - icon_width,
|
||||
widget->statusbar->height,
|
||||
d->align,
|
||||
|
@ -113,14 +120,16 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
d->fg_sel, d->bg_sel);
|
||||
}
|
||||
else
|
||||
draw_text(ctx, widget->area.x + icon_width + box_width * i, 0,
|
||||
draw_text(ctx, widget->area.x + icon_width + box_width * i,
|
||||
widget->area.y,
|
||||
box_width - icon_width,
|
||||
widget->statusbar->height,
|
||||
d->align,
|
||||
widget->font->height / 2, widget->font, c->name,
|
||||
d->fg, d->bg);
|
||||
if(c->isfloating)
|
||||
draw_circle(ctx, widget->area.x + icon_width + box_width * i, 0,
|
||||
draw_circle(ctx, widget->area.x + icon_width + box_width * i,
|
||||
widget->area.y,
|
||||
(widget->font->height + 2) / 4,
|
||||
c->ismax, d->fg);
|
||||
i++;
|
||||
|
|
|
@ -46,10 +46,11 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
else
|
||||
widget->area.width = textwidth(widget->font, d->text);
|
||||
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
draw_text(ctx, widget->area.x, 0, widget->area.width, widget->statusbar->height,
|
||||
d->align, 0, widget->font, d->text, d->fg, d->bg);
|
||||
|
|
Loading…
Reference in New Issue