From 7d7006b8c45a5dcd56e438e05727d8f24ad20267 Mon Sep 17 00:00:00 2001 From: Arthur Bonnaudet Date: Fri, 23 Aug 2024 17:21:38 +0200 Subject: [PATCH 1/2] Flex/Stax: Fix progress bar glitch Fix a progress bar glitch that appeared when a modal screen appeared on a progress bar. --- lib_nbgl/src/nbgl_obj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index 7ed45423..ce1fb33b 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -725,9 +725,10 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool // reset previous state to be sure that in case of full redraw of the screen we redraw the // full bar if (obj->previousState) { - obj->previousState = 255; + obj->previousState = UNTRACKED_PREVIOUS_STATE; + obj->previousWidth = barWidth; } - obj->previousWidth = barWidth; + extendRefreshArea(&barArea); objRefreshAreaDone = true; #else // HAVE_SE_TOUCH From 412adaf0e2b02b3618a2555c2169b83ffff0c93a Mon Sep 17 00:00:00 2001 From: Arthur Bonnaudet Date: Fri, 23 Aug 2024 17:22:40 +0200 Subject: [PATCH 2/2] Flex/Stax: Progress bar drawing - add comments --- lib_nbgl/src/nbgl_obj.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index ce1fb33b..c9973cea 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -665,6 +665,9 @@ static void draw_radioButton(nbgl_radio_t *obj, nbgl_obj_t *prevObj, bool comput static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool computePosition) { #ifdef HAVE_SE_TOUCH + +#define UNTRACKED_PREVIOUS_STATE 255 + uint8_t stroke = 3; // 3 pixels for border if (computePosition) { @@ -679,9 +682,14 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool // inherit background from parent obj->obj.area.backgroundColor = obj->obj.parent->area.backgroundColor; - // if previous state is not nul, we will just draw the small added part + // `obj->previousState` variable allows to control whether if + // - The progress bar is fully redrawn whatever the progress bar state (`obj->previousState == + // 0`). + // - The progress bar is partially drawn from previous draw + // (`obj->previousState > 0 and <= 100`). `obj->previousState` is set by the caller before each + // progress bar redraw. The progress bar state is reset otherwise. if (obj->previousState == 0) { - // draw external part if necessary + // Case of progress bar full draw if (obj->withBorder) { nbgl_drawRoundedBorderedRect((nbgl_area_t *) obj, RADIUS_0_PIXELS, @@ -694,7 +702,7 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool (nbgl_area_t *) obj, RADIUS_0_PIXELS, obj->obj.area.backgroundColor); } } - else if (obj->previousState == 255) { + else if (obj->previousState == UNTRACKED_PREVIOUS_STATE) { obj->state = 0; }