mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
rename specials field "graph_scale" to a generic "scale"
This commit is contained in:
parent
82ef68aafa
commit
1e25633fc1
20
src/conky.c
20
src/conky.c
@ -1296,7 +1296,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
}
|
}
|
||||||
h = specials[special_index].height;
|
h = specials[special_index].height;
|
||||||
bar_usage = specials[special_index].arg;
|
bar_usage = specials[special_index].arg;
|
||||||
scale = specials[special_index].graph_scale;
|
scale = specials[special_index].scale;
|
||||||
by = cur_y - (font_ascent() / 2) - 1;
|
by = cur_y - (font_ascent() / 2) - 1;
|
||||||
|
|
||||||
if (h < font_h) {
|
if (h < font_h) {
|
||||||
@ -1361,7 +1361,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
|
|
||||||
#ifdef MATH
|
#ifdef MATH
|
||||||
usage = specials[special_index].arg;
|
usage = specials[special_index].arg;
|
||||||
scale = specials[special_index].graph_scale;
|
scale = specials[special_index].scale;
|
||||||
angle = (M_PI)*(float)(usage)/scale;
|
angle = (M_PI)*(float)(usage)/scale;
|
||||||
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
|
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
|
||||||
py = (float)(by+(h))-(float)(h)*sin(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
|
#ifdef DEBUG_lol
|
||||||
assert(
|
assert(
|
||||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
(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
|
< w - 1
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
(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
|
> -1
|
||||||
);
|
);
|
||||||
if (specials[special_index].graph[j] == specials[special_index].graph_scale) {
|
if (specials[special_index].graph[j] == specials[special_index].scale) {
|
||||||
assert(
|
assert(
|
||||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
(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
|
== 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_lol */
|
#endif /* DEBUG_lol */
|
||||||
XSetForeground(display, window.gc, tmpcolour[
|
XSetForeground(display, window.gc, tmpcolour[
|
||||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
(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 {
|
} else {
|
||||||
XSetForeground(display, window.gc, tmpcolour[colour_idx++]);
|
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,
|
XDrawLine(display, window.drawable, window.gc,
|
||||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
cur_x + i + 1, by + h, cur_x + i + 1,
|
||||||
round_to_int((double)by + h - specials[special_index].graph[j] *
|
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) /
|
if ((w - i) / ((float) (w - 2) /
|
||||||
(specials[special_index].graph_width)) > j
|
(specials[special_index].graph_width)) > j
|
||||||
&& j < MAX_GRAPH_DEPTH - 3) {
|
&& 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_x += font_ascent() / 2;
|
||||||
cur_y += font_h / 2;
|
cur_y += font_h / 2;
|
||||||
tmp_str = (char *)
|
tmp_str = (char *)
|
||||||
calloc(log10(floor(specials[special_index].graph_scale)) + 4,
|
calloc(log10(floor(specials[special_index].scale)) + 4,
|
||||||
sizeof(char));
|
sizeof(char));
|
||||||
sprintf(tmp_str, "%.1f", specials[special_index].graph_scale);
|
sprintf(tmp_str, "%.1f", specials[special_index].scale);
|
||||||
draw_string(tmp_str);
|
draw_string(tmp_str);
|
||||||
free(tmp_str);
|
free(tmp_str);
|
||||||
cur_x = tmp_x;
|
cur_x = tmp_x;
|
||||||
|
@ -284,7 +284,7 @@ void new_gauge_in_x11(struct text_object *obj, char *buf, int usage)
|
|||||||
s->arg = usage;
|
s->arg = usage;
|
||||||
s->width = g->width;
|
s->width = g->width;
|
||||||
s->height = g->height;
|
s->height = g->height;
|
||||||
s->graph_scale = g->scale;
|
s->scale = g->scale;
|
||||||
}
|
}
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
@ -343,22 +343,22 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!graph->scaled && f > graph->graph_scale) {
|
if (!graph->scaled && f > graph->scale) {
|
||||||
f = graph->graph_scale;
|
f = graph->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
graph->graph[0] = f; /* add new data */
|
graph->graph[0] = f; /* add new data */
|
||||||
/* shift all the data by 1 */
|
/* shift all the data by 1 */
|
||||||
for (i = graph->graph_width - 1; i > 0; i--) {
|
for (i = graph->graph_width - 1; i > 0; i--) {
|
||||||
graph->graph[i] = graph->graph[i - 1];
|
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 */
|
/* 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 */
|
/* 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));
|
s->graph = malloc(s->graph_width * sizeof(double));
|
||||||
memset(s->graph, 0, 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->height = g->height;
|
||||||
s->first_colour = adjust_colours(g->first_colour);
|
s->first_colour = adjust_colours(g->first_colour);
|
||||||
s->last_colour = adjust_colours(g->last_colour);
|
s->last_colour = adjust_colours(g->last_colour);
|
||||||
if (g->scale != 0) {
|
if (g->scale != 0) {
|
||||||
s->scaled = 0;
|
s->scaled = 0;
|
||||||
s->graph_scale = g->scale;
|
s->scale = g->scale;
|
||||||
s->show_scale = 0;
|
s->show_scale = 0;
|
||||||
} else {
|
} else {
|
||||||
s->scaled = 1;
|
s->scaled = 1;
|
||||||
s->graph_scale = 1;
|
s->scale = 1;
|
||||||
s->show_scale = 1;
|
s->show_scale = 1;
|
||||||
}
|
}
|
||||||
s->tempgrad = g->tempgrad;
|
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
|
#ifdef MATH
|
||||||
if (g->flags & SF_SHOWLOG) {
|
if (g->flags & SF_SHOWLOG) {
|
||||||
s->graph_scale = log10(s->graph_scale + 1);
|
s->scale = log10(s->scale + 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
graph_append(s, val, g->flags & SF_SHOWLOG);
|
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->arg = usage;
|
||||||
s->width = b->width;
|
s->width = b->width;
|
||||||
s->height = b->height;
|
s->height = b->height;
|
||||||
s->graph_scale = b->scale;
|
s->scale = b->scale;
|
||||||
}
|
}
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ struct special_t {
|
|||||||
short width;
|
short width;
|
||||||
long arg;
|
long arg;
|
||||||
double *graph;
|
double *graph;
|
||||||
double graph_scale;
|
double scale; /* maximum value */
|
||||||
short show_scale;
|
short show_scale;
|
||||||
int graph_width;
|
int graph_width;
|
||||||
int scaled;
|
int scaled; /* auto adjust maximum */
|
||||||
unsigned long first_colour; // for graph gradient
|
unsigned long first_colour; // for graph gradient
|
||||||
unsigned long last_colour;
|
unsigned long last_colour;
|
||||||
short font_added;
|
short font_added;
|
||||||
|
Loading…
Reference in New Issue
Block a user