23#include "os_io_seph_ux.h"
25#include "os_helpers.h"
32#define INTERNAL_SPACE 16
34#define INNER_MARGIN 12
36#define NB_MAX_LAYOUTS 3
39#define NB_MAX_CONTAINER_CHILDREN 20
41#define TAG_VALUE_ICON_WIDTH 32
43#if defined(TARGET_STAX)
44#define RADIO_CHOICE_HEIGHT 96
45#define FOOTER_HEIGHT 80
46#define BAR_INTERVALE 12
47#define FOOTER_BUTTON_HEIGHT 128
48#define UP_FOOTER_BUTTON_HEIGHT 120
49#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 192
50#define ACTION_AND_FOOTER_FOOTER_HEIGHT 216
51#define FOOTER_TEXT_AND_NAV_WIDTH 160
52#define TAP_TO_CONTINUE_MARGIN 24
53#define SUB_HEADER_MARGIN (2 * 24)
54#define PRE_FIRST_TEXT_MARGIN 24
55#define INTER_PARAGRAPHS_MARGIN 40
56#define PRE_TITLE_MARGIN 24
57#define PRE_DESCRIPTION_MARGIN 16
58#define INTER_ROWS_MARGIN 16
59#define QR_INTER_TEXTS_MARGIN 40
60#define SPINNER_TEXT_MARGIN 20
61#define SPINNER_INTER_TEXTS_MARGIN 20
62#define BAR_TEXT_MARGIN 24
63#define BAR_INTER_TEXTS_MARGIN 16
64#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 28
65#define LEFT_CONTENT_TEXT_PADDING 0
66#elif defined(TARGET_FLEX)
67#define RADIO_CHOICE_HEIGHT 92
68#define FOOTER_HEIGHT 80
69#define BAR_INTERVALE 16
70#define FOOTER_BUTTON_HEIGHT 136
71#define UP_FOOTER_BUTTON_HEIGHT 136
72#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
73#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
74#define FOOTER_TEXT_AND_NAV_WIDTH 192
75#define TAP_TO_CONTINUE_MARGIN 30
76#define SUB_HEADER_MARGIN (2 * 28)
77#define PRE_FIRST_TEXT_MARGIN 0
78#define INTER_PARAGRAPHS_MARGIN 24
79#define PRE_TITLE_MARGIN 16
80#define PRE_DESCRIPTION_MARGIN 24
81#define INTER_ROWS_MARGIN 26
82#define QR_INTER_TEXTS_MARGIN 28
83#define SPINNER_TEXT_MARGIN 24
84#define SPINNER_INTER_TEXTS_MARGIN 16
85#define BAR_TEXT_MARGIN 24
86#define BAR_INTER_TEXTS_MARGIN 16
87#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 32
88#define LEFT_CONTENT_TEXT_PADDING 4
90#error Undefined target
94#define SPINNER_REFRESH_PERIOD 400
122#ifdef HAVE_PIEZO_SOUND
138static uint8_t nbTouchableControls = 0;
145#ifdef HAVE_FAST_HOLD_TO_APPROVE
147#define HOLD_TO_APPROVE_STEP_PERCENT (7)
151#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
153#define HOLD_TO_APPROVE_STEP_PERCENT (25)
154#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
157static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
159#ifdef HAVE_FAST_HOLD_TO_APPROVE
168static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
178 if (gLayout[i].nbChildren > 0) {
183 if (obj == gLayout[i].callbackObjPool[j].obj) {
185 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
186 "nbUsedCallbackObjs = %d\n",
189 gLayout[i].nbUsedCallbackObjs);
190 *layout = &gLayout[i];
201static void radioTouchCallback(
nbgl_obj_t *obj,
214 bool needRefresh =
false;
220 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
222 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
225 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
243 layoutObj->
index = eventType;
292 layoutObj->
index = lSwitch->state;
298 radioTouchCallback(obj, eventType, layout);
305 longTouchCallback(obj, eventType, layout, layoutObj);
310#ifdef HAVE_PIEZO_SOUND
312 os_io_seph_cmd_piezo_play_tune(layoutObj->
tuneId);
333 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
336 gLayout[1].nbChildren);
343 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
347 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
350 if (new_state >= 100) {
355 if (new_state != progressBar->state) {
356 progressBar->partialRedraw =
true;
357 progressBar->state = new_state;
366 if (trigger_callback) {
377 progressBar->partialRedraw =
true;
378 progressBar->state = 0;
385static void radioTouchCallback(
nbgl_obj_t *obj,
389 uint8_t i =
NB_MAX_LAYOUTS, radioIndex = 0, foundRadio = 0xFF, foundRadioIndex;
397 while (i < layout->nbUsedCallbackObjs) {
407 foundRadioIndex = radioIndex;
409 textArea->textColor =
BLACK;
410 textArea->fontId = SMALL_BOLD_FONT;
432 textArea->fontId = SMALL_REGULAR_FONT;
440 if (foundRadio != 0xFF) {
442#ifdef HAVE_PIEZO_SOUND
454static void spinnerTickerCallback(
void)
461 if (gLayout[1].nbChildren > 0) {
462 layout = &gLayout[1];
465 layout = &gLayout[0];
469 while (i < layout->container->nbChildren) {
472 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
477 spinner->position = 0;
489static void animTickerCallback(
void)
496 if (gLayout[1].nbChildren > 0) {
497 layout = &gLayout[1];
500 layout = &gLayout[0];
508 while (i < layout->container->nbChildren) {
511 if (container->children[1]->type ==
IMAGE) {
550static nbgl_line_t *createHorizontalLine(uint8_t layer)
556 line->obj.area.width = SCREEN_WIDTH;
557 line->obj.area.height = 4;
563static nbgl_line_t *createLeftVerticalLine(uint8_t layer)
569 line->obj.area.width = 1;
570 line->obj.area.height = SCREEN_HEIGHT;
589 layoutObj->
obj = obj;
590 layoutObj->
token = token;
591 layoutObj->
tuneId = tuneId;
640 layoutInt->
container->obj.touchMask = swipesMask;
661 int16_t usedHeight = 40;
667 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
674 container->nbChildren = 0;
677 container->obj.area.height = itemDesc->
large ? TOUCHABLE_MAIN_BAR_HEIGHT : TOUCHABLE_BAR_HEIGHT;
679 container->obj.alignmentMarginX = BORDER_MARGIN;
681 container->obj.alignTo = NULL;
686 container->obj.touchMask = (1 <<
TOUCHED);
687 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
688 nbTouchableControls++;
693 textArea->textColor = color;
694 textArea->text = PIC(itemDesc->
text);
695 textArea->onDrawCallback = NULL;
696 textArea->fontId = SMALL_BOLD_FONT;
697 textArea->wrapping =
true;
698 textArea->obj.area.width = container->obj.area.width;
701 textArea->obj.area.width
706 textArea->obj.area.width
710 textArea->obj.area.width -= 60 + BAR_INTERVALE;
713 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
714 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
718 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
719 container->nbChildren++;
724 imageLeft->foregroundColor = color;
725 imageLeft->buffer = PIC(itemDesc->
iconLeft);
727 imageLeft->obj.alignment =
MID_LEFT;
728 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
729 imageLeft->obj.alignmentMarginX = BAR_INTERVALE;
730 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
731 container->nbChildren++;
733 textArea->obj.alignmentMarginX = imageLeft->buffer->width + BAR_INTERVALE;
735 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
740 imageRight->foregroundColor = color;
741 imageRight->buffer = PIC(itemDesc->
iconRight);
744 imageRight->obj.alignmentMarginX = BAR_INTERVALE;
745 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
747 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
748 container->nbChildren++;
750 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
754 switchObj->onColor =
BLACK;
756 switchObj->state = itemDesc->
state;
758 switchObj->obj.alignmentMarginX = BAR_INTERVALE;
759 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
761 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
762 container->nbChildren++;
765 if (itemDesc->
subText != NULL) {
769 subTextArea->textColor = color;
770 subTextArea->text = PIC(itemDesc->
subText);
771 subTextArea->textAlignment =
MID_LEFT;
772 subTextArea->fontId = SMALL_REGULAR_FONT;
774 subTextArea->wrapping =
true;
775 subTextArea->obj.alignment =
MID_LEFT;
776 subTextArea->obj.area.width = container->obj.area.width;
779 subTextArea->obj.area.width,
780 subTextArea->wrapping);
781 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
782 container->nbChildren++;
783 container->obj.area.height += subTextArea->obj.area.height + 12;
786 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
787 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
810 uint16_t fullHeight = 0;
815 container->nbChildren = 0;
820 if (info->
icon != NULL) {
822 image->foregroundColor =
BLACK;
823 image->buffer = PIC(info->
icon);
825 image->obj.alignmentMarginY = info->
iconHug;
827 fullHeight += image->buffer->height + info->
iconHug;
828 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
829 container->nbChildren++;
834 anim->foregroundColor =
BLACK;
840 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
841 container->nbChildren++;
852 tickerCfg.tickerCallback = &animTickerCallback;
857 if (info->
title != NULL) {
859 textArea->textColor =
BLACK;
860 textArea->text = PIC(info->
title);
861 textArea->textAlignment =
CENTER;
862 textArea->fontId = LARGE_MEDIUM_FONT;
863 textArea->wrapping =
true;
866 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
869 if (container->nbChildren > 0) {
872 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
878 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
880 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
881 container->nbChildren++;
886 textArea->textColor =
BLACK;
888 textArea->textAlignment =
CENTER;
889 textArea->fontId = SMALL_BOLD_FONT;
890 textArea->wrapping =
true;
893 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
896 if (container->nbChildren > 0) {
898 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
899 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
900 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
901 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
904 textArea->obj.alignmentMarginY = 16;
911 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
913 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
914 container->nbChildren++;
919 textArea->textColor =
BLACK;
921 textArea->textAlignment =
CENTER;
922 textArea->fontId = SMALL_REGULAR_FONT;
923 textArea->wrapping =
true;
926 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
929 if (container->nbChildren > 0) {
931 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
932 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
934 textArea->obj.alignmentMarginY = 16;
937 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
944 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
946 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
947 container->nbChildren++;
953 textArea->text = PIC(info->
subText);
954 textArea->textAlignment =
CENTER;
955 textArea->fontId = SMALL_REGULAR_FONT;
956 textArea->wrapping =
true;
959 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
961 textArea->obj.area.height += 2 * 8;
963 if (container->nbChildren > 0) {
965 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
966 textArea->obj.alignmentMarginY = 16;
967 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
968 textArea->obj.alignmentMarginY += info->
iconHug;
975 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
977 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
978 container->nbChildren++;
981 container->obj.alignment =
CENTER;
983 container->obj.area.height = fullHeight;
985 container->obj.area.height += 40;
1005 uint16_t fullHeight = 0;
1007 if (layout == NULL) {
1019 textArea->textColor =
BLACK;
1020 textArea->text = PIC(text);
1021 textArea->textAlignment =
MID_LEFT;
1022 textArea->fontId = SMALL_BOLD_FONT;
1024 textArea->wrapping =
true;
1026 textArea->obj.alignmentMarginY = PRE_TEXT_MARGIN;
1027 textArea->obj.area.width = container->obj.area.width;
1028 if (withAlias ==
true) {
1029 textArea->obj.area.width -= 12 + MINI_PUSH_ICON.width;
1032 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1033 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1034 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1035 container->nbChildren++;
1036 if (withAlias ==
true) {
1042 image->foregroundColor =
BLACK;
1043 image->buffer = &PUSH_ICON;
1045 image->obj.alignmentMarginX = 12;
1046 image->obj.alignTo = (
nbgl_obj_t *) textArea;
1047 container->obj.touchMask = (1 <<
TOUCHED);
1050 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
1051 container->nbChildren++;
1054 if (subText != NULL) {
1056 subTextArea->textColor =
BLACK;
1057 subTextArea->text = PIC(subText);
1058 subTextArea->fontId = SMALL_REGULAR_FONT;
1060 subTextArea->wrapping =
true;
1061 subTextArea->obj.area.width = container->obj.area.width;
1064 subTextArea->obj.area.width,
1065 subTextArea->wrapping);
1066 subTextArea->textAlignment =
MID_LEFT;
1069 subTextArea->obj.alignmentMarginY = TEXT_SUBTEXT_MARGIN;
1072 subTextArea->obj.alignmentMarginY = PRE_SUBTEXT_MARGIN;
1074 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
1075 container->nbChildren++;
1076 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
1077 fullHeight += POST_SUBTEXT_MARGIN;
1080 fullHeight += PRE_TEXT_MARGIN;
1082 container->obj.area.height = fullHeight;
1084 container->obj.alignmentMarginX = BORDER_MARGIN;
1089 return container->obj.area.height;
1107 if (description->
modal) {
1108 if (gLayout[1].nbChildren == 0) {
1109 layout = &gLayout[1];
1111 else if (gLayout[2].nbChildren == 0) {
1112 layout = &gLayout[2];
1118 layout = &gLayout[0];
1120 if (layout == NULL) {
1128 nbTouchableControls = 0;
1133 if (description->
modal) {
1147 layout->
container->obj.area.width = SCREEN_WIDTH;
1148 layout->
container->obj.area.height = SCREEN_HEIGHT;
1165 obj->
tuneId = description->tapTuneId;
1173 footerDesc.
text.tuneId = description->tapTuneId;
1192 uint16_t swipesMask,
1195 tune_index_e tuneId)
1200 if (layout == NULL) {
1207 layoutInt->
tapText->text = PIC(text);
1209 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1213 layoutInt->
tapText->obj.alignmentMarginY = TAP_TO_CONTINUE_MARGIN;
1231 tune_index_e tuneId)
1238 if (layout == NULL) {
1247 button->obj.area.width = BUTTON_DIAMETER;
1248 button->obj.area.height = BUTTON_DIAMETER;
1249 button->radius = BUTTON_RADIUS;
1250 button->obj.alignmentMarginX = BORDER_MARGIN;
1251 button->obj.alignmentMarginY = BORDER_MARGIN;
1252 button->foregroundColor =
BLACK;
1253 button->innerColor =
WHITE;
1255 button->obj.touchMask = (1 <<
TOUCHED);
1257 button->icon = PIC(icon);
1302 bool separationLine,
1303 tune_index_e tuneId)
1313 footerDesc.
button.tuneId = tuneId;
1332 if (layout == NULL) {
1336 if (barLayout->
text == NULL) {
1345 itemDesc.tuneId = barLayout->tuneId;
1349 container = addListItem(layoutInt, &itemDesc);
1351 if (container == NULL) {
1354 return container->obj.area.height;
1371 if (layout == NULL) {
1375 if (switchLayout->
text == NULL) {
1381 itemDesc.
text = switchLayout->
text;
1384 itemDesc.tuneId = switchLayout->tuneId;
1386 itemDesc.
large =
false;
1388 container = addListItem(layoutInt, &itemDesc);
1390 if (container == NULL) {
1393 return container->obj.area.height;
1407 return addText(layout, text, subText, 0, 0,
false);
1423 const char *subText,
1428 return addText(layout, text, subText, token, index,
true);
1444 if (layout == NULL) {
1449 textArea->textColor =
BLACK;
1450 textArea->text = PIC(text);
1451 textArea->textAlignment =
MID_LEFT;
1452 textArea->fontId = SMALL_REGULAR_FONT;
1454 textArea->wrapping =
true;
1456 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1459 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1460 textArea->obj.area.height += SUB_HEADER_MARGIN;
1465 return textArea->obj.area.height;
1482 if (layout == NULL) {
1488 textArea->text = PIC(text);
1489 textArea->textAlignment =
MID_LEFT;
1490 textArea->fontId = LARGE_MEDIUM_FONT;
1492 textArea->wrapping =
true;
1494 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1497 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1498 if (layoutInt->
container->nbChildren == 0) {
1500 textArea->obj.alignmentMarginY += PRE_FIRST_TEXT_MARGIN;
1503 textArea->obj.alignmentMarginY = INTER_PARAGRAPHS_MARGIN;
1526 const char *description,
1533 if (layout == NULL) {
1539 textArea->textColor =
BLACK;
1540 textArea->text = PIC(title);
1541 textArea->textAlignment =
MID_LEFT;
1542 textArea->fontId = LARGE_MEDIUM_FONT;
1544 textArea->wrapping =
true;
1546 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1547 textArea->obj.alignmentMarginY = PRE_TITLE_MARGIN;
1550 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1556 textArea->textColor =
BLACK;
1557 textArea->text = PIC(description);
1558 textArea->fontId = SMALL_REGULAR_FONT;
1560 textArea->wrapping =
true;
1563 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1564 textArea->textAlignment =
MID_LEFT;
1566 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1567 textArea->obj.alignmentMarginY = PRE_DESCRIPTION_MARGIN;
1574 textArea->text = PIC(info);
1575 textArea->fontId = SMALL_REGULAR_FONT;
1577 textArea->wrapping =
true;
1580 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1581 textArea->textAlignment =
MID_LEFT;
1583 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1584 textArea->obj.alignmentMarginY = 40;
1588 return layoutInt->
container->obj.area.height;
1605 if (layout == NULL) {
1608 for (i = 0; i < choices->
nbChoices; i++) {
1619 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1625 container->nbChildren = 2;
1628 container->obj.area.height = RADIO_CHOICE_HEIGHT;
1630 container->obj.alignmentMarginX = BORDER_MARGIN;
1631 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1634 button->activeColor =
BLACK;
1636 button->obj.alignTo = (
nbgl_obj_t *) container;
1639 container->children[1] = (
nbgl_obj_t *) button;
1643#ifdef HAVE_LANGUAGE_PACK
1644 textArea->text = get_ux_loc_string(choices->nameIds[i]);
1648 textArea->text = PIC(choices->
names[i]);
1650 textArea->textAlignment =
MID_LEFT;
1651 textArea->obj.area.width = container->obj.area.width - RADIO_WIDTH;
1653 textArea->obj.alignment =
MID_LEFT;
1654 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1655 container->children[0] = (
nbgl_obj_t *) textArea;
1658 container->obj.touchMask = (1 <<
TOUCHED);
1659 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1660 nbTouchableControls++;
1665 textArea->textColor =
BLACK;
1666 textArea->fontId = SMALL_BOLD_FONT;
1671 textArea->fontId = SMALL_REGULAR_FONT;
1675 line = createHorizontalLine(layoutInt->
layer);
1676 line->obj.alignmentMarginY = -4;
1702 if (layout == NULL) {
1709 if (info->
text1 != NULL) {
1717 if (info->
text2 != NULL) {
1725 if (info->
text3 != NULL) {
1733 container = addContentCenter(layoutInt, ¢eredInfo);
1736 container->obj.alignmentMarginX = BORDER_MARGIN;
1737 container->obj.alignmentMarginY = BORDER_MARGIN + info->
offsetY;
1741 container->obj.alignmentMarginY = info->
offsetY;
1744 return container->obj.area.height;
1761 if (layout == NULL) {
1765 container = addContentCenter(layoutInt, info);
1767 return container->obj.area.height;
1785 if (layout == NULL) {
1791 container->nbChildren = info->
nbRows + 1;
1795 container->obj.alignmentMarginX = BORDER_MARGIN;
1799 textArea->textColor =
BLACK;
1800 textArea->text = PIC(info->
title);
1801 textArea->textAlignment =
MID_LEFT;
1802 textArea->fontId = LARGE_MEDIUM_FONT;
1803 textArea->wrapping =
true;
1805 textArea->obj.alignmentMarginY = 24;
1809 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1811 container->obj.area.height += textArea->obj.area.height;
1813 container->children[0] = (
nbgl_obj_t *) textArea;
1815 for (row = 0; row < info->
nbRows; row++) {
1821 rowContainer->nbChildren = 2;
1826 image->foregroundColor =
BLACK;
1827 image->buffer = info->
rowIcons[row];
1828 rowContainer->children[0] = (
nbgl_obj_t *) image;
1831 textArea->textColor =
BLACK;
1832 textArea->text = info->
rowTexts[row];
1833 textArea->textAlignment =
MID_LEFT;
1834 textArea->fontId = SMALL_REGULAR_FONT;
1835 textArea->wrapping =
true;
1836 textArea->obj.area.width =
AVAILABLE_WIDTH - image->buffer->width - 16;
1838 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1840 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1841 rowContainer->obj.area.height
1842 =
MAX(image->buffer->height, textArea->obj.area.height + LEFT_CONTENT_TEXT_PADDING);
1845 rowContainer->obj.alignmentMarginY = 32;
1848 rowContainer->obj.alignmentMarginY = INTER_ROWS_MARGIN;
1850 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1851 container->obj.area.height
1852 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1856 return container->obj.area.height;
1874 uint16_t fullHeight = 0;
1877 if (layout == NULL) {
1885 container->nbChildren = 0;
1889 if (strlen(PIC(info->
url)) > 62) {
1905 fullHeight +=
qrcode->obj.area.height;
1907 container->nbChildren++;
1909 if (info->
text1 != NULL) {
1911 textArea->textColor =
BLACK;
1912 textArea->text = PIC(info->
text1);
1913 textArea->textAlignment =
CENTER;
1914 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1915 textArea->wrapping =
true;
1918 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1920 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1921 textArea->obj.alignmentMarginY = 24;
1923 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1925 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1926 container->nbChildren++;
1928 if (info->
text2 != NULL) {
1931 textArea->text = PIC(info->
text2);
1932 textArea->textAlignment =
CENTER;
1933 textArea->fontId = SMALL_REGULAR_FONT;
1934 textArea->wrapping =
true;
1937 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1939 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1940 if (info->
text1 != NULL) {
1941 textArea->obj.alignmentMarginY = QR_INTER_TEXTS_MARGIN;
1944 textArea->obj.alignmentMarginY = 32;
1948 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1950 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1951 container->nbChildren++;
1954 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1962 container->obj.area.height = fullHeight;
1965 container->obj.alignment =
CENTER;
1969 container->obj.alignTo
1972 container->obj.alignmentMarginY = info->
offsetY;
2018 .horizontalButtons.leftIcon = info->
leftIcon,
2019 .horizontalButtons.leftToken = info->
leftToken,
2020 .horizontalButtons.rightText = info->
rightText,
2021 .horizontalButtons.rightToken = info->
rightToken,
2022 .horizontalButtons.tuneId = info->tuneId};
2044 if (layout == NULL) {
2048 for (i = 0; i < list->
nbPairs; i++) {
2050 uint16_t fullHeight = 0;
2053 if (list->
pairs != NULL) {
2054 pair = &list->
pairs[i];
2071 itemTextArea->text = PIC(pair->
item);
2072 itemTextArea->textAlignment =
MID_LEFT;
2073 itemTextArea->fontId = SMALL_REGULAR_FONT;
2074 itemTextArea->wrapping =
true;
2077 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2080 itemTextArea->obj.alignmentMarginX = 0;
2081 itemTextArea->obj.alignmentMarginY = 0;
2082 itemTextArea->obj.alignTo = NULL;
2083 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2084 container->nbChildren++;
2086 fullHeight += itemTextArea->obj.area.height;
2089 valueTextArea->textColor =
BLACK;
2090 valueTextArea->text = PIC(pair->
value);
2091 valueTextArea->textAlignment =
MID_LEFT;
2093 valueTextArea->fontId = SMALL_BOLD_FONT;
2096 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2104 valueIcon = &MINI_PUSH_ICON;
2111 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2117 valueTextArea->text,
2118 valueTextArea->obj.area.width,
2126 valueTextArea->obj.area.height = nbLines * font->
line_height;
2129 valueTextArea->obj.alignmentMarginY = 4;
2130 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2131 valueTextArea->wrapping = list->
wrapping;
2132 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2133 container->nbChildren++;
2135 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2136 if (valueIcon != NULL) {
2141 image->foregroundColor =
BLACK;
2142 image->buffer = valueIcon;
2144 image->obj.alignmentMarginX = 12;
2145 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2146 image->obj.touchMask = (1 <<
TOUCHED);
2149 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2150 container->nbChildren++;
2154 container->obj.area.height = fullHeight;
2156 container->obj.alignmentMarginX = BORDER_MARGIN;
2158 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2161 container->obj.alignmentMarginY = PRE_TAG_VALUE_MARGIN;
2185 const char *subText,
2194 if (layout == NULL) {
2201 container->nbChildren = (subText != NULL) ? 3 : 2;
2206 container->obj.alignment =
CENTER;
2210 progress->foregroundColor =
BLACK;
2211 progress->withBorder =
true;
2212 progress->state = percentage;
2213 progress->obj.area.width = PROGRESSBAR_WIDTH;
2214 progress->obj.area.height = PROGRESSBAR_HEIGHT;
2218 container->children[0] = (
nbgl_obj_t *) progress;
2221 container->obj.area.height = progress->obj.alignmentMarginY + progress->obj.area.height;
2225 textArea->textColor =
BLACK;
2226 textArea->text = PIC(text);
2227 textArea->textAlignment =
CENTER;
2228 textArea->fontId = LARGE_MEDIUM_FONT;
2229 textArea->wrapping =
true;
2230 textArea->obj.alignmentMarginY = BAR_TEXT_MARGIN;
2231 textArea->obj.alignTo = (
nbgl_obj_t *) progress;
2235 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2239 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
2242 container->children[1] = (
nbgl_obj_t *) textArea;
2244 if (subText != NULL) {
2248 subTextArea->textColor =
BLACK;
2249 subTextArea->text = PIC(subText);
2250 subTextArea->textAlignment =
CENTER;
2251 subTextArea->fontId = SMALL_REGULAR_FONT;
2252 subTextArea->wrapping =
true;
2253 subTextArea->obj.alignmentMarginY = BAR_INTER_TEXTS_MARGIN;
2254 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
2259 subTextArea->obj.area.width,
2260 subTextArea->wrapping);
2264 container->obj.area.height
2265 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
2268 container->children[2] = (
nbgl_obj_t *) subTextArea;
2271 container->obj.area.height = (container->obj.area.height + 7) & 0xFFF8;
2290 line = createHorizontalLine(layoutInt->
layer);
2291 line->obj.alignmentMarginY = -4;
2311 if (layout == NULL) {
2323 footerDesc.
button.tuneId = buttonInfo->tuneId;
2333 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2342 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2347 button->obj.alignmentMarginX = BORDER_MARGIN;
2348 button->obj.alignmentMarginY = 12;
2351 button->innerColor =
BLACK;
2352 button->foregroundColor =
WHITE;
2355 button->innerColor =
WHITE;
2356 button->foregroundColor =
BLACK;
2359 button->borderColor =
WHITE;
2363 button->borderColor =
BLACK;
2369 button->text = PIC(buttonInfo->
text);
2370 button->fontId = SMALL_BOLD_FONT;
2371 button->icon = PIC(buttonInfo->
icon);
2374 + SMALL_BUTTON_HEIGHT
2375 + ((button->icon) ? (button->icon->width + 12) : 0);
2376 button->obj.area.height = SMALL_BUTTON_HEIGHT;
2377 button->radius = SMALL_BUTTON_RADIUS_INDEX;
2378 if (buttonInfo->
onBottom !=
true) {
2379 button->obj.alignmentMarginX
2380 += (SCREEN_WIDTH - 2 * BORDER_MARGIN - button->obj.area.width) / 2;
2385 button->obj.area.height = BUTTON_DIAMETER;
2386 button->radius = BUTTON_RADIUS;
2388 button->obj.alignTo = NULL;
2389 button->obj.touchMask = (1 <<
TOUCHED);
2409 tune_index_e tuneId)
2412 .longPress.text = text,
2413 .longPress.token = token,
2414 .longPress.tuneId = tuneId};
2417 if (layout == NULL) {
2437 tune_index_e tuneId)
2462 const char *leftText,
2464 const char *rightText,
2466 tune_index_e tuneId)
2497 if (layout == NULL) {
2511 switch (headerDesc->
type) {
2541 button->innerColor =
WHITE;
2543 button->borderColor =
WHITE;
2544 button->obj.area.width = BACK_KEY_WIDTH;
2545 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2546 button->text = NULL;
2547 button->icon = PIC(&LEFT_ARROW_ICON);
2560 image->foregroundColor =
BLACK;
2561 image->obj.alignment =
CENTER;
2576 textArea->obj.touchMask = (1 <<
TOUCHED);
2578 textArea->obj.alignment =
CENTER;
2579 textArea->textColor =
BLACK;
2580 textArea->obj.area.width
2584 textArea->obj.area.width -= 16 + image->buffer->width;
2586 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2587 textArea->text = text;
2588 textArea->fontId = SMALL_BOLD_FONT;
2589 textArea->textAlignment =
CENTER;
2590 textArea->wrapping =
true;
2595 textArea->obj.area.width,
2599 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2610 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2611 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2627 button->obj.touchMask = (1 <<
TOUCHED);
2631 button->innerColor =
WHITE;
2632 button->foregroundColor
2635 button->borderColor =
WHITE;
2636 button->obj.area.width = BACK_KEY_WIDTH;
2637 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2638 button->text = NULL;
2646 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2663 button->innerColor =
WHITE;
2664 button->foregroundColor =
BLACK;
2665 button->borderColor =
WHITE;
2666 button->obj.area.width = BACK_KEY_WIDTH;
2667 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2668 button->text = NULL;
2669 button->icon = PIC(&LEFT_ARROW_ICON);
2670 button->obj.touchMask = (1 <<
TOUCHED);
2687 progress->obj.area.width = 224;
2688 progress->obj.alignment =
CENTER;
2696 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2702 textArea->textColor =
BLACK;
2704 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2705 textArea->text = PIC(headerDesc->
title.
text);
2706 textArea->fontId = SMALL_BOLD_FONT;
2707 textArea->textAlignment =
CENTER;
2708 textArea->wrapping =
true;
2712 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2725 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2726 textArea->textColor =
BLACK;
2728 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2730 textArea->fontId = SMALL_BOLD_FONT;
2732 textArea->obj.touchMask = (1 <<
TOUCHED);
2738 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2746 line = createHorizontalLine(layoutInt->
layer);
2753 if (separationLine != NULL) {
2788 if (layout == NULL) {
2802 switch (footerDesc->
type) {
2820 textArea->obj.area.height
2825 textArea->textAlignment =
CENTER;
2826 textArea->obj.touchMask = (1 <<
TOUCHED);
2831 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2844 textArea->textColor =
BLACK;
2846 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2848 textArea->fontId = SMALL_BOLD_FONT;
2849 textArea->textAlignment =
CENTER;
2850 textArea->obj.touchMask = (1 <<
TOUCHED);
2868 textArea->textColor =
BLACK;
2870 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2872 textArea->fontId = SMALL_BOLD_FONT;
2873 textArea->textAlignment =
CENTER;
2874 textArea->obj.touchMask = (1 <<
TOUCHED);
2880 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2885 separationLine->obj.area.width = 1;
2886 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2887 separationLine->direction =
VERTICAL;
2888 separationLine->thickness = 1;
2889 separationLine->obj.alignment =
MID_LEFT;
2890 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2891 separationLine->obj.alignmentMarginX = -1;
2907 textArea->textColor =
BLACK;
2908 textArea->obj.area.width = FOOTER_TEXT_AND_NAV_WIDTH;
2909 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2911 textArea->fontId = SMALL_BOLD_FONT;
2912 textArea->textAlignment =
CENTER;
2913 textArea->obj.touchMask = (1 <<
TOUCHED);
2925 navContainer->nbChildren = 4;
2926 navContainer->children
2929 navContainer->obj.area.width = SCREEN_WIDTH - textArea->obj.area.width;
2930 navContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2943 separationLine->obj.area.width = 1;
2944 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2945 separationLine->direction =
VERTICAL;
2946 separationLine->thickness = 1;
2947 separationLine->obj.alignment =
MID_LEFT;
2948 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2949 separationLine->obj.alignmentMarginX = -1;
2982 footerDesc->
button.tuneId);
2987 button->obj.alignment =
CENTER;
2989 button->innerColor =
BLACK;
2990 button->foregroundColor =
WHITE;
2993 button->innerColor =
WHITE;
2994 button->foregroundColor =
BLACK;
2998 button->borderColor =
WHITE;
3002 button->borderColor =
BLACK;
3009 button->fontId = SMALL_BOLD_FONT;
3011 button->radius = BUTTON_RADIUS;
3012 button->obj.area.height = BUTTON_DIAMETER;
3015 button->obj.area.width = BUTTON_DIAMETER;
3020 button->obj.touchMask = (1 <<
TOUCHED);
3048 button->innerColor =
WHITE;
3050 button->obj.alignmentMarginY
3051 = BOTTOM_BORDER_MARGIN;
3055 button->obj.alignmentMarginY = 4;
3056 button->borderColor =
WHITE;
3058 button->foregroundColor =
BLACK;
3060 button->obj.area.height = BUTTON_DIAMETER;
3061 button->radius = BUTTON_RADIUS;
3063 button->fontId = SMALL_BOLD_FONT;
3064 button->obj.touchMask = (1 <<
TOUCHED);
3074 line = createHorizontalLine(layoutInt->
layer);
3076 line->obj.alignmentMarginY = 4;
3095 button->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
3097 button->innerColor =
WHITE;
3099 button->foregroundColor =
BLACK;
3102 button->innerColor =
BLACK;
3103 button->borderColor =
BLACK;
3104 button->foregroundColor =
WHITE;
3107 button->obj.area.height = BUTTON_DIAMETER;
3108 button->radius = BUTTON_RADIUS;
3113 button->fontId = SMALL_BOLD_FONT;
3114 button->obj.touchMask = (1 <<
TOUCHED);
3122 layoutInt->
footerContainer->obj.area.height = ACTION_AND_FOOTER_FOOTER_HEIGHT;
3125 layoutInt->
footerContainer->obj.area.height = ROUNDED_AND_FOOTER_FOOTER_HEIGHT;
3136 addSwipeInternal(layoutInt,
3147 line = createHorizontalLine(layoutInt->
layer);
3153 if (separationLine != NULL) {
3186 if (layout == NULL) {
3203 switch (upFooterDesc->
type) {
3222 button->obj.alignmentMarginX = BORDER_MARGIN;
3224 button->innerColor =
BLACK;
3225 button->foregroundColor =
WHITE;
3226 button->borderColor =
BLACK;
3227 button->obj.area.width = BUTTON_DIAMETER;
3228 button->obj.area.height = BUTTON_DIAMETER;
3229 button->radius = BUTTON_RADIUS;
3230 button->icon = PIC(&VALIDATE_ICON);
3234 textArea->textColor =
BLACK;
3236 textArea->textAlignment =
MID_LEFT;
3237 textArea->fontId = LARGE_MEDIUM_FONT;
3238 textArea->wrapping =
true;
3239 textArea->obj.area.width = SCREEN_WIDTH - 3 * BORDER_MARGIN - button->obj.area.width;
3241 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3243 textArea->obj.alignment =
MID_LEFT;
3244 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3247 line = createHorizontalLine(layoutInt->
layer);
3253 progressBar->withBorder =
false;
3254 progressBar->obj.area.width = SCREEN_WIDTH;
3255 progressBar->obj.area.height = 8;
3257 progressBar->obj.alignmentMarginY = 4;
3258 progressBar->obj.alignTo = NULL;
3267 upFooterDesc->
button.tuneId);
3274 button->obj.alignment =
CENTER;
3277 button->innerColor =
BLACK;
3278 button->foregroundColor =
WHITE;
3281 button->innerColor =
WHITE;
3282 button->foregroundColor =
BLACK;
3285 button->borderColor =
WHITE;
3289 button->borderColor =
BLACK;
3295 button->text = PIC(upFooterDesc->
button.
text);
3296 button->fontId = SMALL_BOLD_FONT;
3297 button->icon = PIC(upFooterDesc->
button.
icon);
3299 button->obj.area.height = BUTTON_DIAMETER;
3300 button->radius = BUTTON_RADIUS;
3302 button->obj.alignTo = NULL;
3303 button->obj.touchMask = (1 <<
TOUCHED);
3330 button->obj.alignmentMarginX = BORDER_MARGIN;
3332 button->innerColor =
WHITE;
3333 button->foregroundColor =
BLACK;
3334 button->obj.area.width = BUTTON_DIAMETER;
3335 button->obj.area.height = BUTTON_DIAMETER;
3336 button->radius = BUTTON_RADIUS;
3338 button->fontId = SMALL_BOLD_FONT;
3339 button->obj.touchMask = (1 <<
TOUCHED);
3355 button->obj.alignmentMarginX = BORDER_MARGIN;
3356 button->innerColor =
BLACK;
3357 button->borderColor =
BLACK;
3358 button->foregroundColor =
WHITE;
3360 button->obj.area.height = BUTTON_DIAMETER;
3361 button->radius = BUTTON_RADIUS;
3363 button->fontId = SMALL_BOLD_FONT;
3364 button->obj.touchMask = (1 <<
TOUCHED);
3377 upFooterDesc->
tipBox.tuneId);
3386 textArea->textColor =
BLACK;
3387 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3388 textArea->textAlignment =
MID_LEFT;
3389 textArea->fontId = SMALL_REGULAR_FONT;
3390 textArea->wrapping =
true;
3393 textArea->obj.area.width
3398 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3399 textArea->obj.alignment =
MID_LEFT;
3400 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3404 line = createHorizontalLine(layoutInt->
layer);
3411 image->obj.alignmentMarginX = BORDER_MARGIN;
3413 image->foregroundColor =
BLACK;
3414 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3427 upFooterDesc->
text.token,
3428 upFooterDesc->
text.tuneId);
3439 textArea->text = PIC(upFooterDesc->
text.text);
3440 textArea->textAlignment =
CENTER;
3441 textArea->fontId = SMALL_REGULAR_FONT;
3442 textArea->wrapping =
true;
3445 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3446 textArea->obj.alignment =
CENTER;
3482 tune_index_e tuneId)
3485 .separationLine =
false,
3486 .progressAndBack.activePage = activePage,
3487 .progressAndBack.nbPages = nbPages,
3488 .progressAndBack.token = backToken,
3489 .progressAndBack.tuneId = tuneId,
3490 .progressAndBack.withBack = withBack,
3491 .progressAndBack.actionIcon = NULL,
3510 const char *subText,
3511 uint8_t initPosition)
3519 if (layout == NULL) {
3525 container->nbChildren = 3;
3530 container->obj.alignment =
CENTER;
3534 spinner->position = initPosition;
3537 container->children[0] = (
nbgl_obj_t *) spinner;
3540 container->obj.area.height += SPINNER_HEIGHT;
3544 textArea->textColor =
BLACK;
3545 textArea->text = PIC(text);
3546 textArea->textAlignment =
CENTER;
3547 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3548 textArea->wrapping =
true;
3549 textArea->obj.alignmentMarginY = SPINNER_TEXT_MARGIN;
3550 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3554 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3558 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3561 container->children[1] = (
nbgl_obj_t *) textArea;
3563 if (subText != NULL) {
3567 subTextArea->textColor =
BLACK;
3568 subTextArea->text = PIC(subText);
3569 subTextArea->textAlignment =
CENTER;
3570 subTextArea->fontId = SMALL_REGULAR_FONT;
3571 subTextArea->wrapping =
true;
3572 subTextArea->obj.alignmentMarginY = SPINNER_INTER_TEXTS_MARGIN;
3573 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3578 subTextArea->obj.area.width,
3579 subTextArea->wrapping);
3583 container->obj.area.height
3584 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3587 container->children[2] = (
nbgl_obj_t *) subTextArea;
3597 tickerCfg.tickerCallback = &spinnerTickerCallback;
3617 const char *subText,
3627 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3632 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3637 if (spinner->obj.type !=
SPINNER) {
3641 if (spinner->position != position) {
3642 spinner->position = position;
3652 const char *newText = PIC(text);
3653 size_t newTextLen = strlen(newText);
3655 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3656 textArea->text = newText;
3661 if (subText != NULL) {
3664 if (container->nbChildren != 3) {
3668 if (subTextArea->obj.type !=
TEXT_AREA) {
3671 const char *newSubText = PIC(subText);
3672 size_t newSubTextLen = strlen(newSubText);
3674 if ((newSubTextLen != strlen(subTextArea->text))
3675 || memcmp(subTextArea->text, newSubText, newSubTextLen)) {
3676 subTextArea->text = newSubText;
3695 if (layout == NULL) {
3699 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3726 if (layout == NULL) {
3730 if (layout->
modal) {
Random Number Generation.
@ ANIM_ILLUSTRATION
animation
@ ICON_ILLUSTRATION
simple icon
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
#define LOG_FATAL(__logger,...)
Middle Level API of the new BOLOS Graphical Library.
#define QR_V10_NB_PIX_SIZE
#define QR_V4_NB_PIX_SIZE
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
return the height in pixels of the font with the given font ID
uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text)
return the max width in pixels of the given text (can be multiline)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
return the height of the given multiline text, with the given font.
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
const nbgl_font_t * nbgl_getFont(nbgl_font_id_e fontId)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
return the height in pixels of the line of font with the given font ID
Font screen low-Level driver API, to draw elementary forms.
int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list)
Creates a list of [tag,value] pairs.
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
#define HOLD_TO_APPROVE_STEP_PERCENT
int nbgl_layoutAddUpFooter(nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *upFooterDesc)
Creates a touchable area on top of the footer of the screen, containing various controls,...
int nbgl_layoutDraw(nbgl_layout_t *layoutParam)
Applies given layout. The screen will be redrawn.
#define NB_MAX_CONTAINER_CHILDREN
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, const char *title, const char *description, const char *info)
Creates in the main container three text areas:
int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText)
Creates an area with given text (in bold) and sub text (in regular)
int nbgl_layoutAddProgressIndicator(nbgl_layout_t *layout, uint8_t activePage, uint8_t nbPages, bool withBack, uint8_t backToken, tune_index_e tuneId)
Creates a kind of navigation bar with an optional <- arrow on the left. This widget is placed on top ...
int nbgl_layoutAddNavigationBar(nbgl_layout_t *layout, const nbgl_layoutNavigationBar_t *info)
Creates a navigation bar on bottom of main container.
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout)
adds a separation line on bottom of the last added item
int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info)
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under...
int nbgl_layoutAddRadioChoice(nbgl_layout_t *layout, const nbgl_layoutRadioChoice_t *choices)
Creates a list of radio buttons (on the right)
int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
Creates an area on the center of the main panel, with a possible icon/image, a possible text in black...
int nbgl_layoutAddSplitFooter(nbgl_layout_t *layout, const char *leftText, uint8_t leftToken, const char *rightText, uint8_t rightToken, tune_index_e tuneId)
Creates 2 touchable texts at the footer of the screen, separated with a thin line from the rest of th...
int nbgl_layoutAddSubHeaderText(nbgl_layout_t *layout, const char *text)
Creates an area with given text in small regular font, under the header.
int nbgl_layoutAddTextWithAlias(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t token, uint8_t index)
Creates an area with given text (in bold) and sub text (in regular), with a icon on right of text to...
int nbgl_layoutAddTouchableBar(nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout)
Creates a touchable bar in main panel.
#define SPINNER_REFRESH_PERIOD
int nbgl_layoutAddTopRightButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId)
Creates a Top-right button in the top right corner of the top panel.
int nbgl_layoutAddSwipe(nbgl_layout_t *layout, uint16_t swipesMask, const char *text, uint8_t token, tune_index_e tuneId)
Creates a swipe interaction on the main container.
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates a switch with the given text and its state.
int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon a...
int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
Creates a rounded button in the main container.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
Creates an area with a title, and rows of icon + text, left aligned.
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutRelease(nbgl_layout_t *layoutParam)
Release the layout obtained with nbgl_layoutGet()
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
int nbgl_layoutUpdateSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t position)
Update an existing spinner (must be the only object of the layout)
int nbgl_layoutAddLongPressButton(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a long press button in the main container.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
int nbgl_layoutAddProgressBar(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t percentage)
Creates an area in main panel to display a progress bar, with a title text and a subtext if needed.
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
int nbgl_layoutAddBottomButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, bool separationLine, tune_index_e tuneId)
Creates a centered button at bottom of main container.
#define HOLD_TO_APPROVE_STEP_DURATION_MS
int nbgl_layoutAddFooter(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the...
int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool grayedOut)
Creates an area with given text in 32px font (in Black or Light Gray)
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
@ NO_BORDER
simple clickable text, in black
@ BLACK_BACKGROUND
rounded bordered button, with text/icon in white, on black background
@ UP_FOOTER_TEXT
grayed-out text, for example "Tap to continue"
@ UP_FOOTER_BUTTON
simple button
@ UP_FOOTER_LONG_PRESS
long-press button
@ UP_FOOTER_TIP_BOX
Tip-box.
@ UP_FOOTER_HORIZONTAL_BUTTONS
2 buttons, on the same line
void * nbgl_layout_t
type shared externally
@ HEADER_TITLE
simple centered text
@ HEADER_BACK_AND_PROGRESS
optional back key and progress indicator (only on Stax)
@ HEADER_EMPTY
empty space, to have a better vertical centering of centered info
@ HEADER_EXTENDED_BACK
back key, centered text and touchable key on the right
@ HEADER_BACK_AND_TEXT
back key and optional text
@ HEADER_RIGHT_TEXT
touchable text on the right, with a vertical separation line
@ HEADER_BACK_ICON_AND_TEXT
back key and optional icon and text
#define NBGL_INVALID_TOKEN
#define SPINNER_FIXED
position to use for a "fixed" spinner
@ SOFT_ACTION_AND_FOOTER_STYLE
A white button on top of a footer, with a separation line.
@ BOTH_ROUNDED_STYLE
A black button on top of a white button.
@ ROUNDED_AND_FOOTER_STYLE
A black background button on top of a footer.
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
@ FOOTER_SIMPLE_TEXT
simple touchable text in bold
@ FOOTER_NAV
navigation bar
@ FOOTER_SIMPLE_BUTTON
simple black or white button (see nbgl_layoutButtonStyle_t)
@ FOOTER_DOUBLE_TEXT
2 touchable texts in bold, separated by a vertical line (only on Stax)
@ FOOTER_EMPTY
empty space, to have a better vertical centering of centered info
@ FOOTER_CHOICE_BUTTONS
double buttons (see nbgl_layoutChoiceButtonsStyle_t)
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
void layoutNavigationPopulate(nbgl_container_t *navContainer, const nbgl_layoutNavigationBar_t *navConfig, uint8_t layer)
This function creates a full navigation bar "object", with buttons and returns it as a container.
#define LAYOUT_OBJ_POOL_LEN
Max number of complex objects with callback retrievable from pool.
bool layoutNavigationCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType, uint8_t nbPages, uint8_t *activePage)
function to be called when any of the controls in navigation bar is touched
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_radio_s nbgl_radio_t
struct to represent a radio button (RADIO_BUTTON type)
#define NB_SPINNER_POSITIONS
void(* nbgl_touchCallback_t)(void *obj, nbgl_touchType_t eventType)
prototype of function to be called when a touch event is received by an object
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)
This function draws or redraws the given object and its children (recursive version)
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_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.
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
This functions refreshes the actual screen on display with what has changed since the last refresh,...
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
struct PACKED__ nbgl_button_s nbgl_button_t
struct to represent a button (BUTTON type) that can contain a text and/or an icon
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
struct PACKED__ nbgl_switch_s nbgl_switch_t
struct to represent a switch (size is fixed) (SWITCH type)
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
struct PACKED__ nbgl_spinner_s nbgl_spinner_t
struct to represent a "spinner", represented by the Ledger corners, in gray, with one of the corners ...
struct PACKED__ nbgl_qrcode_s nbgl_qrcode_t
struct to represent a QR code (QR_CODE type), whose size is fixed
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...
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....
void nbgl_wait_pipeline(void)
int nbgl_screenUpdateTicker(uint8_t screenIndex, const nbgl_screenTickerConfiguration_t *ticker)
Updates the ticker configuration of the screen at the given screenIndex, always set at WHITE in.
int nbgl_screenPop(uint8_t screenIndex)
Release the screen at the given index in screen array (index returned by nbgl_screenPush())....
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
This function redraws the whole screen on top of stack and its children.
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj)
nbgl_state_t
to represent a boolean state.
@ POST_REFRESH_FORCE_POWER_OFF
Force screen power off after refresh.
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
@ POST_REFRESH_FORCE_POWER_ON_WITH_PIPELINE
Force screen power on and enable pipeline.
nbgl_touchType_t
The different types of Touchscreen events.
@ TOUCHING
corresponding to an object that is currently touched
@ QRCODE_V10
QRCode V10, can encode text len up to 1500 chars, display size = 228*228.
@ QRCODE_V4_SMALL
QRCode V4, can encode text len up to 1500 chars, display size = 132*132.
@ QRCODE_V4
QRCode V4, can encode text len up to 62 chars, display size = 264*264.
@ VERTICAL
from top to bottom
@ HORIZONTAL
from left to right
@ LOOP_PARSING
0, 1, 2, 0, 1, 2, ...
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
@ NO_ALIGNMENT
used when parent container layout is used
@ RIGHT_TOP
on outside right
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
@ SWITCH
Switch to turn on/off something.
@ RADIO_BUTTON
Indicator to inform whether something is on or off.
@ BUTTON
Rounded rectangle button with icon and/or text.
@ PROGRESS_BAR
horizontal bar to indicate progression of something (between 0% and 100%)
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
@ LINE
Vertical or Horizontal line.
@ CONTAINER
Empty container.
@ TEXT_AREA
Area to contain text line(s)
@ NBGL_BPP_1
1 bit per pixel
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
const nbgl_icon_details_t * iconRight
const nbgl_icon_details_t * iconLeft
uint16_t delayMs
delay between 2 drawings
uint8_t nbIcons
number of icons in icons array
const nbgl_icon_details_t ** icons
array of nbIcons pointers on icons
nbgl_parsingType_t parsing
This structure contains info to build a centered (vertically and horizontally) area,...
uint16_t iconHug
vertical margin to apply on top and bottom of the icon
const nbgl_icon_details_t * icon
the icon (can be null)
const char * title
title in black large (can be null)
const char * description
description in black small regular case (can be null)
const char * subText
sub-text in dark gray regular small case
uint16_t animOffsetY
vertical offset of animation in icon if integrated (but usually 0)
bool padding
if true, apply a padding of 40px at the bottom
const nbgl_animation_t * animation
the animation (can be null), used if illustrType is ANIM_ILLUSTRATION
const char * smallTitle
sub-title in black small bold case (can be null)
uint16_t animOffsetX
horizontal offset of animation in icon if integrated (but usually 0)
nbgl_contentIllustrationType_t illustrType
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * text1
first text (can be null)
bool onTop
if set to true, align only horizontally
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
int16_t offsetY
vertical shift to apply to this info (if >0, shift to bottom)
const char * text3
third text (can be null)
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t token
the token that will be used as argument of the callback
bool localized
if set to true, use nameIds and not names
uint8_t initChoice
index of the current choice
const char *const * names
array of strings giving the choices (nbChoices)
uint8_t nbChoices
number of choices
This structure contains info to build a switch (on the right) with a description (on the left),...
const char * text
main text for the switch
uint8_t token
the token that will be used as argument of the callback (unused on Nano)
nbgl_state_t initState
initial state of the switch
const char * subText
description under main text (NULL terminated, single line, may be null)
This structure contains a list of [tag,value] pairs.
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
bool wrapping
if set to true, value text will be wrapped on ' ' to avoid cutting words
uint8_t startIndex
index of the first pair to get with callback
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
This structure contains a [tag,value] pair and possible extensions.
const nbgl_icon_details_t * valueIcon
const char * value
string giving the value name
const char * item
string giving the tag name
const char * text
text of the tip-box
const nbgl_icon_details_t * icon
icon of the tip-box
uint8_t token
token used when tip-box is tapped
structure defining an ASCII font
uint8_t line_height
height of a line for all characters in pixels
This structure contains info to build a clickable "bar" with a text and an icon.
bool inactive
if set to true, the bar is grayed-out and cannot be touched
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
bool large
set to true only for the main level of OS settings
const char * subText
sub text (can be NULL)
const nbgl_icon_details_t * iconLeft
a buffer containing the 1BPP icon for icon on left (can be NULL)
const nbgl_icon_details_t * iconRight
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_screenTickerConfiguration_t ticker
const char * tapActionText
Light gray text used when main container is "tapable".
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
Structure containing all information about the current layout.
uint8_t nbUsedCallbackObjs
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
bool incrementAnim
if true, means that animation index is currently incrementing
uint8_t activePage
index of active page for navigation bar
nbgl_swipe_usage_t swipeUsage
nbgl_layoutTouchCallback_t callback
nbgl_container_t * container
uint8_t iconIdxInAnim
current icon index in animation
nbgl_container_t * headerContainer
container used to store header (progress, back, empty space...)
nbgl_layoutFooterType_t footerType
type of footer
bool modal
if true, means the screen is a modal
uint8_t nbChildren
number of children in above array
nbgl_layoutHeaderType_t headerType
type of header
nbgl_container_t * upFooterContainer
uint8_t nbPages
number of pages for navigation bar
nbgl_layoutUpFooterType_t upFooterType
type of up-footer
layoutObj_t callbackObjPool[LAYOUT_OBJ_POOL_LEN]
nbgl_text_area_t * tapText
nbgl_obj_t ** children
children for main screen
const nbgl_animation_t * animation
current animation (if not NULL)
This structure contains info to build a left content area.
uint8_t nbRows
number of rows in the area
const char * title
title of area in bold
const nbgl_icon_details_t ** rowIcons
array of nbRows icon
const char ** rowTexts
array of nbRows texts (displayed in regular)
This structure contains info to build a navigation bar at the bottom of the screen.
uint8_t activePage
index of active page (from 0 to nbPages-1).
bool withBackKey
if set to true, the "back" key is drawn
bool withExitKey
if set to true, an exit button is drawn (X on the left)
uint8_t token
the token that will be used as argument of the callback
uint8_t nbPages
number of pages. (if 0, no navigation)
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * text1
first text (can be null)
const char * url
URL for QR code.
bool largeText1
if set to true, use 32px font for text1
int16_t offsetY
vertical shift to apply to this info (if > 0, shift to bottom)
bool centered
if set to true, center vertically