widgets/textbox.c area.x miscalculation due to variable width
This commit is contained in:
parent
2476faf85d
commit
64658bcf93
|
@ -43,31 +43,32 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
{
|
||||
Data *d = widget->data;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
widget_area.y = 0;
|
||||
|
||||
if(sel)
|
||||
{
|
||||
draw_text(ctx, widget->area.x, widget->area.y,
|
||||
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, widget->area.y,
|
||||
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, widget->area.y,
|
||||
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;
|
||||
|
|
|
@ -35,7 +35,7 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Data *d = widget->data;
|
||||
Area area = draw_get_image_size(d->image);
|
||||
Area area = draw_get_image_size(d->image), widget_area = widget->area;
|
||||
|
||||
if(d->resize)
|
||||
widget->area.width = ((double) widget->statusbar->height / area.height) * area.width;
|
||||
|
@ -43,15 +43,15 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
widget->area.width = area.width;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
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.y = 0;
|
||||
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
d->resize ? widget->statusbar->height : 0, d->image);
|
||||
|
||||
return widget->area.width;
|
||||
|
|
|
@ -34,19 +34,20 @@ layoutinfo_draw(Widget *widget,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Tag **curtags = get_current_tags(widget->statusbar->screen);
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
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.y = 0;
|
||||
|
||||
widget->area.width = widget->statusbar->height;
|
||||
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
widget->statusbar->height,
|
||||
curtags[0]->layout->image);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static int
|
|||
netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Area area;
|
||||
Area area, widget_area = widget->area;
|
||||
Rule* r;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
NetWMIcon *icon;
|
||||
|
@ -52,14 +52,14 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||
* area.width;
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
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_area.y = 0;
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
widget->statusbar->height, r->icon);
|
||||
|
||||
return widget->area.width;
|
||||
|
@ -75,16 +75,16 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
widget->area.width = ((double) widget->statusbar->height / (double) icon->height) * icon->width;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
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.y = 0;
|
||||
|
||||
draw_image_from_argb_data(ctx,
|
||||
widget->area.x, widget->area.y,
|
||||
widget_area.x, widget_area.y,
|
||||
icon->width, icon->height,
|
||||
widget->statusbar->height, icon->image);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
int i, width, pwidth, margin_top, pb_height, left_offset;
|
||||
Area widget_area = widget->area;
|
||||
|
||||
Data *d = widget->data;
|
||||
|
||||
|
@ -64,17 +65,17 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
width = d->width - d->lpadding;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
d->width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
widget_area.y = 0;
|
||||
|
||||
margin_top = (int) (widget->statusbar->height * (1 - d->height)) / 2 + 0.5 + widget->area.y;
|
||||
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;
|
||||
left_offset = widget_area.x + d->lpadding;
|
||||
|
||||
for(i = 0; i < d->bars; i++)
|
||||
{
|
||||
|
|
|
@ -75,8 +75,7 @@ taglist_draw(Widget *widget,
|
|||
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||
widget->area.width += textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
|
|
@ -40,6 +40,7 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Data *d = widget->data;
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(d->width)
|
||||
widget->area.width = d->width;
|
||||
|
@ -47,13 +48,16 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
widget->area.width = textwidth(widget->font, d->text);
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
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_text(ctx, widget->area.x, 0, widget->area.width, widget->statusbar->height,
|
||||
d->align, 0, widget->font, d->text, d->fg, d->bg);
|
||||
draw_text(ctx, widget_area.x, widget_area.y, widget->area.width,
|
||||
widget->statusbar->height, d->align, 0, widget->font,
|
||||
d->text, d->fg, d->bg);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue