Skip to content

Commit 4141b77

Browse files
Merge pull request #752 from LedgerHQ/abo_fix_progress_bar_glitch
Flex/Stax: Progress bar fix
2 parents e26d098 + 412adaf commit 4141b77

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib_nbgl/src/nbgl_obj.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ static void draw_radioButton(nbgl_radio_t *obj, nbgl_obj_t *prevObj, bool comput
665665
static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool computePosition)
666666
{
667667
#ifdef HAVE_SE_TOUCH
668+
669+
#define UNTRACKED_PREVIOUS_STATE 255
670+
668671
uint8_t stroke = 3; // 3 pixels for border
669672

670673
if (computePosition) {
@@ -679,9 +682,14 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool
679682
// inherit background from parent
680683
obj->obj.area.backgroundColor = obj->obj.parent->area.backgroundColor;
681684

682-
// if previous state is not nul, we will just draw the small added part
685+
// `obj->previousState` variable allows to control whether if
686+
// - The progress bar is fully redrawn whatever the progress bar state (`obj->previousState ==
687+
// 0`).
688+
// - The progress bar is partially drawn from previous draw
689+
// (`obj->previousState > 0 and <= 100`). `obj->previousState` is set by the caller before each
690+
// progress bar redraw. The progress bar state is reset otherwise.
683691
if (obj->previousState == 0) {
684-
// draw external part if necessary
692+
// Case of progress bar full draw
685693
if (obj->withBorder) {
686694
nbgl_drawRoundedBorderedRect((nbgl_area_t *) obj,
687695
RADIUS_0_PIXELS,
@@ -694,7 +702,7 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool
694702
(nbgl_area_t *) obj, RADIUS_0_PIXELS, obj->obj.area.backgroundColor);
695703
}
696704
}
697-
else if (obj->previousState == 255) {
705+
else if (obj->previousState == UNTRACKED_PREVIOUS_STATE) {
698706
obj->state = 0;
699707
}
700708

@@ -725,9 +733,10 @@ static void draw_progressBar(nbgl_progress_bar_t *obj, nbgl_obj_t *prevObj, bool
725733
// reset previous state to be sure that in case of full redraw of the screen we redraw the
726734
// full bar
727735
if (obj->previousState) {
728-
obj->previousState = 255;
736+
obj->previousState = UNTRACKED_PREVIOUS_STATE;
737+
obj->previousWidth = barWidth;
729738
}
730-
obj->previousWidth = barWidth;
739+
731740
extendRefreshArea(&barArea);
732741
objRefreshAreaDone = true;
733742
#else // HAVE_SE_TOUCH

0 commit comments

Comments
 (0)