Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_layout_keyboard.c
Go to the documentation of this file.
1
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)
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// space between number and text
71#define NUMBER_TEXT_SPACE 8
72#define NUMBER_WIDTH 56
73#define DELETE_ICON C_Close_32px
74#elif defined(TARGET_FLEX)
75#define TEXT_ENTRY_NORMAL_HEIGHT 72
76#define TEXT_ENTRY_COMPACT_HEIGHT 56
77#define BOTTOM_NORMAL_MARGIN 24
78#define BOTTOM_CONFIRM_MARGIN 24
79#define BOTTOM_COMPACT_MARGIN 12
80#define TOP_NORMAL_MARGIN 20
81#define TOP_CONFIRM_MARGIN 20
82#define TOP_COMPACT_MARGIN 12
83#define TITLE_ENTRY_MARGIN_Y 4
84#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
85// space between number and text
86#define NUMBER_TEXT_SPACE 8
87#define NUMBER_WIDTH 56
88#define DELETE_ICON C_Close_40px
89#elif defined(TARGET_APEX)
90#define TEXT_ENTRY_NORMAL_HEIGHT 44
91#define TEXT_ENTRY_COMPACT_HEIGHT 44
92#define BOTTOM_NORMAL_MARGIN 20
93#define BOTTOM_CONFIRM_MARGIN 16
94#define BOTTOM_COMPACT_MARGIN 8
95#define TOP_NORMAL_MARGIN 20
96#define TOP_CONFIRM_MARGIN 12
97#define TOP_COMPACT_MARGIN 8
98#define TITLE_ENTRY_MARGIN_Y 4
99#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
100// space between number and text
101#define NUMBER_TEXT_SPACE 4
102#define NUMBER_WIDTH 40
103#define DELETE_ICON C_Close_Tiny_24px
104#endif // TARGETS
105
106#ifdef USE_PARTIAL_BUTTONS
107#if defined(TARGET_FLEX)
108#define LEFT_HALF_ICON C_left_half_64px
109#define SUGGESTION_CONTAINER_HEIGHT 92
110#elif defined(TARGET_APEX)
111#define LEFT_HALF_ICON C_half_disc_left_40px_1bpp
112#define SUGGESTION_CONTAINER_HEIGHT 56
113#endif // TARGETS
114#endif // USE_PARTIAL_BUTTONS
115
116// space on left and right of suggestion buttons
117#define SUGGESTION_BUTTONS_SIDE_MARGIN BORDER_MARGIN
118#if defined(TARGET_APEX)
119#define LINE_THICKNESS 1
120#define LINE_COLOR BLACK
121#else
122#define LINE_THICKNESS 2
123#define LINE_COLOR LIGHT_GRAY
124#endif // TARGETS
125
126/**********************
127 * MACROS
128 **********************/
129
130/**********************
131 * TYPEDEFS
132 **********************/
133
134/**********************
135 * VARIABLES
136 **********************/
137
138static const char *choiceTexts[NB_MAX_SUGGESTION_BUTTONS];
139static char numText[5];
140static uint8_t nbActiveButtons;
141#ifdef USE_PARTIAL_BUTTONS
142static nbgl_image_t *partialButtonImages[2];
143#endif // USE_PARTIAL_BUTTONS
144
145/**********************
146 * STATIC PROTOTYPES
147 **********************/
148
149// function used on Flex to display (or not) beginning of next button and/or end of
150// previous button, and update buttons when swipping
151static bool updateSuggestionButtons(nbgl_container_t *container,
152 nbgl_touchType_t eventType,
153 uint8_t currentLeftButtonIndex)
154{
155 bool needRefresh = false;
156 uint8_t page = 0;
157 uint32_t i;
158
159 if ((eventType == SWIPED_LEFT)
160 && (currentLeftButtonIndex
161 < (uint32_t) (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS))) {
162 // shift all buttons on the left if there are still at least
163 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons to display
164 currentLeftButtonIndex += NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
165 ((nbgl_button_t *) container->children[FIRST_BUTTON_INDEX])->text
166 = choiceTexts[currentLeftButtonIndex];
167
168 for (i = 1; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
169 if (currentLeftButtonIndex < (uint32_t) (nbActiveButtons - i)) {
170 ((nbgl_button_t *) container->children[FIRST_BUTTON_INDEX + i])->text
171 = choiceTexts[currentLeftButtonIndex + i];
172 }
173 else {
174 ((nbgl_button_t *) container->children[FIRST_BUTTON_INDEX + i])->text = NULL;
175 }
176 }
177 page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
178 needRefresh = true;
179 }
180 else if ((eventType == SWIPED_RIGHT)
181 && (currentLeftButtonIndex > (NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1))) {
182 // shift all buttons on the left if we are not already displaying the
183 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS first ones
184 currentLeftButtonIndex -= NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
185 for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
186 ((nbgl_button_t *) container->children[FIRST_BUTTON_INDEX + i])->text
187 = choiceTexts[currentLeftButtonIndex + i];
188 }
189 page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
190 needRefresh = true;
191 }
192 // align top-left button on the left
193 if (container->children[FIRST_BUTTON_INDEX] != NULL) {
194 container->children[FIRST_BUTTON_INDEX]->alignmentMarginX = SUGGESTION_BUTTONS_SIDE_MARGIN;
195 container->children[FIRST_BUTTON_INDEX]->alignmentMarginY = 0;
196 container->children[FIRST_BUTTON_INDEX]->alignment = TOP_LEFT;
197 container->children[FIRST_BUTTON_INDEX]->alignTo = (nbgl_obj_t *) container;
198 }
199
200 // align top-right button on top-left one
201 if (container->children[SECOND_BUTTON_INDEX] != NULL) {
202 container->children[SECOND_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN;
203 container->children[SECOND_BUTTON_INDEX]->alignmentMarginY = 0;
204 container->children[SECOND_BUTTON_INDEX]->alignment = MID_RIGHT;
205 container->children[SECOND_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX];
206 }
207#ifndef USE_PARTIAL_BUTTONS
208 // align bottom-left button on top_left one
209 if (container->children[THIRD_BUTTON_INDEX] != NULL) {
210 container->children[THIRD_BUTTON_INDEX]->alignmentMarginX = 0;
211 container->children[THIRD_BUTTON_INDEX]->alignmentMarginY = INTERNAL_MARGIN;
212 container->children[THIRD_BUTTON_INDEX]->alignment = BOTTOM_MIDDLE;
213 container->children[THIRD_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX];
214 }
215
216 // align bottom-right button on bottom-left one
217 if (container->children[FOURTH_BUTTON_INDEX] != NULL) {
218 container->children[FOURTH_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN;
219 container->children[FOURTH_BUTTON_INDEX]->alignmentMarginY = 0;
220 container->children[FOURTH_BUTTON_INDEX]->alignment = MID_RIGHT;
221 container->children[FOURTH_BUTTON_INDEX]->alignTo = container->children[THIRD_BUTTON_INDEX];
222 }
223#endif // !USE_PARTIAL_BUTTONS
224
225 // the first child is used by the progress indicator, displayed if more that
226 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
227 nbgl_page_indicator_t *indicator
228 = (nbgl_page_indicator_t *) container->children[PAGE_INDICATOR_INDEX];
229 indicator->activePage = page;
230
231#ifdef USE_PARTIAL_BUTTONS
232 // if not on the first button, display end of previous button
233 if (currentLeftButtonIndex > 0) {
234 container->children[LEFT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[0];
235 }
236 else {
237 container->children[LEFT_HALF_INDEX] = NULL;
238 }
239 // if not on the last button, display beginning of next button
240 if (currentLeftButtonIndex < (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS)) {
241 container->children[RIGHT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[1];
242 }
243 else {
244 container->children[RIGHT_HALF_INDEX] = NULL;
245 }
246#endif // USE_PARTIAL_BUTTONS
247 return needRefresh;
248}
249
250/**********************
251 * GLOBAL INTERNAL FUNCTIONS
252 **********************/
253
255{
256 nbgl_container_t *container = (nbgl_container_t *) obj;
257 nbgl_container_t *suggestionsContainer;
258
259 if ((container->nbChildren < 2) || (container->children[1]->type != CONTAINER)) {
260 return false;
261 }
262 suggestionsContainer = (nbgl_container_t *) container->children[1];
263 // try if suggestions buttons (more than NB_MAX_VISIBLE_SUGGESTION_BUTTONS)
264 if (((eventType == SWIPED_LEFT) || (eventType == SWIPED_RIGHT))
265 && (suggestionsContainer->nbChildren == NB_SUGGESTION_CHILDREN)
266 && (nbActiveButtons > NB_MAX_VISIBLE_SUGGESTION_BUTTONS)) {
267 uint32_t i = 0;
268 while (i < (uint32_t) nbActiveButtons) {
269 if (((nbgl_button_t *) suggestionsContainer->children[FIRST_BUTTON_INDEX])->text
270 == choiceTexts[i]) {
271 break;
272 }
273 i++;
274 }
275
276 if (i < (uint32_t) nbActiveButtons) {
277 if (updateSuggestionButtons(suggestionsContainer, eventType, i)) {
278 os_io_seph_cmd_piezo_play_tune(TUNE_TAP_CASUAL);
279 nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
281 }
282
283 return true;
284 }
285 }
286 return false;
287}
288
289static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt,
290 const char *title,
291 const char *text,
292 bool numbered,
293 uint8_t number,
294 int textToken,
295 bool compactMode)
296{
297 nbgl_container_t *mainContainer, *container;
298 nbgl_text_area_t *textArea;
299 layoutObj_t *obj;
300 uint16_t textEntryHeight = (compactMode ? TEXT_ENTRY_COMPACT_HEIGHT : TEXT_ENTRY_NORMAL_HEIGHT);
301 bool withCross = ((text != NULL) && (strlen(text) > 0));
302
303 // create a main container, to store title, and text-entry container
304 mainContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
305 mainContainer->nbChildren = 2;
306 mainContainer->children = nbgl_containerPoolGet(mainContainer->nbChildren, layoutInt->layer);
307 mainContainer->obj.area.width = AVAILABLE_WIDTH;
308 mainContainer->obj.alignment = CENTER;
309
310 if (title != NULL) {
311 // create text area for title
312 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
313 textArea->textColor = BLACK;
314 textArea->text = title;
315 textArea->textAlignment = CENTER;
316 textArea->fontId = SMALL_REGULAR_FONT;
317 textArea->wrapping = true;
318 textArea->obj.alignment = TOP_MIDDLE;
319 textArea->obj.area.width = AVAILABLE_WIDTH;
320 textArea->obj.area.height = nbgl_getTextHeightInWidth(
321 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
322 mainContainer->children[0] = (nbgl_obj_t *) textArea;
323 mainContainer->obj.area.height = textArea->obj.area.height + TITLE_ENTRY_MARGIN_Y;
324 }
325
326 // create a text-entry container number, entered text, potential cross and underline
327 container = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
328 container->nbChildren = 4;
329 container->children = nbgl_containerPoolGet(container->nbChildren, layoutInt->layer);
330 container->obj.area.width = AVAILABLE_WIDTH;
331 container->obj.alignment = BOTTOM_MIDDLE;
332
333 if (numbered) {
334 // create Word num typed text
335 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
336 textArea->textColor = BLACK;
337 snprintf(numText, sizeof(numText), "%d.", number);
338 textArea->text = numText;
339 textArea->textAlignment = CENTER;
340 textArea->fontId = TEXT_ENTRY_FONT;
341 textArea->obj.area.width = NUMBER_WIDTH;
342 textArea->obj.alignment = MID_LEFT;
343 textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
344 // set this text area as child of the container
345 container->children[NUMBER_INDEX] = (nbgl_obj_t *) textArea;
346 }
347
348 // create text area for entered text
349 textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
350 textArea->textColor = BLACK;
351 textArea->text = text;
352 textArea->textAlignment = MID_LEFT;
353 textArea->fontId = TEXT_ENTRY_FONT;
354 textArea->obj.area.width = AVAILABLE_WIDTH - DELETE_ICON.width - NUMBER_TEXT_SPACE;
355 if (numbered) {
356 textArea->obj.alignmentMarginX = NUMBER_TEXT_SPACE;
357 textArea->obj.alignTo = container->children[0];
358 textArea->obj.alignment = MID_RIGHT;
359 textArea->obj.area.width -= textArea->obj.alignmentMarginX + NUMBER_WIDTH;
360 }
361 else {
362 textArea->obj.alignment = MID_LEFT;
363 }
364 textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
365 textArea->autoHideLongLine = true;
366
367 container->children[TEXT_INDEX] = (nbgl_obj_t *) textArea;
368 container->obj.area.height = textEntryHeight;
369
370 // Create Cross
371 nbgl_image_t *image = (nbgl_image_t *) nbgl_objPoolGet(IMAGE, layoutInt->layer);
372 image->buffer = &DELETE_ICON;
373 // only display it if text non empty
374 image->foregroundColor = withCross ? BLACK : WHITE;
375 obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) image, textToken, NBGL_NO_TUNE);
376 if (obj == NULL) {
377 return NULL;
378 }
379 image->obj.alignment = MID_RIGHT;
380 image->obj.alignTo = container->children[TEXT_INDEX];
381 image->obj.alignmentMarginX = NUMBER_TEXT_SPACE;
382 image->obj.touchMask = (1 << TOUCHED);
383 image->obj.touchId = ENTERED_TEXT_ID;
384 container->children[DELETE_INDEX] = (nbgl_obj_t *) image;
385
386 // create gray line
387 nbgl_line_t *line = (nbgl_line_t *) nbgl_objPoolGet(LINE, layoutInt->layer);
388 line->lineColor = LINE_COLOR;
389 // align on bottom of the text entry container
390 line->obj.alignment = BOTTOM_MIDDLE;
391 line->obj.area.width = AVAILABLE_WIDTH;
392 line->obj.area.height = LINE_THICKNESS;
393 line->direction = HORIZONTAL;
394 line->thickness = LINE_THICKNESS;
395 // set this line as child of the text entry container
396 container->children[LINE_INDEX] = (nbgl_obj_t *) line;
397
398 // set this text entry container as child of the main container
399 mainContainer->children[1] = (nbgl_obj_t *) container;
400 mainContainer->obj.area.height += container->obj.area.height;
401
402 return mainContainer;
403}
404
405static nbgl_container_t *addSuggestionButtons(nbgl_layoutInternal_t *layoutInt,
406 uint8_t nbUsedButtons,
407 const char **buttonTexts,
408 int firstButtonToken,
409 tune_index_e tuneId)
410{
411 nbgl_container_t *suggestionsContainer;
412 layoutObj_t *obj;
413
414 nbActiveButtons = nbUsedButtons;
415 suggestionsContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
416 suggestionsContainer->layout = VERTICAL;
417 suggestionsContainer->obj.area.width = SCREEN_WIDTH;
418#ifndef USE_PARTIAL_BUTTONS
419 // 2 rows of buttons with radius=32, and a intervale of 8px
420 suggestionsContainer->obj.area.height = 2 * SMALL_BUTTON_HEIGHT + INTERNAL_MARGIN + 28;
421#else // USE_PARTIAL_BUTTONS
422 // 1 row of buttons + 24px + page indicator
423 suggestionsContainer->obj.area.height = SUGGESTION_CONTAINER_HEIGHT;
424#endif // USE_PARTIAL_BUTTONS
425 suggestionsContainer->nbChildren = NB_SUGGESTION_CHILDREN;
426 suggestionsContainer->children
428
429 // put suggestionsContainer at the bottom of main container
430 suggestionsContainer->obj.alignmentMarginY = BOTTOM_NORMAL_MARGIN;
431 suggestionsContainer->obj.alignment = BOTTOM_MIDDLE;
432
433 // create all possible suggestion buttons, even if not displayed at first
434 for (int i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
435 nbgl_button_t *button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer);
436
437 obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) button, firstButtonToken + i, tuneId);
438 if (obj == NULL) {
439 return NULL;
440 }
441
442 button->innerColor = BLACK;
443 button->borderColor = BLACK;
444 button->foregroundColor = WHITE;
445 button->obj.area.width
446 = (SCREEN_WIDTH - (2 * SUGGESTION_BUTTONS_SIDE_MARGIN) - INTERNAL_MARGIN) / 2;
447 button->obj.area.height = SMALL_BUTTON_HEIGHT;
448 button->radius = SMALL_BUTTON_RADIUS_INDEX;
449 button->fontId = SMALL_BOLD_1BPP_FONT;
450 button->text = buttonTexts[i];
451 button->obj.touchMask = (1 << TOUCHED);
452 button->obj.touchId = CONTROLS_ID + i;
453
454 suggestionsContainer->children[i + FIRST_BUTTON_INDEX] = (nbgl_obj_t *) button;
455 }
456 // The first child is used by the progress indicator, if more that
457 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
458 nbgl_page_indicator_t *indicator
460 indicator->activePage = 0;
461 indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1)
462 / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
463 indicator->obj.area.width
464 = (indicator->nbPages < 3) ? STEPPER_2_PAGES_WIDTH : STEPPER_N_PAGES_WIDTH;
465 indicator->obj.alignment = BOTTOM_MIDDLE;
466 indicator->style = CURRENT_INDICATOR;
467 suggestionsContainer->children[PAGE_INDICATOR_INDEX] = (nbgl_obj_t *) indicator;
468#ifdef USE_PARTIAL_BUTTONS
469 // also allocate the semi disc that may be displayed on the left or right of the full
470 // buttons
471 nbgl_objPoolGetArray(IMAGE, 2, layoutInt->layer, (nbgl_obj_t **) &partialButtonImages);
472 partialButtonImages[0]->buffer = &LEFT_HALF_ICON;
473 partialButtonImages[0]->obj.alignment = TOP_LEFT;
474 partialButtonImages[0]->foregroundColor = BLACK;
475 partialButtonImages[0]->transformation = VERTICAL_MIRROR;
476 partialButtonImages[1]->buffer = &LEFT_HALF_ICON;
477 partialButtonImages[1]->obj.alignment = TOP_RIGHT;
478 partialButtonImages[1]->foregroundColor = BLACK;
479 partialButtonImages[1]->transformation = NO_TRANSFORMATION;
480 updateSuggestionButtons(suggestionsContainer, 0, 0);
481#endif // USE_PARTIAL_BUTTONS
482
483 return suggestionsContainer;
484}
485
486static nbgl_button_t *addConfirmationButton(nbgl_layoutInternal_t *layoutInt,
487 bool active,
488 const char *text,
489 int token,
490 tune_index_e tuneId,
491 bool compactMode)
492{
493 nbgl_button_t *button;
494 layoutObj_t *obj;
495
496 button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer);
497 obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) button, token, tuneId);
498 if (obj == NULL) {
499 return NULL;
500 }
501
502 // put button at the bottom of the main container
503 button->obj.alignmentMarginY = compactMode ? BOTTOM_COMPACT_MARGIN : BOTTOM_CONFIRM_MARGIN;
504 button->obj.alignment = BOTTOM_MIDDLE;
505 button->foregroundColor = WHITE;
506 if (active) {
507 button->innerColor = BLACK;
508 button->borderColor = BLACK;
509 button->obj.touchMask = (1 << TOUCHED);
510 button->obj.touchId = BOTTOM_BUTTON_ID;
511 }
512 else {
513 button->borderColor = INACTIVE_COLOR;
514 button->innerColor = INACTIVE_COLOR;
515 }
516 button->text = PIC(text);
517 button->fontId = SMALL_BOLD_1BPP_FONT;
518 button->obj.area.width = AVAILABLE_WIDTH;
519 button->obj.area.height = BUTTON_DIAMETER;
520 button->radius = BUTTON_RADIUS;
521
522 return button;
523}
524
525/**********************
526 * GLOBAL API FUNCTIONS
527 **********************/
528
537{
538 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
539 nbgl_keyboard_t *keyboard;
540
541 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddKeyboard():\n");
542 if (layout == NULL) {
543 return -1;
544 }
545 // footer must be empty
546 if (layoutInt->footerContainer != NULL) {
547 return -1;
548 }
549
550 // create keyboard
551 keyboard = (nbgl_keyboard_t *) nbgl_objPoolGet(KEYBOARD, layoutInt->layer);
552 keyboard->obj.area.width = SCREEN_WIDTH;
553 keyboard->obj.area.height = 3 * KEYBOARD_KEY_HEIGHT;
554 if (!kbdInfo->lettersOnly) {
555 keyboard->obj.area.height += KEYBOARD_KEY_HEIGHT;
556 }
557#ifdef TARGET_STAX
558 keyboard->obj.alignmentMarginY = 56;
559#endif // TARGET_STAX
560 keyboard->obj.alignment = BOTTOM_MIDDLE;
561 keyboard->borderColor = LIGHT_GRAY;
562 keyboard->callback = PIC(kbdInfo->callback);
563 keyboard->lettersOnly = kbdInfo->lettersOnly;
564 keyboard->mode = kbdInfo->mode;
565 keyboard->keyMask = kbdInfo->keyMask;
566 keyboard->casing = kbdInfo->casing;
567
568 // the keyboard occupies the footer
569 layoutInt->footerContainer = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);
570 layoutInt->footerContainer->obj.area.width = SCREEN_WIDTH;
571 layoutInt->footerContainer->layout = VERTICAL;
572 layoutInt->footerContainer->children
573 = (nbgl_obj_t **) nbgl_containerPoolGet(1, layoutInt->layer);
574 layoutInt->footerContainer->obj.alignment = BOTTOM_MIDDLE;
575 layoutInt->footerContainer->obj.area.height
576 = keyboard->obj.area.height + keyboard->obj.alignmentMarginY;
577 layoutInt->footerContainer->children[0] = (nbgl_obj_t *) keyboard;
578 layoutInt->footerContainer->nbChildren = 1;
579
580 // add footer to layout children
581 layoutInt->children[FOOTER_INDEX] = (nbgl_obj_t *) layoutInt->footerContainer;
582
583 // subtract footer height from main container height
584 layoutInt->container->obj.area.height -= layoutInt->footerContainer->obj.area.height;
585
586 // create the 2 children for main container (to hold keyboard content)
587 layoutAddObject(layoutInt, (nbgl_obj_t *) NULL);
588 layoutAddObject(layoutInt, (nbgl_obj_t *) NULL);
589
590 layoutInt->footerType = KEYBOARD_FOOTER_TYPE;
591
592 return layoutInt->footerContainer->obj.area.height;
593}
594
606 uint8_t index,
607 uint32_t keyMask,
608 bool updateCasing,
609 keyboardCase_t casing)
610{
611 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
612 nbgl_keyboard_t *keyboard;
613
614 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboard(): keyMask = 0x%X\n", keyMask);
615 if (layout == NULL) {
616 return -1;
617 }
618 UNUSED(index);
619
620 // get existing keyboard (in the footer container)
621 keyboard = (nbgl_keyboard_t *) layoutInt->footerContainer->children[0];
622 if ((keyboard == NULL) || (keyboard->obj.type != KEYBOARD)) {
623 return -1;
624 }
625 keyboard->keyMask = keyMask;
626 if (updateCasing) {
627 keyboard->casing = casing;
628 }
629
630 nbgl_objDraw((nbgl_obj_t *) keyboard);
631
632 return 0;
633}
634
643{
644 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
645 nbgl_keyboard_t *keyboard;
646
647 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutKeyboardNeedsRefresh(): \n");
648 if (layout == NULL) {
649 return -1;
650 }
651 UNUSED(index);
652
653 // get existing keyboard (in the footer container)
654 keyboard = (nbgl_keyboard_t *) layoutInt->footerContainer->children[0];
655 if ((keyboard == NULL) || (keyboard->obj.type != KEYBOARD)) {
656 return -1;
657 }
658 if (keyboard->needsRefresh) {
659 keyboard->needsRefresh = false;
660 return true;
661 }
662
663 return false;
664}
665
684 bool numbered,
685 uint8_t number,
686 const char *text,
687 bool grayedOut,
688 int offsetY,
689 int token)
690{
691 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
692 nbgl_container_t *container;
693 uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1;
694 bool compactMode = ((layoutInt->container->children[enteredTextIndex + 1] != NULL)
695 && (layoutInt->container->children[enteredTextIndex + 1]->type == BUTTON)
696 && (layoutInt->container->nbChildren == 3));
697
698 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddEnteredText():\n");
699 if (layout == NULL) {
700 return -1;
701 }
702 UNUSED(offsetY);
703 UNUSED(grayedOut);
704
705 container = addTextEntry(layoutInt, NULL, text, numbered, number, token, compactMode);
706
707 // set this container as first or 2nd child of the main layout container
708 layoutInt->container->children[enteredTextIndex] = (nbgl_obj_t *) container;
709
710 if (layoutInt->container->children[enteredTextIndex + 1] != NULL) {
711 if (layoutInt->container->children[enteredTextIndex + 1]->type == BUTTON) {
712 nbgl_button_t *button
713 = (nbgl_button_t *) layoutInt->container->children[enteredTextIndex + 1];
714 container->obj.alignmentMarginY
715 -= (button->obj.area.height + button->obj.alignmentMarginY
716 + (compactMode ? TOP_COMPACT_MARGIN : TOP_NORMAL_MARGIN))
717 / 2;
718 }
719 else if (layoutInt->container->children[enteredTextIndex + 1]->type == CONTAINER) {
720 nbgl_container_t *suggestionContainer
721 = (nbgl_container_t *) layoutInt->container->children[enteredTextIndex + 1];
722 container->obj.alignmentMarginY
723 -= (suggestionContainer->obj.area.height + suggestionContainer->obj.alignmentMarginY
724 + (compactMode ? TOP_COMPACT_MARGIN : TOP_NORMAL_MARGIN))
725 / 2;
726 }
727 }
728 // if a centered info has be used for title, entered text is the second child and we have to
729 // adjust layout
730 if (layoutInt->container->nbChildren == 3) {
731 container->obj.alignmentMarginY += layoutInt->container->children[0]->area.height / 2;
732 }
733
734 // return 0
735 return 0;
736}
737
752 uint8_t index,
753 bool numbered,
754 uint8_t number,
755 const char *text,
756 bool grayedOut)
757{
758 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
759 nbgl_container_t *container;
760 nbgl_text_area_t *textArea;
761 uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1;
762
763 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateEnteredText():\n");
764 if (layout == NULL) {
765 return -1;
766 }
767 UNUSED(index);
768
769 // update text entry area
770 container = (nbgl_container_t *) layoutInt->container->children[enteredTextIndex];
771 if ((container == NULL) || (container->obj.type != CONTAINER)) {
772 return -1;
773 }
774 textArea = (nbgl_text_area_t *) container->children[2];
775 if ((textArea == NULL) || (textArea->obj.type != TEXT_AREA)) {
776 return -1;
777 }
778 textArea->text = text;
779 textArea->textColor = grayedOut ? INACTIVE_TEXT_COLOR : BLACK;
780 textArea->textAlignment = MID_LEFT;
781 nbgl_objDraw((nbgl_obj_t *) textArea);
782
783 // update number text area
784 if (numbered) {
785 // it is the previously created object
786 textArea = (nbgl_text_area_t *) layoutInt->container->children[1];
787 snprintf(numText, sizeof(numText), "%d.", number);
788 textArea->text = numText;
789 nbgl_objDraw((nbgl_obj_t *) textArea);
790 }
791 // if the text doesn't fit, indicate it by returning 1 instead of 0, for different refresh
792 if (nbgl_getSingleLineTextWidth(textArea->fontId, text) > textArea->obj.area.width) {
793 return 1;
794 }
795 return 0;
796}
797
810 bool active,
811 const char *text,
812 int token,
813 tune_index_e tuneId)
814{
815 nbgl_button_t *button;
816 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
817 uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1;
818 bool compactMode = (layoutInt->container->nbChildren == 3);
819
820 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddConfirmationButton():\n");
821 if (layout == NULL) {
822 return -1;
823 }
824
825 button = addConfirmationButton(layoutInt, active, text, token, tuneId, compactMode);
826 // set this button as second child of the main layout container
827 layoutInt->container->children[enteredTextIndex + 1] = (nbgl_obj_t *) button;
828 if (layoutInt->container->children[enteredTextIndex] != NULL) {
829 ((nbgl_container_t *) layoutInt->container->children[enteredTextIndex])
830 ->obj.alignmentMarginY
831 -= (button->obj.area.height + button->obj.alignmentMarginY
832 + (compactMode ? TOP_COMPACT_MARGIN : TOP_NORMAL_MARGIN))
833 / 2;
834 }
835 // return 0
836 return 0;
837}
838
851 uint8_t index,
852 bool active,
853 const char *text)
854{
855 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
856 nbgl_button_t *button;
857 uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1;
858
859 UNUSED(index);
860
861 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateConfirmationButton():\n");
862 if (layout == NULL) {
863 return -1;
864 }
865
866 // update main text area
867 button = (nbgl_button_t *) layoutInt->container->children[enteredTextIndex + 1];
868 if ((button == NULL) || (button->obj.type != BUTTON)) {
869 return -1;
870 }
871 button->text = text;
872
873 if (active) {
874 button->innerColor = BLACK;
875 button->borderColor = BLACK;
876 button->obj.touchMask = (1 << TOUCHED);
877 button->obj.touchId = BOTTOM_BUTTON_ID;
878 }
879 else {
880 button->borderColor = INACTIVE_COLOR;
881 button->innerColor = INACTIVE_COLOR;
882 }
883 nbgl_objDraw((nbgl_obj_t *) button);
884 return 0;
885}
886
896{
897 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
898 nbgl_container_t *textEntryContainer;
899 bool compactMode = ((content->type == KEYBOARD_WITH_BUTTON) && (content->title != NULL));
900
901 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddKeyboardContent():\n");
902 if (layout == NULL) {
903 return -1;
904 }
905
906 textEntryContainer = addTextEntry(layoutInt,
907 content->title,
908 content->text,
909 content->numbered,
910 content->number,
911 content->textToken,
912 compactMode);
913
914 // set this container as first child of the main layout container
915 layoutInt->container->children[0] = (nbgl_obj_t *) textEntryContainer;
916
917 if (content->type == KEYBOARD_WITH_SUGGESTIONS) {
918 nbgl_container_t *suggestionsContainer
919 = addSuggestionButtons(layoutInt,
921 content->suggestionButtons.buttons,
923 content->tuneId);
924 // set this container as second child of the main layout container
925 layoutInt->container->children[1] = (nbgl_obj_t *) suggestionsContainer;
926 // the main container is swipable on Flex
927 if (layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) layoutInt->container, 0, NBGL_NO_TUNE)
928 == NULL) {
929 return -1;
930 }
931 layoutInt->container->obj.touchMask = (1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT);
932 layoutInt->container->obj.touchId = CONTROLS_ID;
934 textEntryContainer->obj.alignmentMarginY
935 -= (suggestionsContainer->obj.area.height + suggestionsContainer->obj.alignmentMarginY
936 + TOP_NORMAL_MARGIN)
937 / 2;
938 }
939 else if (content->type == KEYBOARD_WITH_BUTTON) {
940 nbgl_button_t *button = addConfirmationButton(layoutInt,
941 content->confirmationButton.active,
942 content->confirmationButton.text,
943 content->confirmationButton.token,
944 content->tuneId,
945 (content->title != NULL));
946 // set this button as second child of the main layout container
947 layoutInt->container->children[1] = (nbgl_obj_t *) button;
948 textEntryContainer->obj.alignmentMarginY
949 -= (button->obj.area.height + button->obj.alignmentMarginY
950 + ((content->title != NULL) ? TOP_COMPACT_MARGIN : TOP_CONFIRM_MARGIN))
951 / 2;
952 }
953 return layoutInt->container->obj.area.height;
954}
955
967{
968 nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
969 nbgl_container_t *mainContainer, *container;
970 nbgl_text_area_t *textArea;
971 nbgl_image_t *image;
972 int ret = 0;
973
974 LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateKeyboardContent():\n");
975 if (layout == NULL) {
976 return -1;
977 }
978
979 // get top container from main container (it shall be the 1st object)
980 mainContainer = (nbgl_container_t *) layoutInt->container->children[0];
981 container = (nbgl_container_t *) mainContainer->children[1];
982
983 if (content->numbered) {
984 // get Word number typed text
985 textArea = (nbgl_text_area_t *) container->children[NUMBER_INDEX];
986 snprintf(numText, sizeof(numText), "%d.", content->number);
987 nbgl_objDraw((nbgl_obj_t *) textArea);
988 }
989
990 // get text area for entered text
991 textArea = (nbgl_text_area_t *) container->children[TEXT_INDEX];
992 textArea->text = content->text;
993 nbgl_objDraw((nbgl_obj_t *) textArea);
994
995 // get delete cross
996 image = (nbgl_image_t *) container->children[DELETE_INDEX];
997 if ((textArea->text != NULL) && (strlen(textArea->text) > 0)) {
998 if (image->foregroundColor == WHITE) {
999 image->foregroundColor = BLACK;
1000 nbgl_objDraw((nbgl_obj_t *) image);
1001 }
1002 }
1003 else {
1004 if (image->foregroundColor == BLACK) {
1005 image->foregroundColor = WHITE;
1006 nbgl_objDraw((nbgl_obj_t *) image);
1007 }
1008 }
1009
1010 if (content->type == KEYBOARD_WITH_SUGGESTIONS) {
1011 uint8_t i = 0;
1012 nbActiveButtons = content->suggestionButtons.nbUsedButtons;
1013 nbgl_container_t *suggestionsContainer
1014 = (nbgl_container_t *) layoutInt->container->children[1];
1015
1016 // update suggestion texts
1017 for (i = 0; i < NB_MAX_SUGGESTION_BUTTONS; i++) {
1018 choiceTexts[i] = content->suggestionButtons.buttons[i];
1019 }
1020 // update suggestion buttons
1021 for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) {
1022 // some buttons may not be visible
1023 if (i < nbActiveButtons) {
1024 ((nbgl_button_t *) suggestionsContainer->children[i + FIRST_BUTTON_INDEX])->text
1025 = choiceTexts[i];
1026 }
1027 else {
1028 ((nbgl_button_t *) suggestionsContainer->children[i + FIRST_BUTTON_INDEX])->text
1029 = NULL;
1030 }
1031 }
1032 suggestionsContainer->forceClean = true;
1033 // the first child is used by the progress indicator, if more than
1034 // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons
1035 nbgl_page_indicator_t *indicator
1036 = (nbgl_page_indicator_t *) suggestionsContainer->children[PAGE_INDICATOR_INDEX];
1037 indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1)
1038 / NB_MAX_VISIBLE_SUGGESTION_BUTTONS;
1039 indicator->activePage = 0;
1040 updateSuggestionButtons(suggestionsContainer, 0, 0);
1041
1042 nbgl_objDraw((nbgl_obj_t *) suggestionsContainer);
1043 }
1044 else if (content->type == KEYBOARD_WITH_BUTTON) {
1045 // update main text area
1046 nbgl_button_t *button = (nbgl_button_t *) layoutInt->container->children[1];
1047 if ((button == NULL) || (button->obj.type != BUTTON)) {
1048 return -1;
1049 }
1050 button->text = content->confirmationButton.text;
1051
1052 if (content->confirmationButton.active) {
1053#if NB_COLOR_BITS == 4
1054 // if the button was inactive (in grey), a non-fast refresh will be necessary
1055 if (button->innerColor == INACTIVE_COLOR) {
1056 ret = 1;
1057 }
1058#endif
1059 button->innerColor = BLACK;
1060 button->borderColor = BLACK;
1061 button->obj.touchMask = (1 << TOUCHED);
1062 button->obj.touchId = BOTTOM_BUTTON_ID;
1063 }
1064 else {
1065 button->borderColor = INACTIVE_COLOR;
1066 button->innerColor = INACTIVE_COLOR;
1067 }
1068 nbgl_objDraw((nbgl_obj_t *) button);
1069 }
1070
1071 // if the entered text doesn't fit, indicate it by returning 1 instead of 0, for different
1072 // refresh
1073 if (nbgl_getSingleLineTextWidth(textArea->fontId, content->text) > textArea->obj.area.width) {
1074 ret = 1;
1075 }
1076 return ret;
1077}
1078
1079#endif // NBGL_KEYBOARD
1080#endif // HAVE_SE_TOUCH
debug traces management
#define LOG_DEBUG(__logger,...)
Definition nbgl_debug.h:86
@ LAYOUT_LOGGER
Definition nbgl_debug.h:33
Middle Level API of the new BOLOS Graphical Library.
uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
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
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_NO_TUNE
Definition nbgl_layout.h:26
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
#define KEYBOARD_FOOTER_TYPE
#define INTERNAL_MARGIN
@ FOOTER_INDEX
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.
bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
@ SECOND_BUTTON_INDEX
@ NB_SUGGESTION_CHILDREN
@ PAGE_INDICATOR_INDEX
@ FIRST_BUTTON_INDEX
@ THIRD_BUTTON_INDEX
@ FOURTH_BUTTON_INDEX
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...
int nbgl_layoutAddEnteredText(nbgl_layout_t *layout, bool numbered, uint8_t number, const char *text, bool grayedOut, int offsetY, int token)
Adds a "text entry" area under the previously entered object. This area can be preceded (beginning of...
int nbgl_layoutUpdateConfirmationButton(nbgl_layout_t *layout, uint8_t index, bool active, const char *text)
Updates an existing black full width confirmation button on top of the previously added keyboard.
int nbgl_layoutUpdateEnteredText(nbgl_layout_t *layout, uint8_t index, bool numbered, uint8_t number, const char *text, bool grayedOut)
Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText()
#define LINE_THICKNESS
#define SUGGESTION_BUTTONS_SIDE_MARGIN
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...
@ DELETE_INDEX
@ NUMBER_INDEX
int nbgl_layoutAddConfirmationButton(nbgl_layout_t *layout, bool active, const char *text, int token, tune_index_e tuneId)
Adds a black full width confirmation button on top of the previously added keyboard.
#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
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)
keyboardCase_t
Letters casing in which to open/set the keyboard.
Definition nbgl_obj.h:613
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:279
#define INACTIVE_TEXT_COLOR
Definition nbgl_obj.h:280
@ CONTROLS_ID
Definition nbgl_obj.h:691
@ ENTERED_TEXT_ID
Definition nbgl_obj.h:685
@ BOTTOM_BUTTON_ID
Definition nbgl_obj.h:672
#define BUTTON_DIAMETER
Definition nbgl_obj.h:99
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:488
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
API to manage screens.
@ WHITE
Definition nbgl_types.h:144
@ LIGHT_GRAY
Definition nbgl_types.h:143
@ BLACK
Definition nbgl_types.h:141
#define VERTICAL_MIRROR
Definition nbgl_types.h:97
nbgl_touchType_t
The different types of Touchscreen events.
Definition nbgl_types.h:259
@ SWIPED_LEFT
Definition nbgl_types.h:274
@ SWIPED_RIGHT
Definition nbgl_types.h:273
@ TOUCHED
Definition nbgl_types.h:260
@ VERTICAL
from top to bottom
Definition nbgl_types.h:209
@ HORIZONTAL
from left to right
Definition nbgl_types.h:210
@ TOP_MIDDLE
Definition nbgl_types.h:182
@ CENTER
Definition nbgl_types.h:185
@ TOP_LEFT
Definition nbgl_types.h:181
@ MID_RIGHT
Definition nbgl_types.h:186
@ TOP_RIGHT
Definition nbgl_types.h:183
@ MID_LEFT
Definition nbgl_types.h:184
@ BOTTOM_MIDDLE
Definition nbgl_types.h:188
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
Definition nbgl_types.h:157
@ BUTTON
Rounded rectangle button with icon and/or text.
Definition nbgl_types.h:160
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
Definition nbgl_types.h:162
@ LINE
Vertical or Horizontal line.
Definition nbgl_types.h:158
@ KEYBOARD
Keyboard.
Definition nbgl_types.h:166
@ CONTAINER
Empty container.
Definition nbgl_types.h:156
@ TEXT_AREA
Area to contain text line(s)
Definition nbgl_types.h:159
#define NO_TRANSFORMATION
Definition nbgl_types.h:91
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
Definition nbgl_types.h:327
int token
token of the button
const char * text
text of the button
bool active
if true, button is active, otherwise inactive (grayed-out)
Structure containing all information about the current layout.
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
uint8_t layer
layer in screen stack
nbgl_swipe_usage_t swipeUsage
nbgl_container_t * container
nbgl_layoutFooterType_t footerType
type of footer
nbgl_obj_t ** children
children for main screen
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 buttons
const char ** buttons
array of 4 strings for buttons (last ones can be NULL)