rename of fg_middle/fg_half to fg_center and fg_full to fg_end

A hint from maxauthority. The names would be unified now in the progressbar
and the graph widget. And (hopefully) it's easier to guess what they mean now.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
marco candrian 2008-02-06 01:07:27 +01:00 committed by Julien Danjou
parent 7565107205
commit 8567009d22
5 changed files with 56 additions and 54 deletions

View File

@ -252,8 +252,10 @@ This widget shows one or more progress-bars.
Draws a bar; Options: fg, bg, bordercolor. Draws a bar; Options: fg, bg, bordercolor.
*fg*:: *fg*::
Foreground color. Foreground color.
*fg_full*:: *fg_center*::
Foreground color of a full bar (as gradient). Foreground color in the center of the bar (as gradient).
*fg_end*::
Foreground color at the end of a bar (as gradient).
*bg*:: *bg*::
Background color. Background color.
*bordercolor*:: *bordercolor*::
@ -283,10 +285,10 @@ This widget shows a graph.
Re-scales when input > max (see below). Re-scales when input > max (see below).
*fg*:: *fg*::
Foreground color. Foreground color.
*fg_middle*:: *fg_center*::
Color at the middle of the graph Foreground color in the center of the bar (as gradient).
*fg_end*:: *fg_end*::
Color at the end of the graph Foreground color at the end of a bar (as gradient).
*style*:: *style*::
bottom (fills to bottom with fg), top, or line. bottom (fills to bottom with fg), top, or line.
*mouse*:: *mouse*::
@ -476,7 +478,7 @@ screen <integer> [MULTI]
{ {
bar [MULTI] bar [MULTI]
{ {
fg = <color> fg_full = <color> fg_half = <color> fg = <color> fg_center = <color> fg_end = <color>
bg = <color> bordercolor = <color> bg = <color> bordercolor = <color>
} }
gap = <integer> gap = <integer>
@ -495,7 +497,7 @@ screen <integer> [MULTI]
data [MULTI] data [MULTI]
{ {
scale = <boolean> max = <float> style = <{bottom, top, line}> scale = <boolean> max = <float> style = <{bottom, top, line}>
fg = <color> fg_middle = <color> fg_end = <color> fg = <color> fg_center = <color> fg_end = <color>
} }
width = <integer> width = <integer>
height = <float> height = <float>

View File

@ -134,7 +134,7 @@ cfg_opt_t widget_graph_data_opts[] =
CFG_FLOAT((char *) "max", 100.0f, CFGF_NONE), CFG_FLOAT((char *) "max", 100.0f, CFGF_NONE),
CFG_BOOL((char *) "scale", cfg_false, CFGF_NONE), CFG_BOOL((char *) "scale", cfg_false, CFGF_NONE),
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "fg_middle", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg_center", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "fg_end", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg_end", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "style", (char *) "bottom", CFGF_NONE), CFG_STR((char *) "style", (char *) "bottom", CFGF_NONE),
CFG_END() CFG_END()
@ -155,8 +155,8 @@ cfg_opt_t widget_graph_opts[] =
cfg_opt_t widget_progressbar_bar_opts[] = cfg_opt_t widget_progressbar_bar_opts[] =
{ {
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "fg_half", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg_center", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "fg_full", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg_end", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "bordercolor", (char *) NULL, CFGF_NONE), CFG_STR((char *) "bordercolor", (char *) NULL, CFGF_NONE),
CFG_END() CFG_END()

View File

@ -188,25 +188,25 @@ draw_text(DrawCtx *ctx,
* \param y y-offset of widget * \param y y-offset of widget
* \param width width in pixels * \param width width in pixels
* \param color color to use from 0% * \param color color to use from 0%
* \param pcolor_middle color at 50% of width * \param pcolor_center color at 50% of width
* \param pcolor_end color at 100% of width * \param pcolor_end color at 100% of width
* \return pat pattern or NULL; needs to get cairo_pattern_destroy()'ed; * \return pat pattern or NULL; needs to get cairo_pattern_destroy()'ed;
*/ */
cairo_pattern_t * cairo_pattern_t *
setup_cairo_color_source(DrawCtx *ctx, int x, int y, int width, setup_cairo_color_source(DrawCtx *ctx, int x, int y, int width,
XColor color, XColor *pcolor_middle, XColor *pcolor_end) XColor color, XColor *pcolor_center, XColor *pcolor_end)
{ {
cairo_pattern_t *pat; cairo_pattern_t *pat;
if(pcolor_middle || pcolor_end) /* draw a gradient */ if(pcolor_center || pcolor_end) /* draw a gradient */
{ {
pat = cairo_pattern_create_linear(x, y, x + width, y); pat = cairo_pattern_create_linear(x, y, x + width, y);
cairo_pattern_add_color_stop_rgb(pat, 0, color.red / 65535.0, cairo_pattern_add_color_stop_rgb(pat, 0, color.red / 65535.0,
color.green / 65535.0, color.blue / 65535.0); color.green / 65535.0, color.blue / 65535.0);
if(pcolor_middle) if(pcolor_center)
cairo_pattern_add_color_stop_rgb(pat, 0.5, pcolor_middle->red / 65535.0, cairo_pattern_add_color_stop_rgb(pat, 0.5, pcolor_center->red / 65535.0,
pcolor_middle->green / 65535.0, pcolor_middle->blue / 65535.0); pcolor_center->green / 65535.0, pcolor_center->blue / 65535.0);
if(pcolor_end) if(pcolor_end)
cairo_pattern_add_color_stop_rgb(pat, 1, pcolor_end->red / 65535.0, cairo_pattern_add_color_stop_rgb(pat, 1, pcolor_end->red / 65535.0,
pcolor_end->green / 65535.0, pcolor_end->blue / 65535.0); pcolor_end->green / 65535.0, pcolor_end->blue / 65535.0);
@ -252,12 +252,12 @@ draw_rectangle(DrawCtx *ctx, Area geometry, Bool filled, XColor color)
* \param fullwidth width of full bar in pixels * \param fullwidth width of full bar in pixels
* \param filled filled rectangle? * \param filled filled rectangle?
* \param color color to use from 0% * \param color color to use from 0%
* \param pcolor_half color at 50% * \param pcolor_center color at 50%
* \param pcolor_full color at 100% * \param pcolor_end color at 100%
*/ */
void void
draw_rectangle_gradient(DrawCtx *ctx, Area geometry, int fullwidth, Bool filled, draw_rectangle_gradient(DrawCtx *ctx, Area geometry, int fullwidth, Bool filled,
XColor color, XColor *pcolor_half, XColor *pcolor_full) XColor color, XColor *pcolor_center, XColor *pcolor_end)
{ {
cairo_pattern_t *pat; cairo_pattern_t *pat;
@ -265,7 +265,7 @@ draw_rectangle_gradient(DrawCtx *ctx, Area geometry, int fullwidth, Bool filled,
cairo_set_line_width(ctx->cr, 1.0); cairo_set_line_width(ctx->cr, 1.0);
pat = setup_cairo_color_source(ctx, geometry.x, geometry.y, fullwidth, pat = setup_cairo_color_source(ctx, geometry.x, geometry.y, fullwidth,
color, pcolor_half, pcolor_full); color, pcolor_center, pcolor_end);
if(filled) if(filled)
{ {
@ -302,16 +302,16 @@ draw_graph_setup(DrawCtx *ctx)
* \param to array of end-point offsets to draw a graph-lines * \param to array of end-point offsets to draw a graph-lines
* \param cur_index current position in data-array (cycles around) * \param cur_index current position in data-array (cycles around)
* \param color color to use from 0% * \param color color to use from 0%
* \param pcolor_middle color at 50% * \param pcolor_center color at 50%
* \param pcolor_end color at 100% * \param pcolor_end color at 100%
*/ */
void void
draw_graph(DrawCtx *ctx, int x, int y, int w, int *from, int *to, int cur_index, draw_graph(DrawCtx *ctx, int x, int y, int w, int *from, int *to, int cur_index,
XColor color, XColor *pcolor_middle, XColor *pcolor_end) XColor color, XColor *pcolor_center, XColor *pcolor_end)
{ {
int i; int i;
cairo_pattern_t *pat; cairo_pattern_t *pat;
pat = setup_cairo_color_source(ctx, x, y, w, color, pcolor_middle, pcolor_end); pat = setup_cairo_color_source(ctx, x, y, w, color, pcolor_center, pcolor_end);
i = -1; i = -1;
while(++i < w) while(++i < w)
@ -337,18 +337,18 @@ draw_graph(DrawCtx *ctx, int x, int y, int w, int *from, int *to, int cur_index,
* \param to array of offsets to draw the line through... * \param to array of offsets to draw the line through...
* \param cur_index current position in data-array (cycles around) * \param cur_index current position in data-array (cycles around)
* \param color color to use from 0% * \param color color to use from 0%
* \param pcolor_middle color at 50% * \param pcolor_center color at 50%
* \param pcolor_end color at 100% * \param pcolor_end color at 100%
*/ */
void void
draw_graph_line(DrawCtx *ctx, int x, int y, int w, int *to, int cur_index, draw_graph_line(DrawCtx *ctx, int x, int y, int w, int *to, int cur_index,
XColor color, XColor *pcolor_middle, XColor *pcolor_end) XColor color, XColor *pcolor_center, XColor *pcolor_end)
{ {
int i; int i;
int flag = 0; /* used to prevent drawing a line from 0 to 0 values */ int flag = 0; /* used to prevent drawing a line from 0 to 0 values */
cairo_pattern_t *pat; cairo_pattern_t *pat;
pat = setup_cairo_color_source(ctx, x, y, w, color, pcolor_middle, pcolor_end); pat = setup_cairo_color_source(ctx, x, y, w, color, pcolor_center, pcolor_end);
/* x-1 (on the border), paints *from* the last point (... not included itself) */ /* x-1 (on the border), paints *from* the last point (... not included itself) */
/* makes sense when you assume there is already some line drawn to it. */ /* makes sense when you assume there is already some line drawn to it. */

View File

@ -53,17 +53,17 @@ typedef struct
int **fillbottom; /** Datatypes holder (data equal to **lines) */ int **fillbottom; /** Datatypes holder (data equal to **lines) */
int fillbottom_total; /** Total of them */ int fillbottom_total; /** Total of them */
XColor *fillbottom_color; /** Color of them */ XColor *fillbottom_color; /** Color of them */
XColor **fillbottom_pcolor_middle; /** Color at middle of graph */ XColor **fillbottom_pcolor_center; /** Color at middle of graph */
XColor **fillbottom_pcolor_end; /** Color at end of graph */ XColor **fillbottom_pcolor_end; /** Color at end of graph */
int **filltop; /** Datatypes holder */ int **filltop; /** Datatypes holder */
int filltop_total; /** Total of them */ int filltop_total; /** Total of them */
XColor *filltop_color; /** Color of them */ XColor *filltop_color; /** Color of them */
XColor **filltop_pcolor_middle; /** Color at middle of graph */ XColor **filltop_pcolor_center; /** Color at center of graph */
XColor **filltop_pcolor_end; /** Color at end of graph */ XColor **filltop_pcolor_end; /** Color at end of graph */
int **drawline; /** Datatypes holder */ int **drawline; /** Datatypes holder */
int drawline_total; /** Total of them */ int drawline_total; /** Total of them */
XColor *drawline_color; /** Color of them */ XColor *drawline_color; /** Color of them */
XColor **drawline_pcolor_middle; /** Color at middle of graph */ XColor **drawline_pcolor_center; /** Color at middle of graph */
XColor **drawline_pcolor_end; /** Color at end of graph */ XColor **drawline_pcolor_end; /** Color at end of graph */
int *draw_from; /** Preparation/tmp array for draw_graph(); */ int *draw_from; /** Preparation/tmp array for draw_graph(); */
@ -130,7 +130,7 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
draw_graph(ctx, draw_graph(ctx,
left_offset + 2, margin_top + d->box_height + 1, left_offset + 2, margin_top + d->box_height + 1,
d->size, d->draw_from, d->draw_to, d->index, d->size, d->draw_from, d->draw_to, d->index,
d->filltop_color[z], d->filltop_pcolor_middle[z], d->filltop_pcolor_end[z]); d->filltop_color[z], d->filltop_pcolor_center[z], d->filltop_pcolor_end[z]);
} }
/* draw style = bottom */ /* draw style = bottom */
@ -152,7 +152,7 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
draw_graph(ctx, draw_graph(ctx,
left_offset + 2, margin_top + d->box_height + 1, left_offset + 2, margin_top + d->box_height + 1,
d->size, d->draw_from, d->fillbottom[z], d->index, d->size, d->draw_from, d->fillbottom[z], d->index,
d->fillbottom_color[z], d->fillbottom_pcolor_middle[z], d->fillbottom_pcolor_end[z]); d->fillbottom_color[z], d->fillbottom_pcolor_center[z], d->fillbottom_pcolor_end[z]);
} }
/* draw style = line */ /* draw style = line */
@ -161,7 +161,7 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
draw_graph_line(ctx, draw_graph_line(ctx,
left_offset + 2, margin_top + d->box_height + 1, left_offset + 2, margin_top + d->box_height + 1,
d->size, d->drawline[z], d->index, d->size, d->drawline[z], d->index,
d->drawline_color[z], d->drawline_pcolor_middle[z], d->drawline_pcolor_end[z]); d->drawline_color[z], d->drawline_pcolor_center[z], d->drawline_pcolor_end[z]);
} }
widget->area.width = d->width; widget->area.width = d->width;
@ -242,7 +242,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
int i; int i;
char *type; char *type;
XColor tmp_color = { 0, 0, 0, 0, 0, 0 }; XColor tmp_color = { 0, 0, 0, 0, 0, 0 };
XColor *ptmp_color_middle; XColor *ptmp_color_center;
XColor *ptmp_color_end; XColor *ptmp_color_end;
w = p_new(Widget, 1); w = p_new(Widget, 1);
@ -280,13 +280,13 @@ graph_new(Statusbar *statusbar, cfg_t *config)
d->lines = p_new(int *, d->data_items); d->lines = p_new(int *, d->data_items);
d->filltop_color = p_new(XColor, d->data_items); d->filltop_color = p_new(XColor, d->data_items);
d->filltop_pcolor_middle = p_new(XColor *, d->data_items); d->filltop_pcolor_center = p_new(XColor *, d->data_items);
d->filltop_pcolor_end = p_new(XColor *, d->data_items); d->filltop_pcolor_end = p_new(XColor *, d->data_items);
d->fillbottom_color = p_new(XColor, d->data_items); d->fillbottom_color = p_new(XColor, d->data_items);
d->fillbottom_pcolor_middle = p_new(XColor *, d->data_items); d->fillbottom_pcolor_center = p_new(XColor *, d->data_items);
d->fillbottom_pcolor_end = p_new(XColor *, d->data_items); d->fillbottom_pcolor_end = p_new(XColor *, d->data_items);
d->drawline_color = p_new(XColor, d->data_items); d->drawline_color = p_new(XColor, d->data_items);
d->drawline_pcolor_middle = p_new(XColor *, d->data_items); d->drawline_pcolor_center = p_new(XColor *, d->data_items);
d->drawline_pcolor_end = p_new(XColor *, d->data_items); d->drawline_pcolor_end = p_new(XColor *, d->data_items);
d->max_index = p_new(int, d->data_items); d->max_index = p_new(int, d->data_items);
@ -296,7 +296,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
for(i = 0; i < d->data_items; i++) for(i = 0; i < d->data_items; i++)
{ {
ptmp_color_middle = ptmp_color_end = NULL; ptmp_color_center = ptmp_color_end = NULL;
cfg = cfg_getnsec(config, "data", i); cfg = cfg_getnsec(config, "data", i);
@ -305,10 +305,10 @@ graph_new(Statusbar *statusbar, cfg_t *config)
else else
tmp_color = globalconf.screens[statusbar->screen].colors_normal[ColFG]; tmp_color = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((color = cfg_getstr(cfg, "fg_middle"))) if((color = cfg_getstr(cfg, "fg_center")))
{ {
ptmp_color_middle = p_new(XColor, 1); ptmp_color_center = p_new(XColor, 1);
*ptmp_color_middle = draw_color_new(globalconf.display, phys_screen, color); *ptmp_color_center = draw_color_new(globalconf.display, phys_screen, color);
} }
if((color = cfg_getstr(cfg, "fg_end"))) if((color = cfg_getstr(cfg, "fg_end")))
@ -339,7 +339,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
{ {
d->fillbottom[d->fillbottom_total] = d->lines[i]; d->fillbottom[d->fillbottom_total] = d->lines[i];
d->fillbottom_color[d->fillbottom_total] = tmp_color; d->fillbottom_color[d->fillbottom_total] = tmp_color;
d->fillbottom_pcolor_middle[d->fillbottom_total] = ptmp_color_middle; d->fillbottom_pcolor_center[d->fillbottom_total] = ptmp_color_center;
d->fillbottom_pcolor_end[d->fillbottom_total] = ptmp_color_end; d->fillbottom_pcolor_end[d->fillbottom_total] = ptmp_color_end;
d->fillbottom_total++; d->fillbottom_total++;
} }
@ -347,7 +347,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
{ {
d->filltop[d->filltop_total] = d->lines[i]; d->filltop[d->filltop_total] = d->lines[i];
d->filltop_color[d->filltop_total] = tmp_color; d->filltop_color[d->filltop_total] = tmp_color;
d->filltop_pcolor_middle[d->fillbottom_total] = ptmp_color_middle; d->filltop_pcolor_center[d->fillbottom_total] = ptmp_color_center;
d->filltop_pcolor_end[d->fillbottom_total] = ptmp_color_end; d->filltop_pcolor_end[d->fillbottom_total] = ptmp_color_end;
d->filltop_total++; d->filltop_total++;
} }
@ -355,7 +355,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
{ {
d->drawline[d->drawline_total] = d->lines[i]; d->drawline[d->drawline_total] = d->lines[i];
d->drawline_color[d->drawline_total] = tmp_color; d->drawline_color[d->drawline_total] = tmp_color;
d->drawline_pcolor_middle[d->fillbottom_total] = ptmp_color_middle; d->drawline_pcolor_center[d->fillbottom_total] = ptmp_color_center;
d->drawline_pcolor_end[d->fillbottom_total] = ptmp_color_end; d->drawline_pcolor_end[d->fillbottom_total] = ptmp_color_end;
d->drawline_total++; d->drawline_total++;
} }

View File

@ -43,9 +43,9 @@ typedef struct
/** Foreground color */ /** Foreground color */
XColor *fg; XColor *fg;
/** Foreground color when bar is half-full */ /** Foreground color when bar is half-full */
XColor **pfg_half; XColor **pfg_center;
/** Foreground color when bar is full */ /** Foreground color when bar is full */
XColor **pfg_full; XColor **pfg_end;
/** Background color */ /** Background color */
XColor *bg; XColor *bg;
/** Border color */ /** Border color */
@ -97,7 +97,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
rectangle.width = pwidth; rectangle.width = pwidth;
rectangle.height = pb_height - 2; rectangle.height = pb_height - 2;
draw_rectangle_gradient(ctx, rectangle, width - 2, True, d->fg[i], draw_rectangle_gradient(ctx, rectangle, width - 2, True, d->fg[i],
d->pfg_half[i], d->pfg_full[i]); d->pfg_center[i], d->pfg_end[i]);
} }
if(width - 2 - pwidth > 0) /* not filled area */ if(width - 2 - pwidth > 0) /* not filled area */
@ -157,8 +157,8 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
} }
d->fg = p_new(XColor, d->bars); d->fg = p_new(XColor, d->bars);
d->pfg_full = p_new(XColor *, d->bars); d->pfg_end = p_new(XColor *, d->bars);
d->pfg_half = p_new(XColor *, d->bars); d->pfg_center = p_new(XColor *, d->bars);
d->bg = p_new(XColor, d->bars); d->bg = p_new(XColor, d->bars);
d->bordercolor = p_new(XColor, d->bars); d->bordercolor = p_new(XColor, d->bars);
d->percent = p_new(int, d->bars); d->percent = p_new(int, d->bars);
@ -172,16 +172,16 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
else else
d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG]; d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((color = cfg_getstr(cfg, "fg_half"))) if((color = cfg_getstr(cfg, "fg_center")))
{ {
d->pfg_half[i] = p_new(XColor, 1); d->pfg_center[i] = p_new(XColor, 1);
*(d->pfg_half[i]) = draw_color_new(globalconf.display, phys_screen, color); *(d->pfg_center[i]) = draw_color_new(globalconf.display, phys_screen, color);
} }
if((color = cfg_getstr(cfg, "fg_full"))) if((color = cfg_getstr(cfg, "fg_end")))
{ {
d->pfg_full[i] = p_new(XColor, 1); d->pfg_end[i] = p_new(XColor, 1);
*(d->pfg_full[i]) = draw_color_new(globalconf.display, phys_screen, color); *(d->pfg_end[i]) = draw_color_new(globalconf.display, phys_screen, color);
} }
if((color = cfg_getstr(cfg, "bg"))) if((color = cfg_getstr(cfg, "bg")))