24#include "os_helpers.h"
31#define INTERNAL_SPACE 16
33#define INNER_MARGIN 12
35#define NB_MAX_LAYOUTS 3
38#define NB_MAX_CONTAINER_CHILDREN 20
40#define TAG_VALUE_ICON_WIDTH 32
42#if defined(TARGET_STAX)
43#define RADIO_CHOICE_HEIGHT 96
44#define FOOTER_HEIGHT 80
45#define BAR_INTERVALE 12
46#define FOOTER_BUTTON_HEIGHT 128
47#define UP_FOOTER_BUTTON_HEIGHT 120
48#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 192
49#define ACTION_AND_FOOTER_FOOTER_HEIGHT 216
50#define FOOTER_TEXT_AND_NAV_WIDTH 160
51#define TAP_TO_CONTINUE_MARGIN 24
52#define SUB_HEADER_MARGIN (2 * 24)
53#define PRE_FIRST_TEXT_MARGIN 24
54#define INTER_PARAGRAPHS_MARGIN 40
55#define PRE_TITLE_MARGIN 24
56#define PRE_DESCRIPTION_MARGIN 16
57#define INTER_ROWS_MARGIN 16
58#define QR_INTER_TEXTS_MARGIN 40
59#define SPINNER_TEXT_MARGIN 20
60#define SPINNER_INTER_TEXTS_MARGIN 20
61#define BAR_TEXT_MARGIN 24
62#define BAR_INTER_TEXTS_MARGIN 16
63#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 28
64#define LEFT_CONTENT_TEXT_PADDING 0
65#elif defined(TARGET_FLEX)
66#define RADIO_CHOICE_HEIGHT 92
67#define FOOTER_HEIGHT 80
68#define BAR_INTERVALE 16
69#define FOOTER_BUTTON_HEIGHT 136
70#define UP_FOOTER_BUTTON_HEIGHT 136
71#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
72#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
73#define FOOTER_TEXT_AND_NAV_WIDTH 192
74#define TAP_TO_CONTINUE_MARGIN 30
75#define SUB_HEADER_MARGIN (2 * 28)
76#define PRE_FIRST_TEXT_MARGIN 0
77#define INTER_PARAGRAPHS_MARGIN 24
78#define PRE_TITLE_MARGIN 16
79#define PRE_DESCRIPTION_MARGIN 24
80#define INTER_ROWS_MARGIN 26
81#define QR_INTER_TEXTS_MARGIN 28
82#define SPINNER_TEXT_MARGIN 24
83#define SPINNER_INTER_TEXTS_MARGIN 16
84#define BAR_TEXT_MARGIN 24
85#define BAR_INTER_TEXTS_MARGIN 16
86#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 32
87#define LEFT_CONTENT_TEXT_PADDING 4
89#error Undefined target
93#define SPINNER_REFRESH_PERIOD 400
121#ifdef HAVE_PIEZO_SOUND
137static uint8_t nbTouchableControls = 0;
144#ifdef HAVE_FAST_HOLD_TO_APPROVE
146#define HOLD_TO_APPROVE_STEP_PERCENT (7)
150#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
152#define HOLD_TO_APPROVE_STEP_PERCENT (25)
153#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
156static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
158#ifdef HAVE_FAST_HOLD_TO_APPROVE
167static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
177 if (gLayout[i].nbChildren > 0) {
182 if (obj == gLayout[i].callbackObjPool[j].obj) {
184 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
185 "nbUsedCallbackObjs = %d\n",
188 gLayout[i].nbUsedCallbackObjs);
189 *layout = &gLayout[i];
200static void radioTouchCallback(
nbgl_obj_t *obj,
213 bool needRefresh =
false;
219 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
221 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
224 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
242 layoutObj->
index = eventType;
291 layoutObj->
index = lSwitch->state;
297 radioTouchCallback(obj, eventType, layout);
304 longTouchCallback(obj, eventType, layout, layoutObj);
309#ifdef HAVE_PIEZO_SOUND
311 io_seproxyhal_play_tune(layoutObj->
tuneId);
332 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
335 gLayout[1].nbChildren);
342 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
346 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
349 if (new_state >= 100) {
354 if (new_state != progressBar->state) {
355 progressBar->partialRedraw =
true;
356 progressBar->state = new_state;
365 if (trigger_callback) {
376 progressBar->partialRedraw =
true;
377 progressBar->state = 0;
384static void radioTouchCallback(
nbgl_obj_t *obj,
396 while (i < layout->nbUsedCallbackObjs) {
406 foundRadioIndex = radioIndex;
408 textArea->textColor =
BLACK;
409 textArea->fontId = SMALL_BOLD_FONT;
431 textArea->fontId = SMALL_REGULAR_FONT;
439 if (foundRadio != 0xFF) {
441#ifdef HAVE_PIEZO_SOUND
453static void spinnerTickerCallback(
void)
460 if (gLayout[1].nbChildren > 0) {
461 layout = &gLayout[1];
464 layout = &gLayout[0];
468 while (i < layout->container->nbChildren) {
471 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
476 spinner->position = 0;
488static void animTickerCallback(
void)
495 if (gLayout[1].nbChildren > 0) {
496 layout = &gLayout[1];
499 layout = &gLayout[0];
507 while (i < layout->container->nbChildren) {
510 if (container->children[1]->type ==
IMAGE) {
555 line->obj.area.width = SCREEN_WIDTH;
556 line->obj.area.height = 4;
568 line->obj.area.width = 1;
569 line->obj.area.height = SCREEN_HEIGHT;
588 layoutObj->
obj = obj;
589 layoutObj->
token = token;
590 layoutObj->
tuneId = tuneId;
639 layoutInt->
container->obj.touchMask = swipesMask;
666 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
673 container->nbChildren = 0;
676 container->obj.area.height = itemDesc->
large ? TOUCHABLE_MAIN_BAR_HEIGHT : TOUCHABLE_BAR_HEIGHT;
678 container->obj.alignmentMarginX = BORDER_MARGIN;
680 container->obj.alignTo = NULL;
685 container->obj.touchMask = (1 <<
TOUCHED);
686 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
687 nbTouchableControls++;
692 textArea->textColor = color;
693 textArea->text = PIC(itemDesc->
text);
694 textArea->onDrawCallback = NULL;
695 textArea->fontId = SMALL_BOLD_FONT;
696 textArea->wrapping =
true;
697 textArea->obj.area.width = container->obj.area.width;
700 textArea->obj.area.width
705 textArea->obj.area.width
709 textArea->obj.area.width -= 60 + BAR_INTERVALE;
712 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
713 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
717 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
718 container->nbChildren++;
723 imageLeft->foregroundColor = color;
724 imageLeft->buffer = PIC(itemDesc->
iconLeft);
726 imageLeft->obj.alignment =
MID_LEFT;
727 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
728 imageLeft->obj.alignmentMarginX = BAR_INTERVALE;
729 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
730 container->nbChildren++;
732 textArea->obj.alignmentMarginX = imageLeft->buffer->width + BAR_INTERVALE;
734 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
739 imageRight->foregroundColor = color;
740 imageRight->buffer = PIC(itemDesc->
iconRight);
743 imageRight->obj.alignmentMarginX = BAR_INTERVALE;
744 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
746 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
747 container->nbChildren++;
749 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
753 switchObj->onColor =
BLACK;
755 switchObj->state = itemDesc->
state;
757 switchObj->obj.alignmentMarginX = BAR_INTERVALE;
758 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
760 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
761 container->nbChildren++;
764 if (itemDesc->
subText != NULL) {
768 subTextArea->textColor = color;
769 subTextArea->text = PIC(itemDesc->
subText);
770 subTextArea->textAlignment =
MID_LEFT;
771 subTextArea->fontId = SMALL_REGULAR_FONT;
773 subTextArea->wrapping =
true;
774 subTextArea->obj.alignment =
MID_LEFT;
775 subTextArea->obj.area.width = container->obj.area.width;
778 subTextArea->obj.area.width,
779 subTextArea->wrapping);
780 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
781 container->nbChildren++;
782 container->obj.area.height += subTextArea->obj.area.height + 12;
785 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
786 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
814 container->nbChildren = 0;
819 if (info->
icon != NULL) {
821 image->foregroundColor =
BLACK;
822 image->buffer = PIC(info->
icon);
824 image->obj.alignmentMarginY = info->
iconHug;
826 fullHeight += image->buffer->height + info->
iconHug;
827 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
828 container->nbChildren++;
833 anim->foregroundColor =
BLACK;
839 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
840 container->nbChildren++;
851 tickerCfg.tickerCallback = &animTickerCallback;
856 if (info->
title != NULL) {
858 textArea->textColor =
BLACK;
859 textArea->text = PIC(info->
title);
860 textArea->textAlignment =
CENTER;
861 textArea->fontId = LARGE_MEDIUM_FONT;
862 textArea->wrapping =
true;
865 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
868 if (container->nbChildren > 0) {
871 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
877 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
879 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
880 container->nbChildren++;
885 textArea->textColor =
BLACK;
887 textArea->textAlignment =
CENTER;
888 textArea->fontId = SMALL_BOLD_FONT;
889 textArea->wrapping =
true;
892 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
895 if (container->nbChildren > 0) {
897 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
898 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
899 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
900 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
903 textArea->obj.alignmentMarginY = 16;
910 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
912 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
913 container->nbChildren++;
918 textArea->textColor =
BLACK;
920 textArea->textAlignment =
CENTER;
921 textArea->fontId = SMALL_REGULAR_FONT;
922 textArea->wrapping =
true;
925 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
928 if (container->nbChildren > 0) {
930 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
931 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
933 textArea->obj.alignmentMarginY = 16;
936 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
943 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
945 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
946 container->nbChildren++;
952 textArea->text = PIC(info->
subText);
953 textArea->textAlignment =
CENTER;
954 textArea->fontId = SMALL_REGULAR_FONT;
955 textArea->wrapping =
true;
958 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
960 textArea->obj.area.height += 2 * 8;
962 if (container->nbChildren > 0) {
964 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
965 textArea->obj.alignmentMarginY = 16;
966 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
967 textArea->obj.alignmentMarginY += info->
iconHug;
974 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
976 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
977 container->nbChildren++;
980 container->obj.alignment =
CENTER;
982 container->obj.area.height = fullHeight;
984 container->obj.area.height += 40;
1006 if (layout == NULL) {
1018 textArea->textColor =
BLACK;
1019 textArea->text = PIC(text);
1020 textArea->textAlignment =
MID_LEFT;
1021 textArea->fontId = SMALL_BOLD_FONT;
1023 textArea->wrapping =
true;
1025 textArea->obj.alignmentMarginY = PRE_TEXT_MARGIN;
1026 textArea->obj.area.width = container->obj.area.width;
1027 if (withAlias ==
true) {
1028 textArea->obj.area.width -= 12 + MINI_PUSH_ICON.width;
1031 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1032 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1033 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1034 container->nbChildren++;
1035 if (withAlias ==
true) {
1041 image->foregroundColor =
BLACK;
1042 image->buffer = &PUSH_ICON;
1044 image->obj.alignmentMarginX = 12;
1045 image->obj.alignTo = (
nbgl_obj_t *) textArea;
1046 container->obj.touchMask = (1 <<
TOUCHED);
1049 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
1050 container->nbChildren++;
1053 if (subText != NULL) {
1055 subTextArea->textColor =
BLACK;
1056 subTextArea->text = PIC(subText);
1057 subTextArea->fontId = SMALL_REGULAR_FONT;
1059 subTextArea->wrapping =
true;
1060 subTextArea->obj.area.width = container->obj.area.width;
1063 subTextArea->obj.area.width,
1064 subTextArea->wrapping);
1065 subTextArea->textAlignment =
MID_LEFT;
1068 subTextArea->obj.alignmentMarginY = TEXT_SUBTEXT_MARGIN;
1071 subTextArea->obj.alignmentMarginY = PRE_SUBTEXT_MARGIN;
1073 fullHeight += subTextArea->obj.alignmentMarginY;
1074 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
1075 container->nbChildren++;
1076 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
1079 fullHeight += PRE_TEXT_MARGIN;
1081 container->obj.area.height = fullHeight;
1083 container->obj.alignmentMarginX = BORDER_MARGIN;
1088 return container->obj.area.height;
1106 if (description->
modal) {
1107 if (gLayout[1].nbChildren == 0) {
1108 layout = &gLayout[1];
1110 else if (gLayout[2].nbChildren == 0) {
1111 layout = &gLayout[2];
1117 layout = &gLayout[0];
1119 if (layout == NULL) {
1127 nbTouchableControls = 0;
1132 if (description->
modal) {
1146 layout->
container->obj.area.width = SCREEN_WIDTH;
1147 layout->
container->obj.area.height = SCREEN_HEIGHT;
1164 obj->
tuneId = description->tapTuneId;
1172 footerDesc.
text.tuneId = description->tapTuneId;
1194 tune_index_e tuneId)
1199 if (layout == NULL) {
1206 layoutInt->
tapText->text = PIC(text);
1208 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1212 layoutInt->
tapText->obj.alignmentMarginY = TAP_TO_CONTINUE_MARGIN;
1230 tune_index_e tuneId)
1237 if (layout == NULL) {
1246 button->obj.area.width = BUTTON_DIAMETER;
1247 button->obj.area.height = BUTTON_DIAMETER;
1248 button->radius = BUTTON_RADIUS;
1249 button->obj.alignmentMarginX = BORDER_MARGIN;
1250 button->obj.alignmentMarginY = BORDER_MARGIN;
1251 button->foregroundColor =
BLACK;
1252 button->innerColor =
WHITE;
1254 button->obj.touchMask = (1 <<
TOUCHED);
1256 button->icon = PIC(icon);
1301 bool separationLine,
1302 tune_index_e tuneId)
1312 footerDesc.
button.tuneId = tuneId;
1331 if (layout == NULL) {
1335 if (barLayout->
text == NULL) {
1344 itemDesc.tuneId = barLayout->tuneId;
1348 container = addListItem(layoutInt, &itemDesc);
1350 if (container == NULL) {
1353 return container->obj.area.height;
1370 if (layout == NULL) {
1374 if (switchLayout->
text == NULL) {
1380 itemDesc.
text = switchLayout->
text;
1383 itemDesc.tuneId = switchLayout->tuneId;
1385 itemDesc.
large =
false;
1387 container = addListItem(layoutInt, &itemDesc);
1389 if (container == NULL) {
1392 return container->obj.area.height;
1406 return addText(layout, text, subText, 0, 0,
false);
1422 const char *subText,
1427 return addText(layout, text, subText, token, index,
true);
1443 if (layout == NULL) {
1448 textArea->textColor =
BLACK;
1449 textArea->text = PIC(text);
1450 textArea->textAlignment =
MID_LEFT;
1451 textArea->fontId = SMALL_REGULAR_FONT;
1453 textArea->wrapping =
true;
1455 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1458 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1459 textArea->obj.area.height += SUB_HEADER_MARGIN;
1464 return textArea->obj.area.height;
1481 if (layout == NULL) {
1487 textArea->text = PIC(text);
1488 textArea->textAlignment =
MID_LEFT;
1489 textArea->fontId = LARGE_MEDIUM_FONT;
1491 textArea->wrapping =
true;
1493 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1496 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1497 if (layoutInt->
container->nbChildren == 0) {
1499 textArea->obj.alignmentMarginY += PRE_FIRST_TEXT_MARGIN;
1502 textArea->obj.alignmentMarginY = INTER_PARAGRAPHS_MARGIN;
1525 const char *description,
1532 if (layout == NULL) {
1538 textArea->textColor =
BLACK;
1539 textArea->text = PIC(title);
1540 textArea->textAlignment =
MID_LEFT;
1541 textArea->fontId = LARGE_MEDIUM_FONT;
1543 textArea->wrapping =
true;
1545 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1546 textArea->obj.alignmentMarginY = PRE_TITLE_MARGIN;
1549 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1555 textArea->textColor =
BLACK;
1556 textArea->text = PIC(description);
1557 textArea->fontId = SMALL_REGULAR_FONT;
1559 textArea->wrapping =
true;
1562 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1563 textArea->textAlignment =
MID_LEFT;
1565 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1566 textArea->obj.alignmentMarginY = PRE_DESCRIPTION_MARGIN;
1573 textArea->text = PIC(info);
1574 textArea->fontId = SMALL_REGULAR_FONT;
1576 textArea->wrapping =
true;
1579 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1580 textArea->textAlignment =
MID_LEFT;
1582 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1583 textArea->obj.alignmentMarginY = 40;
1587 return layoutInt->
container->obj.area.height;
1604 if (layout == NULL) {
1607 for (i = 0; i < choices->
nbChoices; i++) {
1618 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1624 container->nbChildren = 2;
1627 container->obj.area.height = RADIO_CHOICE_HEIGHT;
1629 container->obj.alignmentMarginX = BORDER_MARGIN;
1630 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1633 button->activeColor =
BLACK;
1635 button->obj.alignTo = (
nbgl_obj_t *) container;
1638 container->children[1] = (
nbgl_obj_t *) button;
1642#ifdef HAVE_LANGUAGE_PACK
1647 textArea->text = PIC(choices->
names[i]);
1649 textArea->textAlignment =
MID_LEFT;
1650 textArea->obj.area.width = container->obj.area.width - RADIO_WIDTH;
1652 textArea->obj.alignment =
MID_LEFT;
1653 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1654 container->children[0] = (
nbgl_obj_t *) textArea;
1657 container->obj.touchMask = (1 <<
TOUCHED);
1658 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1659 nbTouchableControls++;
1664 textArea->textColor =
BLACK;
1665 textArea->fontId = SMALL_BOLD_FONT;
1670 textArea->fontId = SMALL_REGULAR_FONT;
1674 line = createHorizontalLine(layoutInt->
layer);
1675 line->obj.alignmentMarginY = -4;
1701 if (layout == NULL) {
1708 if (info->
text1 != NULL) {
1716 if (info->
text2 != NULL) {
1724 if (info->
text3 != NULL) {
1732 container = addContentCenter(layoutInt, ¢eredInfo);
1735 container->obj.alignmentMarginX = BORDER_MARGIN;
1736 container->obj.alignmentMarginY = BORDER_MARGIN + info->
offsetY;
1740 container->obj.alignmentMarginY = info->
offsetY;
1743 return container->obj.area.height;
1760 if (layout == NULL) {
1764 container = addContentCenter(layoutInt, info);
1766 return container->obj.area.height;
1784 if (layout == NULL) {
1790 container->nbChildren = info->
nbRows + 1;
1794 container->obj.alignmentMarginX = BORDER_MARGIN;
1798 textArea->textColor =
BLACK;
1799 textArea->text = PIC(info->
title);
1800 textArea->textAlignment =
MID_LEFT;
1801 textArea->fontId = LARGE_MEDIUM_FONT;
1802 textArea->wrapping =
true;
1804 textArea->obj.alignmentMarginY = 24;
1808 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1810 container->obj.area.height += textArea->obj.area.height;
1812 container->children[0] = (
nbgl_obj_t *) textArea;
1814 for (row = 0; row < info->
nbRows; row++) {
1820 rowContainer->nbChildren = 2;
1825 image->foregroundColor =
BLACK;
1826 image->buffer = info->
rowIcons[row];
1827 rowContainer->children[0] = (
nbgl_obj_t *) image;
1830 textArea->textColor =
BLACK;
1831 textArea->text = info->
rowTexts[row];
1832 textArea->textAlignment =
MID_LEFT;
1833 textArea->fontId = SMALL_REGULAR_FONT;
1834 textArea->wrapping =
true;
1835 textArea->obj.area.width =
AVAILABLE_WIDTH - image->buffer->width - 16;
1837 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1839 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1840 rowContainer->obj.area.height
1841 =
MAX(image->buffer->height, textArea->obj.area.height + LEFT_CONTENT_TEXT_PADDING);
1844 rowContainer->obj.alignmentMarginY = 32;
1847 rowContainer->obj.alignmentMarginY = INTER_ROWS_MARGIN;
1849 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1850 container->obj.area.height
1851 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1855 return container->obj.area.height;
1876 if (layout == NULL) {
1884 container->nbChildren = 0;
1888 if (strlen(PIC(info->
url)) > 62) {
1904 fullHeight +=
qrcode->obj.area.height;
1906 container->nbChildren++;
1908 if (info->
text1 != NULL) {
1910 textArea->textColor =
BLACK;
1911 textArea->text = PIC(info->
text1);
1912 textArea->textAlignment =
CENTER;
1913 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1914 textArea->wrapping =
true;
1917 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1919 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1920 textArea->obj.alignmentMarginY = 24;
1922 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1924 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1925 container->nbChildren++;
1927 if (info->
text2 != NULL) {
1930 textArea->text = PIC(info->
text2);
1931 textArea->textAlignment =
CENTER;
1932 textArea->fontId = SMALL_REGULAR_FONT;
1933 textArea->wrapping =
true;
1936 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1938 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1939 if (info->
text1 != NULL) {
1940 textArea->obj.alignmentMarginY = QR_INTER_TEXTS_MARGIN;
1943 textArea->obj.alignmentMarginY = 32;
1947 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1949 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1950 container->nbChildren++;
1953 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1961 container->obj.area.height = fullHeight;
1964 container->obj.alignment =
CENTER;
1968 container->obj.alignTo
1971 container->obj.alignmentMarginY = info->
offsetY;
2017 .horizontalButtons.leftIcon = info->
leftIcon,
2018 .horizontalButtons.leftToken = info->
leftToken,
2019 .horizontalButtons.rightText = info->
rightText,
2020 .horizontalButtons.rightToken = info->
rightToken,
2021 .horizontalButtons.tuneId = info->tuneId};
2043 if (layout == NULL) {
2047 for (i = 0; i < list->
nbPairs; i++) {
2052 if (list->
pairs != NULL) {
2053 pair = &list->
pairs[i];
2070 itemTextArea->text = PIC(pair->
item);
2071 itemTextArea->textAlignment =
MID_LEFT;
2072 itemTextArea->fontId = SMALL_REGULAR_FONT;
2073 itemTextArea->wrapping =
true;
2076 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2079 itemTextArea->obj.alignmentMarginX = 0;
2080 itemTextArea->obj.alignmentMarginY = 0;
2081 itemTextArea->obj.alignTo = NULL;
2082 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2083 container->nbChildren++;
2085 fullHeight += itemTextArea->obj.area.height;
2088 valueTextArea->textColor =
BLACK;
2089 valueTextArea->text = PIC(pair->
value);
2090 valueTextArea->textAlignment =
MID_LEFT;
2092 valueTextArea->fontId = SMALL_BOLD_FONT;
2095 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2103 valueIcon = &MINI_PUSH_ICON;
2110 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2116 valueTextArea->text,
2117 valueTextArea->obj.area.width,
2125 valueTextArea->obj.area.height = nbLines * font->
line_height;
2128 valueTextArea->obj.alignmentMarginY = 4;
2129 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2130 valueTextArea->wrapping = list->
wrapping;
2131 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2132 container->nbChildren++;
2134 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2135 if (valueIcon != NULL) {
2140 image->foregroundColor =
BLACK;
2141 image->buffer = valueIcon;
2143 image->obj.alignmentMarginX = 12;
2144 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2145 image->obj.touchMask = (1 <<
TOUCHED);
2148 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2149 container->nbChildren++;
2153 container->obj.area.height = fullHeight;
2155 container->obj.alignmentMarginX = BORDER_MARGIN;
2157 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2160 container->obj.alignmentMarginY = PRE_TAG_VALUE_MARGIN;
2184 const char *subText,
2193 if (layout == NULL) {
2200 container->nbChildren = (subText != NULL) ? 3 : 2;
2205 container->obj.alignment =
CENTER;
2209 progress->foregroundColor =
BLACK;
2210 progress->withBorder =
true;
2211 progress->state = percentage;
2212 progress->obj.area.width = PROGRESSBAR_WIDTH;
2213 progress->obj.area.height = PROGRESSBAR_HEIGHT;
2217 container->children[0] = (
nbgl_obj_t *) progress;
2220 container->obj.area.height = progress->obj.alignmentMarginY + progress->obj.area.height;
2224 textArea->textColor =
BLACK;
2225 textArea->text = PIC(text);
2226 textArea->textAlignment =
CENTER;
2227 textArea->fontId = LARGE_MEDIUM_FONT;
2228 textArea->wrapping =
true;
2229 textArea->obj.alignmentMarginY = BAR_TEXT_MARGIN;
2230 textArea->obj.alignTo = (
nbgl_obj_t *) progress;
2234 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2238 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
2241 container->children[1] = (
nbgl_obj_t *) textArea;
2243 if (subText != NULL) {
2247 subTextArea->textColor =
BLACK;
2248 subTextArea->text = PIC(subText);
2249 subTextArea->textAlignment =
CENTER;
2250 subTextArea->fontId = SMALL_REGULAR_FONT;
2251 subTextArea->wrapping =
true;
2252 subTextArea->obj.alignmentMarginY = BAR_INTER_TEXTS_MARGIN;
2253 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
2258 subTextArea->obj.area.width,
2259 subTextArea->wrapping);
2263 container->obj.area.height
2264 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
2267 container->children[2] = (
nbgl_obj_t *) subTextArea;
2270 container->obj.area.height = (container->obj.area.height + 7) & 0xFFF8;
2289 line = createHorizontalLine(layoutInt->
layer);
2290 line->obj.alignmentMarginY = -4;
2310 if (layout == NULL) {
2322 footerDesc.
button.tuneId = buttonInfo->tuneId;
2332 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2341 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2346 button->obj.alignmentMarginX = BORDER_MARGIN;
2347 button->obj.alignmentMarginY = 12;
2350 button->innerColor =
BLACK;
2351 button->foregroundColor =
WHITE;
2354 button->innerColor =
WHITE;
2355 button->foregroundColor =
BLACK;
2358 button->borderColor =
WHITE;
2362 button->borderColor =
BLACK;
2368 button->text = PIC(buttonInfo->
text);
2369 button->fontId = SMALL_BOLD_FONT;
2370 button->icon = PIC(buttonInfo->
icon);
2373 + SMALL_BUTTON_HEIGHT
2374 + ((button->icon) ? (button->icon->width + 12) : 0);
2375 button->obj.area.height = SMALL_BUTTON_HEIGHT;
2376 button->radius = SMALL_BUTTON_RADIUS_INDEX;
2377 if (buttonInfo->
onBottom !=
true) {
2378 button->obj.alignmentMarginX
2379 += (SCREEN_WIDTH - 2 * BORDER_MARGIN - button->obj.area.width) / 2;
2384 button->obj.area.height = BUTTON_DIAMETER;
2385 button->radius = BUTTON_RADIUS;
2387 button->obj.alignTo = NULL;
2388 button->obj.touchMask = (1 <<
TOUCHED);
2408 tune_index_e tuneId)
2411 .longPress.text = text,
2412 .longPress.token = token,
2413 .longPress.tuneId = tuneId};
2416 if (layout == NULL) {
2436 tune_index_e tuneId)
2461 const char *leftText,
2463 const char *rightText,
2465 tune_index_e tuneId)
2496 if (layout == NULL) {
2510 switch (headerDesc->
type) {
2540 button->innerColor =
WHITE;
2542 button->borderColor =
WHITE;
2543 button->obj.area.width = BACK_KEY_WIDTH;
2544 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2545 button->text = NULL;
2546 button->icon = PIC(&LEFT_ARROW_ICON);
2559 image->foregroundColor =
BLACK;
2560 image->obj.alignment =
CENTER;
2575 textArea->obj.touchMask = (1 <<
TOUCHED);
2577 textArea->obj.alignment =
CENTER;
2578 textArea->textColor =
BLACK;
2579 textArea->obj.area.width
2583 textArea->obj.area.width -= 16 + image->buffer->width;
2585 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2586 textArea->text = text;
2587 textArea->fontId = SMALL_BOLD_FONT;
2588 textArea->textAlignment =
CENTER;
2589 textArea->wrapping =
true;
2594 textArea->obj.area.width,
2598 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2609 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2610 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2626 button->obj.touchMask = (1 <<
TOUCHED);
2630 button->innerColor =
WHITE;
2631 button->foregroundColor
2634 button->borderColor =
WHITE;
2635 button->obj.area.width = BACK_KEY_WIDTH;
2636 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2637 button->text = NULL;
2645 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2662 button->innerColor =
WHITE;
2663 button->foregroundColor =
BLACK;
2664 button->borderColor =
WHITE;
2665 button->obj.area.width = BACK_KEY_WIDTH;
2666 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2667 button->text = NULL;
2668 button->icon = PIC(&LEFT_ARROW_ICON);
2669 button->obj.touchMask = (1 <<
TOUCHED);
2686 progress->obj.area.width = 224;
2687 progress->obj.alignment =
CENTER;
2695 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2701 textArea->textColor =
BLACK;
2703 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2704 textArea->text = PIC(headerDesc->
title.
text);
2705 textArea->fontId = SMALL_BOLD_FONT;
2706 textArea->textAlignment =
CENTER;
2707 textArea->wrapping =
true;
2711 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2724 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2725 textArea->textColor =
BLACK;
2727 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2729 textArea->fontId = SMALL_BOLD_FONT;
2731 textArea->obj.touchMask = (1 <<
TOUCHED);
2737 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2745 line = createHorizontalLine(layoutInt->
layer);
2752 if (separationLine != NULL) {
2787 if (layout == NULL) {
2801 switch (footerDesc->
type) {
2819 textArea->obj.area.height
2824 textArea->textAlignment =
CENTER;
2825 textArea->obj.touchMask = (1 <<
TOUCHED);
2830 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2843 textArea->textColor =
BLACK;
2845 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2847 textArea->fontId = SMALL_BOLD_FONT;
2848 textArea->textAlignment =
CENTER;
2849 textArea->obj.touchMask = (1 <<
TOUCHED);
2867 textArea->textColor =
BLACK;
2869 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2871 textArea->fontId = SMALL_BOLD_FONT;
2872 textArea->textAlignment =
CENTER;
2873 textArea->obj.touchMask = (1 <<
TOUCHED);
2879 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2884 separationLine->obj.area.width = 1;
2885 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2886 separationLine->direction =
VERTICAL;
2887 separationLine->thickness = 1;
2888 separationLine->obj.alignment =
MID_LEFT;
2889 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2890 separationLine->obj.alignmentMarginX = -1;
2906 textArea->textColor =
BLACK;
2907 textArea->obj.area.width = FOOTER_TEXT_AND_NAV_WIDTH;
2908 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2910 textArea->fontId = SMALL_BOLD_FONT;
2911 textArea->textAlignment =
CENTER;
2912 textArea->obj.touchMask = (1 <<
TOUCHED);
2924 navContainer->nbChildren = 4;
2925 navContainer->children
2928 navContainer->obj.area.width = SCREEN_WIDTH - textArea->obj.area.width;
2929 navContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2942 separationLine->obj.area.width = 1;
2943 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2944 separationLine->direction =
VERTICAL;
2945 separationLine->thickness = 1;
2946 separationLine->obj.alignment =
MID_LEFT;
2947 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2948 separationLine->obj.alignmentMarginX = -1;
2981 footerDesc->
button.tuneId);
2986 button->obj.alignment =
CENTER;
2988 button->innerColor =
BLACK;
2989 button->foregroundColor =
WHITE;
2992 button->innerColor =
WHITE;
2993 button->foregroundColor =
BLACK;
2997 button->borderColor =
WHITE;
3001 button->borderColor =
BLACK;
3008 button->fontId = SMALL_BOLD_FONT;
3010 button->radius = BUTTON_RADIUS;
3011 button->obj.area.height = BUTTON_DIAMETER;
3014 button->obj.area.width = BUTTON_DIAMETER;
3019 button->obj.touchMask = (1 <<
TOUCHED);
3047 button->innerColor =
WHITE;
3049 button->obj.alignmentMarginY
3050 = BOTTOM_BORDER_MARGIN;
3054 button->obj.alignmentMarginY = 4;
3055 button->borderColor =
WHITE;
3057 button->foregroundColor =
BLACK;
3059 button->obj.area.height = BUTTON_DIAMETER;
3060 button->radius = BUTTON_RADIUS;
3062 button->fontId = SMALL_BOLD_FONT;
3063 button->obj.touchMask = (1 <<
TOUCHED);
3073 line = createHorizontalLine(layoutInt->
layer);
3075 line->obj.alignmentMarginY = 4;
3094 button->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
3096 button->innerColor =
WHITE;
3098 button->foregroundColor =
BLACK;
3101 button->innerColor =
BLACK;
3102 button->borderColor =
BLACK;
3103 button->foregroundColor =
WHITE;
3106 button->obj.area.height = BUTTON_DIAMETER;
3107 button->radius = BUTTON_RADIUS;
3112 button->fontId = SMALL_BOLD_FONT;
3113 button->obj.touchMask = (1 <<
TOUCHED);
3121 layoutInt->
footerContainer->obj.area.height = ACTION_AND_FOOTER_FOOTER_HEIGHT;
3124 layoutInt->
footerContainer->obj.area.height = ROUNDED_AND_FOOTER_FOOTER_HEIGHT;
3135 addSwipeInternal(layoutInt,
3146 line = createHorizontalLine(layoutInt->
layer);
3152 if (separationLine != NULL) {
3185 if (layout == NULL) {
3202 switch (upFooterDesc->
type) {
3221 button->obj.alignmentMarginX = BORDER_MARGIN;
3223 button->innerColor =
BLACK;
3224 button->foregroundColor =
WHITE;
3225 button->borderColor =
BLACK;
3226 button->obj.area.width = BUTTON_DIAMETER;
3227 button->obj.area.height = BUTTON_DIAMETER;
3228 button->radius = BUTTON_RADIUS;
3229 button->icon = PIC(&VALIDATE_ICON);
3233 textArea->textColor =
BLACK;
3235 textArea->textAlignment =
MID_LEFT;
3236 textArea->fontId = LARGE_MEDIUM_FONT;
3237 textArea->wrapping =
true;
3238 textArea->obj.area.width = SCREEN_WIDTH - 3 * BORDER_MARGIN - button->obj.area.width;
3240 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3242 textArea->obj.alignment =
MID_LEFT;
3243 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3246 line = createHorizontalLine(layoutInt->
layer);
3252 progressBar->withBorder =
false;
3253 progressBar->obj.area.width = SCREEN_WIDTH;
3254 progressBar->obj.area.height = 8;
3256 progressBar->obj.alignmentMarginY = 4;
3257 progressBar->obj.alignTo = NULL;
3266 upFooterDesc->
button.tuneId);
3273 button->obj.alignment =
CENTER;
3276 button->innerColor =
BLACK;
3277 button->foregroundColor =
WHITE;
3280 button->innerColor =
WHITE;
3281 button->foregroundColor =
BLACK;
3284 button->borderColor =
WHITE;
3288 button->borderColor =
BLACK;
3294 button->text = PIC(upFooterDesc->
button.
text);
3295 button->fontId = SMALL_BOLD_FONT;
3296 button->icon = PIC(upFooterDesc->
button.
icon);
3298 button->obj.area.height = BUTTON_DIAMETER;
3299 button->radius = BUTTON_RADIUS;
3301 button->obj.alignTo = NULL;
3302 button->obj.touchMask = (1 <<
TOUCHED);
3329 button->obj.alignmentMarginX = BORDER_MARGIN;
3331 button->innerColor =
WHITE;
3332 button->foregroundColor =
BLACK;
3333 button->obj.area.width = BUTTON_DIAMETER;
3334 button->obj.area.height = BUTTON_DIAMETER;
3335 button->radius = BUTTON_RADIUS;
3337 button->fontId = SMALL_BOLD_FONT;
3338 button->obj.touchMask = (1 <<
TOUCHED);
3354 button->obj.alignmentMarginX = BORDER_MARGIN;
3355 button->innerColor =
BLACK;
3356 button->borderColor =
BLACK;
3357 button->foregroundColor =
WHITE;
3359 button->obj.area.height = BUTTON_DIAMETER;
3360 button->radius = BUTTON_RADIUS;
3362 button->fontId = SMALL_BOLD_FONT;
3363 button->obj.touchMask = (1 <<
TOUCHED);
3376 upFooterDesc->
tipBox.tuneId);
3385 textArea->textColor =
BLACK;
3386 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3387 textArea->textAlignment =
MID_LEFT;
3388 textArea->fontId = SMALL_REGULAR_FONT;
3389 textArea->wrapping =
true;
3392 textArea->obj.area.width
3397 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3398 textArea->obj.alignment =
MID_LEFT;
3399 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3403 line = createHorizontalLine(layoutInt->
layer);
3410 image->obj.alignmentMarginX = BORDER_MARGIN;
3412 image->foregroundColor =
BLACK;
3413 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3426 upFooterDesc->
text.token,
3427 upFooterDesc->
text.tuneId);
3438 textArea->text = PIC(upFooterDesc->
text.text);
3439 textArea->textAlignment =
CENTER;
3440 textArea->fontId = SMALL_REGULAR_FONT;
3441 textArea->wrapping =
true;
3444 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3445 textArea->obj.alignment =
CENTER;
3481 tune_index_e tuneId)
3484 .separationLine =
false,
3485 .progressAndBack.activePage = activePage,
3486 .progressAndBack.nbPages = nbPages,
3487 .progressAndBack.token = backToken,
3488 .progressAndBack.tuneId = tuneId,
3489 .progressAndBack.withBack = withBack,
3490 .progressAndBack.actionIcon = NULL,
3509 const char *subText,
3518 if (layout == NULL) {
3524 container->nbChildren = 3;
3529 container->obj.alignment =
CENTER;
3533 spinner->position = initPosition;
3536 container->children[0] = (
nbgl_obj_t *) spinner;
3539 container->obj.area.height += SPINNER_HEIGHT;
3543 textArea->textColor =
BLACK;
3544 textArea->text = PIC(text);
3545 textArea->textAlignment =
CENTER;
3546 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3547 textArea->wrapping =
true;
3548 textArea->obj.alignmentMarginY = SPINNER_TEXT_MARGIN;
3549 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3553 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3557 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3560 container->children[1] = (
nbgl_obj_t *) textArea;
3562 if (subText != NULL) {
3566 subTextArea->textColor =
BLACK;
3567 subTextArea->text = PIC(subText);
3568 subTextArea->textAlignment =
CENTER;
3569 subTextArea->fontId = SMALL_REGULAR_FONT;
3570 subTextArea->wrapping =
true;
3571 subTextArea->obj.alignmentMarginY = SPINNER_INTER_TEXTS_MARGIN;
3572 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3577 subTextArea->obj.area.width,
3578 subTextArea->wrapping);
3582 container->obj.area.height
3583 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3586 container->children[2] = (
nbgl_obj_t *) subTextArea;
3596 tickerCfg.tickerCallback = &spinnerTickerCallback;
3616 const char *subText,
3626 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3631 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3636 if (spinner->obj.type !=
SPINNER) {
3640 if (spinner->position != position) {
3641 spinner->position = position;
3651 const char *newText = PIC(text);
3652 size_t newTextLen = strlen(newText);
3654 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3655 textArea->text = newText;
3660 if (subText != NULL) {
3663 if (container->nbChildren != 3) {
3667 if (subTextArea->obj.type !=
TEXT_AREA) {
3670 const char *newSubText = PIC(subText);
3671 size_t newSubTextLen = strlen(newSubText);
3673 if ((newSubTextLen != strlen(subTextArea->text))
3674 || memcmp(subTextArea->text, newSubText, newSubTextLen)) {
3675 subTextArea->text = newSubText;
3694 if (layout == NULL) {
3698 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3725 if (layout == NULL) {
3729 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.
const char * get_ux_loc_string(uint32_t index)
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