Embedded SDK
Embedded SDK
nbgl_layout_nanos.c
Go to the documentation of this file.
1 
6 #ifndef HAVE_SE_TOUCH
7 /*********************
8  * INCLUDES
9  *********************/
10 #include <string.h>
11 #include <stdlib.h>
12 #include "nbgl_debug.h"
13 #include "nbgl_front.h"
15 #include "nbgl_obj.h"
16 #include "nbgl_draw.h"
17 #include "nbgl_screen.h"
18 #include "nbgl_touch.h"
19 #include "glyphs.h"
20 #include "os_pic.h"
21 #include "os_helpers.h"
22 #include "lcx_rng.h"
23 
24 /*********************
25  * DEFINES
26  *********************/
27 
28 #define NB_MAX_LAYOUTS 3
29 
30 // used by screen
31 #define NB_MAX_SCREEN_CHILDREN 7
32 
33 /**********************
34  * MACROS
35  **********************/
36 
37 /**********************
38  * TYPEDEFS
39  **********************/
40 
41 /**********************
42  * VARIABLES
43  **********************/
44 
49 static nbgl_layoutInternal_t gLayout[NB_MAX_LAYOUTS] = {0};
50 
51 /**********************
52  * STATIC PROTOTYPES
53  **********************/
54 
55 static void buttonCallback(nbgl_screen_t *screen, nbgl_buttonEvent_t buttonEvent)
56 {
58  nbgl_layoutInternal_t *layout = NULL;
59 
60  // parse all layouts (starting with modals) to find the object
61  while (i > 0) {
62  i--;
63  if ((screen->index == gLayout[i].layer) && (gLayout[i].nbChildren > 0)) {
64  // found
65  layout = &gLayout[i];
66  break;
67  }
68  }
69  if (layout == NULL) {
70  LOG_WARN(
72  "touchCallback(): screen->index = %d, buttonEvent = %d, no matching active layout\n",
73  screen->index,
74  buttonEvent);
75  return;
76  }
77 
78 #ifdef NBGL_KEYPAD
79  // special case of keypad
81  if (kpd) {
82  nbgl_keypadCallback(kpd, buttonEvent);
83  return;
84  }
85  else
86 #endif // NBGL_KEYPAD
87 #ifdef NBGL_KEYBOARD
88  {
90  if (kbd) {
91  nbgl_keyboardCallback(kbd, buttonEvent);
92  return;
93  }
94  }
95 #endif // NBGL_KEYBOARD
96  if (layout->callback != NULL) {
97  layout->callback((nbgl_layout_t *) layout, buttonEvent);
98  }
99 }
100 
108 {
109  if (layout->nbChildren == NB_MAX_SCREEN_CHILDREN) {
110  LOG_FATAL(LAYOUT_LOGGER, "layoutAddObject(): No more object\n");
111  }
112  layout->children[layout->nbChildren] = obj;
113  layout->nbChildren++;
114 }
115 
116 /**********************
117  * GLOBAL FUNCTIONS
118  **********************/
119 
127 {
128  nbgl_layoutInternal_t *layout = NULL;
129 
130  // find an empty layout in the proper "layer"
131  if (description->modal) {
132  if (gLayout[1].nbChildren == 0) {
133  layout = &gLayout[1];
134  }
135  else if (gLayout[2].nbChildren == 0) {
136  layout = &gLayout[2];
137  }
138  }
139  else {
140  // automatically "release" a potentially opened non-modal layout
141  gLayout[0].nbChildren = 0;
142  layout = &gLayout[0];
143  }
144  if (layout == NULL) {
145  LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutGet(): impossible to get a layout!\n");
146  return NULL;
147  }
148 
149  // reset globals
150  memset(layout, 0, sizeof(nbgl_layoutInternal_t));
151 
152  layout->callback = (nbgl_layoutButtonCallback_t) PIC(description->onActionCallback);
153  layout->modal = description->modal;
154  if (description->modal) {
155  layout->layer = nbgl_screenPush(&layout->children,
157  &description->ticker,
158  (nbgl_buttonCallback_t) buttonCallback);
159  }
160  else {
161  nbgl_screenSet(&layout->children,
163  &description->ticker,
164  (nbgl_buttonCallback_t) buttonCallback);
165  layout->layer = 0;
166  }
167 
168  return (nbgl_layout_t *) layout;
169 }
170 
178 int nbgl_layoutAddNavigation(nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
179 {
180  nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
181 
182  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddNavigation():\n");
183  if (layout == NULL) {
184  return -1;
185  }
186 
187  nbgl_image_t *image;
188  if (info->indication & LEFT_ARROW) {
189  image = (nbgl_image_t *) nbgl_objPoolGet(IMAGE, layoutInt->layer);
190  image->foregroundColor = WHITE;
191  image->buffer = (info->direction == HORIZONTAL_NAV) ? &C_icon_left : &C_icon_up;
192  image->obj.area.bpp = NBGL_BPP_1;
193  image->obj.alignment = MID_LEFT;
194  layoutAddObject(layoutInt, (nbgl_obj_t *) image);
195  }
196  if (info->indication & RIGHT_ARROW) {
197  image = (nbgl_image_t *) nbgl_objPoolGet(IMAGE, layoutInt->layer);
198  image->foregroundColor = WHITE;
199  image->buffer = (info->direction == HORIZONTAL_NAV) ? &C_icon_right : &C_icon_down;
200  image->obj.area.bpp = NBGL_BPP_1;
201  image->obj.alignment = MID_RIGHT;
202  layoutAddObject(layoutInt, (nbgl_obj_t *) image);
203  }
204  return 0;
205 }
206 
217  const char *text,
218  const char *subText,
220 {
221  nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
222  nbgl_container_t *container;
223  nbgl_text_area_t *textArea;
224  uint16_t fullHeight = 0;
225 
226  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddText():\n");
227  if (layout == NULL) {
228  return -1;
229  }
230  container = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
231 
232  // get container children
233  container->nbChildren = 1;
234  if (subText != NULL) {
235  container->nbChildren++;
236  }
237 
238  container->children = nbgl_containerPoolGet(container->nbChildren, layoutInt->layer);
239  container->obj.area.width = AVAILABLE_WIDTH;
240 
241  textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
242  textArea->textColor = WHITE;
243  textArea->text = PIC(text);
244  textArea->textAlignment = CENTER;
245  textArea->fontId = (style == REGULAR_INFO) ? BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
247  textArea->obj.area.width = AVAILABLE_WIDTH;
248 
249  uint16_t nbLines
250  = nbgl_getTextNbLinesInWidth(textArea->fontId, textArea->text, AVAILABLE_WIDTH, true);
251  // if more than available lines on screen
252  if (nbLines > NB_MAX_LINES) {
253  uint16_t len;
254 
255  nbLines = NB_MAX_LINES;
256  textArea->nbMaxLines = NB_MAX_LINES;
258  textArea->fontId, textArea->text, AVAILABLE_WIDTH, nbLines, &len, true);
259  textArea->len = len;
260  }
261  const nbgl_font_t *font = nbgl_getFont(textArea->fontId);
262  textArea->obj.area.height = nbLines * font->line_height;
263  textArea->wrapping = true;
264  textArea->obj.alignment = TOP_MIDDLE;
265  fullHeight += textArea->obj.area.height;
266  container->children[0] = (nbgl_obj_t *) textArea;
267 
268  if (subText != NULL) {
269  textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
270  textArea->textColor = WHITE;
271  textArea->text = PIC(subText);
272  textArea->wrapping = true;
273  textArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp;
274  textArea->obj.area.width = AVAILABLE_WIDTH;
275  nbLines
276  = nbgl_getTextNbLinesInWidth(textArea->fontId, textArea->text, AVAILABLE_WIDTH, true);
277  // if more than available lines on screen
278  if (nbLines > (NB_MAX_LINES - 1)) {
279  uint16_t len;
280  nbLines = NB_MAX_LINES - 1;
281  textArea->nbMaxLines = nbLines;
283  textArea->fontId, textArea->text, AVAILABLE_WIDTH, nbLines, &len, true);
284  textArea->len = len;
285  }
286  textArea->obj.area.height = nbLines * font->line_height;
287  textArea->textAlignment = CENTER;
288  textArea->obj.alignment = NO_ALIGNMENT;
289  textArea->obj.alignmentMarginY = 2;
290  fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
291  container->children[1] = (nbgl_obj_t *) textArea;
292  }
293  container->obj.area.height = fullHeight;
294  container->layout = VERTICAL;
295  container->obj.alignment = CENTER;
296  // set this new obj as child of main container
297  layoutAddObject(layoutInt, (nbgl_obj_t *) container);
298 
299  return 0;
300 }
301 
310 int nbgl_layoutAddMenuList(nbgl_layout_t *layout, nbgl_layoutMenuList_t *list)
311 {
312  nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
313  uint8_t i;
314 
315  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddMenuList():\n");
316  if (layout == NULL) {
317  return -1;
318  }
319  for (i = 0; i < list->nbChoices; i++) {
320  nbgl_text_area_t *textArea;
321 
322  // check whether this object is visible or not
323  // only the two objects above or below the selected one are visible
324  if (((list->selectedChoice > 2) && (i < (list->selectedChoice - 2)))
325  || (i > (list->selectedChoice + 2))) {
326  continue;
327  }
328 
329  textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
330 
331  // init text area for this choice
332  textArea->text = list->callback(i);
333  textArea->textAlignment = CENTER;
334  textArea->obj.area.width = AVAILABLE_WIDTH;
335  textArea->obj.area.height = 12;
336  textArea->style = NO_STYLE;
337  textArea->obj.alignment = CENTER;
338  textArea->obj.alignmentMarginY = ((i - list->selectedChoice) * 16);
339  textArea->textColor = WHITE;
340 
341  // highlight init choice
342  if (i == list->selectedChoice) {
343  textArea->fontId = BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp;
344  }
345  else {
346  textArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp;
347  }
348 
349  // set this new obj as child of main container
350  layoutAddObject(layoutInt, (nbgl_obj_t *) textArea);
351  }
352 
353  return 0;
354 }
355 
365 {
366  nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
367  nbgl_container_t *container;
368  nbgl_text_area_t *textArea = NULL;
369  nbgl_image_t *image = NULL;
370  uint16_t fullHeight = 0;
371 
372  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddCenteredInfo():\n");
373  if (layout == NULL) {
374  return -1;
375  }
376 
377  container = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
378 
379  // 3 children at max
380  container->children = nbgl_containerPoolGet(3, layoutInt->layer);
381  container->nbChildren = 0;
382  if (info->icon != NULL) {
383  image = (nbgl_image_t *) nbgl_objPoolGet(IMAGE, layoutInt->layer);
384  image->foregroundColor = WHITE;
385  image->buffer = PIC(info->icon);
386  image->obj.area.bpp = NBGL_BPP_1;
387  image->obj.alignment = TOP_MIDDLE;
388  image->obj.alignTo = NULL;
389 
390  fullHeight += image->buffer->height;
391  container->children[container->nbChildren] = (nbgl_obj_t *) image;
392  container->nbChildren++;
393  }
394  if (info->text1 != NULL) {
395  textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
396  textArea->textColor = WHITE;
397  textArea->text = PIC(info->text1);
398  textArea->textAlignment = CENTER;
399  textArea->fontId = (info->style == REGULAR_INFO) ? BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
401  textArea->obj.area.width = AVAILABLE_WIDTH;
402  textArea->wrapping = true;
403  uint16_t nbLines
404  = nbgl_getTextNbLinesInWidth(textArea->fontId, textArea->text, AVAILABLE_WIDTH, true);
405  // if more than available lines on screen
406  if (nbLines > NB_MAX_LINES) {
407  uint16_t len;
408  nbLines = NB_MAX_LINES;
409  textArea->nbMaxLines = NB_MAX_LINES;
411  textArea->fontId, textArea->text, AVAILABLE_WIDTH, nbLines, &len, true);
412  textArea->len = len;
413  }
414  const nbgl_font_t *font = nbgl_getFont(textArea->fontId);
415  textArea->obj.area.height = nbLines * font->line_height;
416  textArea->style = NO_STYLE;
417  if (info->icon != NULL) {
418  textArea->obj.alignment = BOTTOM_MIDDLE; // under icon
419  textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1];
420  textArea->obj.alignmentMarginY = (nbLines < 3) ? 4 : 0;
421  }
422  else if (info->text2 == NULL) {
423  textArea->obj.alignment = CENTER;
424  textArea->obj.alignTo = NULL;
425  }
426  else {
427  textArea->obj.alignment = TOP_MIDDLE;
428  textArea->obj.alignTo = NULL;
429  }
430 
431  fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
432 
433  container->children[container->nbChildren] = (nbgl_obj_t *) textArea;
434  container->nbChildren++;
435  }
436  if (info->text2 != NULL) {
437  textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
438  textArea->textColor = WHITE;
439  textArea->text = PIC(info->text2);
440  textArea->textAlignment = CENTER;
441  textArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp;
442  textArea->obj.area.width = AVAILABLE_WIDTH;
443  uint16_t nbLines
444  = nbgl_getTextNbLinesInWidth(textArea->fontId, textArea->text, AVAILABLE_WIDTH, true);
445  // if more than available lines on screen
446  if (nbLines > (NB_MAX_LINES - 1)) {
447  uint16_t len;
448  nbLines = NB_MAX_LINES - 1;
449  textArea->nbMaxLines = nbLines;
451  textArea->fontId, textArea->text, AVAILABLE_WIDTH, nbLines, &len, true);
452  textArea->len = len;
453  }
454  const nbgl_font_t *font = nbgl_getFont(textArea->fontId);
455  textArea->obj.area.height = nbLines * font->line_height;
456 
457  textArea->style = NO_STYLE;
458  textArea->obj.alignment = BOTTOM_MIDDLE;
459  textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1];
460  textArea->obj.alignmentMarginY = 2;
461 
462  fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
463 
464  container->children[container->nbChildren] = (nbgl_obj_t *) textArea;
465  container->nbChildren++;
466  }
467  container->obj.area.height = fullHeight;
468  container->layout = VERTICAL;
469  container->obj.alignmentMarginY = 0;
470  if (info->onTop) {
471  container->obj.alignment = TOP_MIDDLE;
472  }
473  else {
474  container->obj.alignment = CENTER;
475  }
476 
477  container->obj.area.width = AVAILABLE_WIDTH;
478 
479  // set this new container as child of main container
480  layoutAddObject(layoutInt, (nbgl_obj_t *) container);
481 
482  return 0;
483 }
484 
494 {
495  nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
496  nbgl_progress_bar_t *progress;
497 
498  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddProgressBar():\n");
499  if (layout == NULL) {
500  return -1;
501  }
502  if (barLayout->text != NULL) {
503  nbgl_text_area_t *textArea;
504 
506  ((nbgl_layoutInternal_t *) layout)->layer);
507  textArea->textColor = WHITE;
508  textArea->text = PIC(barLayout->text);
509  textArea->textAlignment = CENTER;
510  textArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp;
511  textArea->obj.area.width = AVAILABLE_WIDTH;
512  textArea->obj.area.height = nbgl_getTextHeight(textArea->fontId, textArea->text);
513  textArea->obj.alignment = TOP_MIDDLE;
514  textArea->obj.alignmentMarginX = 0;
515  textArea->obj.alignmentMarginY = 16; // 16 px from top
516  layoutAddObject(layoutInt, (nbgl_obj_t *) textArea);
517  }
519  ((nbgl_layoutInternal_t *) layout)->layer);
520  progress->foregroundColor = WHITE;
521  progress->withBorder = true;
522  progress->state = barLayout->percentage;
523  progress->obj.area.width = 102;
524  progress->obj.area.height = 14;
525  progress->obj.alignment = TOP_MIDDLE;
526  progress->obj.alignmentMarginX = 0;
527  progress->obj.alignmentMarginY = 33; // 33px from top
528  layoutAddObject(layoutInt, (nbgl_obj_t *) progress);
529 
530  if (barLayout->subText != NULL) {
531  nbgl_text_area_t *subTextArea;
532 
533  subTextArea = (nbgl_text_area_t *) nbgl_objPoolGet(
534  TEXT_AREA, ((nbgl_layoutInternal_t *) layout)->layer);
535  subTextArea->textColor = WHITE;
536  subTextArea->text = PIC(barLayout->subText);
537  subTextArea->textAlignment = CENTER;
538  subTextArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp;
539  subTextArea->obj.area.width = AVAILABLE_WIDTH;
540  subTextArea->obj.area.height = nbgl_getTextHeight(subTextArea->fontId, subTextArea->text);
541  subTextArea->obj.alignment = BOTTOM_MIDDLE;
542  subTextArea->obj.alignTo = (nbgl_obj_t *) progress;
543  subTextArea->obj.alignmentMarginX = 0;
544  subTextArea->obj.alignmentMarginY = 4;
545  layoutAddObject(layoutInt, (nbgl_obj_t *) subTextArea);
546  }
547 
548  return 0;
549 }
550 
557 int nbgl_layoutDraw(nbgl_layout_t *layoutParam)
558 {
559  nbgl_layoutInternal_t *layout = (nbgl_layoutInternal_t *) layoutParam;
560 
561  if (layout == NULL) {
562  return -1;
563  }
564  LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutDraw(): layout->nbChildren = %d\n", layout->nbChildren);
566 
567  return 0;
568 }
569 
576 int nbgl_layoutRelease(nbgl_layout_t *layoutParam)
577 {
578  nbgl_layoutInternal_t *layout = (nbgl_layoutInternal_t *) layoutParam;
579  LOG_DEBUG(PAGE_LOGGER, "nbgl_layoutRelease(): \n");
580  if (layout == NULL) {
581  return -1;
582  }
583  // if modal
584  if (layout->modal) {
585  nbgl_screenPop(layout->layer);
586  }
587  layout->nbChildren = 0;
588  return 0;
589 }
590 #endif // HAVE_SE_TOUCH
Random Number Generation.
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
Definition: nbgl_content.h:34
debug traces management
#define LOG_WARN(__logger,...)
Definition: nbgl_debug.h:87
#define LOG_DEBUG(__logger,...)
Definition: nbgl_debug.h:86
#define LOG_FATAL(__logger,...)
Definition: nbgl_debug.h:88
@ LAYOUT_LOGGER
Definition: nbgl_debug.h:33
@ PAGE_LOGGER
Definition: nbgl_debug.h:34
Middle Level API of the new BOLOS Graphical Library.
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
compute the len of the given text (in bytes) fitting in the given maximum nb lines,...
Definition: nbgl_fonts.c:564
@ BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
Definition: nbgl_fonts.h:149
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
Definition: nbgl_fonts.h:147
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
compute the number of lines of the given text fitting in the given maxWidth
Definition: nbgl_fonts.c:723
uint16_t nbgl_getTextHeight(nbgl_font_id_e fontId, const char *text)
return the height of the given multiline text, with the given font.
Definition: nbgl_fonts.c:433
const nbgl_font_t * nbgl_getFont(nbgl_font_id_e fontId)
Font screen low-Level driver API, to draw elementary forms.
#define NB_MAX_LAYOUTS
Definition: nbgl_layout.c:35
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
Definition: nbgl_layout.c:519
#define NB_MAX_LINES
Definition: nbgl_layout.h:68
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
Definition: nbgl_layout.h:141
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)
Definition: nbgl_layout.c:1301
@ LEFT_ARROW
left arrow is used
Definition: nbgl_layout.h:151
@ RIGHT_ARROW
right arrow is used
Definition: nbgl_layout.h:152
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...
Definition: nbgl_layout.c:1610
int nbgl_layoutAddProgressBar(nbgl_layout_t *layout, const nbgl_layoutProgressBar_t *barLayout)
Creates an area in main panel to display a progress bar, with a title text and a description under th...
Definition: nbgl_layout.c:2112
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
Definition: nbgl_layout.c:3437
#define AVAILABLE_WIDTH
Definition: nbgl_layout.h:66
void * nbgl_layout_t
type shared externally
Definition: nbgl_layout.h:96
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
Definition: nbgl_layout.h:111
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
Definition: nbgl_layout.c:3468
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
Definition: nbgl_layout.c:995
@ NB_MAX_SCREEN_CHILDREN
Internal functions/constants of NBGL layout layer.
API to draw all basic graphic objects.
struct PACKED__ nbgl_text_area_s nbgl_text_area_t
struct to represent a text area (TEXT_AREA type)
struct PACKED__ nbgl_progress_bar_s nbgl_progress_bar_t
struct to represent a progress bar (PROGRESS_BAR type)
nbgl_obj_t ** nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer)
Gets a new container from the pool, with the given number of obj pointers.
nbgl_buttonEvent_t
Definition: nbgl_obj.h:182
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
void(* nbgl_buttonCallback_t)(void *obj, nbgl_buttonEvent_t buttonEvent)
prototype of function to be called when a button event is received by an object (TODO: change to scre...
Definition: nbgl_obj.h:200
nbgl_obj_t * nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer)
Gets a new graphic object from the pool, with the given type. The type field of the object is set.
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
API to manage screens.
int nbgl_screenSet(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_touchCallback_t touchCallback)
Configures the lowest layer screen. To be used by applications A nbgl_screenRedraw() can be called af...
Definition: nbgl_screen.c:225
int nbgl_screenPush(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_touchCallback_t touchCallback)
Pushes a screen on top of the stack, with the given number of elements, if possible....
Definition: nbgl_screen.c:330
struct PACKED__ nbgl_screen_s nbgl_screen_t
struct to represent a screen (SCREEN type)
int nbgl_screenPop(uint8_t screenIndex)
Release the screen at the given index in screen array (index returned by nbgl_screenPush())....
Definition: nbgl_screen.c:403
nbgl_obj_t * nbgl_screenContainsObjType(nbgl_screen_t *screen, nbgl_obj_type_t type)
return an object of the given type in the given screen
Definition: nbgl_screen.c:583
void nbgl_screenRedraw(void)
This function redraws the whole screen on top of stack and its children.
Definition: nbgl_screen.c:66
@ WHITE
Definition: nbgl_types.h:105
@ VERTICAL
from top to bottom
Definition: nbgl_types.h:170
@ TOP_MIDDLE
Definition: nbgl_types.h:143
@ CENTER
Definition: nbgl_types.h:146
@ NO_ALIGNMENT
used when parent container layout is used
Definition: nbgl_types.h:141
@ MID_RIGHT
Definition: nbgl_types.h:147
@ MID_LEFT
Definition: nbgl_types.h:145
@ BOTTOM_MIDDLE
Definition: nbgl_types.h:149
@ KEYPAD
Keypad.
Definition: nbgl_types.h:128
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
Definition: nbgl_types.h:118
@ PROGRESS_BAR
horizontal bar to indicate progression of something (between 0% and 100%)
Definition: nbgl_types.h:124
@ KEYBOARD
Keyboard.
Definition: nbgl_types.h:127
@ CONTAINER
Empty container.
Definition: nbgl_types.h:117
@ TEXT_AREA
Area to contain text line(s)
Definition: nbgl_types.h:120
@ NBGL_BPP_1
1 bit per pixel
Definition: nbgl_types.h:245
@ NO_STYLE
no border
Definition: nbgl_types.h:179
This structure contains info to build a centered (vertically and horizontally) area,...
Definition: nbgl_content.h:57
const char * text2
second text (can be null)
Definition: nbgl_content.h:59
const char * text1
first text (can be null)
Definition: nbgl_content.h:58
bool onTop
if set to true, align only horizontally
Definition: nbgl_content.h:64
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
Definition: nbgl_content.h:65
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
Definition: nbgl_content.h:63
structure defining an ASCII font
Definition: nbgl_fonts.h:80
uint8_t line_height
height of a line for all characters in pixels
Definition: nbgl_fonts.h:85
Structure containing all information when creating a layout. This structure must be passed as argumen...
Definition: nbgl_layout.h:171
nbgl_screenTickerConfiguration_t ticker
Definition: nbgl_layout.h:190
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
Definition: nbgl_layout.h:185
Structure containing all information about the current layout.
nbgl_layoutTouchCallback_t callback
bool modal
if true, means the screen is a modal
uint8_t nbChildren
number of children in above array
nbgl_obj_t ** children
children for main screen
This structure contains a list of names to build a menu list on Nanos, with for each item a descripti...
Definition: nbgl_layout.h:235
nbgl_menuListCallback_t callback
function to call to retrieve a menu list item text
Definition: nbgl_layout.h:236
uint8_t nbChoices
total number of choices in the menu list
Definition: nbgl_layout.h:237
uint8_t selectedChoice
index of the selected choice (centered, in bold)
Definition: nbgl_layout.h:238
This structure contains info to build a navigation bar at the bottom of the screen.
Definition: nbgl_layout.h:160
nbgl_layoutNavDirection_t direction
vertical or horizontal navigation
Definition: nbgl_layout.h:161
nbgl_layoutNavIndication_t indication
specifies which arrows to use (left or right)
Definition: nbgl_layout.h:162
This structure contains info to build a progress bar with info. The progress bar itself is 120px widt...
Definition: nbgl_layout.h:565
uint8_t percentage
percentage of completion, from 0 to 100.
Definition: nbgl_layout.h:566
const char * text
text in black, on top of progress bar
Definition: nbgl_layout.h:567
const char * subText
text in gray, under progress bar
Definition: nbgl_layout.h:568
unsigned short uint16_t
Definition: usbd_conf.h:54
unsigned char uint8_t
Definition: usbd_conf.h:53