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 BACK_KEY_WIDTH 88
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#elif defined(TARGET_FLEX)
63#define RADIO_CHOICE_HEIGHT 92
64#define FOOTER_HEIGHT 80
65#define BAR_INTERVALE 16
66#define BACK_KEY_WIDTH 104
67#define FOOTER_BUTTON_HEIGHT 136
68#define UP_FOOTER_BUTTON_HEIGHT 136
69#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
70#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
71#define FOOTER_TEXT_AND_NAV_WIDTH 192
72#define TAP_TO_CONTINUE_MARGIN 30
73#define SUB_HEADER_MARGIN (2 * 28)
74#define PRE_FIRST_TEXT_MARGIN 0
75#define INTER_PARAGRAPHS_MARGIN 24
76#define PRE_TITLE_MARGIN 16
77#define PRE_DESCRIPTION_MARGIN 24
78#define INTER_ROWS_MARGIN 26
79#define QR_INTER_TEXTS_MARGIN 28
80#define SPINNER_TEXT_MARGIN 24
81#define SPINNER_INTER_TEXTS_MARGIN 16
83#error Undefined target
87#define SPINNER_REFRESH_PERIOD 400
115#ifdef HAVE_PIEZO_SOUND
131static uint8_t nbTouchableControls = 0;
138#ifdef HAVE_FAST_HOLD_TO_APPROVE
140#define HOLD_TO_APPROVE_STEP_PERCENT (7)
144#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
146#define HOLD_TO_APPROVE_STEP_PERCENT (25)
147#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
150static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
152#ifdef HAVE_FAST_HOLD_TO_APPROVE
161static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
171 if (gLayout[i].nbChildren > 0) {
176 if (obj == gLayout[i].callbackObjPool[j].obj) {
178 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
179 "nbUsedCallbackObjs = %d\n",
182 gLayout[i].nbUsedCallbackObjs);
183 *layout = &gLayout[i];
194static void radioTouchCallback(
nbgl_obj_t *obj,
207 bool needRefresh =
false;
213 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
215 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
218 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
236 layoutObj->
index = eventType;
285 layoutObj->
index = lSwitch->state;
291 radioTouchCallback(obj, eventType, layout);
298 longTouchCallback(obj, eventType, layout, layoutObj);
303#ifdef HAVE_PIEZO_SOUND
305 io_seproxyhal_play_tune(layoutObj->
tuneId);
326 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
329 gLayout[1].nbChildren);
336 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
340 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
343 if (new_state >= 100) {
348 if (new_state != progressBar->state) {
349 progressBar->partialRedraw =
true;
350 progressBar->state = new_state;
359 if (trigger_callback) {
370 progressBar->partialRedraw =
true;
371 progressBar->state = 0;
378static void radioTouchCallback(
nbgl_obj_t *obj,
390 while (i < layout->nbUsedCallbackObjs) {
400 foundRadioIndex = radioIndex;
402 textArea->textColor =
BLACK;
403 textArea->fontId = SMALL_BOLD_FONT;
425 textArea->fontId = SMALL_REGULAR_FONT;
433 if (foundRadio != 0xFF) {
435#ifdef HAVE_PIEZO_SOUND
447static void spinnerTickerCallback(
void)
454 if (gLayout[1].nbChildren > 0) {
455 layout = &gLayout[1];
458 layout = &gLayout[0];
462 while (i < layout->container->nbChildren) {
465 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
470 spinner->position = 0;
482static void animTickerCallback(
void)
489 if (gLayout[1].nbChildren > 0) {
490 layout = &gLayout[1];
493 layout = &gLayout[0];
501 while (i < layout->container->nbChildren) {
504 if (container->children[1]->type ==
IMAGE) {
549 line->obj.area.width = SCREEN_WIDTH;
550 line->obj.area.height = 4;
562 line->obj.area.width = 1;
563 line->obj.area.height = SCREEN_HEIGHT;
582 layoutObj->
obj = obj;
583 layoutObj->
token = token;
584 layoutObj->
tuneId = tuneId;
633 layoutInt->
container->obj.touchMask = swipesMask;
660 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
667 container->nbChildren = 0;
670 container->obj.area.height = itemDesc->
large ? TOUCHABLE_MAIN_BAR_HEIGHT : TOUCHABLE_BAR_HEIGHT;
672 container->obj.alignmentMarginX = BORDER_MARGIN;
674 container->obj.alignTo = NULL;
679 container->obj.touchMask = (1 <<
TOUCHED);
680 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
681 nbTouchableControls++;
686 textArea->textColor = color;
687 textArea->text = PIC(itemDesc->
text);
688 textArea->onDrawCallback = NULL;
689 textArea->fontId = SMALL_BOLD_FONT;
690 textArea->wrapping =
true;
691 textArea->obj.area.width = container->obj.area.width;
694 textArea->obj.area.width
699 textArea->obj.area.width
703 textArea->obj.area.width -= 60 + BAR_INTERVALE;
706 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
707 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
711 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
712 container->nbChildren++;
717 imageLeft->foregroundColor = color;
718 imageLeft->buffer = PIC(itemDesc->
iconLeft);
720 imageLeft->obj.alignment =
MID_LEFT;
721 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
722 imageLeft->obj.alignmentMarginX = BAR_INTERVALE;
723 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
724 container->nbChildren++;
726 textArea->obj.alignmentMarginX = imageLeft->buffer->width + BAR_INTERVALE;
728 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
733 imageRight->foregroundColor = color;
734 imageRight->buffer = PIC(itemDesc->
iconRight);
737 imageRight->obj.alignmentMarginX = BAR_INTERVALE;
738 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
740 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
741 container->nbChildren++;
743 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
747 switchObj->onColor =
BLACK;
749 switchObj->state = itemDesc->
state;
751 switchObj->obj.alignmentMarginX = BAR_INTERVALE;
752 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
754 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
755 container->nbChildren++;
758 if (itemDesc->
subText != NULL) {
762 subTextArea->textColor = color;
763 subTextArea->text = PIC(itemDesc->
subText);
764 subTextArea->textAlignment =
MID_LEFT;
765 subTextArea->fontId = SMALL_REGULAR_FONT;
767 subTextArea->wrapping =
true;
768 subTextArea->obj.alignment =
MID_LEFT;
769 subTextArea->obj.area.width = container->obj.area.width;
772 subTextArea->obj.area.width,
773 subTextArea->wrapping);
774 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
775 container->nbChildren++;
776 container->obj.area.height += subTextArea->obj.area.height + 12;
779 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
780 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
808 container->nbChildren = 0;
813 if (info->
icon != NULL) {
815 image->foregroundColor =
BLACK;
816 image->buffer = PIC(info->
icon);
818 image->obj.alignmentMarginY = info->
iconHug;
820 fullHeight += image->buffer->height + info->
iconHug;
821 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
822 container->nbChildren++;
827 anim->foregroundColor =
BLACK;
833 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
834 container->nbChildren++;
845 tickerCfg.tickerCallback = &animTickerCallback;
850 if (info->
title != NULL) {
852 textArea->textColor =
BLACK;
853 textArea->text = PIC(info->
title);
854 textArea->textAlignment =
CENTER;
855 textArea->fontId = LARGE_MEDIUM_FONT;
856 textArea->wrapping =
true;
859 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
862 if (container->nbChildren > 0) {
865 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
871 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
873 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
874 container->nbChildren++;
879 textArea->textColor =
BLACK;
881 textArea->textAlignment =
CENTER;
882 textArea->fontId = SMALL_BOLD_FONT;
883 textArea->wrapping =
true;
886 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
889 if (container->nbChildren > 0) {
891 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
892 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
893 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
894 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
897 textArea->obj.alignmentMarginY = 16;
904 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
906 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
907 container->nbChildren++;
912 textArea->textColor =
BLACK;
914 textArea->textAlignment =
CENTER;
915 textArea->fontId = SMALL_REGULAR_FONT;
916 textArea->wrapping =
true;
919 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
922 if (container->nbChildren > 0) {
924 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
925 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
927 textArea->obj.alignmentMarginY = 16;
930 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
937 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
939 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
940 container->nbChildren++;
946 textArea->text = PIC(info->
subText);
947 textArea->textAlignment =
CENTER;
948 textArea->fontId = SMALL_REGULAR_FONT;
949 textArea->wrapping =
true;
952 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
954 textArea->obj.area.height += 2 * 8;
956 if (container->nbChildren > 0) {
958 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
959 textArea->obj.alignmentMarginY = 16;
960 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
961 textArea->obj.alignmentMarginY += info->
iconHug;
968 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
970 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
971 container->nbChildren++;
974 container->obj.alignment =
CENTER;
976 container->obj.area.height = fullHeight;
978 container->obj.area.height += 40;
1000 if (layout == NULL) {
1012 textArea->textColor =
BLACK;
1013 textArea->text = PIC(text);
1014 textArea->textAlignment =
MID_LEFT;
1015 textArea->fontId = SMALL_BOLD_FONT;
1017 textArea->wrapping =
true;
1019 textArea->obj.alignmentMarginY = PRE_TEXT_MARGIN;
1020 textArea->obj.area.width = container->obj.area.width;
1021 if (withAlias ==
true) {
1022 textArea->obj.area.width -= 12 + MINI_PUSH_ICON.width;
1025 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1026 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1027 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1028 container->nbChildren++;
1029 if (withAlias ==
true) {
1035 image->foregroundColor =
BLACK;
1036 image->buffer = &PUSH_ICON;
1038 image->obj.alignmentMarginX = 12;
1039 image->obj.alignTo = (
nbgl_obj_t *) textArea;
1040 container->obj.touchMask = (1 <<
TOUCHED);
1043 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
1044 container->nbChildren++;
1047 if (subText != NULL) {
1049 subTextArea->textColor =
BLACK;
1050 subTextArea->text = PIC(subText);
1051 subTextArea->fontId = SMALL_REGULAR_FONT;
1053 subTextArea->wrapping =
true;
1054 subTextArea->obj.area.width = container->obj.area.width;
1057 subTextArea->obj.area.width,
1058 subTextArea->wrapping);
1059 subTextArea->textAlignment =
MID_LEFT;
1062 subTextArea->obj.alignmentMarginY = TEXT_SUBTEXT_MARGIN;
1065 subTextArea->obj.alignmentMarginY = PRE_SUBTEXT_MARGIN;
1067 fullHeight += subTextArea->obj.alignmentMarginY;
1068 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
1069 container->nbChildren++;
1070 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
1073 fullHeight += PRE_TEXT_MARGIN;
1075 container->obj.area.height = fullHeight;
1077 container->obj.alignmentMarginX = BORDER_MARGIN;
1082 return container->obj.area.height;
1100 if (description->
modal) {
1101 if (gLayout[1].nbChildren == 0) {
1102 layout = &gLayout[1];
1104 else if (gLayout[2].nbChildren == 0) {
1105 layout = &gLayout[2];
1111 layout = &gLayout[0];
1113 if (layout == NULL) {
1121 nbTouchableControls = 0;
1126 if (description->
modal) {
1140 layout->
container->obj.area.width = SCREEN_WIDTH;
1141 layout->
container->obj.area.height = SCREEN_HEIGHT;
1158 obj->
tuneId = description->tapTuneId;
1166 footerDesc.
text.tuneId = description->tapTuneId;
1188 tune_index_e tuneId)
1193 if (layout == NULL) {
1200 layoutInt->
tapText->text = PIC(text);
1202 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1206 layoutInt->
tapText->obj.alignmentMarginY = TAP_TO_CONTINUE_MARGIN;
1224 tune_index_e tuneId)
1231 if (layout == NULL) {
1240 button->obj.area.width = BUTTON_DIAMETER;
1241 button->obj.area.height = BUTTON_DIAMETER;
1242 button->radius = BUTTON_RADIUS;
1243 button->obj.alignmentMarginX = BORDER_MARGIN;
1244 button->obj.alignmentMarginY = BORDER_MARGIN;
1245 button->foregroundColor =
BLACK;
1246 button->innerColor =
WHITE;
1248 button->obj.touchMask = (1 <<
TOUCHED);
1250 button->icon = PIC(icon);
1295 bool separationLine,
1296 tune_index_e tuneId)
1306 footerDesc.
button.tuneId = tuneId;
1325 if (layout == NULL) {
1329 if (barLayout->
text == NULL) {
1338 itemDesc.tuneId = barLayout->tuneId;
1342 container = addListItem(layoutInt, &itemDesc);
1344 if (container == NULL) {
1347 return container->obj.area.height;
1364 if (layout == NULL) {
1368 if (switchLayout->
text == NULL) {
1374 itemDesc.
text = switchLayout->
text;
1377 itemDesc.tuneId = switchLayout->tuneId;
1379 itemDesc.
large =
false;
1381 container = addListItem(layoutInt, &itemDesc);
1383 if (container == NULL) {
1386 return container->obj.area.height;
1400 return addText(layout, text, subText, 0, 0,
false);
1416 const char *subText,
1421 return addText(layout, text, subText, token, index,
true);
1437 if (layout == NULL) {
1442 textArea->textColor =
BLACK;
1443 textArea->text = PIC(text);
1444 textArea->textAlignment =
MID_LEFT;
1445 textArea->fontId = SMALL_REGULAR_FONT;
1447 textArea->wrapping =
true;
1449 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1452 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1453 textArea->obj.area.height += SUB_HEADER_MARGIN;
1458 return textArea->obj.area.height;
1475 if (layout == NULL) {
1481 textArea->text = PIC(text);
1482 textArea->textAlignment =
MID_LEFT;
1483 textArea->fontId = LARGE_MEDIUM_FONT;
1485 textArea->wrapping =
true;
1487 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1490 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1491 if (layoutInt->
container->nbChildren == 0) {
1493 textArea->obj.alignmentMarginY += PRE_FIRST_TEXT_MARGIN;
1496 textArea->obj.alignmentMarginY = INTER_PARAGRAPHS_MARGIN;
1519 const char *description,
1526 if (layout == NULL) {
1532 textArea->textColor =
BLACK;
1533 textArea->text = PIC(title);
1534 textArea->textAlignment =
MID_LEFT;
1535 textArea->fontId = LARGE_MEDIUM_FONT;
1537 textArea->wrapping =
true;
1539 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1540 textArea->obj.alignmentMarginY = PRE_TITLE_MARGIN;
1543 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1549 textArea->textColor =
BLACK;
1550 textArea->text = PIC(description);
1551 textArea->fontId = SMALL_REGULAR_FONT;
1553 textArea->wrapping =
true;
1556 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1557 textArea->textAlignment =
MID_LEFT;
1559 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1560 textArea->obj.alignmentMarginY = PRE_DESCRIPTION_MARGIN;
1567 textArea->text = PIC(info);
1568 textArea->fontId = SMALL_REGULAR_FONT;
1570 textArea->wrapping =
true;
1573 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1574 textArea->textAlignment =
MID_LEFT;
1576 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1577 textArea->obj.alignmentMarginY = 40;
1581 return layoutInt->
container->obj.area.height;
1598 if (layout == NULL) {
1601 for (i = 0; i < choices->
nbChoices; i++) {
1612 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1618 container->nbChildren = 2;
1621 container->obj.area.height = RADIO_CHOICE_HEIGHT;
1623 container->obj.alignmentMarginX = BORDER_MARGIN;
1624 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1627 button->activeColor =
BLACK;
1629 button->obj.alignTo = (
nbgl_obj_t *) container;
1632 container->children[1] = (
nbgl_obj_t *) button;
1636#ifdef HAVE_LANGUAGE_PACK
1641 textArea->text = PIC(choices->
names[i]);
1643 textArea->textAlignment =
MID_LEFT;
1644 textArea->obj.area.width = container->obj.area.width - RADIO_WIDTH;
1646 textArea->obj.alignment =
MID_LEFT;
1647 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1648 container->children[0] = (
nbgl_obj_t *) textArea;
1651 container->obj.touchMask = (1 <<
TOUCHED);
1652 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1653 nbTouchableControls++;
1658 textArea->textColor =
BLACK;
1659 textArea->fontId = SMALL_BOLD_FONT;
1664 textArea->fontId = SMALL_REGULAR_FONT;
1668 line = createHorizontalLine(layoutInt->
layer);
1669 line->obj.alignmentMarginY = -4;
1695 if (layout == NULL) {
1702 if (info->
text1 != NULL) {
1710 if (info->
text2 != NULL) {
1718 if (info->
text3 != NULL) {
1726 container = addContentCenter(layoutInt, ¢eredInfo);
1729 container->obj.alignmentMarginX = BORDER_MARGIN;
1730 container->obj.alignmentMarginY = BORDER_MARGIN + info->
offsetY;
1734 container->obj.alignmentMarginY = info->
offsetY;
1737 return container->obj.area.height;
1754 if (layout == NULL) {
1758 container = addContentCenter(layoutInt, info);
1760 return container->obj.area.height;
1778 if (layout == NULL) {
1784 container->nbChildren = info->
nbRows + 1;
1788 container->obj.alignmentMarginX = BORDER_MARGIN;
1792 textArea->textColor =
BLACK;
1793 textArea->text = PIC(info->
title);
1794 textArea->textAlignment =
MID_LEFT;
1795 textArea->fontId = LARGE_MEDIUM_FONT;
1796 textArea->wrapping =
true;
1799 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1801 container->obj.area.height += textArea->obj.area.height;
1803 container->children[0] = (
nbgl_obj_t *) textArea;
1805 for (row = 0; row < info->
nbRows; row++) {
1811 rowContainer->nbChildren = 2;
1816 image->foregroundColor =
BLACK;
1817 image->buffer = info->
rowIcons[row];
1818 rowContainer->children[0] = (
nbgl_obj_t *) image;
1821 textArea->textColor =
BLACK;
1822 textArea->text = info->
rowTexts[row];
1823 textArea->textAlignment =
MID_LEFT;
1824 textArea->fontId = SMALL_REGULAR_FONT;
1825 textArea->wrapping =
true;
1826 textArea->obj.alignmentMarginX = 16;
1827 textArea->obj.area.width
1828 =
AVAILABLE_WIDTH - image->buffer->width - textArea->obj.alignmentMarginX;
1830 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1832 textArea->obj.alignTo = (
nbgl_obj_t *) image;
1833 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1834 rowContainer->obj.area.height =
MAX(image->buffer->height, textArea->obj.area.height);
1837 rowContainer->obj.alignmentMarginY = 32;
1840 rowContainer->obj.alignmentMarginY = INTER_ROWS_MARGIN;
1842 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1843 container->obj.area.height
1844 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1848 return container->obj.area.height;
1869 if (layout == NULL) {
1877 container->nbChildren = 0;
1881 if (strlen(PIC(info->
url)) > 62) {
1897 fullHeight +=
qrcode->obj.area.height;
1899 container->nbChildren++;
1901 if (info->
text1 != NULL) {
1903 textArea->textColor =
BLACK;
1904 textArea->text = PIC(info->
text1);
1905 textArea->textAlignment =
CENTER;
1906 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1907 textArea->wrapping =
true;
1910 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1912 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1913 textArea->obj.alignmentMarginY = 24;
1915 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1917 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1918 container->nbChildren++;
1920 if (info->
text2 != NULL) {
1923 textArea->text = PIC(info->
text2);
1924 textArea->textAlignment =
CENTER;
1925 textArea->fontId = SMALL_REGULAR_FONT;
1926 textArea->wrapping =
true;
1929 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1931 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1932 if (info->
text1 != NULL) {
1933 textArea->obj.alignmentMarginY = QR_INTER_TEXTS_MARGIN;
1936 textArea->obj.alignmentMarginY = 32;
1940 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1942 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1943 container->nbChildren++;
1946 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1954 container->obj.area.height = fullHeight;
1957 container->obj.alignment =
CENTER;
1961 container->obj.alignTo
1964 container->obj.alignmentMarginY = info->
offsetY;
2010 .horizontalButtons.leftIcon = info->
leftIcon,
2011 .horizontalButtons.leftToken = info->
leftToken,
2012 .horizontalButtons.rightText = info->
rightText,
2013 .horizontalButtons.rightToken = info->
rightToken,
2014 .horizontalButtons.tuneId = info->tuneId};
2036 if (layout == NULL) {
2040 for (i = 0; i < list->
nbPairs; i++) {
2045 if (list->
pairs != NULL) {
2046 pair = &list->
pairs[i];
2063 itemTextArea->text = PIC(pair->
item);
2064 itemTextArea->textAlignment =
MID_LEFT;
2065 itemTextArea->fontId = SMALL_REGULAR_FONT;
2066 itemTextArea->wrapping =
true;
2069 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2072 itemTextArea->obj.alignmentMarginX = 0;
2073 itemTextArea->obj.alignmentMarginY = 0;
2074 itemTextArea->obj.alignTo = NULL;
2075 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2076 container->nbChildren++;
2078 fullHeight += itemTextArea->obj.area.height;
2081 valueTextArea->textColor =
BLACK;
2082 valueTextArea->text = PIC(pair->
value);
2083 valueTextArea->textAlignment =
MID_LEFT;
2085 valueTextArea->fontId = SMALL_BOLD_FONT;
2088 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2096 valueIcon = &MINI_PUSH_ICON;
2103 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2109 valueTextArea->text,
2110 valueTextArea->obj.area.width,
2118 valueTextArea->obj.area.height = nbLines * font->
line_height;
2121 valueTextArea->obj.alignmentMarginY = 4;
2122 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2123 valueTextArea->wrapping = list->
wrapping;
2124 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2125 container->nbChildren++;
2127 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2128 if (valueIcon != NULL) {
2133 image->foregroundColor =
BLACK;
2134 image->buffer = valueIcon;
2136 image->obj.alignmentMarginX = 12;
2137 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2138 image->obj.touchMask = (1 <<
TOUCHED);
2141 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2142 container->nbChildren++;
2146 container->obj.area.height = fullHeight;
2148 container->obj.alignmentMarginX = BORDER_MARGIN;
2150 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2153 container->obj.alignmentMarginY = PRE_TAG_VALUE_MARGIN;
2177 if (layout == NULL) {
2180 if (barLayout->
text != NULL) {
2185 textArea->textColor =
BLACK;
2186 textArea->text = PIC(barLayout->
text);
2187 textArea->textAlignment =
MID_LEFT;
2188 textArea->fontId = SMALL_REGULAR_FONT;
2189 textArea->wrapping =
true;
2192 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2195 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2196 textArea->obj.alignmentMarginY = BORDER_MARGIN;
2201 progress->foregroundColor =
BLACK;
2202 progress->withBorder =
true;
2204 progress->obj.area.width = 120;
2205 progress->obj.area.height = 12;
2207 progress->obj.alignmentMarginX = (
AVAILABLE_WIDTH - progress->obj.area.width) / 2;
2208 progress->obj.alignmentMarginY = BORDER_MARGIN;
2211 if (barLayout->
subText != NULL) {
2217 subTextArea->text = PIC(barLayout->
subText);
2218 subTextArea->textAlignment =
MID_LEFT;
2219 subTextArea->fontId = SMALL_REGULAR_FONT;
2220 subTextArea->wrapping =
true;
2224 subTextArea->obj.area.width,
2225 subTextArea->wrapping);
2228 subTextArea->obj.alignmentMarginX = BORDER_MARGIN;
2229 subTextArea->obj.alignmentMarginY = BORDER_MARGIN;
2248 line = createHorizontalLine(layoutInt->
layer);
2249 line->obj.alignmentMarginY = -4;
2269 if (layout == NULL) {
2281 footerDesc.
button.tuneId = buttonInfo->tuneId;
2291 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2300 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2305 button->obj.alignmentMarginX = BORDER_MARGIN;
2306 button->obj.alignmentMarginY = 12;
2309 button->innerColor =
BLACK;
2310 button->foregroundColor =
WHITE;
2313 button->innerColor =
WHITE;
2314 button->foregroundColor =
BLACK;
2317 button->borderColor =
WHITE;
2321 button->borderColor =
BLACK;
2327 button->text = PIC(buttonInfo->
text);
2328 button->fontId = SMALL_BOLD_FONT;
2329 button->icon = PIC(buttonInfo->
icon);
2332 + SMALL_BUTTON_HEIGHT
2333 + ((button->icon) ? (button->icon->width + 12) : 0);
2334 button->obj.area.height = SMALL_BUTTON_HEIGHT;
2335 button->radius = SMALL_BUTTON_RADIUS_INDEX;
2336 if (buttonInfo->
onBottom !=
true) {
2337 button->obj.alignmentMarginX
2338 += (SCREEN_WIDTH - 2 * BORDER_MARGIN - button->obj.area.width) / 2;
2343 button->obj.area.height = BUTTON_DIAMETER;
2344 button->radius = BUTTON_RADIUS;
2346 button->obj.alignTo = NULL;
2347 button->obj.touchMask = (1 <<
TOUCHED);
2367 tune_index_e tuneId)
2370 .longPress.text = text,
2371 .longPress.token = token,
2372 .longPress.tuneId = tuneId};
2375 if (layout == NULL) {
2395 tune_index_e tuneId)
2420 const char *leftText,
2422 const char *rightText,
2424 tune_index_e tuneId)
2455 if (layout == NULL) {
2469 switch (headerDesc->
type) {
2494 button->innerColor =
WHITE;
2495 button->foregroundColor =
BLACK;
2496 button->borderColor =
WHITE;
2497 button->obj.area.width = BACK_KEY_WIDTH;
2498 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2499 button->text = NULL;
2500 button->icon = PIC(&LEFT_ARROW_ICON);
2501 button->obj.touchMask = (1 <<
TOUCHED);
2513 image->foregroundColor =
BLACK;
2514 image->obj.alignment =
CENTER;
2529 textArea->obj.touchMask = (1 <<
TOUCHED);
2531 textArea->obj.alignment =
CENTER;
2532 textArea->textColor =
BLACK;
2533 textArea->obj.area.width
2537 textArea->obj.area.width -= 16 + image->buffer->width;
2539 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2540 textArea->text = text;
2541 textArea->fontId = SMALL_BOLD_FONT;
2542 textArea->textAlignment =
CENTER;
2543 textArea->wrapping =
true;
2548 textArea->obj.area.width,
2552 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2563 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2564 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2580 button->obj.touchMask = (1 <<
TOUCHED);
2584 button->innerColor =
WHITE;
2585 button->foregroundColor
2588 button->borderColor =
WHITE;
2589 button->obj.area.width = BACK_KEY_WIDTH;
2590 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2591 button->text = NULL;
2599 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2616 button->innerColor =
WHITE;
2617 button->foregroundColor =
BLACK;
2618 button->borderColor =
WHITE;
2619 button->obj.area.width = BACK_KEY_WIDTH;
2620 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2621 button->text = NULL;
2622 button->icon = PIC(&LEFT_ARROW_ICON);
2623 button->obj.touchMask = (1 <<
TOUCHED);
2640 progress->obj.area.width = 224;
2641 progress->obj.alignment =
CENTER;
2649 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2655 textArea->textColor =
BLACK;
2657 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2658 textArea->text = PIC(headerDesc->
title.
text);
2659 textArea->fontId = SMALL_BOLD_FONT;
2660 textArea->textAlignment =
CENTER;
2661 textArea->wrapping =
true;
2665 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2678 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2679 textArea->textColor =
BLACK;
2681 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2683 textArea->fontId = SMALL_BOLD_FONT;
2685 textArea->obj.touchMask = (1 <<
TOUCHED);
2691 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2699 line = createHorizontalLine(layoutInt->
layer);
2706 if (separationLine != NULL) {
2741 if (layout == NULL) {
2755 switch (footerDesc->
type) {
2773 textArea->obj.area.height
2778 textArea->textAlignment =
CENTER;
2779 textArea->obj.touchMask = (1 <<
TOUCHED);
2784 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2797 textArea->textColor =
BLACK;
2799 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2801 textArea->fontId = SMALL_BOLD_FONT;
2802 textArea->textAlignment =
CENTER;
2803 textArea->obj.touchMask = (1 <<
TOUCHED);
2821 textArea->textColor =
BLACK;
2823 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2825 textArea->fontId = SMALL_BOLD_FONT;
2826 textArea->textAlignment =
CENTER;
2827 textArea->obj.touchMask = (1 <<
TOUCHED);
2833 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2838 separationLine->obj.area.width = 1;
2839 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2840 separationLine->direction =
VERTICAL;
2841 separationLine->thickness = 1;
2842 separationLine->obj.alignment =
MID_LEFT;
2843 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2844 separationLine->obj.alignmentMarginX = -1;
2860 textArea->textColor =
BLACK;
2861 textArea->obj.area.width = FOOTER_TEXT_AND_NAV_WIDTH;
2862 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2864 textArea->fontId = SMALL_BOLD_FONT;
2865 textArea->textAlignment =
CENTER;
2866 textArea->obj.touchMask = (1 <<
TOUCHED);
2878 navContainer->nbChildren = 4;
2879 navContainer->children
2882 navContainer->obj.area.width = SCREEN_WIDTH - textArea->obj.area.width;
2883 navContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2896 separationLine->obj.area.width = 1;
2897 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2898 separationLine->direction =
VERTICAL;
2899 separationLine->thickness = 1;
2900 separationLine->obj.alignment =
MID_LEFT;
2901 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2902 separationLine->obj.alignmentMarginX = -1;
2935 footerDesc->
button.tuneId);
2940 button->obj.alignment =
CENTER;
2942 button->innerColor =
BLACK;
2943 button->foregroundColor =
WHITE;
2946 button->innerColor =
WHITE;
2947 button->foregroundColor =
BLACK;
2951 button->borderColor =
WHITE;
2955 button->borderColor =
BLACK;
2962 button->fontId = SMALL_BOLD_FONT;
2964 button->radius = BUTTON_RADIUS;
2965 button->obj.area.height = BUTTON_DIAMETER;
2968 button->obj.area.width = BUTTON_DIAMETER;
2973 button->obj.touchMask = (1 <<
TOUCHED);
3001 button->innerColor =
WHITE;
3003 button->obj.alignmentMarginY
3004 = BOTTOM_BORDER_MARGIN;
3008 button->obj.alignmentMarginY = 4;
3009 button->borderColor =
WHITE;
3011 button->foregroundColor =
BLACK;
3013 button->obj.area.height = BUTTON_DIAMETER;
3014 button->radius = BUTTON_RADIUS;
3016 button->fontId = SMALL_BOLD_FONT;
3017 button->obj.touchMask = (1 <<
TOUCHED);
3027 line = createHorizontalLine(layoutInt->
layer);
3029 line->obj.alignmentMarginY = 4;
3048 button->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
3050 button->innerColor =
WHITE;
3052 button->foregroundColor =
BLACK;
3055 button->innerColor =
BLACK;
3056 button->borderColor =
BLACK;
3057 button->foregroundColor =
WHITE;
3060 button->obj.area.height = BUTTON_DIAMETER;
3061 button->radius = BUTTON_RADIUS;
3066 button->fontId = SMALL_BOLD_FONT;
3067 button->obj.touchMask = (1 <<
TOUCHED);
3075 layoutInt->
footerContainer->obj.area.height = ACTION_AND_FOOTER_FOOTER_HEIGHT;
3078 layoutInt->
footerContainer->obj.area.height = ROUNDED_AND_FOOTER_FOOTER_HEIGHT;
3089 addSwipeInternal(layoutInt,
3100 line = createHorizontalLine(layoutInt->
layer);
3106 if (separationLine != NULL) {
3139 if (layout == NULL) {
3156 switch (upFooterDesc->
type) {
3175 button->obj.alignmentMarginX = BORDER_MARGIN;
3177 button->innerColor =
BLACK;
3178 button->foregroundColor =
WHITE;
3179 button->borderColor =
BLACK;
3180 button->obj.area.width = BUTTON_DIAMETER;
3181 button->obj.area.height = BUTTON_DIAMETER;
3182 button->radius = BUTTON_RADIUS;
3183 button->icon = PIC(&VALIDATE_ICON);
3187 textArea->textColor =
BLACK;
3189 textArea->textAlignment =
MID_LEFT;
3190 textArea->fontId = LARGE_MEDIUM_FONT;
3191 textArea->wrapping =
true;
3192 textArea->obj.area.width = SCREEN_WIDTH - 3 * BORDER_MARGIN - button->obj.area.width;
3194 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3196 textArea->obj.alignment =
MID_LEFT;
3197 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3200 line = createHorizontalLine(layoutInt->
layer);
3206 progressBar->withBorder =
false;
3207 progressBar->obj.area.width = SCREEN_WIDTH;
3208 progressBar->obj.area.height = 8;
3210 progressBar->obj.alignmentMarginY = 4;
3211 progressBar->obj.alignTo = NULL;
3220 upFooterDesc->
button.tuneId);
3227 button->obj.alignment =
CENTER;
3230 button->innerColor =
BLACK;
3231 button->foregroundColor =
WHITE;
3234 button->innerColor =
WHITE;
3235 button->foregroundColor =
BLACK;
3238 button->borderColor =
WHITE;
3242 button->borderColor =
BLACK;
3248 button->text = PIC(upFooterDesc->
button.
text);
3249 button->fontId = SMALL_BOLD_FONT;
3250 button->icon = PIC(upFooterDesc->
button.
icon);
3252 button->obj.area.height = BUTTON_DIAMETER;
3253 button->radius = BUTTON_RADIUS;
3255 button->obj.alignTo = NULL;
3256 button->obj.touchMask = (1 <<
TOUCHED);
3283 button->obj.alignmentMarginX = BORDER_MARGIN;
3285 button->innerColor =
WHITE;
3286 button->foregroundColor =
BLACK;
3287 button->obj.area.width = BUTTON_DIAMETER;
3288 button->obj.area.height = BUTTON_DIAMETER;
3289 button->radius = BUTTON_RADIUS;
3291 button->fontId = SMALL_BOLD_FONT;
3292 button->obj.touchMask = (1 <<
TOUCHED);
3308 button->obj.alignmentMarginX = BORDER_MARGIN;
3309 button->innerColor =
BLACK;
3310 button->borderColor =
BLACK;
3311 button->foregroundColor =
WHITE;
3313 button->obj.area.height = BUTTON_DIAMETER;
3314 button->radius = BUTTON_RADIUS;
3316 button->fontId = SMALL_BOLD_FONT;
3317 button->obj.touchMask = (1 <<
TOUCHED);
3330 upFooterDesc->
tipBox.tuneId);
3339 textArea->textColor =
BLACK;
3340 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3341 textArea->textAlignment =
MID_LEFT;
3342 textArea->fontId = SMALL_REGULAR_FONT;
3343 textArea->wrapping =
true;
3346 textArea->obj.area.width
3351 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3352 textArea->obj.alignment =
MID_LEFT;
3353 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3357 line = createHorizontalLine(layoutInt->
layer);
3364 image->obj.alignmentMarginX = BORDER_MARGIN;
3366 image->foregroundColor =
BLACK;
3367 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3380 upFooterDesc->
text.token,
3381 upFooterDesc->
text.tuneId);
3392 textArea->text = PIC(upFooterDesc->
text.text);
3393 textArea->textAlignment =
CENTER;
3394 textArea->fontId = SMALL_REGULAR_FONT;
3395 textArea->wrapping =
true;
3398 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3399 textArea->obj.alignment =
CENTER;
3435 tune_index_e tuneId)
3438 .separationLine =
false,
3439 .progressAndBack.activePage = activePage,
3440 .progressAndBack.nbPages = nbPages,
3441 .progressAndBack.token = backToken,
3442 .progressAndBack.tuneId = tuneId,
3443 .progressAndBack.withBack = withBack,
3444 .progressAndBack.actionIcon = NULL,
3463 const char *subText,
3472 if (layout == NULL) {
3478 container->nbChildren = 3;
3483 container->obj.alignment =
CENTER;
3487 spinner->position = initPosition;
3490 container->children[0] = (
nbgl_obj_t *) spinner;
3493 container->obj.area.height += SPINNER_HEIGHT;
3497 textArea->textColor =
BLACK;
3498 textArea->text = PIC(text);
3499 textArea->textAlignment =
CENTER;
3500 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3501 textArea->wrapping =
true;
3502 textArea->obj.alignmentMarginY = SPINNER_TEXT_MARGIN;
3503 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3507 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3511 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3514 container->children[1] = (
nbgl_obj_t *) textArea;
3516 if (subText != NULL) {
3520 subTextArea->textColor =
BLACK;
3521 subTextArea->text = PIC(subText);
3522 subTextArea->textAlignment =
CENTER;
3523 subTextArea->fontId = SMALL_REGULAR_FONT;
3524 subTextArea->wrapping =
true;
3525 subTextArea->obj.alignmentMarginY = SPINNER_INTER_TEXTS_MARGIN;
3526 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3531 subTextArea->obj.area.width,
3532 subTextArea->wrapping);
3536 container->obj.area.height
3537 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3540 container->children[2] = (
nbgl_obj_t *) subTextArea;
3550 tickerCfg.tickerCallback = &spinnerTickerCallback;
3570 const char *subText,
3580 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3585 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3590 if (spinner->obj.type !=
SPINNER) {
3594 if (spinner->position != position) {
3595 spinner->position = position;
3605 const char *newText = PIC(text);
3606 size_t newTextLen = strlen(newText);
3608 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3609 textArea->text = newText;
3614 if (subText != NULL) {
3617 if (container->nbChildren != 3) {
3621 if (subTextArea->obj.type !=
TEXT_AREA) {
3624 const char *newSubText = PIC(subText);
3625 size_t newSubTextLen = strlen(newSubText);
3627 if ((newSubTextLen != strlen(subTextArea->text))
3628 || memcmp(subTextArea->text, newSubText, newSubTextLen)) {
3629 subTextArea->text = newSubText;
3648 if (layout == NULL) {
3652 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3679 if (layout == NULL) {
3683 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_layoutAddProgressBar(nbgl_layout_t *layout, const nbgl_layoutProgressBar_t *barLayout)
Creates an area in main panel to display a progress bar, with a title text and a description under th...
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_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
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.
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 progress bar with info. The progress bar itself is 120px widt...
uint8_t percentage
percentage of completion, from 0 to 100.
const char * text
text in black, on top of progress bar
const char * subText
text in gray, under progress bar
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