Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex/Stax: Progress bar fix #752

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib_nbgl/src/nbgl_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -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;
}

Expand Down Expand Up @@ -725,9 +733,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
Expand Down
Loading