Make the draw_*() functions take a color_t*
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
293f2a312d
commit
37862c83c0
66
draw.c
66
draw.c
|
@ -284,8 +284,8 @@ draw_text(draw_context_t *ctx, draw_text_context_t *data,
|
||||||
*/
|
*/
|
||||||
static cairo_pattern_t *
|
static cairo_pattern_t *
|
||||||
draw_setup_cairo_color_source(draw_context_t *ctx, vector_t gradient_vector,
|
draw_setup_cairo_color_source(draw_context_t *ctx, vector_t gradient_vector,
|
||||||
const xcolor_t *pcolor, const xcolor_t *pcolor_center,
|
const color_t *pcolor, const color_t *pcolor_center,
|
||||||
const xcolor_t *pcolor_end)
|
const color_t *pcolor_end)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pat = NULL;
|
cairo_pattern_t *pat = NULL;
|
||||||
bool has_center = pcolor_center->initialized;
|
bool has_center = pcolor_center->initialized;
|
||||||
|
@ -294,10 +294,10 @@ draw_setup_cairo_color_source(draw_context_t *ctx, vector_t gradient_vector,
|
||||||
/* no need for a real pattern: */
|
/* no need for a real pattern: */
|
||||||
if(!has_end && !has_center)
|
if(!has_end && !has_center)
|
||||||
cairo_set_source_rgba(ctx->cr,
|
cairo_set_source_rgba(ctx->cr,
|
||||||
pcolor->red / 65535.0,
|
pcolor->red / 255.0,
|
||||||
pcolor->green / 65535.0,
|
pcolor->green / 255.0,
|
||||||
pcolor->blue / 65535.0,
|
pcolor->blue / 255.0,
|
||||||
pcolor->alpha / 65535.0);
|
pcolor->alpha / 255.0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pat = cairo_pattern_create_linear(gradient_vector.x,
|
pat = cairo_pattern_create_linear(gradient_vector.x,
|
||||||
|
@ -307,30 +307,30 @@ draw_setup_cairo_color_source(draw_context_t *ctx, vector_t gradient_vector,
|
||||||
|
|
||||||
/* pcolor is always set (so far in awesome) */
|
/* pcolor is always set (so far in awesome) */
|
||||||
cairo_pattern_add_color_stop_rgba(pat, 0.0,
|
cairo_pattern_add_color_stop_rgba(pat, 0.0,
|
||||||
pcolor->red / 65535.0,
|
pcolor->red / 255.0,
|
||||||
pcolor->green / 65535.0,
|
pcolor->green / 255.0,
|
||||||
pcolor->blue / 65535.0,
|
pcolor->blue / 255.0,
|
||||||
pcolor->alpha / 65535.0);
|
pcolor->alpha / 255.0);
|
||||||
|
|
||||||
if(has_center)
|
if(has_center)
|
||||||
cairo_pattern_add_color_stop_rgba(pat, 0.5,
|
cairo_pattern_add_color_stop_rgba(pat, 0.5,
|
||||||
pcolor_center->red / 65535.0,
|
pcolor_center->red / 255.0,
|
||||||
pcolor_center->green / 65535.0,
|
pcolor_center->green / 255.0,
|
||||||
pcolor_center->blue / 65535.0,
|
pcolor_center->blue / 255.0,
|
||||||
pcolor_center->alpha / 65535.0);
|
pcolor_center->alpha / 255.0);
|
||||||
|
|
||||||
if(has_end)
|
if(has_end)
|
||||||
cairo_pattern_add_color_stop_rgba(pat, 1.0,
|
cairo_pattern_add_color_stop_rgba(pat, 1.0,
|
||||||
pcolor_end->red / 65535.0,
|
pcolor_end->red / 255.0,
|
||||||
pcolor_end->green / 65535.0,
|
pcolor_end->green / 255.0,
|
||||||
pcolor_end->blue / 65535.0,
|
pcolor_end->blue / 255.0,
|
||||||
pcolor_end->alpha / 65535.0);
|
pcolor_end->alpha / 255.0);
|
||||||
else
|
else
|
||||||
cairo_pattern_add_color_stop_rgba(pat, 1.0,
|
cairo_pattern_add_color_stop_rgba(pat, 1.0,
|
||||||
pcolor->red / 65535.0,
|
pcolor->red / 255.0,
|
||||||
pcolor->green / 65535.0,
|
pcolor->green / 255.0,
|
||||||
pcolor->blue / 65535.0,
|
pcolor->blue / 255.0,
|
||||||
pcolor->alpha / 65535.0);
|
pcolor->alpha / 255.0);
|
||||||
cairo_set_source(ctx->cr, pat);
|
cairo_set_source(ctx->cr, pat);
|
||||||
}
|
}
|
||||||
return pat;
|
return pat;
|
||||||
|
@ -345,17 +345,17 @@ draw_setup_cairo_color_source(draw_context_t *ctx, vector_t gradient_vector,
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_rectangle(draw_context_t *ctx, area_t geometry,
|
draw_rectangle(draw_context_t *ctx, area_t geometry,
|
||||||
float line_width, bool filled, const xcolor_t *color)
|
float line_width, bool filled, const color_t *color)
|
||||||
{
|
{
|
||||||
cairo_set_antialias(ctx->cr, CAIRO_ANTIALIAS_NONE);
|
cairo_set_antialias(ctx->cr, CAIRO_ANTIALIAS_NONE);
|
||||||
cairo_set_line_width(ctx->cr, line_width);
|
cairo_set_line_width(ctx->cr, line_width);
|
||||||
cairo_set_miter_limit(ctx->cr, 10.0);
|
cairo_set_miter_limit(ctx->cr, 10.0);
|
||||||
cairo_set_line_join(ctx->cr, CAIRO_LINE_JOIN_MITER);
|
cairo_set_line_join(ctx->cr, CAIRO_LINE_JOIN_MITER);
|
||||||
cairo_set_source_rgba(ctx->cr,
|
cairo_set_source_rgba(ctx->cr,
|
||||||
color->red / 65535.0,
|
color->red / 255.0,
|
||||||
color->green / 65535.0,
|
color->green / 255.0,
|
||||||
color->blue / 65535.0,
|
color->blue / 255.0,
|
||||||
color->alpha / 65535.0);
|
color->alpha / 255.0);
|
||||||
if(filled)
|
if(filled)
|
||||||
{
|
{
|
||||||
cairo_rectangle(ctx->cr, geometry.x, geometry.y,
|
cairo_rectangle(ctx->cr, geometry.x, geometry.y,
|
||||||
|
@ -382,8 +382,8 @@ draw_rectangle(draw_context_t *ctx, area_t geometry,
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_rectangle_gradient(draw_context_t *ctx, area_t geometry, float line_width, bool filled,
|
draw_rectangle_gradient(draw_context_t *ctx, area_t geometry, float line_width, bool filled,
|
||||||
vector_t gradient_vector, const xcolor_t *pcolor,
|
vector_t gradient_vector, const color_t *pcolor,
|
||||||
const xcolor_t *pcolor_center, const xcolor_t *pcolor_end)
|
const color_t *pcolor_center, const color_t *pcolor_end)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pat;
|
cairo_pattern_t *pat;
|
||||||
|
|
||||||
|
@ -437,8 +437,8 @@ draw_graph_setup(draw_context_t *ctx)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_graph(draw_context_t *ctx, area_t rect, int *from, int *to, int cur_index,
|
draw_graph(draw_context_t *ctx, area_t rect, int *from, int *to, int cur_index,
|
||||||
position_t grow, vector_t gradient_vector, const xcolor_t *pcolor,
|
position_t grow, vector_t gradient_vector, const color_t *pcolor,
|
||||||
const xcolor_t *pcolor_center, const xcolor_t *pcolor_end)
|
const color_t *pcolor_center, const color_t *pcolor_end)
|
||||||
{
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
float x = rect.x + 0.5; /* middle of a pixel */
|
float x = rect.x + 0.5; /* middle of a pixel */
|
||||||
|
@ -490,8 +490,8 @@ draw_graph(draw_context_t *ctx, area_t rect, int *from, int *to, int cur_index,
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_graph_line(draw_context_t *ctx, area_t rect, int *to, int cur_index,
|
draw_graph_line(draw_context_t *ctx, area_t rect, int *to, int cur_index,
|
||||||
position_t grow, vector_t gradient_vector, const xcolor_t *pcolor,
|
position_t grow, vector_t gradient_vector, const color_t *pcolor,
|
||||||
const xcolor_t *pcolor_center, const xcolor_t *pcolor_end)
|
const color_t *pcolor_center, const color_t *pcolor_end)
|
||||||
{
|
{
|
||||||
int i, w;
|
int i, w;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
|
8
draw.h
8
draw.h
|
@ -166,15 +166,15 @@ typedef struct
|
||||||
|
|
||||||
bool draw_text_context_init(draw_text_context_t *, const char *, ssize_t);
|
bool draw_text_context_init(draw_text_context_t *, const char *, ssize_t);
|
||||||
void draw_text(draw_context_t *, draw_text_context_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, padding_t *, area_t, area_t *);
|
void draw_text(draw_context_t *, draw_text_context_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, padding_t *, area_t, area_t *);
|
||||||
void draw_rectangle(draw_context_t *, area_t, float, bool, const xcolor_t *);
|
void draw_rectangle(draw_context_t *, area_t, float, bool, const color_t *);
|
||||||
void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, vector_t,
|
void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, vector_t,
|
||||||
const xcolor_t *, const xcolor_t *, const xcolor_t *);
|
const color_t *, const color_t *, const color_t *);
|
||||||
|
|
||||||
void draw_graph_setup(draw_context_t *);
|
void draw_graph_setup(draw_context_t *);
|
||||||
void draw_graph(draw_context_t *, area_t, int *, int *, int, position_t, vector_t,
|
void draw_graph(draw_context_t *, area_t, int *, int *, int, position_t, vector_t,
|
||||||
const xcolor_t *, const xcolor_t *, const xcolor_t *);
|
const color_t *, const color_t *, const color_t *);
|
||||||
void draw_graph_line(draw_context_t *, area_t, int *, int, position_t, vector_t,
|
void draw_graph_line(draw_context_t *, area_t, int *, int, position_t, vector_t,
|
||||||
const xcolor_t *, const xcolor_t *, const xcolor_t *);
|
const color_t *, const color_t *, const color_t *);
|
||||||
void draw_image(draw_context_t *, int, int, double, image_t *);
|
void draw_image(draw_context_t *, int, int, double, image_t *);
|
||||||
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
|
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
|
||||||
area_t draw_text_extents(draw_text_context_t *);
|
area_t draw_text_extents(draw_text_context_t *);
|
||||||
|
|
4
widget.c
4
widget.c
|
@ -141,6 +141,7 @@ widget_render(wibox_t *wibox)
|
||||||
draw_context_t *ctx = &wibox->sw.ctx;
|
draw_context_t *ctx = &wibox->sw.ctx;
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
area_t rectangle = { 0, 0, 0, 0 };
|
area_t rectangle = { 0, 0, 0, 0 };
|
||||||
|
color_t col;
|
||||||
|
|
||||||
rectangle.width = ctx->width;
|
rectangle.width = ctx->width;
|
||||||
rectangle.height = ctx->height;
|
rectangle.height = ctx->height;
|
||||||
|
@ -265,7 +266,8 @@ widget_render(wibox_t *wibox)
|
||||||
draw_image(ctx, 0, 0, 1.0, wibox->bg_image);
|
draw_image(ctx, 0, 0, 1.0, wibox->bg_image);
|
||||||
|
|
||||||
/* draw background color */
|
/* draw background color */
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &ctx->bg);
|
xcolor_to_color(&ctx->bg, &col);
|
||||||
|
draw_rectangle(ctx, rectangle, 1.0, true, &col);
|
||||||
|
|
||||||
/* draw everything! */
|
/* draw everything! */
|
||||||
for(int i = 0; i < widgets->len; i++)
|
for(int i = 0; i < widgets->len; i++)
|
||||||
|
|
|
@ -174,6 +174,8 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
graph_data_t *d = widget->data;
|
graph_data_t *d = widget->data;
|
||||||
area_t rectangle;
|
area_t rectangle;
|
||||||
vector_t color_gradient;
|
vector_t color_gradient;
|
||||||
|
color_t col;
|
||||||
|
color_t color_start, color_center, color_end;
|
||||||
|
|
||||||
if(!d->plots.len)
|
if(!d->plots.len)
|
||||||
return;
|
return;
|
||||||
|
@ -189,7 +191,8 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
rectangle.y = margin_top + 1;
|
rectangle.y = margin_top + 1;
|
||||||
rectangle.width = d->size;
|
rectangle.width = d->size;
|
||||||
rectangle.height = d->box_height;
|
rectangle.height = d->box_height;
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &d->bg);
|
xcolor_to_color(&d->bg, &col);
|
||||||
|
draw_rectangle(ctx, rectangle, 1.0, true, &col);
|
||||||
|
|
||||||
/* for plot drawing */
|
/* for plot drawing */
|
||||||
rectangle.y = margin_top + d->box_height + 1; /* bottom left corner as starting point */
|
rectangle.y = margin_top + d->box_height + 1; /* bottom left corner as starting point */
|
||||||
|
@ -207,6 +210,11 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
{
|
{
|
||||||
plot_t *plot = &d->plots.tab[i];
|
plot_t *plot = &d->plots.tab[i];
|
||||||
|
|
||||||
|
/* Prepare colors */
|
||||||
|
xcolor_to_color(&plot->color_start, &color_start);
|
||||||
|
xcolor_to_color(&plot->pcolor_center, &color_center);
|
||||||
|
xcolor_to_color(&plot->pcolor_end, &color_end);
|
||||||
|
|
||||||
switch(plot->draw_style)
|
switch(plot->draw_style)
|
||||||
{
|
{
|
||||||
case Top_Style:
|
case Top_Style:
|
||||||
|
@ -233,7 +241,7 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
d->draw_to[y] = d->box_height - plot->lines[y]; /* i.e. on full plot -> 0 = bottom */
|
d->draw_to[y] = d->box_height - plot->lines[y]; /* i.e. on full plot -> 0 = bottom */
|
||||||
}
|
}
|
||||||
draw_graph(ctx, rectangle , d->draw_from, d->draw_to, plot->index, d->grow, color_gradient,
|
draw_graph(ctx, rectangle , d->draw_from, d->draw_to, plot->index, d->grow, color_gradient,
|
||||||
&plot->color_start, &plot->pcolor_center, &plot->pcolor_end);
|
&color_start, &color_center, &color_end);
|
||||||
break;
|
break;
|
||||||
case Bottom_Style:
|
case Bottom_Style:
|
||||||
color_gradient.y = rectangle.y;
|
color_gradient.y = rectangle.y;
|
||||||
|
@ -254,7 +262,7 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
|
|
||||||
p_clear(d->draw_from, d->size);
|
p_clear(d->draw_from, d->size);
|
||||||
draw_graph(ctx, rectangle, d->draw_from, plot->lines, plot->index, d->grow, color_gradient,
|
draw_graph(ctx, rectangle, d->draw_from, plot->lines, plot->index, d->grow, color_gradient,
|
||||||
&plot->color_start, &plot->pcolor_center, &plot->pcolor_end);
|
&color_start, &color_center, &color_end);
|
||||||
break;
|
break;
|
||||||
case Line_Style:
|
case Line_Style:
|
||||||
color_gradient.y = rectangle.y;
|
color_gradient.y = rectangle.y;
|
||||||
|
@ -273,7 +281,7 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_graph_line(ctx, rectangle, plot->lines, plot->index, d->grow, color_gradient,
|
draw_graph_line(ctx, rectangle, plot->lines, plot->index, d->grow, color_gradient,
|
||||||
&plot->color_start, &plot->pcolor_center, &plot->pcolor_end);
|
&color_start, &color_center, &color_end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +291,8 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
rectangle.y = margin_top;
|
rectangle.y = margin_top;
|
||||||
rectangle.width = d->size + 2;
|
rectangle.width = d->size + 2;
|
||||||
rectangle.height = d->box_height + 2;
|
rectangle.height = d->box_height + 2;
|
||||||
draw_rectangle(ctx, rectangle, 1.0, false, &d->border_color);
|
xcolor_to_color(&d->border_color, &col);
|
||||||
|
draw_rectangle(ctx, rectangle, 1.0, false, &col);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set various plot graph properties.
|
/** Set various plot graph properties.
|
||||||
|
|
|
@ -85,8 +85,12 @@ imagebox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p
|
||||||
|
|
||||||
if(d->image && geometry.width && geometry.height)
|
if(d->image && geometry.width && geometry.height)
|
||||||
{
|
{
|
||||||
if(d->bg.initialized)
|
color_t bg;
|
||||||
draw_rectangle(ctx, geometry, 1.0, true, &d->bg);
|
|
||||||
|
xcolor_to_color(&d->bg, &bg);
|
||||||
|
|
||||||
|
if(bg.initialized)
|
||||||
|
draw_rectangle(ctx, geometry, 1.0, true, &bg);
|
||||||
|
|
||||||
int y = geometry.y;
|
int y = geometry.y;
|
||||||
double ratio = d->resize ? (double) geometry.height / d->image->height : 1;
|
double ratio = d->resize ? (double) geometry.height / d->image->height : 1;
|
||||||
|
|
|
@ -217,6 +217,20 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
for(int i = 0; i < d->bars.len; i++)
|
for(int i = 0; i < d->bars.len; i++)
|
||||||
{
|
{
|
||||||
bar_t *bar = &d->bars.tab[i];
|
bar_t *bar = &d->bars.tab[i];
|
||||||
|
color_t bg;
|
||||||
|
color_t border_color;
|
||||||
|
color_t fg;
|
||||||
|
color_t fg_center;
|
||||||
|
color_t fg_end;
|
||||||
|
color_t fg_off;
|
||||||
|
|
||||||
|
xcolor_to_color(&bar->bg, &bg);
|
||||||
|
xcolor_to_color(&bar->border_color, &border_color);
|
||||||
|
xcolor_to_color(&bar->fg_off, &fg_off);
|
||||||
|
xcolor_to_color(&bar->fg, &fg);
|
||||||
|
xcolor_to_color(&bar->fg_center, &fg_center);
|
||||||
|
xcolor_to_color(&bar->fg_end, &fg_end);
|
||||||
|
|
||||||
if(d->ticks_count && d->ticks_gap)
|
if(d->ticks_count && d->ticks_gap)
|
||||||
{
|
{
|
||||||
values_ticks = (int)(d->ticks_count * (bar->value - bar->min_value)
|
values_ticks = (int)(d->ticks_count * (bar->value - bar->min_value)
|
||||||
|
@ -243,8 +257,8 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
||||||
|
|
||||||
if(d->border_padding)
|
if(d->border_padding)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, &bg);
|
||||||
draw_rectangle(ctx, rectangle, d->border_width, false, &bar->border_color);
|
draw_rectangle(ctx, rectangle, d->border_width, false, &border_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_gradient.x = pb_x;
|
color_gradient.x = pb_x;
|
||||||
|
@ -275,10 +289,10 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
|
|
||||||
/* fg color */
|
/* fg color */
|
||||||
if(bar->reverse)
|
if(bar->reverse)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->fg_off);
|
draw_rectangle(ctx, rectangle, 1.0, true, &fg_off);
|
||||||
else
|
else
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
||||||
&bar->fg, &bar->fg_center, &bar->fg_end);
|
&fg, &fg_center, &fg_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* top part */
|
/* top part */
|
||||||
|
@ -292,9 +306,9 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
/* bg color */
|
/* bg color */
|
||||||
if(bar->reverse)
|
if(bar->reverse)
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
||||||
&bar->fg, &bar->fg_center, &bar->fg_end);
|
&fg, &fg_center, &fg_end);
|
||||||
else
|
else
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->fg_off);
|
draw_rectangle(ctx, rectangle, 1.0, true, &fg_off);
|
||||||
}
|
}
|
||||||
/* draw gaps TODO: improve e.g all in one */
|
/* draw gaps TODO: improve e.g all in one */
|
||||||
if(d->ticks_count && d->ticks_gap)
|
if(d->ticks_count && d->ticks_gap)
|
||||||
|
@ -305,7 +319,7 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
for(rectangle.y = pb_y + (unit - d->ticks_gap);
|
for(rectangle.y = pb_y + (unit - d->ticks_gap);
|
||||||
pb_y + pb_height - d->ticks_gap >= rectangle.y;
|
pb_y + pb_height - d->ticks_gap >= rectangle.y;
|
||||||
rectangle.y += unit)
|
rectangle.y += unit)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, &bg);
|
||||||
}
|
}
|
||||||
pb_offset += pb_width + d->gap + 2 * (d->border_width + d->border_padding);
|
pb_offset += pb_width + d->gap + 2 * (d->border_width + d->border_padding);
|
||||||
}
|
}
|
||||||
|
@ -329,6 +343,21 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
for(int i = 0; i < d->bars.len; i++)
|
for(int i = 0; i < d->bars.len; i++)
|
||||||
{
|
{
|
||||||
bar_t *bar = &d->bars.tab[i];
|
bar_t *bar = &d->bars.tab[i];
|
||||||
|
|
||||||
|
color_t bg;
|
||||||
|
color_t fg;
|
||||||
|
color_t fg_off;
|
||||||
|
color_t fg_center;
|
||||||
|
color_t fg_end;
|
||||||
|
color_t border_color;
|
||||||
|
|
||||||
|
xcolor_to_color(&bar->bg, &bg);
|
||||||
|
xcolor_to_color(&bar->fg, &fg);
|
||||||
|
xcolor_to_color(&bar->fg_off, &fg_off);
|
||||||
|
xcolor_to_color(&bar->fg_center, &fg_center);
|
||||||
|
xcolor_to_color(&bar->fg_end, &fg_end);
|
||||||
|
xcolor_to_color(&bar->border_color, &border_color);
|
||||||
|
|
||||||
if(d->ticks_count && d->ticks_gap)
|
if(d->ticks_count && d->ticks_gap)
|
||||||
{
|
{
|
||||||
/* +0.5 rounds up ticks -> turn on a tick when half of it is reached */
|
/* +0.5 rounds up ticks -> turn on a tick when half of it is reached */
|
||||||
|
@ -352,8 +381,8 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
||||||
|
|
||||||
if(d->border_padding)
|
if(d->border_padding)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, &bg);
|
||||||
draw_rectangle(ctx, rectangle, d->border_width, false, &bar->border_color);
|
draw_rectangle(ctx, rectangle, d->border_width, false, &border_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_gradient.y = pb_y;
|
color_gradient.y = pb_y;
|
||||||
|
@ -382,10 +411,10 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
|
|
||||||
/* fg color */
|
/* fg color */
|
||||||
if(bar->reverse)
|
if(bar->reverse)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->fg_off);
|
draw_rectangle(ctx, rectangle, 1.0, true, &fg_off);
|
||||||
else
|
else
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
||||||
&bar->fg, &bar->fg_center, &bar->fg_end);
|
&fg, &fg_center, &fg_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* right part */
|
/* right part */
|
||||||
|
@ -399,9 +428,9 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
/* bg color */
|
/* bg color */
|
||||||
if(bar->reverse)
|
if(bar->reverse)
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, color_gradient,
|
||||||
&bar->fg, &bar->fg_center, &bar->fg_end);
|
&fg, &fg_center, &fg_end);
|
||||||
else
|
else
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->fg_off);
|
draw_rectangle(ctx, rectangle, 1.0, true, &fg_off);
|
||||||
}
|
}
|
||||||
/* draw gaps TODO: improve e.g all in one */
|
/* draw gaps TODO: improve e.g all in one */
|
||||||
if(d->ticks_count && d->ticks_gap)
|
if(d->ticks_count && d->ticks_gap)
|
||||||
|
@ -412,7 +441,7 @@ progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t
|
||||||
for(rectangle.x = pb_x + (unit - d->ticks_gap);
|
for(rectangle.x = pb_x + (unit - d->ticks_gap);
|
||||||
pb_x + pb_width - d->ticks_gap >= rectangle.x;
|
pb_x + pb_width - d->ticks_gap >= rectangle.x;
|
||||||
rectangle.x += unit)
|
rectangle.x += unit)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &bar->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, &bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_offset += pb_height + d->gap + 2 * (d->border_width + d->border_padding);
|
pb_offset += pb_height + d->gap + 2 * (d->border_width + d->border_padding);
|
||||||
|
|
|
@ -84,12 +84,17 @@ static void
|
||||||
textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
|
textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
|
||||||
{
|
{
|
||||||
textbox_data_t *d = widget->data;
|
textbox_data_t *d = widget->data;
|
||||||
|
color_t bg;
|
||||||
|
color_t border_color;
|
||||||
|
|
||||||
if(d->bg.initialized)
|
xcolor_to_color(&d->bg, &bg);
|
||||||
draw_rectangle(ctx, geometry, 1.0, true, &d->bg);
|
xcolor_to_color(&d->border.color, &border_color);
|
||||||
|
|
||||||
|
if(bg.initialized)
|
||||||
|
draw_rectangle(ctx, geometry, 1.0, true, &bg);
|
||||||
|
|
||||||
if(d->border.width > 0)
|
if(d->border.width > 0)
|
||||||
draw_rectangle(ctx, geometry, d->border.width, false, &d->border.color);
|
draw_rectangle(ctx, geometry, d->border.width, false, &border_color);
|
||||||
|
|
||||||
if(d->bg_image)
|
if(d->bg_image)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue