From 85c80148804af2c0d8d7652100ad789292d29be8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 28 Oct 2020 11:13:51 +0100 Subject: [PATCH] gauge: make the needle images to use the styles from LV_GAUGE_PART_PART --- CHANGELOG.md | 1 + src/lv_widgets/lv_gauge.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 307af71a0..95e64e25e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v7.7.1 (04.11.2020) ### Bugfixes - Respect btnmatrix's `one_check` in `lv_btnmatrix_set_btn_ctrl` +- Gauge: make the needle images to use the styles from `LV_GAUGE_PART_PART` ## v7.7.0 (20.10.2020) diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index a555bd5f1..f0203adf2 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -586,8 +586,14 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) uint8_t i; lv_draw_line_dsc_t line_dsc; - lv_draw_line_dsc_init(&line_dsc); - lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc); + lv_draw_img_dsc_t img_dsc; + if(ext->needle_img == NULL) { + lv_draw_line_dsc_init(&line_dsc); + lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc); + } else { + lv_draw_img_dsc_init(&img_dsc); + lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_NEEDLE, &img_dsc); + } p_mid.x = x_ofs; p_mid.y = y_ofs; @@ -616,14 +622,10 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y; a.x2 = a.x1 + info.w - 1; a.y2 = a.y1 + info.h - 1; - lv_draw_img_dsc_t img_dsc; - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc); img_dsc.pivot.x = ext->needle_img_pivot.x; img_dsc.pivot.y = ext->needle_img_pivot.y; - if(ext->needle_colors != NULL) - img_dsc.recolor = ext->needle_colors[i]; + if(ext->needle_colors != NULL) img_dsc.recolor = ext->needle_colors[i]; needle_angle = (needle_angle * 10); if(needle_angle > 3600) needle_angle -= 3600;