Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_step.c
Go to the documentation of this file.
1
6#ifdef NBGL_STEP
7/*********************
8 * INCLUDES
9 *********************/
10#include <string.h>
11#include "nbgl_debug.h"
12#include "nbgl_step.h"
13#include "glyphs.h"
14#include "os_pic.h"
15#include "os_print.h"
16#ifdef BUILD_SCREENSHOTS
17#include "json_scenario.h"
18#endif // BUILD_SCREENSHOTS
19
20/*********************
21 * DEFINES
22 *********************/
23// string to store the title for a multi-pages text+subtext
24#define TMP_STRING_MAX_LEN 24
25
27#define NB_MAX_LAYERS 3
28
29/**********************
30 * TYPEDEFS
31 **********************/
40
60
70
81
82/**********************
83 * STATIC VARIABLES
84 **********************/
87
88/**********************
89 * VARIABLES
90 **********************/
91#ifdef BUILD_SCREENSHOTS
92// Variables used to store important values (nb lines, bold state etc)
93extern uint16_t last_nb_lines;
94extern uint16_t last_nb_pages;
95extern bool last_bold_state;
96#endif // BUILD_SCREENSHOTS
97
98/**********************
99 * STATIC PROTOTYPES
100 **********************/
101
102static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event);
104
105// returns a non-used step context from the contexts[] array, or NULL if not found
106static StepContext_t *getFreeContext(StepStype_t type, bool modal)
107{
108 StepContext_t *ctx = NULL;
109
110 if (!modal) {
111 // Index 0 is reserved for background
112 ctx = &contexts[0];
113 }
114 else {
115 uint32_t i = 1;
116 while (i < NB_MAX_LAYERS) {
117 if (contexts[i].layout == NULL) {
118 ctx = &contexts[i];
119 break;
120 }
121 i++;
122 }
123 }
124 if (ctx == NULL) {
125 LOG_FATAL(STEP_LOGGER, "getFreeContext(): no available context\n");
126 }
127 else {
128 memset(ctx, 0, sizeof(StepContext_t));
129 ctx->type = type;
130 ctx->modal = modal;
131 }
132 return ctx;
133}
134
135// returns the step context from the contexts[] array matching with the given layout handler, or
136// NULL if not found
138{
139 StepContext_t *ctx = NULL;
140 uint32_t i = 0;
141 while (i < NB_MAX_LAYERS) {
142 if (contexts[i].layout == layout) {
143 ctx = &contexts[i];
144 break;
145 }
146 i++;
147 }
148 if (ctx == NULL) {
149 LOG_WARN(STEP_LOGGER, "getContextFromLayout(): no matching context\n");
150 }
151 return ctx;
152}
153
154// from the current details context, return a pointer on the details at the given page
155static const char *getTextPageAt(StepContext_t *ctx, uint8_t textPage)
156{
157 uint8_t page = 0;
158 const char *currentChar = ctx->textContext.txtStart;
159 while (page < textPage) {
160 if (page < (ctx->textContext.nbPages - 1)) {
161 uint16_t len;
163 currentChar,
166 &len,
167 true);
168 currentChar = currentChar + len;
169 }
170 page++;
171 }
172 return currentChar;
173}
174
175// from the current details context, return a pointer on the details at the given page, for subText
176static const char *getSubTextPageAt(StepContext_t *ctx, uint8_t textPage)
177{
178 uint8_t page = 0;
179 const char *currentChar = ctx->textContext.subTxtStart;
180 while (page < textPage) {
181 if (page < (ctx->textContext.nbPages - 1)) {
182 uint16_t len;
184 currentChar,
186 NB_MAX_LINES - 1,
187 &len,
188 true);
189 currentChar = currentChar + len;
190 }
191 page++;
192 }
193 return currentChar;
194}
195
196// utility function to compute navigation arrows
198 uint8_t nbPages,
199 uint8_t currentPage)
200{
202
203 if (nbPages > 1) {
204 if (currentPage > 0) {
205 indication |= LEFT_ARROW;
206 }
207 if (currentPage < (nbPages - 1)) {
208 indication |= RIGHT_ARROW;
209 }
210 }
211 if (pos == FIRST_STEP) {
212 indication |= RIGHT_ARROW;
213 }
214 else if (pos == LAST_STEP) {
215 indication |= LEFT_ARROW;
216 }
217 else if (pos == NEITHER_FIRST_NOR_LAST_STEP) {
218 indication |= RIGHT_ARROW | LEFT_ARROW;
219 }
220 return indication;
221}
222
223// function used to display the current page in details review mode
224static void displayTextPage(StepContext_t *ctx, uint8_t textPage)
225{
226 const char *txt;
227 char intermediateString[36]; // a bit bigger but we know that one line cannot contain
228 // more than 23 chars
229
230 // if move backward or first page
231 if (textPage <= ctx->textContext.currentPage) {
232 // recompute current start from beginning
233 if (ctx->textContext.subTxtStart == NULL) {
234 txt = getTextPageAt(ctx, textPage);
235 }
236 else {
237 txt = getSubTextPageAt(ctx, textPage);
238 }
239 }
240 // else move forward
241 else {
242 txt = ctx->textContext.nextPageStart;
243 }
244 ctx->textContext.currentPage = textPage;
245
246 if (ctx->textContext.currentPage < (ctx->textContext.nbPages - 1)) {
247 uint16_t len;
248 uint8_t nbLines
249 = (ctx->textContext.subTxtStart == NULL) ? NB_MAX_LINES : (NB_MAX_LINES - 1);
251 BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp, txt, AVAILABLE_WIDTH, nbLines, &len, true);
252 // memorize next position to save processing
253 ctx->textContext.nextPageStart = txt + len;
254 // if the next char is '\n', skip it to avoid starting with an empty line
255 if (*ctx->textContext.nextPageStart == '\n') {
257 }
258 }
259 else {
260 ctx->textContext.nextPageStart = NULL;
261 }
262 nbgl_layoutDescription_t layoutDescription = {0};
263 nbgl_layoutNavigation_t navInfo = {
265 };
266
267 layoutDescription.modal = ctx->modal;
268 layoutDescription.onActionCallback = actionCallback;
269 layoutDescription.ticker.tickerCallback = ctx->ticker.tickerCallback;
270 layoutDescription.ticker.tickerIntervale = ctx->ticker.tickerIntervale;
271 layoutDescription.ticker.tickerValue = ctx->ticker.tickerValue;
272 ctx->layout = nbgl_layoutGet(&layoutDescription);
273
276
277 if (ctx->textContext.subTxtStart == NULL) {
278 nbgl_layoutAddText(ctx->layout, txt, NULL, ctx->textContext.style);
279 }
280 else {
281 if (ctx->textContext.nbPages == 1) {
282 // truncate title to fit in one line, if necessary
286 false)
287 > 1) {
291 1,
294 }
295 else {
296 if (ctx->textContext.txtStart != NULL) {
297 // simply copy
298 memcpy(ctx->textContext.tmpString,
302 }
303 else {
304 ctx->textContext.tmpString[0] = 0;
305 }
306 }
307 }
308 else {
309 SPRINTF(intermediateString,
310 "%s (%d/%d)",
312 ctx->textContext.currentPage + 1,
313 ctx->textContext.nbPages);
314 // truncate title to fit in one line, if necessary
316 intermediateString,
318 false)
319 > 1) {
321 intermediateString,
323 1,
326 }
327 else {
328 // simply copy
329 memcpy(ctx->textContext.tmpString, intermediateString, TMP_STRING_MAX_LEN - 1);
331 }
332 }
334 }
335 if (navInfo.indication != NO_ARROWS) {
336 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
337 }
339 nbgl_refresh();
340}
341
342// callback on key touch
344{
345 StepContext_t *ctx = getContextFromLayout(layout);
346
347 if (!ctx) {
348 LOG_WARN(STEP_LOGGER, "actionCallback(): ctx not found\n");
349 return;
350 }
351 if (event == BUTTON_LEFT_PRESSED) {
352 if (ctx->textContext.currentPage > 0) {
354 return;
355 }
356 else if ((ctx->textContext.pos == LAST_STEP)
358 || (ctx->textContext.actionOnAnyButton)) {
359 if (ctx->textContext.onActionCallback != NULL) {
360 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
361 }
362 }
363 }
364 else if (event == BUTTON_RIGHT_PRESSED) {
365 if (ctx->textContext.currentPage < (ctx->textContext.nbPages - 1)) {
367 return;
368 }
369 else if ((ctx->textContext.pos == FIRST_STEP)
371 || (ctx->textContext.actionOnAnyButton)) {
372 if (ctx->textContext.onActionCallback != NULL) {
373 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
374 }
375 }
376 }
377 else if (event == BUTTON_BOTH_PRESSED) {
378 if (ctx->textContext.onActionCallback != NULL) {
379 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
380 }
381 }
382}
383
385{
386 nbgl_layoutDescription_t layoutDescription
387 = {.modal = ctx->modal, .onActionCallback = menuListActionCallback};
389
390 layoutDescription.ticker.tickerCallback = ctx->ticker.tickerCallback;
391 layoutDescription.ticker.tickerIntervale = ctx->ticker.tickerIntervale;
392 layoutDescription.ticker.tickerValue = ctx->ticker.tickerValue;
393
394 ctx->layout = nbgl_layoutGet(&layoutDescription);
395 nbgl_layoutAddMenuList(ctx->layout, list);
396 if (list->nbChoices > 1) {
398 navInfo.indication = 0;
399 if (list->selectedChoice > 0) {
400 navInfo.indication |= LEFT_ARROW;
401 }
402 if (list->selectedChoice < (list->nbChoices - 1)) {
403 navInfo.indication |= RIGHT_ARROW;
404 }
405
406 if (navInfo.indication != NO_ARROWS) {
407 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
408 }
409 }
411 nbgl_refresh();
412}
413
414// callback on key touch
416{
417 StepContext_t *ctx = getContextFromLayout(layout);
418 if (!ctx) {
419 LOG_WARN(STEP_LOGGER, "menuListActionCallback(): ctx not found\n");
420 return;
421 }
422
423 if (event == BUTTON_LEFT_PRESSED) {
424 if (ctx->menuListContext.list.selectedChoice > 0) {
426 displayMenuList(ctx);
427 }
428 }
429 else if (event == BUTTON_RIGHT_PRESSED) {
432 displayMenuList(ctx);
433 }
434 }
435 else if (event == BUTTON_BOTH_PRESSED) {
437 }
438}
439
440/**********************
441 * GLOBAL FUNCTIONS
442 **********************/
443
459 nbgl_stepButtonCallback_t onActionCallback,
461 const char *text,
462 const char *subText,
464 bool modal)
465{
466#ifdef BUILD_SCREENSHOTS
467 // Initialize a default area
468 nbgl_area_t area = {0};
469 area.x0 = area.y0 = 0;
470 area.width = AVAILABLE_WIDTH;
472#endif // BUILD_SCREENSHOTS
474 if (!ctx) {
475 LOG_WARN(STEP_LOGGER, "nbgl_stepDrawText(): no free context\n");
476 return NULL;
477 }
478 // initialize context (already set to 0 by getFreeContext())
479 ctx->textContext.onActionCallback = onActionCallback;
480 if (ticker) {
481 ctx->ticker.tickerCallback = ticker->tickerCallback;
482 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
483 ctx->ticker.tickerValue = ticker->tickerValue;
484 }
485
486 // if no subText, get the number of pages for main text
487 if (subText == NULL) {
490#ifdef BUILD_SCREENSHOTS
491 store_string_infos(text,
493 &area,
494 true,
495 last_nb_lines,
496 last_nb_pages,
497 last_bold_state);
498#endif // BUILD_SCREENSHOTS
499 }
500 else {
501#ifdef BUILD_SCREENSHOTS
502 uint16_t nb_lines_title;
503 // Call this function to get correct nb_lines/nb_pages for text field.
506 nb_lines_title = last_nb_lines;
507 // There is a sub text, so no more than 3 lines for title...
508 if (nb_lines_title > 3) {
509 nb_lines_title = 3;
510 }
511 area.height
513 store_string_infos(text,
515 &area,
516 true,
517 last_nb_lines,
518 last_nb_pages,
519 last_bold_state);
520#endif // BUILD_SCREENSHOTS
521 // NB_MAX_LINES-1 because first line is for main text
524#ifdef BUILD_SCREENSHOTS
525 area.height = (NB_MAX_LINES - nb_lines_title)
527 // If subTxtid is not valid, we'll use txtId for nb_lines/nb_pages values
528 store_string_infos(subText,
530 &area,
531 true,
532 last_nb_lines,
533 last_nb_pages,
534 last_bold_state);
535#endif // BUILD_SCREENSHOTS
536 }
538 "nbgl_stepDrawText: ctx = %p, nbPages = %d, pos = 0x%X\n",
539 ctx,
540 ctx->textContext.nbPages,
541 pos);
542 if (pos & BACKWARD_DIRECTION) {
543 // start with last page
545 }
546 ctx->textContext.txtStart = text;
547 ctx->textContext.subTxtStart = subText;
548 // keep only direction part of position
551 ctx->textContext.style = style;
553
554 return (nbgl_step_t) ctx;
555}
556
568 nbgl_stepButtonCallback_t onActionCallback,
571 bool modal)
572{
573 nbgl_layoutDescription_t layoutDescription
574 = {.modal = modal, .onActionCallback = (nbgl_layoutButtonCallback_t) actionCallback};
575 nbgl_layoutNavigation_t navInfo = {
577 };
579 if (!ctx) {
580 LOG_WARN(STEP_LOGGER, "nbgl_stepDrawCenteredInfo(): no free context\n");
581 return NULL;
582 }
583
584 // initialize context (already set to 0 by getFreeContext())
585 ctx->textContext.onActionCallback = onActionCallback;
586 if (ticker) {
587 ctx->ticker.tickerCallback = ticker->tickerCallback;
588 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
589 ctx->ticker.tickerValue = ticker->tickerValue;
590 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
591 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
592 layoutDescription.ticker.tickerValue = ticker->tickerValue;
593 }
594
595 ctx->textContext.nbPages = 1;
596 // keep only direction part of position
597 ctx->textContext.pos = pos & (RIGHT_ARROW | LEFT_ARROW);
600
601 ctx->layout = nbgl_layoutGet(&layoutDescription);
603 if (navInfo.indication != NO_ARROWS) {
604 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
605 }
607 nbgl_refresh();
608
609 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawCenteredInfo(): step = %p\n", ctx);
610 return (nbgl_step_t) ctx;
611}
612
626 bool modal)
627{
629 if (!ctx) {
630 LOG_WARN(STEP_LOGGER, "nbgl_stepDrawMenuList(): no free context\n");
631 return NULL;
632 }
633
634 // initialize context (already set to 0 by getFreeContext())
635 if (ticker) {
636 ctx->ticker.tickerCallback = ticker->tickerCallback;
637 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
638 ctx->ticker.tickerValue = ticker->tickerValue;
639 }
640
644 ctx->menuListContext.selectedCallback = onActionCallback;
645
646 displayMenuList(ctx);
647
648 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawMenuList(): step = %p\n", ctx);
649
650 return (nbgl_step_t) ctx;
651}
652
660{
661 StepContext_t *ctx = (StepContext_t *) step;
662 if (!ctx) {
663 return 0;
664 }
665 return (ctx->menuListContext.list.selectedChoice);
666}
667
681 nbgl_stepButtonCallback_t onActionCallback,
683 nbgl_layoutSwitch_t *switchInfo,
684 bool modal)
685{
686 nbgl_layoutDescription_t layoutDescription
687 = {.modal = modal, .onActionCallback = (nbgl_layoutButtonCallback_t) actionCallback};
688 nbgl_layoutNavigation_t navInfo = {
690 };
692 if (!ctx) {
693 LOG_WARN(STEP_LOGGER, "nbgl_stepDrawSwitch(): no free context\n");
694 return NULL;
695 }
696
697 // initialize context (already set to 0 by getFreeContext())
698 ctx->textContext.onActionCallback = onActionCallback;
699 if (ticker) {
700 ctx->ticker.tickerCallback = ticker->tickerCallback;
701 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
702 ctx->ticker.tickerValue = ticker->tickerValue;
703 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
704 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
705 layoutDescription.ticker.tickerValue = ticker->tickerValue;
706 }
707
708 ctx->textContext.nbPages = 1;
709 // keep only direction part of position
710 ctx->textContext.pos = pos & (RIGHT_ARROW | LEFT_ARROW);
713
714 ctx->layout = nbgl_layoutGet(&layoutDescription);
715 nbgl_layoutAddSwitch(ctx->layout, switchInfo);
716 if (navInfo.indication != NO_ARROWS) {
717 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
718 }
720 nbgl_refresh();
721
722 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawSwitch(): ctx = %p\n", ctx);
723 return (nbgl_step_t) ctx;
724}
725
733{
734 StepContext_t *ctx = (StepContext_t *) step;
735 int ret;
736
737 LOG_DEBUG(STEP_LOGGER, "nbgl_stepRelease(): ctx = %p\n", ctx);
738 if (!ctx) {
739 return -1;
740 }
742
743 ctx->layout = NULL;
744
745 return ret;
746}
747
748#endif // NBGL_STEP
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
debug traces management
#define LOG_WARN(__logger,...)
Definition nbgl_debug.h:87
@ STEP_LOGGER
Definition nbgl_debug.h:40
#define LOG_DEBUG(__logger,...)
Definition nbgl_debug.h:86
#define LOG_FATAL(__logger,...)
Definition nbgl_debug.h:88
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
@ BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
Definition nbgl_fonts.h:150
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
Definition nbgl_fonts.h:148
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
#define NB_MAX_LINES
int nbgl_layoutAddMenuList(nbgl_layout_t *layout, nbgl_layoutMenuList_t *list)
Creates a menu list (only for nanos) with the given parameters. The navigation (and selection) must b...
@ VERTICAL_NAV
'\/' and '/\' are displayed, to navigate in a list (vertical scrolling)
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
nbgl_layoutNavIndication_t
possible styles for Navigation arrows (it's a bit field)
@ NO_ARROWS
@ LEFT_ARROW
left arrow is used
@ RIGHT_ARROW
right arrow is used
int nbgl_layoutAddNavigation(nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
Creates navigation arrows on side(s) of the screen.
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_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style)
Creates an area with given text and sub text, using the given style.
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
#define AVAILABLE_WIDTH
void * nbgl_layout_t
type shared externally
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates an area in main panel to display a switch.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
void(* nbgl_layoutButtonCallback_t)(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
void nbgl_refresh(void)
nbgl_buttonEvent_t
Definition nbgl_obj.h:193
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
Definition nbgl_obj.h:200
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
Definition nbgl_obj.h:194
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
Definition nbgl_obj.h:195
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
#define NB_MAX_LAYERS
Definition nbgl_step.c:27
static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
Definition nbgl_step.c:343
static void displayMenuList(StepContext_t *ctx)
Definition nbgl_step.c:384
uint8_t nbgl_stepGetMenuListCurrent(nbgl_step_t step)
Get the index of the currently selected item in the menulist.
Definition nbgl_step.c:659
#define TMP_STRING_MAX_LEN
Maximum number of layers for steps, cannot be greater than max number of layout layers.
Definition nbgl_step.c:24
static const char * getTextPageAt(StepContext_t *ctx, uint8_t textPage)
Definition nbgl_step.c:155
struct StepContext_s StepContext_t
nbgl_step_t nbgl_stepDrawSwitch(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutSwitch_t *switchInfo, bool modal)
draw a step page with a switch and navigation arrows to navigate to other pages.
Definition nbgl_step.c:680
static nbgl_layoutNavIndication_t getNavigationInfo(nbgl_stepPosition_t pos, uint8_t nbPages, uint8_t currentPage)
Definition nbgl_step.c:197
static StepContext_t * getFreeContext(StepStype_t type, bool modal)
Definition nbgl_step.c:106
static void displayTextPage(StepContext_t *ctx, uint8_t textPage)
Definition nbgl_step.c:224
struct TextContext_s TextContext_t
nbgl_step_t nbgl_stepDrawMenuList(nbgl_stepMenuListCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutMenuList_t *list, bool modal)
draw a step page with a menu list and navigation arrows to parse it. This step must be alone
Definition nbgl_step.c:623
static StepContext_t contexts[NB_MAX_LAYERS]
< array of step contexts. Index 0 is reserved for background
Definition nbgl_step.c:86
static const char * getSubTextPageAt(StepContext_t *ctx, uint8_t textPage)
Definition nbgl_step.c:176
int nbgl_stepRelease(nbgl_step_t step)
Release the step obtained with any of the nbgl_stepDrawXXX() functions.
Definition nbgl_step.c:732
StepStype_t
Definition nbgl_step.c:35
@ CENTERED_INFO_STEP
for a centered info step
Definition nbgl_step.c:37
@ MENU_LIST_STEP
for a menu list step
Definition nbgl_step.c:38
@ TEXT_STEP
for a simple text step
Definition nbgl_step.c:36
static void menuListActionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
Definition nbgl_step.c:415
struct MenuListContext_s MenuListContext_t
static StepContext_t * getContextFromLayout(nbgl_layout_t layout)
Definition nbgl_step.c:137
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal)
draws a text type step, that can be multi-pages, depending of the length of text and subText....
Definition nbgl_step.c:458
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
draw a step with a centered info (icon + text). This is always a single page step
Definition nbgl_step.c:567
Step construction API of NBGL.
void(* nbgl_stepButtonCallback_t)(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
Definition nbgl_step.h:57
void * nbgl_step_t
type shared externally
Definition nbgl_step.h:44
uint8_t nbgl_stepPosition_t
this type is a bitfield containing:
Definition nbgl_step.h:88
#define STEP_POSITION_MASK
Definition nbgl_step.h:79
#define ACTION_ON_ANY_BUTTON
When action callback applies only on both button press.
Definition nbgl_step.h:75
@ NEITHER_FIRST_NOR_LAST_STEP
neither first nor last in a multiple steps flow
Definition nbgl_step.h:67
@ LAST_STEP
last in a multiple steps flow
Definition nbgl_step.h:66
@ FIRST_STEP
first in a multiple steps flow
Definition nbgl_step.h:65
void(* nbgl_stepMenuListCallback_t)(uint8_t choiceIndex)
prototype of chosen menu list item callback
Definition nbgl_step.h:50
#define BACKWARD_DIRECTION
When action callback applies on any button press.
Definition nbgl_step.h:73
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.
nbgl_layoutMenuList_t list
structure to store the number of menu items and the way to select them
Definition nbgl_step.c:68
nbgl_stepMenuListCallback_t selectedCallback
function to call when a menu list item is selected
Definition nbgl_step.c:66
StepStype_t type
type of step
Definition nbgl_step.c:78
TextContext_t textContext
if type is TEXT_STEP or CENTERED_INFO_STEP
Definition nbgl_step.c:73
nbgl_layout_t * layout
handler of the used layout
Definition nbgl_step.c:77
nbgl_screenTickerConfiguration_t ticker
structure containing information about ticker
Definition nbgl_step.c:76
bool modal
true if modal
Definition nbgl_step.c:79
MenuListContext_t menuListContext
if type is MENU_LIST_STEP
Definition nbgl_step.c:74
const char * nextPageStart
pointer on the start point of text at the next page
Definition nbgl_step.c:48
char tmpString[TMP_STRING_MAX_LEN]
Definition nbgl_step.c:55
nbgl_contentCenteredInfoStyle_t style
style to be used with a CENTERED_INFO_STEP step
Definition nbgl_step.c:58
const char * txtStart
pointer on the start point of text (first page)
Definition nbgl_step.c:47
nbgl_stepPosition_t pos
position of the step within a flow (used for navigation arrows)
Definition nbgl_step.c:51
uint8_t currentPage
current page for this text step
Definition nbgl_step.c:46
const char * subTxtStart
pointer on the start point of sub-text (first page)
Definition nbgl_step.c:49
bool actionOnAnyButton
if true, action applies on any button
Definition nbgl_step.c:52
uint8_t nbPages
number of pages for this text step
Definition nbgl_step.c:45
nbgl_stepButtonCallback_t onActionCallback
Definition nbgl_step.c:53
This structure contains info to build a centered (vertically and horizontally) area,...
This structure contains info to build a switch (on the right) with a description (on the left),...
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_screenTickerConfiguration_t ticker
nbgl_layoutButtonCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains a list of names to build a menu list on Nanos, with for each item a descripti...
nbgl_menuListCallback_t callback
function to call to retrieve a menu list item text
uint8_t nbChoices
total number of choices in the menu list
uint8_t selectedChoice
index of the selected choice (centered, in bold)
This structure contains info to build a navigation bar at the bottom of the screen.
nbgl_layoutNavDirection_t direction
vertical or horizontal navigation
nbgl_layoutNavIndication_t indication
specifies which arrows to use (left or right)