From 0e1dbe40d22b70b73e54db507055f8525e2a15df Mon Sep 17 00:00:00 2001 From: marco candrian Date: Thu, 27 Mar 2008 22:40:40 +0100 Subject: [PATCH] [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. --- widgets/progressbar.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/widgets/progressbar.c b/widgets/progressbar.c index c2e39b2ef..5261042bb 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -152,7 +152,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset, * 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; 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_width = (int) ((d->width - d->padding - (d->border_width + d->border_padding) * 2 * d->data_items - - d->gap * (d->data_items - 1)) / d->data_items + 0.5); + 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); 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.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]); } @@ -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.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]); } /* new value/progress in px + pattern setup */ @@ -552,7 +554,6 @@ progressbar_new(Statusbar *statusbar, cfg_t *config) else d->bordercolor[i] = d->fg[i]; } - return w; } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80