Skip to content

Commit 861e149

Browse files
Rename and simplify object drawing API
1 parent c9649ec commit 861e149

13 files changed

+131
-120
lines changed

lib_nbgl/doc/nbgl_api.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ Once defined and set as children (or sub-children) of the main @ref SCREEN, all
151151
with a simple call to @ref nbgl_screenRedraw().
152152

153153
But if only a given object has been modified since the last redraw, for example by changing its text or its color, it can be redrawn
154-
(with all of its children and sub-children, if any) with a call to @ref nbgl_redrawObject().
154+
(with all of its children and sub-children, if any) with a call to @ref nbgl_objDraw().
155155

156156
The only properties that should not have changed for this object are its dimensions and position.
157157

158-
Except in some specific cases, the previousObj parameter of @ref nbgl_redrawObject() can be set to NULL and computeDimensions set to false.
158+
Except in some specific cases, the previousObj parameter of @ref nbgl_objDraw() can be set to NULL and computeDimensions set to false.
159159

160160
@subsection refresh Refreshing screen
161161

lib_nbgl/include/nbgl_obj.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ enum {
567567
/**********************
568568
* GLOBAL PROTOTYPES
569569
**********************/
570-
void nbgl_redrawObject(nbgl_obj_t *obj, nbgl_obj_t *prevObj, bool computePosition);
571570

572571
void nbgl_refresh(void);
573572
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode);
@@ -576,6 +575,7 @@ bool nbgl_refreshIsNeeded(void);
576575
void nbgl_refreshReset(void);
577576

578577
void nbgl_objInit(void);
578+
void nbgl_objDraw(nbgl_obj_t *obj);
579579
void nbgl_objAllowDrawing(bool enable);
580580

581581
void nbgl_objPoolRelease(uint8_t layer);

lib_nbgl/include/nbgl_screen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typedef struct PACKED__ nbgl_screen_s {
6464
struct nbgl_screen_s *previous; ///< pointer to screen on bottom of this one (or NULL is this
6565
///< screen is bottom of stack)
6666
uint8_t index; ///< index in screenStack array
67+
bool isUxScreen; ///< set to TRUE if allocated by Bolos-UX
6768
} nbgl_screen_t;
6869

