1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

rename specials field "graph_scale" to a generic "scale"

This commit is contained in:
Phil Sutter 2009-12-02 00:55:20 +01:00
parent 82ef68aafa
commit 1e25633fc1
3 changed files with 24 additions and 24 deletions

View File

@ -1296,7 +1296,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
}
h = specials[special_index].height;
bar_usage = specials[special_index].arg;
scale = specials[special_index].graph_scale;
scale = specials[special_index].scale;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) {
@ -1361,7 +1361,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
#ifdef MATH
usage = specials[special_index].arg;
scale = specials[special_index].graph_scale;
scale = specials[special_index].scale;
angle = (M_PI)*(float)(usage)/scale;
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
py = (float)(by+(h))-(float)(h)*sin(angle);
@ -1425,25 +1425,25 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
#ifdef DEBUG_lol
assert(
(int)((float)(w - 2) - specials[special_index].graph[j] *
(w - 2) / (float)specials[special_index].graph_scale)
(w - 2) / (float)specials[special_index].scale)
< w - 1
);
assert(
(int)((float)(w - 2) - specials[special_index].graph[j] *
(w - 2) / (float)specials[special_index].graph_scale)
(w - 2) / (float)specials[special_index].scale)
> -1
);
if (specials[special_index].graph[j] == specials[special_index].graph_scale) {
if (specials[special_index].graph[j] == specials[special_index].scale) {
assert(
(int)((float)(w - 2) - specials[special_index].graph[j] *
(w - 2) / (float)specials[special_index].graph_scale)
(w - 2) / (float)specials[special_index].scale)
== 0
);
}
#endif /* DEBUG_lol */
XSetForeground(display, window.gc, tmpcolour[
(int)((float)(w - 2) - specials[special_index].graph[j] *
(w - 2) / (float)specials[special_index].graph_scale)
(w - 2) / (float)specials[special_index].scale)
]);
} else {
XSetForeground(display, window.gc, tmpcolour[colour_idx++]);
@ -1453,7 +1453,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
XDrawLine(display, window.drawable, window.gc,
cur_x + i + 1, by + h, cur_x + i + 1,
round_to_int((double)by + h - specials[special_index].graph[j] *
(h - 1) / specials[special_index].graph_scale));
(h - 1) / specials[special_index].scale));
if ((w - i) / ((float) (w - 2) /
(specials[special_index].graph_width)) > j
&& j < MAX_GRAPH_DEPTH - 3) {
@ -1526,9 +1526,9 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
cur_x += font_ascent() / 2;
cur_y += font_h / 2;
tmp_str = (char *)
calloc(log10(floor(specials[special_index].graph_scale)) + 4,
calloc(log10(floor(specials[special_index].scale)) + 4,
sizeof(char));
sprintf(tmp_str, "%.1f", specials[special_index].graph_scale);
sprintf(tmp_str, "%.1f", specials[special_index].scale);
draw_string(tmp_str);
free(tmp_str);
cur_x = tmp_x;

View File

@ -284,7 +284,7 @@ void new_gauge_in_x11(struct text_object *obj, char *buf, int usage)
s->arg = usage;
s->width = g->width;
s->height = g->height;
s->graph_scale = g->scale;
s->scale = g->scale;
}
#endif /* X11 */
@ -343,22 +343,22 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
#endif
}
if (!graph->scaled && f > graph->graph_scale) {
f = graph->graph_scale;
if (!graph->scaled && f > graph->scale) {
f = graph->scale;
}
graph->graph[0] = f; /* add new data */
/* shift all the data by 1 */
for (i = graph->graph_width - 1; i > 0; i--) {
graph->graph[i] = graph->graph[i - 1];
if (graph->scaled && graph->graph[i - 1] > graph->graph_scale) {
if (graph->scaled && graph->graph[i - 1] > graph->scale) {
/* check if we need to update the scale */
graph->graph_scale = graph->graph[i - 1];
graph->scale = graph->graph[i - 1];
}
}
if (graph->scaled && graph->graph[graph->graph_width] > graph->graph_scale) {
if (graph->scaled && graph->graph[graph->graph_width] > graph->scale) {
/* check if we need to update the scale */
graph->graph_scale = graph->graph[graph->graph_width];
graph->scale = graph->graph[graph->graph_width];
}
}
@ -385,18 +385,18 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
}
s->graph = malloc(s->graph_width * sizeof(double));
memset(s->graph, 0, s->graph_width * sizeof(double));
s->graph_scale = 100;
s->scale = 100;
}
s->height = g->height;
s->first_colour = adjust_colours(g->first_colour);
s->last_colour = adjust_colours(g->last_colour);
if (g->scale != 0) {
s->scaled = 0;
s->graph_scale = g->scale;
s->scale = g->scale;
s->show_scale = 0;
} else {
s->scaled = 1;
s->graph_scale = 1;
s->scale = 1;
s->show_scale = 1;
}
s->tempgrad = g->tempgrad;
@ -405,7 +405,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
} */
#ifdef MATH
if (g->flags & SF_SHOWLOG) {
s->graph_scale = log10(s->graph_scale + 1);
s->scale = log10(s->scale + 1);
}
#endif
graph_append(s, val, g->flags & SF_SHOWLOG);
@ -532,7 +532,7 @@ static void new_bar_in_x11(struct text_object *obj, char *buf, int usage)
s->arg = usage;
s->width = b->width;
s->height = b->height;
s->graph_scale = b->scale;
s->scale = b->scale;
}
#endif /* X11 */

View File

@ -64,10 +64,10 @@ struct special_t {
short width;
long arg;
double *graph;
double graph_scale;
double scale; /* maximum value */
short show_scale;
int graph_width;
int scaled;
int scaled; /* auto adjust maximum */
unsigned long first_colour; // for graph gradient
unsigned long last_colour;
short font_added;