Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_page.c
Go to the documentation of this file.
1
5
6#ifdef NBGL_PAGE
7/*********************
8 * INCLUDES
9 *********************/
10#include <string.h>
11#include "nbgl_debug.h"
12#include "nbgl_page.h"
13#include "nbgl_use_case.h"
15#include "glyphs.h"
16#include "os_pic.h"
17
18/*********************
19 * DEFINES
20 *********************/
21// number of value lines taken by the details button of a TAG_VALUE_DETAILS page
22#define NB_LINES_FOR_DETAILS_BUTTON 3
23
24/**********************
25 * TYPEDEFS
26 **********************/
27
28/**********************
29 * STATIC VARIABLES
30 **********************/
31
32/**********************
33 * STATIC PROTOTYPES
34 **********************/
35// The choice buttons of a layout share a single token, both buttons being only distinguished by
36// their index. Rebind the bottom one (index 1) to the given token, so that it can never be
37// reported with the token of the top one.
38static void setChoiceButtonsBottomToken(nbgl_layout_t *layout, uint8_t token)
39{
40 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
41
42 if (layoutInt == NULL) {
43 return;
44 }
45 for (uint8_t i = 0; i < layoutInt->nbUsedCallbackObjs; i++) {
46 layoutObj_t *layoutObj = &layoutInt->callbackObjPool[i];
47 if ((layoutObj->obj != NULL) && (layoutObj->obj->touchId == CHOICE_2_ID)) {
48 layoutObj->token = token;
49 }
50 }
51}
52
53static void addEmptyHeader(nbgl_layout_t *layout, uint16_t height)
54{
55 nbgl_layoutHeader_t headerDesc
56 = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = height};
57 nbgl_layoutAddHeader(layout, &headerDesc);
58}
59
60static void addContent(nbgl_pageContent_t *content,
61 nbgl_layout_t *layout,
62 int availableHeight,
63 bool headerAdded)
64{
65 if (content->title != NULL) {
66 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
67 .separationLine = true,
68 .backAndText.token = content->titleToken,
69 .backAndText.tuneId = content->tuneId,
70 .backAndText.text = content->title};
71 nbgl_layoutAddHeader(layout, &headerDesc);
72 headerAdded = true;
73 }
74 if (content->topRightIcon != NULL) {
76 layout, content->topRightIcon, content->topRightToken, content->tuneId);
77 }
78 switch (content->type) {
79 case INFO_LONG_PRESS: {
80 nbgl_contentCenter_t centeredInfo = {0};
81 centeredInfo.icon = content->infoLongPress.icon;
82 centeredInfo.title = content->infoLongPress.text;
83 centeredInfo.illustrType = ICON_ILLUSTRATION;
84 nbgl_layoutAddContentCenter(layout, &centeredInfo);
88 content->infoLongPress.tuneId);
89 break;
90 }
91 case INFO_BUTTON: {
92 nbgl_contentCenter_t centeredInfo = {0};
93 nbgl_layoutButton_t buttonInfo = {0};
94
95 centeredInfo.icon = content->infoButton.icon;
96 centeredInfo.title = content->infoButton.text;
97 centeredInfo.illustrType = ICON_ILLUSTRATION;
98 nbgl_layoutAddContentCenter(layout, &centeredInfo);
99
100 buttonInfo.onBottom = true;
101 buttonInfo.style = BLACK_BACKGROUND;
102 buttonInfo.text = content->infoButton.buttonText;
103 buttonInfo.token = content->infoButton.buttonToken;
104 buttonInfo.tuneId = content->infoButton.tuneId;
105 nbgl_layoutAddButton(layout, &buttonInfo);
106 break;
107 }
108 case CENTERED_INFO:
109 if (!headerAdded) {
110 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
111 }
112 nbgl_layoutAddCenteredInfo(layout, &content->centeredInfo);
113 break;
114
115 case EXTENDED_CENTER:
116 if (!headerAdded) {
117 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
118 }
120 if (content->extendedCenter.tipBox.text != NULL) {
121 nbgl_layoutUpFooter_t upFooterDesc
122 = {.type = UP_FOOTER_TIP_BOX,
123 .tipBox.text = content->extendedCenter.tipBox.text,
124 .tipBox.icon = content->extendedCenter.tipBox.icon,
125 .tipBox.token = content->extendedCenter.tipBox.token,
126 .tipBox.tuneId = content->extendedCenter.tipBox.tuneId};
127 nbgl_layoutAddUpFooter(layout, &upFooterDesc);
128 }
129 break;
130
131 case TAG_VALUE_LIST:
132 // add a space of 32/40px if no header already added
133 if (!headerAdded) {
134 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
135 }
136 nbgl_layoutAddTagValueList(layout, &content->tagValueList);
137 break;
138 case TAG_VALUE_DETAILS: {
139 // add a space of 32/40px if no header already added
140 if (!headerAdded) {
141 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
142 }
143 // display a button under tag/value
144 nbgl_layoutButton_t buttonInfo = {0};
145 // work on a local copy, so that the caller's content is left untouched and drawing
146 // the same content several times always gives the same page
148 // 0 normally means "no limit", but the value must leave room for the details
149 // button, so use the review limit instead
150 if (tagValueList.nbMaxLinesForValue == 0) {
152 }
153 // remove the lines used by the details button, always keeping at least one line
156 }
157 else {
158 tagValueList.nbMaxLinesForValue = 1;
159 }
160 nbgl_layoutAddTagValueList(layout, &tagValueList);
161 buttonInfo.fittingContent = true;
162 buttonInfo.icon = content->tagValueDetails.detailsButtonIcon;
163 buttonInfo.style = WHITE_BACKGROUND;
164 buttonInfo.text = content->tagValueDetails.detailsButtonText;
165 buttonInfo.token = content->tagValueDetails.detailsButtonToken;
166 buttonInfo.tuneId = content->tagValueDetails.tuneId;
167 nbgl_layoutAddButton(layout, &buttonInfo);
168 break;
169 }
170 case TAG_VALUE_CONFIRM: {
171 nbgl_layoutButton_t buttonInfo = {0};
172 if (!headerAdded) {
173 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
174 }
176 // Always display the details button as a normal button (full width),
177 // even if "Confirm" button is on the same page
178 if (content->tagValueConfirm.detailsButtonText != NULL) {
179 buttonInfo.fittingContent = true;
180 buttonInfo.icon = content->tagValueConfirm.detailsButtonIcon;
181 buttonInfo.style = WHITE_BACKGROUND;
182 buttonInfo.text = content->tagValueConfirm.detailsButtonText;
183 buttonInfo.token = content->tagValueConfirm.detailsButtonToken;
184 buttonInfo.tuneId = content->tagValueConfirm.tuneId;
185 nbgl_layoutAddButton(layout, &buttonInfo);
186 }
187 else if ((content->tagValueConfirm.detailsButtonIcon != NULL)
188 && (content->tagValueConfirm.confirmationText != NULL)) {
189 // On Flex, a small button with only the icon is displayed on the left
190 // of "Confirm"
192 = {.leftIcon = content->tagValueConfirm.detailsButtonIcon,
193 .rightText = content->tagValueConfirm.confirmationText,
194 .leftToken = content->tagValueConfirm.detailsButtonToken,
195 .rightToken = content->tagValueConfirm.confirmationToken,
196 .tuneId = content->tagValueConfirm.tuneId};
197 nbgl_layoutAddHorizontalButtons(layout, &choice);
198 break;
199 }
200 if (content->tagValueConfirm.confirmationText != NULL) {
201 buttonInfo.fittingContent = false;
202 buttonInfo.icon = NULL;
203 buttonInfo.style = BLACK_BACKGROUND;
204 buttonInfo.text = content->tagValueConfirm.confirmationText;
205 buttonInfo.token = content->tagValueConfirm.confirmationToken;
206 buttonInfo.tuneId = content->tagValueConfirm.tuneId;
207 buttonInfo.onBottom = true;
208 nbgl_layoutAddButton(layout, &buttonInfo);
209 }
210 break;
211 }
212 case SWITCHES_LIST: {
213 uint8_t i;
214 for (i = 0; i < content->switchesList.nbSwitches; i++) {
215 availableHeight -= nbgl_layoutAddSwitch(layout, &content->switchesList.switches[i]);
216 // do not draw a separation line if too low in the container
217 if (availableHeight > 10) {
219 }
220 }
221 break;
222 }
223 case INFOS_LIST: {
224 uint8_t i;
225 for (i = 0; i < content->infosList.nbInfos; i++) {
226 // if the extension is valid for this index, use a Text with Alias
227 if ((content->infosList.withExtensions == true)
228 && (content->infosList.infoExtensions != NULL)
229 && (content->infosList.infoExtensions[i].fullValue != NULL)) {
230 availableHeight
232 content->infosList.infoTypes[i],
233 content->infosList.infoContents[i],
234 content->infosList.token,
235 i);
236 }
237 else {
238 availableHeight -= nbgl_layoutAddText(layout,
239 content->infosList.infoTypes[i],
240 content->infosList.infoContents[i]);
241 }
242 // do not draw a separation line if too low in the container
243 if (availableHeight > 10) {
245 }
246 }
247 break;
248 }
249 case CHOICES_LIST:
250 nbgl_layoutAddRadioChoice(layout, &content->choicesList);
251 break;
252 case BARS_LIST: {
253 uint8_t i;
254 for (i = 0; i < content->barsList.nbBars; i++) {
255 nbgl_layoutBar_t bar = {0};
256 bar.text = content->barsList.barTexts[i];
257 bar.iconRight = &PUSH_ICON;
258 bar.token = content->barsList.tokens[i];
259 bar.tuneId = content->barsList.tuneId;
260 availableHeight -= nbgl_layoutAddTouchableBar(layout, &bar);
261 // do not draw a separation line if too low in the container
262 if (availableHeight > 10) {
264 }
265 }
266 break;
267 }
268 }
269}
270
271/**********************
272 * GLOBAL FUNCTIONS
273 **********************/
274
286 const char *text,
287 int tapActionToken)
288{
289 nbgl_layoutDescription_t layoutDescription = {0};
290 nbgl_layout_t *layout;
291 nbgl_layoutCenteredInfo_t centeredInfo = {.text1 = text,
292 .text2 = NULL,
293 .text3 = NULL,
294 .style = LARGE_CASE_INFO,
295 .icon = &CHECK_CIRCLE_ICON,
296 .offsetY = 0};
297
298 layoutDescription.withLeftBorder = true;
299
300 layoutDescription.onActionCallback = onActionCallback;
301 layoutDescription.tapActionText = "";
302 layoutDescription.tapActionToken = tapActionToken;
303 layoutDescription.tapTuneId = TUNE_TAP_CASUAL;
304
305 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
306 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
307 layoutDescription.ticker.tickerValue = ticker->tickerValue;
308 layout = nbgl_layoutGet(&layoutDescription);
309
310 nbgl_layoutAddCenteredInfo(layout, &centeredInfo);
311
312 nbgl_layoutDraw(layout);
313
314 return (nbgl_page_t *) layout;
315}
316
326nbgl_page_t *nbgl_pageDrawSpinner(const char *text, uint8_t initPosition)
327{
328 nbgl_layoutDescription_t layoutDescription = {0};
329 nbgl_layout_t *layout;
330
331 layoutDescription.withLeftBorder = true;
332
333 layout = nbgl_layoutGet(&layoutDescription);
334
335 nbgl_layoutAddSpinner(layout, text, NULL, initPosition);
336
337 nbgl_layoutDraw(layout);
338
339 return (nbgl_page_t *) layout;
340}
341
353 const nbgl_pageInfoDescription_t *info)
354{
355 nbgl_layoutDescription_t layoutDescription = {0};
356 nbgl_layout_t *layout;
357
358 layoutDescription.withLeftBorder = true;
359
360 layoutDescription.onActionCallback = onActionCallback;
361 if (!info->isSwipeable) {
362 layoutDescription.tapActionText = info->tapActionText;
363 layoutDescription.tapActionToken = info->tapActionToken;
364 layoutDescription.tapTuneId = info->tuneId;
365 }
366
367 if (ticker != NULL) {
368 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
369 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
370 layoutDescription.ticker.tickerValue = ticker->tickerValue;
371 }
372 layout = nbgl_layoutGet(&layoutDescription);
373 if (info->isSwipeable) {
374 nbgl_layoutAddSwipe(layout,
375 ((1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT)),
376 info->tapActionText,
377 info->tapActionToken,
378 info->tuneId);
379 }
380 // add an empty header if a top-right button is used or if the tap text is not empty
381 if ((info->topRightStyle != NO_BUTTON_STYLE)
382 || (info->tapActionText && strlen(PIC(info->tapActionText)))) {
383 addEmptyHeader(layout, SMALL_CENTERING_HEADER);
384 }
386
387 // if action button but not QUIT_APP_TEXT bottom button, use a small black button
388 if ((info->actionButtonText != NULL) && (info->bottomButtonStyle != QUIT_APP_TEXT)) {
389 nbgl_layoutButton_t buttonInfo = {.fittingContent = true,
390 .icon = info->actionButtonIcon,
391 .onBottom = false,
392 .style = info->actionButtonStyle,
393 .text = info->actionButtonText,
394 .token = info->bottomButtonsToken,
395 .tuneId = info->tuneId};
396 nbgl_layoutAddButton(layout, &buttonInfo);
397 }
398
399 if (info->footerText != NULL) {
400 nbgl_layoutAddFooter(layout, PIC(info->footerText), info->footerToken, info->tuneId);
401 }
402 if (info->topRightStyle != NO_BUTTON_STYLE) {
403 const nbgl_icon_details_t *icon;
404 if (info->topRightStyle == SETTINGS_ICON) {
405 icon = &WHEEL_ICON;
406 }
407 else if (info->topRightStyle == INFO_ICON) {
408 icon = &INFO_I_ICON;
409 }
410 else if (info->topRightStyle == QUIT_ICON) {
411 icon = &CLOSE_ICON;
412 }
413 else {
415 "nbgl_pageDrawInfo(): unknown topRightStyle %d\n",
416 info->topRightStyle);
417 return NULL;
418 }
419 nbgl_layoutAddTopRightButton(layout, PIC(icon), info->topRightToken, info->tuneId);
420 }
421 if (info->bottomButtonStyle == QUIT_APP_TEXT) {
422 // if action button and QUIT_APP_TEXT bottom button, use a pair of choice buttons
423 if ((info->actionButtonText != NULL)) {
424 nbgl_layoutChoiceButtons_t buttonsInfo = {.topText = info->actionButtonText,
425 .bottomText = "Quit app",
426 .token = info->bottomButtonsToken,
427 .tuneId = info->tuneId,
428 .topIcon = info->actionButtonIcon};
429 buttonsInfo.style = (info->actionButtonStyle == BLACK_BACKGROUND)
432 nbgl_layoutAddChoiceButtons(layout, &buttonsInfo);
433 }
434 else {
435 nbgl_layoutAddFooter(layout, "Quit app", info->bottomButtonsToken, info->tuneId);
436 }
437 }
438 else if (info->bottomButtonStyle != NO_BUTTON_STYLE) {
439 const nbgl_icon_details_t *icon;
440 if (info->bottomButtonStyle == SETTINGS_ICON) {
441 icon = &WHEEL_ICON;
442 }
443 else if (info->bottomButtonStyle == INFO_ICON) {
444 icon = &INFO_I_ICON;
445 }
446 else if (info->bottomButtonStyle == QUIT_ICON) {
447 icon = &CLOSE_ICON;
448 }
449 else {
451 "nbgl_pageDrawInfo(): unknown bottomButtonStyle %d\n",
452 info->bottomButtonStyle);
453 return NULL;
454 }
456 layout, PIC(icon), info->bottomButtonsToken, false, info->tuneId);
457 }
458 nbgl_layoutDraw(layout);
459
460 return (nbgl_page_t *) layout;
461}
462
473{
474 nbgl_layoutDescription_t layoutDescription = {0};
475 nbgl_layout_t *layout;
477 = {.bottomText = (info->cancelText != NULL) ? PIC(info->cancelText) : "Cancel",
478 .token = info->confirmationToken,
479 .topText = PIC(info->confirmationText),
481 .tuneId = info->tuneId};
482
483 layoutDescription.modal = info->modal;
484 layoutDescription.withLeftBorder = true;
485 layoutDescription.onActionCallback = onActionCallback;
486
487 layout = nbgl_layoutGet(&layoutDescription);
488
489 addEmptyHeader(layout, MEDIUM_CENTERING_HEADER);
490 nbgl_layoutAddChoiceButtons(layout, &buttonsInfo);
491 // the cancel button shall use its own token, not the confirmation one
493
495
496 nbgl_layoutDraw(layout);
497
498 return (nbgl_page_t *) layout;
499}
500
512 const nbgl_pageNavigationInfo_t *nav,
513 nbgl_pageContent_t *content,
514 bool modal)
515{
516 nbgl_layoutDescription_t layoutDescription = {0};
517 nbgl_layout_t *layout;
518 int availableHeight = SCREEN_HEIGHT;
519 bool headerAdded = false;
520
521 layoutDescription.modal = modal;
522 layoutDescription.withLeftBorder = true;
523 layoutDescription.onActionCallback = onActionCallback;
524
525 if ((nav != NULL) && (nav->navType == NAV_WITH_TAP)) {
526 layoutDescription.tapActionText = nav->navWithTap.nextPageText;
527 layoutDescription.tapActionToken = nav->navWithTap.nextPageToken;
528 layoutDescription.tapTuneId = nav->tuneId;
529 }
530
531 layout = nbgl_layoutGet(&layoutDescription);
532 if (nav != NULL) {
533 if (nav->navType == NAV_WITH_TAP) {
534 if (nav->skipText == NULL) {
535 availableHeight -= nbgl_layoutAddFooter(
536 layout, nav->navWithTap.quitText, nav->quitToken, nav->tuneId);
537 }
538 else {
539 availableHeight -= nbgl_layoutAddSplitFooter(layout,
540 nav->navWithTap.quitText,
541 nav->quitToken,
542 nav->skipText,
543 nav->skipToken,
544 nav->tuneId);
545 }
546 if (nav->progressIndicator) {
547 availableHeight -= nbgl_layoutAddProgressIndicator(layout,
548 nav->activePage,
549 nav->nbPages,
552 nav->tuneId);
553 headerAdded = true;
554 }
555 }
556 else if (nav->navType == NAV_WITH_BUTTONS) {
557 nbgl_layoutFooter_t footerDesc = {0};
558 bool drawFooter = true;
559
560 if (nav->skipText != NULL) {
561 nbgl_layoutHeader_t headerDesc = {.type = HEADER_RIGHT_TEXT,
562 .separationLine = false,
563 .rightText.text = nav->skipText,
564 .rightText.token = nav->skipToken,
565 .rightText.tuneId = nav->tuneId};
566 availableHeight -= nbgl_layoutAddHeader(layout, &headerDesc);
567 headerAdded = true;
568 }
569 footerDesc.separationLine = true;
570 if (nav->nbPages > 1) {
571 if (nav->navWithButtons.quitText == NULL) {
572 footerDesc.type = FOOTER_NAV;
573 footerDesc.navigation.activePage = nav->activePage;
574 footerDesc.navigation.nbPages = nav->nbPages;
577 footerDesc.navigation.token = nav->navWithButtons.navToken;
578 footerDesc.navigation.tuneId = nav->tuneId;
579 }
580 else {
581 footerDesc.type = FOOTER_TEXT_AND_NAV;
582 footerDesc.textAndNav.text = nav->navWithButtons.quitText;
583 footerDesc.textAndNav.tuneId = nav->tuneId;
584 footerDesc.textAndNav.token = nav->quitToken;
585 footerDesc.textAndNav.navigation.activePage = nav->activePage;
586 footerDesc.textAndNav.navigation.nbPages = nav->nbPages;
590 footerDesc.textAndNav.navigation.withPageIndicator = true;
592 footerDesc.textAndNav.navigation.tuneId = nav->tuneId;
593 }
594 }
595 else if (nav->navWithButtons.quitText != NULL) {
596 // simple footer
597 footerDesc.type = FOOTER_SIMPLE_TEXT;
598 footerDesc.simpleText.text = nav->navWithButtons.quitText;
599 footerDesc.simpleText.token = nav->quitToken;
600 footerDesc.simpleText.tuneId = nav->tuneId;
601 }
602 else {
603 drawFooter = false;
604 }
605 if (drawFooter) {
606 availableHeight -= nbgl_layoutAddExtendedFooter(layout, &footerDesc);
607 }
608
609#ifdef TARGET_STAX
610 if (nav->progressIndicator) {
611 availableHeight -= nbgl_layoutAddProgressIndicator(
612 layout, nav->activePage, nav->nbPages, false, 0, nav->tuneId);
613 headerAdded = true;
614 }
615#endif // TARGET_STAX
616 }
617 }
618 addContent(content, layout, availableHeight, headerAdded);
619 nbgl_layoutDraw(layout);
620
621 return (nbgl_page_t *) layout;
622}
623
634 const nbgl_pageNavigationInfo_t *nav,
635 nbgl_pageContent_t *content)
636{
637 return nbgl_pageDrawGenericContentExt(onActionCallback, nav, content, false);
638}
639
647{
648 int ret;
649
650 LOG_DEBUG(PAGE_LOGGER, "nbgl_pageRelease(): \n");
651 ret = nbgl_layoutRelease((nbgl_layout_t *) page);
652
653 return ret;
654}
655#endif // NBGL_PAGE
@ ICON_ILLUSTRATION
simple icon
@ LARGE_CASE_INFO
text in BLACK and large case (INTER 32px), subText in black in Inter24px
struct nbgl_contentTagValueList_s nbgl_contentTagValueList_t
This structure contains a list of [tag,value] pairs.
@ INFO_LONG_PRESS
a centered info and a long press button
@ EXTENDED_CENTER
a centered content and a possible tip-box
@ CHOICES_LIST
list of choices through radio buttons
@ CENTERED_INFO
a centered info
@ SWITCHES_LIST
list of switches with descriptions
@ TAG_VALUE_DETAILS
a tag/value pair and a small button to get details.
@ INFOS_LIST
list of infos with titles
@ TAG_VALUE_CONFIRM
tag/value pairs and a black button/footer to confirm/cancel.
@ TAG_VALUE_LIST
list of tag/value pairs
@ BARS_LIST
list of touchable bars (with > on the right to go to sub-pages)
@ INFO_BUTTON
a centered info and a simple black button
debug traces management
#define LOG_WARN(__logger,...)
Definition nbgl_debug.h:89
@ PAGE_LOGGER
Definition nbgl_debug.h:36
#define LOG_DEBUG(__logger,...)
Definition nbgl_debug.h:88
struct nbgl_pageContent_s nbgl_pageContent_t
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent).
int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list)
Creates a list of [tag,value] pairs.
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
int nbgl_layoutAddUpFooter(nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *upFooterDesc)
Creates a touchable area on top of the footer of the screen, containing various controls,...
int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText)
Creates an area with given text (in bold) and sub text (in regular).
int nbgl_layoutAddProgressIndicator(nbgl_layout_t *layout, uint8_t activePage, uint8_t nbPages, bool withBack, uint8_t backToken, tune_index_e tuneId)
Creates a kind of navigation bar with an optional <- arrow on the left. This widget is placed on top ...
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout)
adds a separation line on bottom of the last added item
int nbgl_layoutAddRadioChoice(nbgl_layout_t *layout, const nbgl_layoutRadioChoice_t *choices)
Creates a list of radio buttons (on the right).
int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
Creates an area on the center of the main panel, with a possible icon/image, a possible text in black...
int nbgl_layoutAddSplitFooter(nbgl_layout_t *layout, const char *leftText, uint8_t leftToken, const char *rightText, uint8_t rightToken, tune_index_e tuneId)
Creates 2 touchable texts at the footer of the screen, separated with a thin line from the rest of th...
int nbgl_layoutAddTextWithAlias(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t token, uint8_t index)
Creates an area with given text (in bold) and sub text (in regular), with a.
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
int nbgl_layoutAddTouchableBar(nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout)
Creates a touchable bar in main panel.
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
@ BLACK_BACKGROUND
rounded bordered button, with text/icon in white, on black background
int nbgl_layoutAddTopRightButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId)
Creates a Top-right button in the top right corner of the top panel.
@ UP_FOOTER_TIP_BOX
Tip-box.
int nbgl_layoutAddSwipe(nbgl_layout_t *layout, uint16_t swipesMask, const char *text, uint8_t token, tune_index_e tuneId)
Creates a swipe interaction on the main container.
void * nbgl_layout_t
type shared externally
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates a switch with the given text and its state.
int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon a...
@ HEADER_EMPTY
empty space, to have a better vertical centering of centered info
@ HEADER_BACK_AND_TEXT
back key and optional text
@ HEADER_RIGHT_TEXT
touchable text on the right, with a vertical separation line
int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
Creates a rounded button in the main container.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
@ SOFT_ACTION_AND_FOOTER_STYLE
A white button on top of a footer, with a separation line.
@ ROUNDED_AND_FOOTER_STYLE
A black background button on top of a footer.
@ STRONG_ACTION_AND_FOOTER_STYLE
A black button on top of a footer, with a separation line.
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
int nbgl_layoutAddLongPressButton(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a long press button in the main container.
struct nbgl_layoutDescription_s nbgl_layoutDescription_t
Structure containing all information when creating a layout. This structure must be passed as argumen...
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
int nbgl_layoutAddBottomButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, bool separationLine, tune_index_e tuneId)
Creates a centered button at bottom of main container.
@ FOOTER_SIMPLE_TEXT
simple touchable text in bold
@ FOOTER_NAV
navigation bar
@ FOOTER_TEXT_AND_NAV
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet().
int nbgl_layoutAddFooter(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the...
nbgl_contentCenteredInfo_t nbgl_layoutCenteredInfo_t
Deprecated, kept for retro compatibility.
Internal functions/constants of NBGL layout layer.
struct nbgl_layoutInternal_s nbgl_layoutInternal_t
Structure containing all information about the current layout.
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
@ CHOICE_2_ID
Definition nbgl_obj.h:545
static void addContent(nbgl_pageContent_t *content, nbgl_layout_t *layout, int availableHeight, bool headerAdded)
Definition nbgl_page.c:60
static void addEmptyHeader(nbgl_layout_t *layout, uint16_t height)
Definition nbgl_page.c:53
nbgl_page_t * nbgl_pageDrawGenericContent(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
Definition nbgl_page.c:633
int nbgl_pageRelease(nbgl_page_t *page)
Release the page obtained with any of the nbgl_pageDrawXXX() functions.
Definition nbgl_page.c:646
nbgl_page_t * nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const nbgl_pageInfoDescription_t *info)
draw a page with a centered info (icon and/or texts) with a touchable footer, in a potential "tapable...
Definition nbgl_page.c:351
nbgl_page_t * nbgl_pageDrawLedgerInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const char *text, int tapActionToken)
draw a page with a centered text in large case, with a round check icon
Definition nbgl_page.c:284
#define NB_LINES_FOR_DETAILS_BUTTON
Definition nbgl_page.c:22
nbgl_page_t * nbgl_pageDrawConfirmation(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageConfirmationDescription_t *info)
draw a confirmation page, with a centered info (icon and/or text), a button to confirm and a footer t...
Definition nbgl_page.c:471
static void setChoiceButtonsBottomToken(nbgl_layout_t *layout, uint8_t token)
Definition nbgl_page.c:38
nbgl_page_t * nbgl_pageDrawSpinner(const char *text, uint8_t initPosition)
draw a spinner page with the given parameters. The spinner will "rotate" automatically every 800 ms
Definition nbgl_page.c:326
nbgl_page_t * nbgl_pageDrawGenericContentExt(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content, bool modal)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
Definition nbgl_page.c:511
API of the Advanced BOLOS Graphical Library, for predefined pages.
struct nbgl_pageInfoDescription_s nbgl_pageInfoDescription_t
Structure containing all specific information when creating an information page.
void * nbgl_page_t
type shared externally
Definition nbgl_page.h:50
@ NAV_WITH_BUTTONS
move forward and backward with buttons in bottom nav bar
Definition nbgl_page.h:58
@ NAV_WITH_TAP
move forward with "tap" and possibly backward with top left arrow
Definition nbgl_page.h:57
struct nbgl_pageMultiScreensDescription_s nbgl_pageNavigationInfo_t
Structure containing all specific information when creating a multi-screens page.
struct nbgl_pageConfirmationDescription_s nbgl_pageConfirmationDescription_t
Structure containing all specific information when creating a confirmation page.
@ QUIT_APP_TEXT
A full width button with "Quit app" text (only for bottom button).
Definition nbgl_page.h:43
@ INFO_ICON
info (i) icon in the button.
Definition nbgl_page.h:42
@ QUIT_ICON
quit (X) icon in the button.
Definition nbgl_page.h:41
@ NO_BUTTON_STYLE
no button.
Definition nbgl_page.h:39
@ SETTINGS_ICON
settings (wheel) icon in the button.
Definition nbgl_page.h:40
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
@ SWIPED_LEFT
Definition nbgl_types.h:287
@ SWIPED_RIGHT
Definition nbgl_types.h:286
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
#define NB_MAX_LINES_IN_REVIEW
maximum number of lines for value field in review pages
const uint8_t * tokens
array of tokens, one for each bar (nbBars items)
const char *const * barTexts
array of texts for each bar (nbBars items, in black/bold)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when a bar is touched
uint8_t nbBars
number of elements in barTexts and tokens array
This structure contains info to build a centered (vertically and horizontally) area,...
const nbgl_icon_details_t * icon
the icon (can be null)
const char * title
title in black large (can be null)
nbgl_contentIllustrationType_t illustrType
nbgl_contentTipBox_t tipBox
if text field is NULL, no tip-box
nbgl_contentCenter_t contentCenter
centered content (icon + text(s))
const char * buttonText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is touched
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
const nbgl_contentValueExt_t * infoExtensions
uint8_t nbInfos
number of elements in infoTypes and infoContents array
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is touched
const char * longPressText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when details button is touched
const char * confirmationText
text of the confirmation button, if NULL "It matches" is used
uint8_t confirmationToken
the token used as argument of the onActionCallback
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
const char * detailsButtonText
this text is used for "details" button (if NULL, no button)
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
const char * detailsButtonText
this text is used for "details" button
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when details button is touched
const char * text
text of the tip-box
const nbgl_icon_details_t * icon
icon of the tip-box
uint8_t token
token used when tip-box is tapped
tune_index_e tuneId
tune played when tip-box is tapped
const char * fullValue
full string of the value when used as an alias
This structure contains info to build a clickable "bar" with a text and an icon.
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
const nbgl_icon_details_t * iconRight
This structure contains info to build a single button.
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
const char * text
button text
uint8_t token
the token that will be used as argument of the callback
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon for button
nbgl_layoutButtonStyle_t style
bool fittingContent
if set to true, fit the width of button to text, otherwise full width
This structure contains info to build a pair of buttons, one on top of the other.
nbgl_layoutChoiceButtonsStyle_t style
the style of the pair
nbgl_screenTickerConfiguration_t ticker
const char * tapActionText
Light gray text used when main container is "tapable".
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build an extended footer.
struct nbgl_layoutFooter_t::@317013035216204022361376155037350165325274163355::@317110117255175277312206226160312336077163317321 textAndNav
if type is FOOTER_TEXT_AND_NAV
bool separationLine
if true, a separation line is added at the top of this control
nbgl_layoutFooterType_t type
type of footer
nbgl_layoutNavigationBar_t navigation
if type is FOOTER_NAV
const char * text
tune_index_e tuneId
struct nbgl_layoutFooter_t::@317013035216204022361376155037350165325274163355::@343035261056315142010134240160306014300343317053 simpleText
if type is FOOTER_SIMPLE_TEXT
This structure contains info to build a header.
This structure contains info to build a pair of buttons, the small one, with icon,...
layoutObj_t callbackObjPool[LAYOUT_OBJ_POOL_LEN]
uint8_t activePage
index of active page (from 0 to nbPages-1).
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when pressing keys)
bool withBackKey
if set to true, the "back" key is drawn
bool withExitKey
if set to true, an exit button is drawn (X on the left)
uint8_t token
the token that will be used as argument of the callback
uint8_t nbPages
number of pages. (if 0, no navigation)
This structure contains info to build an up-footer (area on top of footer).
const char * cancelText
the text used for cancel action, if NULL a simple X button is used
Definition nbgl_page.h:121
uint8_t confirmationToken
the token used as argument of the onActionCallback
Definition nbgl_page.h:122
bool modal
if true, page is open as a modal
Definition nbgl_page.h:127
const char * confirmationText
text of the confirmation button
Definition nbgl_page.h:120
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
Definition nbgl_page.h:119
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is pressed
Definition nbgl_page.h:126
nbgl_contentTagValueDetails_t tagValueDetails
TAG_VALUE_DETAILS type
const char * title
text for the title of the page (if NULL, no title)
uint8_t topRightToken
token used when top-right button (if not NULL) is touched
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
Definition nbgl_flow.h:69
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
Definition nbgl_flow.h:67
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when title is touched
nbgl_contentBarsList_t barsList
BARS_LIST type
Definition nbgl_flow.h:70
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
Definition nbgl_flow.h:64
nbgl_contentInfoList_t infosList
INFOS_LIST type
Definition nbgl_flow.h:68
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
Definition nbgl_flow.h:65
const nbgl_icon_details_t * topRightIcon
nbgl_contentType_t type
type of page content in the following union
Definition nbgl_flow.h:61
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
Definition nbgl_flow.h:63
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
Definition nbgl_flow.h:66
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
nbgl_layoutButtonStyle_t actionButtonStyle
style of "action" button
Definition nbgl_page.h:171
const char * actionButtonText
if not NULL an "action" button is set under the centered info
Definition nbgl_page.h:169
const char * footerText
if not NULL, add a touchable footer
Definition nbgl_page.h:161
nbgl_pageButtonStyle_t topRightStyle
style to apply to the Top-Right button
Definition nbgl_page.h:156
uint8_t topRightToken
the token that will be used as argument of the onActionCallback
Definition nbgl_page.h:158
bool isSwipeable
if true, main area is swipeable
Definition nbgl_page.h:165
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button/footer is pressed
Definition nbgl_page.h:173
uint8_t footerToken
the token that will be used as argument of the onActionCallback
Definition nbgl_page.h:162
const nbgl_icon_details_t * actionButtonIcon
potential icon of "action" button
Definition nbgl_page.h:170
nbgl_pageButtonStyle_t bottomButtonStyle
style to apply to the Bottom button
Definition nbgl_page.h:157
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
Definition nbgl_page.h:155
uint8_t nbPages
the number of pages to display (if <2, no navigation bar)
Definition nbgl_page.h:98
uint8_t quitToken
the token used as argument of the actionCallback when the footer is touched
Definition nbgl_page.h:100
uint8_t skipToken
if skipText is NULL the token used when right part of footer is touched
Definition nbgl_page.h:108
nbgl_pageNavigationType_t navType
Definition nbgl_page.h:101
uint8_t activePage
the index of the page to display at start-up
Definition nbgl_page.h:97
bool progressIndicator
if set to true, display a progress indicator on top of the page
Definition nbgl_page.h:103
nbgl_pageNavWithButtons_t navWithButtons
structure used when navigation with buttons
Definition nbgl_page.h:111
nbgl_pageNavWithTap_t navWithTap
structure used when navigation with "tap"
Definition nbgl_page.h:110
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when next or back is pressed
Definition nbgl_page.h:105
bool visiblePageIndicator
if set to true, the page indicator will be visible in navigation
Definition nbgl_page.h:85
bool quitButton
if set to true, a quit button (X) is displayed in the nav bar
Definition nbgl_page.h:82
const char * quitText
the text displayed in footer (on the left), used to quit (only on Flex)
Definition nbgl_page.h:89
bool backButton
if set to true, a back button (<-) is displayed in the nav bar
Definition nbgl_page.h:83
const char * quitText
the text displayed in footer, used to quit
Definition nbgl_page.h:74
const char * nextPageText
Definition nbgl_page.h:72
uint8_t nbSwitches
number of elements in switches and tokens array
const nbgl_contentSwitch_t * switches
array of switches (nbSwitches items)