[widgets/progressbar.c] x_offset+1 and bg color fix

the widget got drawn 1 pixel to much on the left.
adding one progressbar x offset (pb_x) seems to work nicely.

also. bg shall draw (according to the manpage), the gaps
between the 'ticks' + the padding between the border and the ticks
(... everthing inside the border only the ticks)

so, an additional rectangle draw line to achieve that basic bg color.
This commit is contained in:
marco candrian 2008-03-27 22:40:40 +01:00 committed by Julien Danjou
parent a8ab903e24
commit 0e1dbe40d2
1 changed files with 5 additions and 4 deletions

View File

@ -152,7 +152,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
* 4. finally draw the gaps * 4. finally draw the gaps
*/ */
pb_x = widget->area.x + d->padding; pb_x = widget->area.x + d->padding + 1;
border_offset = d->border_width / 2; border_offset = d->border_width / 2;
pb_offset = 0; pb_offset = 0;
@ -166,8 +166,8 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
pb_height = unit * d->ticks_count - d->ticks_gap; /* rounded to match ticks... */ pb_height = unit * d->ticks_count - d->ticks_gap; /* rounded to match ticks... */
} }
pb_width = (int) ((d->width - d->padding - (d->border_width + d->border_padding) * 2 * d->data_items - pb_width = (int) ((d->width - d->padding - 2 * (d->border_width + d->border_padding) * d->data_items -
d->gap * (d->data_items - 1)) / d->data_items + 0.5); d->gap * (d->data_items - 1)) / d->data_items);
pb_y = widget->area.y + ((int) (widget->statusbar->height * (1 - d->height)) / 2) + d->border_width + d->border_padding; pb_y = widget->area.y + ((int) (widget->statusbar->height * (1 - d->height)) / 2) + d->border_width + d->border_padding;
@ -196,6 +196,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
rectangle.width = pb_width + d->border_width + 2 * d->border_padding - 1 + 2; rectangle.width = pb_width + d->border_width + 2 * d->border_padding - 1 + 2;
rectangle.height = pb_height + d->border_width + 2 * d->border_padding + 1; rectangle.height = pb_height + d->border_width + 2 * d->border_padding + 1;
draw_rectangle(ctx, rectangle, d->border_width, True, d->bg[i]);
draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]); draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]);
} }
@ -304,6 +305,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
rectangle.width = pb_width + d->border_width + 2 * d->border_padding - 1 + 2; rectangle.width = pb_width + d->border_width + 2 * d->border_padding - 1 + 2;
rectangle.height = pb_height + d->border_width + 2 * d->border_padding + 1; rectangle.height = pb_height + d->border_width + 2 * d->border_padding + 1;
draw_rectangle(ctx, rectangle, d->border_width, True, d->bg[i]);
draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]); draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]);
} }
/* new value/progress in px + pattern setup */ /* new value/progress in px + pattern setup */
@ -552,7 +554,6 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
else else
d->bordercolor[i] = d->fg[i]; d->bordercolor[i] = d->fg[i];
} }
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