Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_layout_keyboard.c
Go to the documentation of this file.
1
6
7#ifdef HAVE_SE_TOUCH
8#ifdef NBGL_KEYBOARD
9/*********************
10 * INCLUDES
11 *********************/
12#include <string.h>
13#include <stdlib.h>
14#include <stdio.h>
15#include "nbgl_debug.h"
16#include "nbgl_front.h"
18#include "nbgl_obj.h"
19#include "nbgl_draw.h"
20#include "nbgl_screen.h"
21#include "nbgl_touch.h"
22#include "glyphs.h"
23#include "os_io_seph_cmd.h"
24#include "os_io_seph_ux.h"
25#include "os_pic.h"
26#include "os_helpers.h"
27
28/*********************
29 * DEFINES
30 *********************/
31#if defined(TARGET_FLEX) || defined(TARGET_APEX) || defined(TARGET_APOLLO)
32#define USE_PARTIAL_BUTTONS 1
33#endif // TARGET_FLEX
34
35// for suggestion buttons, on Flex there are other objects than buttons
36enum {
38#ifdef USE_PARTIAL_BUTTONS
39 LEFT_HALF_INDEX, // half disc displayed on the bottom left
40 RIGHT_HALF_INDEX, // half disc displayed on the bottom right
41#endif // USE_PARTIAL_BUTTONS
44#ifndef USE_PARTIAL_BUTTONS
47#endif // !USE_PARTIAL_BUTTONS
49};
50
51// Keyboard Text Entry container children
52enum {
57};
58
59#if defined(TARGET_STAX)
60#define TEXT_ENTRY_NORMAL_HEIGHT 64
61#define TEXT_ENTRY_COMPACT_HEIGHT 64
62#define BOTTOM_NORMAL_MARGIN 24
63#define BOTTOM_CONFIRM_MARGIN 24
64#define BOTTOM_COMPACT_MARGIN 24
65#define TOP_NORMAL_MARGIN 20
66#define TOP_CONFIRM_MARGIN 20
67#define TOP_COMPACT_MARGIN 20
68#define TITLE_ENTRY_MARGIN_Y 4
69#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
70#define TEXT_ENTRY_FONT_OBFUSCATED LARGE_OBFUSCATED_MEDIUM_1BPP_FONT
71// #define TEXT_ENTRY_FONT_OBFUSCATED LARGE_MEDIUM_
72// space between number and text
73#define NUMBER_TEXT_SPACE 8
74#define NUMBER_WIDTH 56
75#define DELETE_ICON C_Close_32px
76#elif defined(TARGET_FLEX) || defined(TARGET_APOLLO)
77#define TEXT_ENTRY_NORMAL_HEIGHT 72
78#define TEXT_ENTRY_COMPACT_HEIGHT 56
79#define BOTTOM_NORMAL_MARGIN 24
80#define BOTTOM_CONFIRM_MARGIN 24
81#define BOTTOM_COMPACT_MARGIN 12
82#define TOP_NORMAL_MARGIN 20
83#define TOP_CONFIRM_MARGIN 20
84#define TOP_COMPACT_MARGIN 12
85#define TITLE_ENTRY_MARGIN_Y 4
86#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
87#define TEXT_ENTRY_FONT_OBFUSCATED LARGE_OBFUSCATED_MEDIUM_1BPP_FONT
88// space between number and text
89#define NUMBER_TEXT_SPACE 8
90#define NUMBER_WIDTH 56
91#define DELETE_ICON C_Close_40px
92#elif defined(TARGET_APEX)
93#define TEXT_ENTRY_NORMAL_HEIGHT 44
94#define TEXT_ENTRY_COMPACT_HEIGHT 44
95#define BOTTOM_NORMAL_MARGIN 20
96#define BOTTOM_CONFIRM_MARGIN 16
97#define BOTTOM_COMPACT_MARGIN 8
98#define TOP_NORMAL_MARGIN 20
99#define TOP_CONFIRM_MARGIN 12
100#define TOP_COMPACT_MARGIN 8
101#define TITLE_ENTRY_MARGIN_Y 4
102#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
103#define TEXT_ENTRY_FONT_OBFUSCATED LARGE_OBFUSCATED_MEDIUM_1BPP_FONT
104// space between number and text
105#define NUMBER_TEXT_SPACE 4
106#define NUMBER_WIDTH 40
107#define DELETE_ICON C_Close_Tiny_24px
108#endif // TARGETS
109
110#ifdef USE_PARTIAL_BUTTONS
111#if defined(TARGET_FLEX) || defined(TARGET_APOLLO)
112#define LEFT_HALF_ICON C_left_half_64px
113#define SUGGESTION_CONTAINER_HEIGHT 92
114#elif defined(TARGET_APEX)
115#define LEFT_HALF_ICON C_half_disc_left_40px_1bpp
116#define SUGGESTION_CONTAINER_HEIGHT 56
117#endif // TARGETS
118#endif // USE_PARTIAL_BUTTONS
119
120// space on left and right of suggestion buttons
121#define SUGGESTION_BUTTONS_SIDE_MARGIN BORDER_MARGIN
122#if defined(TARGET_APEX)
123#define LINE_THICKNESS 1
124#define LINE_COLOR BLACK
125#else
126#define LINE_THICKNESS 2
127#define LINE_COLOR LIGHT_GRAY
128#endif // TARGETS
129
130/**********************
131 * MACROS
132 **********************/
133
134/**********************
135 * TYPEDEFS
136 **********************/
137
138/**********************
139 * VARIABLES
140 **********************/
141
142static const char *choiceTexts[NB_MAX_SUGGESTION_BUTTONS];
143static char numText[5];
144static uint8_t nbActiveButtons;
146#ifdef USE_PARTIAL_BUTTONS
147static nbgl_image_t *partialButtonImages[2];
148#endif // USE_PARTIAL_BUTTONS
149
150/**********************
151 * STATIC PROTOTYPES
152 **********************/
153
154// configure the given suggestion button to display the suggestion at the given index. If this
155// index is not one of the active suggestions, the button is emptied and made untouchable, to
156// never trigger the callback with a token not matching a displayed suggestion
158 nbgl_button_t *button,
159 uint32_t index)
160{
161 if (index < (uint32_t) nbActiveButtons) {
162 button->text = choiceTexts[index];
163 button->obj.touchMask = (1 << TOUCHED);
165 layoutInt, (nbgl_obj_t *) button, currentFirstButtonToken + index);
166 }
167 else {
168 button->text = NULL;
169 button->obj.touchMask = 0;
171 }
172}
173
174// function used on Flex to display (or not) beginning of next button and/or end of
175// previous button, and update buttons when swipping
177 nbgl_container_t *container,
178 nbgl_touchType_t eventType,
179 uint8_t currentLeftButtonIndex)
180{
181 bool needRefresh = false;
182 uint8_t page = 0;
183 uint32_t i = 0;
184 nbgl_button_t *button = NULL;
185
186 if ((eventType == SWIPED_LEFT) && (nbActiveButtons > NB_MAX_VISIBLE_SUGGESTION_BUTTONS)
187 && (currentLeftButtonIndex < (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS))) {
188 // shift all buttons on the left if there are still at least
189 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons to display
190 currentLeftButtonIndex += NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
191
192 for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
193 // Update button text and touch token (some buttons may not be used)
194 button = (nbgl_button_t *) container->children[FIRST_BUTTON_INDEX + i];
195 setSuggestionButton(layoutInt, button, (uint32_t) currentLeftButtonIndex + i);
196 }
197 page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
198 needRefresh = true;
199 }
200 else if ((eventType == SWIPED_RIGHT)
201 && (currentLeftButtonIndex > (NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1))) {
202 // shift all buttons on the left if we are not already displaying the
203 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS first ones
204 currentLeftButtonIndex -= NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
205 for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
206 // Update button text and touch token
207 button = (nbgl_button_t *) container->children[FIRST_BUTTON_INDEX + i];
208 setSuggestionButton(layoutInt, button, (uint32_t) currentLeftButtonIndex + i);
209 }
210 page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
211 needRefresh = true;
212 }
213 // align top-left button on the left
214 if (container->children[FIRST_BUTTON_INDEX] != NULL) {
215 container->children[FIRST_BUTTON_INDEX]->alignmentMarginX = SUGGESTION_BUTTONS_SIDE_MARGIN;
216 container->children[FIRST_BUTTON_INDEX]->alignmentMarginY = 0;
217 container->children[FIRST_BUTTON_INDEX]->alignment = TOP_LEFT;
218 container->children[FIRST_BUTTON_INDEX]->alignTo = (nbgl_obj_t *) container;
219 }
220
221 // align top-right button on top-left one
222 if (container->children[SECOND_BUTTON_INDEX] != NULL) {
223 container->children[SECOND_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN;
224 container->children[SECOND_BUTTON_INDEX]->alignmentMarginY = 0;
225 container->children[SECOND_BUTTON_INDEX]->alignment = MID_RIGHT;
226 container->children[SECOND_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX];
227 }
228#ifndef USE_PARTIAL_BUTTONS
229 // align bottom-left button on top_left one
230 if (container->children[THIRD_BUTTON_INDEX] != NULL) {
231 container->children[THIRD_BUTTON_INDEX]->alignmentMarginX = 0;
232 container->children[THIRD_BUTTON_INDEX]->alignmentMarginY = INTERNAL_MARGIN;
233 container->children[THIRD_BUTTON_INDEX]->alignment = BOTTOM_MIDDLE;
234 container->children[THIRD_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX];
235 }
236
237 // align bottom-right button on bottom-left one
238 if (container->children[FOURTH_BUTTON_INDEX] != NULL) {
239 container->children[FOURTH_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN;
240 container->children[FOURTH_BUTTON_INDEX]->alignmentMarginY = 0;
241 container->children[FOURTH_BUTTON_INDEX]->alignment = MID_RIGHT;
242 container->children[FOURTH_BUTTON_INDEX]->alignTo = container->children[THIRD_BUTTON_INDEX];
243 }
244#endif // !USE_PARTIAL_BUTTONS
245
246 // the first child is used by the progress indicator, displayed if more that
247 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
248 nbgl_page_indicator_t *indicator
249 = (nbgl_page_indicator_t *) container->children[PAGE_INDICATOR_INDEX];
250 indicator->activePage = page;
251
252#ifdef USE_PARTIAL_BUTTONS
253 // if not on the first button, display end of previous button
254 if (currentLeftButtonIndex > 0) {
255 container->children[LEFT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[0];
256 }
257 else {
258 container->children[LEFT_HALF_INDEX] = NULL;
259 }
260 // if not on the last button, display beginning of next button
261 if ((nbActiveButtons > NB_MAX_VISIBLE_SUGGESTION_BUTTONS)
262 && (currentLeftButtonIndex < (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS))) {
263 container->children[RIGHT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[1];
264 }
265 else {
266 container->children[RIGHT_HALF_INDEX] = NULL;
267 }
268#endif // USE_PARTIAL_BUTTONS
269 return needRefresh;
270}
271
272/**********************
273 * GLOBAL INTERNAL FUNCTIONS
274 **********************/
275
277 nbgl_obj_t *obj,
278 nbgl_touchType_t eventType)
279{
280 nbgl_container_t *container = (nbgl_container_t *) obj;
281 nbgl_container_t *suggestionsContainer;
282
283 if ((container->nbChildren < 2) || (container->children[1]->type != CONTAINER)) {
284 return false;
285 }
286 suggestionsContainer = (nbgl_container_t *) container->children[1];
287 // try if suggestions buttons (more than NB_MAX_VISIBLE_SUGGESTION_BUTTONS)
288 if (((eventType == SWIPED_LEFT) || (eventType == SWIPED_RIGHT))
289 && (suggestionsContainer->nbChildren == NB_SUGGESTION_CHILDREN)
290 && (nbActiveButtons > NB_MAX_VISIBLE_SUGGESTION_BUTTONS)) {
291 uint32_t i = 0;
292 while (i < (uint32_t) nbActiveButtons) {
293 if (((nbgl_button_t *) suggestionsContainer->children[FIRST_BUTTON_INDEX])->text
294 == choiceTexts[i]) {
295 break;
296 }
297 i++;
298 }
299
300 if (i < (uint32_t) nbActiveButtons) {
301 if (updateSuggestionButtons(layoutInt, suggestionsContainer, eventType, i)) {
302 os_io_seph_cmd_piezo_play_tune(TUNE_TAP_CASUAL);
303 nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
305 }
306
307 return true;
308 }
309 }
310 return false;
311}
312
314 const char *title,
315 const char *text,
316 bool numbered,
317 uint8_t number,
318 int textToken,
319 bool compactMode,
320 bool obfuscated)
321{
322 nbgl_container_t *mainContainer, *container;
323 nbgl_text_area_t *textArea;
324 layoutObj_t *obj;
325 uint16_t textEntryHeight = (compactMode ? TEXT_ENTRY_COMPACT_HEIGHT : TEXT_ENTRY_NORMAL_HEIGHT);
326 bool withCross = ((text != NULL) && (strlen(text) > 0));
327
328 // create a main container, to store title, and text-entry container
329 mainContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
330 mainContainer->nbChildren = 2;
331 mainContainer->children = nbgl_containerPoolGet(mainContainer->nbChildren, layoutInt->layer);
332 mainContainer->obj.area.width = AVAILABLE_WIDTH;
333 mainContainer->obj.alignment = CENTER;
334
335 if (title != NULL) {
336 // create text area for title
337 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
338 textArea->textColor = BLACK;
339 textArea->text = title;
340 textArea->textAlignment = CENTER;
341 textArea->fontId = SMALL_REGULAR_FONT;
342 textArea->wrapping = true;
343 textArea->obj.alignment = TOP_MIDDLE;
344 textArea->obj.area.width = AVAILABLE_WIDTH;
345 textArea->obj.area.height = nbgl_getTextHeightInWidth(
346 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
347 mainContainer->children[0] = (nbgl_obj_t *) textArea;
348 mainContainer->obj.area.height = textArea->obj.area.height + TITLE_ENTRY_MARGIN_Y;
349 }
350
351 // create a text-entry container number, entered text, potential cross and underline
352 container = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
353 container->nbChildren = 4;
354 container->children = nbgl_containerPoolGet(container->nbChildren, layoutInt->layer);
355 container->obj.area.width = AVAILABLE_WIDTH;
356 container->obj.alignment = BOTTOM_MIDDLE;
357
358 if (numbered) {
359 // create Word num typed text
360 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
361 textArea->textColor = BLACK;
362 snprintf(numText, sizeof(numText), "%d.", number);
363 textArea->text = numText;
364 textArea->textAlignment = CENTER;
365 textArea->fontId = TEXT_ENTRY_FONT;
366 textArea->obj.area.width = NUMBER_WIDTH;
367 textArea->obj.alignment = MID_LEFT;
368 textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
369 // set this text area as child of the container
370 container->children[NUMBER_INDEX] = (nbgl_obj_t *) textArea;
371 }
372
373 nbgl_font_id_e enteredTextFont = TEXT_ENTRY_FONT;
374 if (obfuscated) {
375 enteredTextFont = TEXT_ENTRY_FONT_OBFUSCATED;
376 }
377
378 // create text area for entered text
379 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
380 textArea->textColor = BLACK;
381 textArea->text = text;
382 textArea->textAlignment = MID_LEFT;
383 textArea->fontId = enteredTextFont;
384 textArea->obj.area.width = AVAILABLE_WIDTH - DELETE_ICON.width - NUMBER_TEXT_SPACE;
385 if (numbered) {
386 textArea->obj.alignmentMarginX = NUMBER_TEXT_SPACE;
387 textArea->obj.alignTo = container->children[0];
388 textArea->obj.alignment = MID_RIGHT;
389 textArea->obj.area.width -= textArea->obj.alignmentMarginX + NUMBER_WIDTH;
390 }
391 else {
392 textArea->obj.alignment = MID_LEFT;
393 }
394 textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
395 textArea->autoHideLongLine = true;
396
397 container->children[TEXT_INDEX] = (nbgl_obj_t *) textArea;
398 container->obj.area.height = textEntryHeight;
399
400 // Create Cross
401 nbgl_image_t *image = (nbgl_image_t *) nbgl_objPoolGet(IMAGE, layoutInt->layer);
402 image->buffer = &DELETE_ICON;
403 // only display it if text non empty
404 image->foregroundColor = withCross ? BLACK : WHITE;
405 obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) image, textToken, NBGL_NO_TUNE);
406 if (obj == NULL) {
407 return NULL;
408 }
409 image->obj.alignment = MID_RIGHT;
410 image->obj.alignTo = container->children[TEXT_INDEX];
411 image->obj.alignmentMarginX = NUMBER_TEXT_SPACE;
412 image->obj.touchMask = (1 << TOUCHED);
413 image->obj.touchId = ENTERED_TEXT_ID;
414 container->children[DELETE_INDEX] = (nbgl_obj_t *) image;
415
416 // create gray line
417 nbgl_line_t *line = (nbgl_line_t *) nbgl_objPoolGet(LINE, layoutInt->layer);
418 line->lineColor = LINE_COLOR;
419 // align on bottom of the text entry container
420 line->obj.alignment = BOTTOM_MIDDLE;
421 line->obj.area.width = AVAILABLE_WIDTH;
422 line->obj.area.height = LINE_THICKNESS;
423 line->direction = HORIZONTAL;
424 line->thickness = LINE_THICKNESS;
425 // set this line as child of the text entry container
426 container->children[LINE_INDEX] = (nbgl_obj_t *) line;
427
428 // set this text entry container as child of the main container
429 mainContainer->children[1] = (nbgl_obj_t *) container;
430 mainContainer->obj.area.height += container->obj.area.height;
431
432 return mainContainer;
433}
434
436 uint8_t nbUsedButtons,
437 const char **buttonTexts,
438 int firstButtonToken,
439 tune_index_e tuneId,
440 bool obfuscated)
441{
442 nbgl_container_t *suggestionsContainer;
443 layoutObj_t *obj;
444
445 if ((nbUsedButtons > NB_MAX_SUGGESTION_BUTTONS)
446 || ((nbUsedButtons > 0) && (buttonTexts == NULL))) {
447 LOG_WARN(LAYOUT_LOGGER, "addSuggestionButtons(): invalid suggestions\n");
448 return NULL;
449 }
450
451 // only the used suggestions are kept, to never display or select stale ones
452 for (uint32_t i = 0; i < NB_MAX_SUGGESTION_BUTTONS; i++) {
453 choiceTexts[i] = (i < nbUsedButtons) ? buttonTexts[i] : NULL;
454 }
455
456 nbActiveButtons = nbUsedButtons;
457 currentFirstButtonToken = firstButtonToken;
458 suggestionsContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
459 suggestionsContainer->layout = VERTICAL;
460 suggestionsContainer->obj.area.width = SCREEN_WIDTH;
461#ifndef USE_PARTIAL_BUTTONS
462 // 2 rows of buttons with radius=32, and a intervale of 8px
463 suggestionsContainer->obj.area.height = 2 * SMALL_BUTTON_HEIGHT + INTERNAL_MARGIN + 28;
464#else // USE_PARTIAL_BUTTONS
465 // 1 row of buttons + 24px + page indicator
466 suggestionsContainer->obj.area.height = SUGGESTION_CONTAINER_HEIGHT;
467#endif // USE_PARTIAL_BUTTONS
468 suggestionsContainer->nbChildren = NB_SUGGESTION_CHILDREN;
469 suggestionsContainer->children
471
472 // put suggestionsContainer at the bottom of main container
473 suggestionsContainer->obj.alignmentMarginY = BOTTOM_NORMAL_MARGIN;
474 suggestionsContainer->obj.alignment = BOTTOM_MIDDLE;
475
476 nbgl_font_id_e suggestionsFontId = SMALL_BOLD_1BPP_FONT;
477 if (obfuscated) {
478 suggestionsFontId = SMALL_OBFUSCATED_BOLD_1BPP_FONT;
479 }
480
481 // create all possible suggestion buttons, even if not displayed at first
482 for (int i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
483 nbgl_button_t *button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer);
484
485 // the actual token is set by setSuggestionButton(), only if this button is used
486 obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) button, NBGL_INVALID_TOKEN, tuneId);
487 if (obj == NULL) {
488 return NULL;
489 }
490
491 button->innerColor = BLACK;
492 button->borderColor = BLACK;
493 button->foregroundColor = WHITE;
494 button->obj.area.width
495 = (SCREEN_WIDTH - (2 * SUGGESTION_BUTTONS_SIDE_MARGIN) - INTERNAL_MARGIN) / 2;
496 button->obj.area.height = SMALL_BUTTON_HEIGHT;
497 button->radius = SMALL_BUTTON_RADIUS_INDEX;
498 button->fontId = suggestionsFontId;
499 button->obj.touchId = CONTROLS_ID + i;
500 setSuggestionButton(layoutInt, button, i);
501
502 suggestionsContainer->children[i + FIRST_BUTTON_INDEX] = (nbgl_obj_t *) button;
503 }
504 // The first child is used by the progress indicator, if more that
505 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
506 nbgl_page_indicator_t *indicator
508 indicator->activePage = 0;
509 indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1)
510 / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
511 indicator->obj.area.width
512 = (indicator->nbPages < 3) ? STEPPER_2_PAGES_WIDTH : STEPPER_N_PAGES_WIDTH;
513 indicator->obj.alignment = BOTTOM_MIDDLE;
514 indicator->style = CURRENT_INDICATOR;
515 suggestionsContainer->children[PAGE_INDICATOR_INDEX] = (nbgl_obj_t *) indicator;
516#ifdef USE_PARTIAL_BUTTONS
517 // also allocate the semi disc that may be displayed on the left or right of the full
518 // buttons
519 nbgl_objPoolGetArray(IMAGE, 2, layoutInt->layer, (nbgl_obj_t **) &partialButtonImages);
520 partialButtonImages[0]->buffer = &LEFT_HALF_ICON;
521 partialButtonImages[0]->obj.alignment = TOP_LEFT;
522 partialButtonImages[0]->foregroundColor = BLACK;
523 partialButtonImages[0]->transformation = VERTICAL_MIRROR;
524 partialButtonImages[1]->buffer = &LEFT_HALF_ICON;
525 partialButtonImages[1]->obj.alignment = TOP_RIGHT;
526 partialButtonImages[1]->foregroundColor = BLACK;
527 partialButtonImages[1]->transformation = NO_TRANSFORMATION;
528 updateSuggestionButtons(layoutInt, suggestionsContainer, 0, 0);
529#endif // USE_PARTIAL_BUTTONS
530
531 return suggestionsContainer;
532}
533
535 bool active,
536 const char *text,
537 int token,
538 tune_index_e tuneId,
539 bool compactMode)
540{
541 nbgl_button_t *button;
542 layoutObj_t *obj;
543
544 button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer);
545 // an inactive button must not trigger the callback
547 layoutInt, (nbgl_obj_t *) button, active ? token : NBGL_INVALID_TOKEN, tuneId);
548 if (obj == NULL) {
549 return NULL;
550 }
551
552 // put button at the bottom of the main container
553 button->obj.alignmentMarginY = compactMode ? BOTTOM_COMPACT_MARGIN : BOTTOM_CONFIRM_MARGIN;
554 button->obj.alignment = BOTTOM_MIDDLE;
555 button->foregroundColor = WHITE;
556 if (active) {
557 button->innerColor = BLACK;
558 button->borderColor = BLACK;
559 button->obj.touchMask = (1 << TOUCHED);
560 button->obj.touchId = BOTTOM_BUTTON_ID;
561 }
562 else {
563 button->borderColor = INACTIVE_COLOR;
564 button->innerColor = INACTIVE_COLOR;
565 }
566 button->text = PIC(text);
567 button->fontId = SMALL_BOLD_1BPP_FONT;
568 button->obj.area.width = AVAILABLE_WIDTH;
569 button->obj.area.height = BUTTON_DIAMETER;
570 button->radius = BUTTON_RADIUS;
571
572 return button;
573}
574
575/**********************
576 * GLOBAL API FUNCTIONS
577 **********************/
578
587{
588 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
589 nbgl_keyboard_t *keyboard = NULL;
590
591 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddKeyboard():\n");
592 if (layout == NULL) {
593 return -1;
594 }
595 // footer must be empty
596 if (layoutInt->footerContainer != NULL) {
597 LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutAddKeyboard(): footer already set\n");
598 return -1;
599 }
600
601 // create keyboard
602 keyboard = (nbgl_keyboard_t *) nbgl_objPoolGet(KEYBOARD, layoutInt->layer);
603 keyboard->obj.area.width = SCREEN_WIDTH;
604 keyboard->obj.area.height = 3 * KEYBOARD_KEY_HEIGHT;
605 if (!kbdInfo->lettersOnly) {
606 keyboard->obj.area.height += KEYBOARD_KEY_HEIGHT;
607 }
608#ifdef TARGET_STAX
609 keyboard->obj.alignmentMarginY = 56;
610#endif // TARGET_STAX
611 keyboard->obj.alignment = BOTTOM_MIDDLE;
612 keyboard->borderColor = LIGHT_GRAY;
613 keyboard->callback = PIC(kbdInfo->callback);
614 keyboard->lettersOnly = kbdInfo->lettersOnly;
615 keyboard->mode = kbdInfo->mode;
616 keyboard->keyMask = kbdInfo->keyMask;
617 keyboard->casing = kbdInfo->casing;
618
619 // the keyboard occupies the footer
620 layoutInt->footerContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
621 layoutInt->footerContainer->obj.area.width = SCREEN_WIDTH;
622 layoutInt->footerContainer->layout = VERTICAL;
623 layoutInt->footerContainer->children
624 = (nbgl_obj_t **) nbgl_containerPoolGet(1, layoutInt->layer);
625 layoutInt->footerContainer->obj.alignment = BOTTOM_MIDDLE;
626 layoutInt->footerContainer->obj.area.height
627 = keyboard->obj.area.height + keyboard->obj.alignmentMarginY;
628 layoutInt->footerContainer->children[0] = (nbgl_obj_t *) keyboard;
629 layoutInt->footerContainer->nbChildren = 1;
630
631 // add footer to layout children
632 layoutInt->children[FOOTER_INDEX] = (nbgl_obj_t *) layoutInt->footerContainer;
633
634 // subtract footer height from main container height
635 layoutInt->container->obj.area.height -= layoutInt->footerContainer->obj.area.height;
636
637 // create the 2 children for main container (to hold keyboard content)
638 layoutAddObject(layoutInt, (nbgl_obj_t *) NULL);
639 layoutAddObject(layoutInt, (nbgl_obj_t *) NULL);
640
641 layoutInt->footerType = KEYBOARD_FOOTER_TYPE;
642
643 return layoutInt->footerContainer->obj.area.height;
644}
645
657 uint8_t index,
658 uint32_t keyMask,
659 bool updateCasing,
660 keyboardCase_t casing)
661{
662 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
663 nbgl_keyboard_t *keyboard;
664
665 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboard(): keyMask = 0x%X\n", keyMask);
666 if (layout == NULL) {
667 return -1;
668 }
669 UNUSED(index);
670
671 // get existing keyboard (in the footer container)
672 keyboard = (nbgl_keyboard_t *) layoutInt->footerContainer->children[0];
673 if ((keyboard == NULL) || (keyboard->obj.type != KEYBOARD)) {
674 LOG_WARN(
675 LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboard(): keyboard not found at index %d\n", index);
676 return -1;
677 }
678 keyboard->keyMask = keyMask;
679 if (updateCasing) {
680 keyboard->casing = casing;
681 }
682
683 nbgl_objDraw((nbgl_obj_t *) keyboard);
684
685 return 0;
686}
687
696{
697 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
698 nbgl_keyboard_t *keyboard;
699
700 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutKeyboardNeedsRefresh(): \n");
701 if (layout == NULL) {
702 return -1;
703 }
704 UNUSED(index);
705
706 // get existing keyboard (in the footer container)
707 keyboard = (nbgl_keyboard_t *) layoutInt->footerContainer->children[0];
708 if ((keyboard == NULL) || (keyboard->obj.type != KEYBOARD)) {
710 "nbgl_layoutKeyboardNeedsRefresh(): keyboard not found at index %d\n",
711 index);
712 return -1;
713 }
714 if (keyboard->needsRefresh) {
715 keyboard->needsRefresh = false;
716 return true;
717 }
718
719 return false;
720}
721
731{
732 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
733 nbgl_container_t *textEntryContainer;
734 bool compactMode = ((content->type == KEYBOARD_WITH_BUTTON) && (content->title != NULL));
735
736 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddKeyboardContent():\n");
737 if (layout == NULL) {
738 return -1;
739 }
740
741 textEntryContainer = addTextEntry(layoutInt,
742 content->title,
743 content->text,
744 content->numbered,
745 content->number,
746 content->textToken,
747 compactMode,
748 content->obfuscated);
749 if (textEntryContainer == NULL) {
750 LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutAddKeyboardContent(): addTextEntry failed\n");
751 return -1;
752 }
753
754 // set this container as first child of the main layout container
755 layoutInt->container->children[0] = (nbgl_obj_t *) textEntryContainer;
756
757 if (content->type == KEYBOARD_WITH_SUGGESTIONS) {
758 nbgl_container_t *suggestionsContainer
759 = addSuggestionButtons(layoutInt,
761 content->suggestionButtons.buttons,
763 content->tuneId,
764 content->obfuscated);
765 if (suggestionsContainer == NULL) {
767 "nbgl_layoutAddKeyboardContent(): addSuggestionButtons failed\n");
768 return -1;
769 }
770
771 // set this container as second child of the main layout container
772 layoutInt->container->children[1] = (nbgl_obj_t *) suggestionsContainer;
773 // the main container is swipable on Flex
774 if (layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) layoutInt->container, 0, NBGL_NO_TUNE)
775 == NULL) {
777 "nbgl_layoutAddKeyboardContent(): cannot add callback object\n");
778 return -1;
779 }
780 layoutInt->container->obj.touchMask = (1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT);
781 layoutInt->container->obj.touchId = CONTROLS_ID;
783 textEntryContainer->obj.alignmentMarginY
784 -= (suggestionsContainer->obj.area.height + suggestionsContainer->obj.alignmentMarginY
785 + TOP_NORMAL_MARGIN)
786 / 2;
787 }
788 else if (content->type == KEYBOARD_WITH_BUTTON) {
789 nbgl_button_t *button = addConfirmationButton(layoutInt,
790 content->confirmationButton.active,
791 content->confirmationButton.text,
792 content->confirmationButton.token,
793 content->tuneId,
794 (content->title != NULL));
795 if (button == NULL) {
797 "nbgl_layoutAddKeyboardContent(): addConfirmationButton failed\n");
798 return -1;
799 }
800 // set this button as second child of the main layout container
801 layoutInt->container->children[1] = (nbgl_obj_t *) button;
802 textEntryContainer->obj.alignmentMarginY
803 -= (button->obj.area.height + button->obj.alignmentMarginY
804 + ((content->title != NULL) ? TOP_COMPACT_MARGIN : TOP_CONFIRM_MARGIN))
805 / 2;
806 }
807 return layoutInt->container->obj.area.height;
808}
809
821{
822 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
823 nbgl_container_t *mainContainer, *container;
824 nbgl_text_area_t *textArea;
825 nbgl_image_t *image;
826 int ret = 0;
827
828 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboardContent():\n");
829 if (layout == NULL) {
830 return -1;
831 }
832
833 // get top container from main container (it shall be the 1st object)
834 mainContainer = (nbgl_container_t *) layoutInt->container->children[0];
835 if ((mainContainer == NULL) || (mainContainer->obj.type != CONTAINER)) {
836 LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboardContent(): main container not found\n");
837 return -1;
838 }
839 container = (nbgl_container_t *) mainContainer->children[1];
840 if ((container == NULL) || (container->obj.type != CONTAINER)) {
842 "nbgl_layoutUpdateKeyboardContent(): text entry container not found\n");
843 return -1;
844 }
845
846 if (content->numbered) {
847 // get Word number typed text
848 textArea = (nbgl_text_area_t *) container->children[NUMBER_INDEX];
849 snprintf(numText, sizeof(numText), "%d.", content->number);
850 nbgl_objDraw((nbgl_obj_t *) textArea);
851 }
852
853 // get text area for entered text
854 textArea = (nbgl_text_area_t *) container->children[TEXT_INDEX];
855 textArea->text = content->text;
856 textArea->fontId = content->obfuscated ? TEXT_ENTRY_FONT_OBFUSCATED : TEXT_ENTRY_FONT;
857 nbgl_objDraw((nbgl_obj_t *) textArea);
858
859 // get delete cross
860 image = (nbgl_image_t *) container->children[DELETE_INDEX];
861 if ((textArea->text != NULL) && (strlen(textArea->text) > 0)) {
862 if (image->foregroundColor == WHITE) {
863 image->foregroundColor = BLACK;
864 nbgl_objDraw((nbgl_obj_t *) image);
865 }
866 }
867 else {
868 if (image->foregroundColor == BLACK) {
869 image->foregroundColor = WHITE;
870 nbgl_objDraw((nbgl_obj_t *) image);
871 }
872 }
873
874 if (content->type == KEYBOARD_WITH_SUGGESTIONS) {
875 uint8_t i = 0;
876 nbgl_container_t *suggestionsContainer
877 = (nbgl_container_t *) layoutInt->container->children[1];
878 if ((suggestionsContainer == NULL) || (suggestionsContainer->obj.type != CONTAINER)) {
880 "nbgl_layoutUpdateKeyboardContent(): suggestions container not found\n");
881 return -1;
882 }
883 if ((content->suggestionButtons.nbUsedButtons > NB_MAX_SUGGESTION_BUTTONS)
884 || ((content->suggestionButtons.nbUsedButtons > 0)
885 && (content->suggestionButtons.buttons == NULL))) {
886 LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboardContent(): invalid suggestions\n");
887 return -1;
888 }
890
891 // update suggestion texts, only the used ones are kept
892 for (i = 0; i < NB_MAX_SUGGESTION_BUTTONS; i++) {
893 choiceTexts[i] = (i < nbActiveButtons) ? content->suggestionButtons.buttons[i] : NULL;
894 }
895 // update suggestion buttons (some buttons may not be used)
896 for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
897 nbgl_button_t *button
898 = (nbgl_button_t *) suggestionsContainer->children[i + FIRST_BUTTON_INDEX];
899 setSuggestionButton(layoutInt, button, i);
900 }
901 suggestionsContainer->forceClean = true;
902 // the first child is used by the progress indicator, if more than
903 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
904 nbgl_page_indicator_t *indicator
905 = (nbgl_page_indicator_t *) suggestionsContainer->children[PAGE_INDICATOR_INDEX];
906 indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1)
907 / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
908 indicator->activePage = 0;
909 updateSuggestionButtons(layoutInt, suggestionsContainer, 0, 0);
910
911 nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
912 }
913 else if (content->type == KEYBOARD_WITH_BUTTON) {
914 // update main text area
915 nbgl_button_t *button = (nbgl_button_t *) layoutInt->container->children[1];
916 if ((button == NULL) || (button->obj.type != BUTTON)) {
917 LOG_WARN(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboardContent(): button not found\n");
918 return -1;
919 }
920 button->text = content->confirmationButton.text;
921
922 if (content->confirmationButton.active) {
923#if NB_COLOR_BITS == 4
924 // if the button was inactive (in grey), a non-fast refresh will be necessary
925 if (button->innerColor == INACTIVE_COLOR) {
926 ret = 1;
927 }
928#endif
929 // restore the token before making the button touchable again
931 layoutInt, (nbgl_obj_t *) button, content->confirmationButton.token);
932 button->innerColor = BLACK;
933 button->borderColor = BLACK;
934 button->obj.touchMask = (1 << TOUCHED);
935 button->obj.touchId = BOTTOM_BUTTON_ID;
936 }
937 else {
938 // an inactive button must not be touchable, nor trigger the callback
939 button->borderColor = INACTIVE_COLOR;
940 button->innerColor = INACTIVE_COLOR;
941 button->obj.touchMask = 0;
942 button->obj.touchId = 0;
944 }
945 nbgl_objDraw((nbgl_obj_t *) button);
946 }
947
948 // if the entered text doesn't fit, indicate it by returning 1 instead of 0, for different
949 // refresh
950 if (nbgl_getSingleLineTextWidth(textArea->fontId, content->text) > textArea->obj.area.width) {
951 ret = 1;
952 }
953 return ret;
954}
955
956#endif // NBGL_KEYBOARD
957#endif // HAVE_SE_TOUCH
debug traces management
#define LOG_WARN(__logger,...)
Definition nbgl_debug.h:89
@ LAYOUT_LOGGER
Definition nbgl_debug.h:35
#define LOG_DEBUG(__logger,...)
Definition nbgl_debug.h:88
Middle Level API of the new BOLOS Graphical Library.
uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
nbgl_font_id_e
Definition nbgl_fonts.h:143
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
Font screen low-Level driver API, to draw elementary forms.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
void layoutUpdateCallbackObjToken(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token)
Update the token associated with a specific object in a layout.
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
#define AVAILABLE_WIDTH
void * nbgl_layout_t
type shared externally
#define NBGL_INVALID_TOKEN
Definition nbgl_layout.h:32
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
@ FOOTER_INDEX
#define KEYBOARD_FOOTER_TYPE
#define INTERNAL_MARGIN
struct nbgl_layoutInternal_s nbgl_layoutInternal_t
Structure containing all information about the current layout.
int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t keyMask, bool updateCasing, keyboardCase_t casing)
Updates an existing keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeyboard(nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
Creates a keyboard on bottom of the screen, with the given configuration.
static nbgl_container_t * addTextEntry(nbgl_layoutInternal_t *layoutInt, const char *title, const char *text, bool numbered, uint8_t number, int textToken, bool compactMode, bool obfuscated)
static char numText[5]
static bool updateSuggestionButtons(nbgl_layoutInternal_t *layoutInt, nbgl_container_t *container, nbgl_touchType_t eventType, uint8_t currentLeftButtonIndex)
int nbgl_layoutAddKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Adds an area containing a potential title, a text entry and either confirmation or suggestion buttons...
#define LINE_THICKNESS
#define SUGGESTION_BUTTONS_SIDE_MARGIN
static nbgl_button_t * addConfirmationButton(nbgl_layoutInternal_t *layoutInt, bool active, const char *text, int token, tune_index_e tuneId, bool compactMode)
bool keyboardSwipeCallback(nbgl_layoutInternal_t *layoutInt, nbgl_obj_t *obj, nbgl_touchType_t eventType)
static uint8_t currentFirstButtonToken
int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Updates an area containing a potential title, a text entry and either confirmation or suggestion butt...
@ SECOND_BUTTON_INDEX
@ NB_SUGGESTION_CHILDREN
@ PAGE_INDICATOR_INDEX
@ FIRST_BUTTON_INDEX
@ THIRD_BUTTON_INDEX
@ FOURTH_BUTTON_INDEX
static nbgl_container_t * addSuggestionButtons(nbgl_layoutInternal_t *layoutInt, uint8_t nbUsedButtons, const char **buttonTexts, int firstButtonToken, tune_index_e tuneId, bool obfuscated)
static const char * choiceTexts[NB_MAX_SUGGESTION_BUTTONS]
static void setSuggestionButton(nbgl_layoutInternal_t *layoutInt, nbgl_button_t *button, uint32_t index)
#define LINE_COLOR
bool nbgl_layoutKeyboardNeedsRefresh(nbgl_layout_t *layout, uint8_t index)
function called to know whether the keyboard has been redrawn and needs a refresh
@ DELETE_INDEX
@ NUMBER_INDEX
static uint8_t nbActiveButtons
#define NBGL_NO_TUNE
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
API to draw all basic graphic objects.
struct PACKED__ nbgl_line_s nbgl_line_t
struct to represent a vertical or horizontal line
struct PACKED__ nbgl_navigation_bar_s nbgl_page_indicator_t
struct to represent a navigation bar (PAGE_INDICATOR type) There can be up to 5 page indicators,...
struct PACKED__ nbgl_text_area_s nbgl_text_area_t
struct to represent a text area (TEXT_AREA type)
void nbgl_objDraw(nbgl_obj_t *obj)
nbgl_obj_t ** nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer)
nbgl_obj_t * nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer)
struct PACKED__ nbgl_keyboard_s nbgl_keyboard_t
struct to represent a keyboard (KEYBOARD type)
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
int nbgl_objPoolGetArray(nbgl_obj_type_t type, uint8_t nbObjs, uint8_t layer, nbgl_obj_t **objArray)
struct PACKED__ nbgl_button_s nbgl_button_t
struct to represent a button (BUTTON type) that can contain a text and/or an icon
#define INACTIVE_COLOR
Definition nbgl_obj.h:169
#define BUTTON_DIAMETER
Definition nbgl_obj.h:108
@ CONTROLS_ID
Definition nbgl_obj.h:555
@ ENTERED_TEXT_ID
Definition nbgl_obj.h:549
@ BOTTOM_BUTTON_ID
Definition nbgl_obj.h:536
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
@ CURRENT_INDICATOR
only current page dash is black
Definition nbgl_obj.h:377
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
keyboardCase_t
Letters casing in which to open/set the keyboard.
API to manage screens.
@ WHITE
Definition nbgl_types.h:157
@ LIGHT_GRAY
Definition nbgl_types.h:156
@ BLACK
Definition nbgl_types.h:154
#define VERTICAL_MIRROR
Definition nbgl_types.h:110
nbgl_touchType_t
The different types of Touchscreen events.
Definition nbgl_types.h:272
@ SWIPED_LEFT
Definition nbgl_types.h:287
@ SWIPED_RIGHT
Definition nbgl_types.h:286
@ TOUCHED
Definition nbgl_types.h:273
@ VERTICAL
from top to bottom
Definition nbgl_types.h:222
@ HORIZONTAL
from left to right
Definition nbgl_types.h:223
@ TOP_MIDDLE
Definition nbgl_types.h:195
@ CENTER
Definition nbgl_types.h:198
@ TOP_LEFT
Definition nbgl_types.h:194
@ MID_RIGHT
Definition nbgl_types.h:199
@ TOP_RIGHT
Definition nbgl_types.h:196
@ MID_LEFT
Definition nbgl_types.h:197
@ BOTTOM_MIDDLE
Definition nbgl_types.h:201
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax).
Definition nbgl_types.h:170
@ BUTTON
Rounded rectangle button with icon and/or text.
Definition nbgl_types.h:173
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
Definition nbgl_types.h:175
@ LINE
Vertical or Horizontal line.
Definition nbgl_types.h:171
@ KEYBOARD
Keyboard.
Definition nbgl_types.h:179
@ CONTAINER
Empty container.
Definition nbgl_types.h:169
@ TEXT_AREA
Area to contain text line(s).
Definition nbgl_types.h:172
#define NO_TRANSFORMATION
Definition nbgl_types.h:104
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
Definition nbgl_types.h:340
const char * text
text of the button
bool active
if true, button is active, otherwise inactive (grayed-out)
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
uint8_t layer
layer in screen stack
nbgl_obj_t ** children
children for main screen
nbgl_swipe_usage_t swipeUsage
nbgl_container_t * container
nbgl_layoutFooterType_t footerType
type of footer
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard().
bool lettersOnly
if true, only display letter keys and Backspace
keyboardCallback_t callback
function called when an active key is pressed
keyboardMode_t mode
keyboard mode to start with
keyboardCase_t casing
keyboard casing mode (lower, upper once or upper locked)
This structure contains info to build a keyboard content (controls that are linked to keyboard).
uint8_t number
if numbered is true, number used to build 'number.' text
const char * text
already entered text
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
nbgl_layoutKeyboardContentType_t type
type of content
nbgl_layoutSuggestionButtons_t suggestionButtons
nbgl_layoutConfirmationButton_t confirmationButton
used if type is KEYBOARD_WITH_SUGGESTIONS
const char * title
centered title explaining the screen
bool numbered
if set to true, the text is preceded on the left by 'number.'
uint8_t nbUsedButtons
the number of actually used (displayed) buttons
const char ** buttons
array of 4 strings for buttons (last ones can be NULL)