From 2ae387c0339faea7f0e3c66bed615a583a5e1502 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sun, 14 Sep 2014 16:18:28 +0200 Subject: [PATCH] avoid partial drawing of the smooth curve outside the graph area --- src/graph.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/graph.c b/src/graph.c index b68c346..790e26a 100644 --- a/src/graph.c +++ b/src/graph.c @@ -68,19 +68,28 @@ static time_t get_graph_end_time_s(struct psensor **sensors) time_t ret, t; struct psensor *s; struct measure *measures; - int i; + int i, n; ret = 0; while (*sensors) { s = *sensors; measures = s->measures; + if (is_smooth_curves_enabled) + n = 2; + else + n = 0; + for (i = s->values_max_length - 1; i >= 0; i--) { if (measures[i].value != UNKNOWN_DBL_VALUE) { - t = measures[i].time.tv_sec; + if (!n) { + t = measures[i].time.tv_sec; - if (t > ret) - ret = t; + if (t > ret) + ret = t; + } else { + n--; + } } i--; } @@ -133,6 +142,22 @@ static void draw_left_region(cairo_t *cr, struct graph_info *info) cairo_fill(cr); } +static void draw_right_region(cairo_t *cr, struct graph_info *info) +{ + cairo_set_source_rgb(cr, + info->theme_bg_color.red, + info->theme_bg_color.green, + info->theme_bg_color.blue); + + + cairo_rectangle(cr, + info->g_xoff + info->g_width, + 0, + info->g_xoff + info->g_width + GRAPH_H_PADDING, + info->height); + cairo_fill(cr); +} + static void draw_graph_background(cairo_t *cr, struct config *config, @@ -557,6 +582,7 @@ graph_update(struct psensor **sensors, } draw_left_region(cr, &info); + draw_right_region(cr, &info); /* draw min and max temp */ cairo_set_source_rgb(cr, -- 2.7.4