6970
/**********************
@@ -84,6 +85,7 @@ void nbgl_screenRedraw(void);
8485
nbgl_obj_t *nbgl_screenGetAt(uint8_t screenIndex);
8586
nbgl_obj_t *nbgl_screenGetTop(void);
8687
uint8_t nbgl_screenGetCurrentStackSize(void);
88+
uint8_t nbgl_screenGetUxStackSize(void);
8789
bool nbgl_screenContainsObj(nbgl_obj_t *obj);
8890
nbgl_obj_t *nbgl_screenContainsObjType(nbgl_screen_t *screen, nbgl_obj_type_t type);
8991

lib_nbgl/src/nbgl_layout.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void touchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
262262
&& (((nbgl_container_t *) obj)->children[1]->type == SWITCH)) {
263263
nbgl_switch_t *lSwitch = (nbgl_switch_t *) ((nbgl_container_t *) obj)->children[1];
264264
lSwitch->state = (lSwitch->state == ON_STATE) ? OFF_STATE : ON_STATE;
265-
nbgl_redrawObject((nbgl_obj_t *) lSwitch, false, false);
265+
nbgl_objDraw((nbgl_obj_t *) lSwitch);
266266
// refresh will be done after tune playback
267267
needRefresh = true;
268268
// index is used for state
@@ -333,7 +333,7 @@ static void longTouchCallback(nbgl_obj_t *obj,
333333
progressBar->previousState = progressBar->state;
334334
progressBar->state = new_state;
335335

336-
nbgl_redrawObject((nbgl_obj_t *) progressBar, false, false);
336+
nbgl_objDraw((nbgl_obj_t *) progressBar);
337337
// Ensure progress bar is fully drawn
338338
// before calling the callback.
339339
nbgl_refreshSpecialWithPostRefresh(BLACK_AND_WHITE_FAST_REFRESH,
@@ -352,7 +352,7 @@ static void longTouchCallback(nbgl_obj_t *obj,
352352
|| (eventType == SWIPED_LEFT) || (eventType == SWIPED_RIGHT)) {
353353
nbgl_wait_pipeline();
354354
progressBar->state = 0;
355-
nbgl_redrawObject((nbgl_obj_t *) progressBar, false, false);
355+
nbgl_objDraw((nbgl_obj_t *) progressBar);
356356
nbgl_refreshSpecialWithPostRefresh(BLACK_AND_WHITE_REFRESH, POST_REFRESH_FORCE_POWER_OFF);
357357
}
358358
}
@@ -387,7 +387,7 @@ static void radioTouchCallback(nbgl_obj_t *obj,
387387
// ensure that radio button is ON
388388
radio->state = ON_STATE;
389389
// redraw container
390-
nbgl_redrawObject((nbgl_obj_t *) obj, NULL, false);
390+
nbgl_objDraw((nbgl_obj_t *) obj);
391391
}
392392
else if ((layout->callbackObjPool[i].obj->type == CONTAINER)
393393
&& (((nbgl_container_t *) layout->callbackObjPool[i].obj)->nbChildren == 2)
@@ -407,7 +407,7 @@ static void radioTouchCallback(nbgl_obj_t *obj,
407407
textArea->textColor = DARK_GRAY;
408408
textArea->fontId = SMALL_REGULAR_FONT;
409409
// redraw container
410-
nbgl_redrawObject((nbgl_obj_t *) layout->callbackObjPool[i].obj, NULL, false);
410+
nbgl_objDraw((nbgl_obj_t *) layout->callbackObjPool[i].obj);
411411
}
412412
}
413413
i++;
@@ -447,7 +447,7 @@ static void spinnerTickerCallback(void)
447447
spinner = (nbgl_spinner_t *) layout->container->children[i];
448448
spinner->position++;
449449
spinner->position &= 3; // modulo 4
450-
nbgl_redrawObject((nbgl_obj_t *) spinner, NULL, false);
450+
nbgl_objDraw((nbgl_obj_t *) spinner);
451451
nbgl_refreshSpecial(BLACK_AND_WHITE_FAST_REFRESH);
452452
return;
453453
}

lib_nbgl/src/nbgl_layout_keyboard.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
218218
if (i < (uint32_t) nbActiveButtons) {
219219
if (updateSuggestionButtons(suggestionsContainer, eventType, i)) {
220220
io_seproxyhal_play_tune(TUNE_TAP_CASUAL);
221-
nbgl_redrawObject((nbgl_obj_t *) suggestionsContainer, NULL, false);
221+
nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
222222
nbgl_refreshSpecial(FULL_COLOR_PARTIAL_REFRESH);
223223
}
224224

@@ -565,7 +565,7 @@ int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout,
565565
keyboard->casing = casing;
566566
}
567567

568-
nbgl_redrawObject((nbgl_obj_t *) keyboard, NULL, false);
568+
nbgl_objDraw((nbgl_obj_t *) keyboard);
569569

570570
return 0;
571571
}
@@ -728,7 +728,7 @@ int nbgl_layoutUpdateSuggestionButtons(nbgl_layout_t *layout,
728728
updateSuggestionButtons(container, 0, 0);
729729
#endif // TARGET_STAX
730730

731-
nbgl_redrawObject((nbgl_obj_t *) container, NULL, false);
731+
nbgl_objDraw((nbgl_obj_t *) container);
732732

733733
return 0;
734734
}
@@ -848,15 +848,15 @@ int nbgl_layoutUpdateEnteredText(nbgl_layout_t *layout,
848848
textArea->text = text;
849849
textArea->textColor = grayedOut ? LIGHT_GRAY : BLACK;
850850
textArea->textAlignment = MID_LEFT;
851-
nbgl_redrawObject((nbgl_obj_t *) textArea, NULL, false);
851+
nbgl_objDraw((nbgl_obj_t *) textArea);
852852

853853
// update number text area
854854
if (numbered) {
855855
// it is the previously created object
856856
textArea = (nbgl_text_area_t *) layoutInt->container->children[1];
857857
snprintf(numText, sizeof(numText), "%d.", number);
858858
textArea->text = numText;
859-
nbgl_redrawObject((nbgl_obj_t *) textArea, NULL, false);
859+
nbgl_objDraw((nbgl_obj_t *) textArea);
860860
}
861861
// if the text doesn't fit, indicate it by returning 1 instead of 0, for different refresh
862862
if (nbgl_getSingleLineTextWidth(textArea->fontId, text) > textArea->obj.area.width) {
@@ -950,7 +950,7 @@ int nbgl_layoutUpdateConfirmationButton(nbgl_layout_t *layout,
950950
button->borderColor = LIGHT_GRAY;
951951
button->innerColor = LIGHT_GRAY;
952952
}
953-
nbgl_redrawObject((nbgl_obj_t *) button, NULL, false);
953+
nbgl_objDraw((nbgl_obj_t *) button);
954954
return 0;
955955
}
956956

@@ -1054,14 +1054,14 @@ int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardC
10541054
// get Word number typed text
10551055
textArea = (nbgl_text_area_t *) container->children[1];
10561056
snprintf(numText, sizeof(numText), "%d.", content->number);
1057-
nbgl_redrawObject((nbgl_obj_t *) textArea, NULL, false);
1057+
nbgl_objDraw((nbgl_obj_t *) textArea);
10581058
}
10591059

10601060
// get text area for entered text
10611061
textArea = (nbgl_text_area_t *) container->children[2];
10621062
textArea->textColor = content->grayedOut ? LIGHT_GRAY : BLACK;
10631063
textArea->text = content->text;
1064-
nbgl_redrawObject((nbgl_obj_t *) textArea, NULL, false);
1064+
nbgl_objDraw((nbgl_obj_t *) textArea);
10651065

10661066
if (content->type == KEYBOARD_WITH_SUGGESTIONS) {
10671067
nbActiveButtons = content->suggestionButtons.nbUsedButtons;
@@ -1091,7 +1091,7 @@ int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardC
10911091
indicator->activePage = 0;
10921092
updateSuggestionButtons(suggestionsContainer, 0, 0);
10931093

1094-
nbgl_redrawObject((nbgl_obj_t *) suggestionsContainer, NULL, false);
1094+
nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
10951095
}
10961096
else if (content->type == KEYBOARD_WITH_BUTTON) {
10971097
// update main text area
@@ -1111,7 +1111,7 @@ int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardC
11111111
button->borderColor = LIGHT_GRAY;
11121112
button->innerColor = LIGHT_GRAY;
11131113
}
1114-
nbgl_redrawObject((nbgl_obj_t *) button, NULL, false);
1114+
nbgl_objDraw((nbgl_obj_t *) button);
11151115
}
11161116

11171117
// if the entered text doesn't fit, indicate it by returning 1 instead of 0, for different

lib_nbgl/src/nbgl_layout_keyboard_nanos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t key
114114
}
115115
}
116116

117-
nbgl_redrawObject((nbgl_obj_t *) keyboard, NULL, false);
117+
nbgl_objDraw((nbgl_obj_t *) keyboard);
118118

119119
return 0;
120120
}
@@ -182,7 +182,7 @@ int nbgl_layoutUpdateEnteredText(nbgl_layout_t *layout, uint8_t index, const cha
182182
return -1;
183183
}
184184
textEntry->text = text;
185-
nbgl_redrawObject((nbgl_obj_t *) textEntry, NULL, false);
185+
nbgl_objDraw((nbgl_obj_t *) textEntry);
186186

187187
return 0;
188188
}

lib_nbgl/src/nbgl_layout_keypad.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout,
158158
keypad->enableBackspace = enableBackspace;
159159
keypad->enableDigits = enableDigits;
160160

161-
nbgl_redrawObject((nbgl_obj_t *) keypad, NULL, false);
161+
nbgl_objDraw((nbgl_obj_t *) keypad);
162162

163163
return 0;
164164
}
@@ -313,7 +313,7 @@ int nbgl_layoutUpdateHiddenDigits(nbgl_layout_t *layout, uint8_t index, uint8_t
313313
}
314314
}
315315

316-
nbgl_redrawObject((nbgl_obj_t *) image, NULL, false);
316+
nbgl_objDraw((nbgl_obj_t *) image);
317317

318318
return 0;
319319
}
@@ -538,7 +538,7 @@ int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout,
538538
}
539539
}
540540

541-
nbgl_redrawObject((nbgl_obj_t *) image, NULL, false);
541+
nbgl_objDraw((nbgl_obj_t *) image);
542542
}
543543
else {
544544
// update main text area (second child of the main container)
@@ -551,7 +551,7 @@ int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout,
551551
textArea->text = text;
552552
textArea->textColor = BLACK;
553553
textArea->textAlignment = MID_LEFT;
554-
nbgl_redrawObject((nbgl_obj_t *) textArea, NULL, false);
554+
nbgl_objDraw((nbgl_obj_t *) textArea);
555555

556556
// if the text doesn't fit, indicate it by returning 1 instead of 0, for different refresh
557557
if (nbgl_getSingleLineTextWidth(textArea->fontId, text) > textArea->obj.area.width) {

lib_nbgl/src/nbgl_layout_keypad_nanos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout,
143143
keypad->enableValidate = enableValidate;
144144
keypad->enableBackspace = enableBackspace;
145145

146-
nbgl_redrawObject((nbgl_obj_t *) keypad, NULL, false);
146+
nbgl_objDraw((nbgl_obj_t *) keypad);
147147

148148
return 0;
149149
}
@@ -260,7 +260,7 @@ int nbgl_layoutUpdateHiddenDigits(nbgl_layout_t *layout, uint8_t index, uint8_t
260260
}
261261
}
262262

263-
nbgl_redrawObject((nbgl_obj_t *) image, NULL, false);
263+
nbgl_objDraw((nbgl_obj_t *) image);
264264

265265
return 0;
266266
}

0 commit comments

Comments
 (0)