23#include "os_io_seph_ux.h"
25#include "os_helpers.h"
32#define INTERNAL_SPACE 16
34#define INNER_MARGIN 12
36#define NB_MAX_LAYOUTS 3
39#define NB_MAX_CONTAINER_CHILDREN 20
41#define TAG_VALUE_ICON_WIDTH 32
43#if defined(TARGET_STAX)
44#define RADIO_CHOICE_HEIGHT 96
45#define FOOTER_HEIGHT 80
46#define BAR_INTERVALE 12
47#define FOOTER_BUTTON_HEIGHT 128
48#define 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 ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
71#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
72#define FOOTER_TEXT_AND_NAV_WIDTH 192
73#define TAP_TO_CONTINUE_MARGIN 30
74#define SUB_HEADER_MARGIN (2 * 28)
75#define PRE_FIRST_TEXT_MARGIN 0
76#define INTER_PARAGRAPHS_MARGIN 24
77#define PRE_TITLE_MARGIN 16
78#define PRE_DESCRIPTION_MARGIN 24
79#define INTER_ROWS_MARGIN 26
80#define QR_INTER_TEXTS_MARGIN 28
81#define SPINNER_TEXT_MARGIN 24
82#define SPINNER_INTER_TEXTS_MARGIN 16
83#define BAR_TEXT_MARGIN 24
84#define BAR_INTER_TEXTS_MARGIN 16
85#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 32
86#define LEFT_CONTENT_TEXT_PADDING 4
88#error Undefined target
92#define SPINNER_REFRESH_PERIOD 400
120#ifdef HAVE_PIEZO_SOUND
136static uint8_t nbTouchableControls = 0;
143#ifdef HAVE_FAST_HOLD_TO_APPROVE
145#define HOLD_TO_APPROVE_STEP_PERCENT (7)
149#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
151#define HOLD_TO_APPROVE_STEP_PERCENT (25)
152#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
155static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
157#ifdef HAVE_FAST_HOLD_TO_APPROVE
166static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
176 if (gLayout[i].nbChildren > 0) {
181 if (obj == gLayout[i].callbackObjPool[j].obj) {
183 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
184 "nbUsedCallbackObjs = %d\n",
187 gLayout[i].nbUsedCallbackObjs);
188 *layout = &gLayout[i];
199static void radioTouchCallback(
nbgl_obj_t *obj,
212 bool needRefresh =
false;
218 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
220 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
223 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
241 layoutObj->
index = eventType;
290 layoutObj->
index = lSwitch->state;
296 radioTouchCallback(obj, eventType, layout);
303 longTouchCallback(obj, eventType, layout, layoutObj);
308#ifdef HAVE_PIEZO_SOUND
310 os_io_seph_cmd_piezo_play_tune(layoutObj->
tuneId);
331 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
334 gLayout[1].nbChildren);
341 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
345 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
348 if (new_state >= 100) {
353 if (new_state != progressBar->state) {
354 progressBar->partialRedraw =
true;
355 progressBar->state = new_state;
364 if (trigger_callback) {
375 progressBar->partialRedraw =
true;
376 progressBar->state = 0;
383static void radioTouchCallback(
nbgl_obj_t *obj,
387 uint8_t i =
NB_MAX_LAYOUTS, radioIndex = 0, foundRadio = 0xFF, foundRadioIndex;
395 while (i < layout->nbUsedCallbackObjs) {
405 foundRadioIndex = radioIndex;
407 textArea->textColor =
BLACK;
408 textArea->fontId = SMALL_BOLD_FONT;
430 textArea->fontId = SMALL_REGULAR_FONT;
438 if (foundRadio != 0xFF) {
440#ifdef HAVE_PIEZO_SOUND
452static void spinnerTickerCallback(
void)
459 if (gLayout[1].nbChildren > 0) {
460 layout = &gLayout[1];
463 layout = &gLayout[0];
467 while (i < layout->container->nbChildren) {
470 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
475 spinner->position = 0;
487static void animTickerCallback(
void)
494 if (gLayout[1].nbChildren > 0) {
495 layout = &gLayout[1];
498 layout = &gLayout[0];
506 while (i < layout->container->nbChildren) {
509 if (container->children[1]->type ==
IMAGE) {
548static nbgl_line_t *createHorizontalLine(uint8_t layer)
554 line->obj.area.width = SCREEN_WIDTH;
555 line->obj.area.height = 4;
561static nbgl_line_t *createLeftVerticalLine(uint8_t layer)
567 line->obj.area.width = 1;
568 line->obj.area.height = SCREEN_HEIGHT;
587 layoutObj->
obj = obj;
588 layoutObj->
token = token;
589 layoutObj->
tuneId = tuneId;
638 layoutInt->
container->obj.touchMask = swipesMask;
659 int16_t usedHeight = 40;
665 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
672 container->nbChildren = 0;
675 container->obj.area.height = itemDesc->
large ? TOUCHABLE_MAIN_BAR_HEIGHT : TOUCHABLE_BAR_HEIGHT;
677 container->obj.alignmentMarginX = BORDER_MARGIN;
679 container->obj.alignTo = NULL;
684 container->obj.touchMask = (1 <<
TOUCHED);
685 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
686 nbTouchableControls++;
691 textArea->textColor = color;
692 textArea->text = PIC(itemDesc->
text);
693 textArea->onDrawCallback = NULL;
694 textArea->fontId = SMALL_BOLD_FONT;
695 textArea->wrapping =
true;
696 textArea->obj.area.width = container->obj.area.width;
699 textArea->obj.area.width
704 textArea->obj.area.width
708 textArea->obj.area.width -= 60 + BAR_INTERVALE;
711 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
712 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
716 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
717 container->nbChildren++;
722 imageLeft->foregroundColor = color;
723 imageLeft->buffer = PIC(itemDesc->
iconLeft);
725 imageLeft->obj.alignment =
MID_LEFT;
726 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
727 imageLeft->obj.alignmentMarginX = BAR_INTERVALE;
728 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
729 container->nbChildren++;
731 textArea->obj.alignmentMarginX = imageLeft->buffer->width + BAR_INTERVALE;
733 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
738 imageRight->foregroundColor = color;
739 imageRight->buffer = PIC(itemDesc->
iconRight);
742 imageRight->obj.alignmentMarginX = BAR_INTERVALE;
743 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
745 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
746 container->nbChildren++;
748 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
752 switchObj->onColor =
BLACK;
754 switchObj->state = itemDesc->
state;
756 switchObj->obj.alignmentMarginX = BAR_INTERVALE;
757 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
759 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
760 container->nbChildren++;
763 if (itemDesc->
subText != NULL) {
767 subTextArea->textColor = color;
768 subTextArea->text = PIC(itemDesc->
subText);
769 subTextArea->textAlignment =
MID_LEFT;
770 subTextArea->fontId = SMALL_REGULAR_FONT;
772 subTextArea->wrapping =
true;
773 subTextArea->obj.alignment =
MID_LEFT;
774 subTextArea->obj.area.width = container->obj.area.width;
777 subTextArea->obj.area.width,
778 subTextArea->wrapping);
779 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
780 container->nbChildren++;
781 container->obj.area.height += subTextArea->obj.area.height + 12;
784 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
785 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
808 uint16_t fullHeight = 0;
813 container->nbChildren = 0;
818 if (info->
icon != NULL) {
820 image->foregroundColor =
BLACK;
821 image->buffer = PIC(info->
icon);
823 image->obj.alignmentMarginY = info->
iconHug;
825 fullHeight += image->buffer->height + info->
iconHug;
826 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
827 container->nbChildren++;
832 anim->foregroundColor =
BLACK;
838 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
839 container->nbChildren++;
850 tickerCfg.tickerCallback = &animTickerCallback;
855 if (info->
title != NULL) {
857 textArea->textColor =
BLACK;
858 textArea->text = PIC(info->
title);
859 textArea->textAlignment =
CENTER;
860 textArea->fontId = LARGE_MEDIUM_FONT;
861 textArea->wrapping =
true;
864 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
867 if (container->nbChildren > 0) {
870 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
876 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
878 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
879 container->nbChildren++;
884 textArea->textColor =
BLACK;
886 textArea->textAlignment =
CENTER;
887 textArea->fontId = SMALL_BOLD_FONT;
888 textArea->wrapping =
true;
891 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
894 if (container->nbChildren > 0) {
896 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
897 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
898 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
899 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
902 textArea->obj.alignmentMarginY = 16;
909 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
911 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
912 container->nbChildren++;
917 textArea->textColor =
BLACK;
919 textArea->textAlignment =
CENTER;
920 textArea->fontId = SMALL_REGULAR_FONT;
921 textArea->wrapping =
true;
924 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
927 if (container->nbChildren > 0) {
929 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
930 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
932 textArea->obj.alignmentMarginY = 16;
935 textArea->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN + info->
iconHug;
942 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
944 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
945 container->nbChildren++;
951 textArea->text = PIC(info->
subText);
952 textArea->textAlignment =
CENTER;
953 textArea->fontId = SMALL_REGULAR_FONT;
954 textArea->wrapping =
true;
957 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
959 textArea->obj.area.height += 2 * 8;
961 if (container->nbChildren > 0) {
963 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
964 textArea->obj.alignmentMarginY = 16;
965 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
966 textArea->obj.alignmentMarginY += info->
iconHug;
973 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
975 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
976 container->nbChildren++;
979 container->obj.alignment =
CENTER;
981 container->obj.area.height = fullHeight;
983 container->obj.area.height += 40;
1003 uint16_t fullHeight = 0;
1005 if (layout == NULL) {
1017 textArea->textColor =
BLACK;
1018 textArea->text = PIC(text);
1019 textArea->textAlignment =
MID_LEFT;
1020 textArea->fontId = SMALL_BOLD_FONT;
1022 textArea->wrapping =
true;
1024 textArea->obj.alignmentMarginY = PRE_TEXT_MARGIN;
1025 textArea->obj.area.width = container->obj.area.width;
1026 if (withAlias ==
true) {
1027 textArea->obj.area.width -= 12 + MINI_PUSH_ICON.width;
1030 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1031 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1032 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1033 container->nbChildren++;
1034 if (withAlias ==
true) {
1040 image->foregroundColor =
BLACK;
1041 image->buffer = &PUSH_ICON;
1043 image->obj.alignmentMarginX = 12;
1044 image->obj.alignTo = (
nbgl_obj_t *) textArea;
1045 container->obj.touchMask = (1 <<
TOUCHED);
1048 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
1049 container->nbChildren++;
1052 if (subText != NULL) {
1054 subTextArea->textColor =
BLACK;
1055 subTextArea->text = PIC(subText);
1056 subTextArea->fontId = SMALL_REGULAR_FONT;
1058 subTextArea->wrapping =
true;
1059 subTextArea->obj.area.width = container->obj.area.width;
1062 subTextArea->obj.area.width,
1063 subTextArea->wrapping);
1064 subTextArea->textAlignment =
MID_LEFT;
1067 subTextArea->obj.alignmentMarginY = TEXT_SUBTEXT_MARGIN;
1070 subTextArea->obj.alignmentMarginY = PRE_SUBTEXT_MARGIN;
1072 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
1073 container->nbChildren++;
1074 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
1075 fullHeight += POST_SUBTEXT_MARGIN;
1078 fullHeight += PRE_TEXT_MARGIN;
1080 container->obj.area.height = fullHeight;
1082 container->obj.alignmentMarginX = BORDER_MARGIN;
1087 return container->obj.area.height;
1105 if (description->
modal) {
1106 if (gLayout[1].nbChildren == 0) {
1107 layout = &gLayout[1];
1109 else if (gLayout[2].nbChildren == 0) {
1110 layout = &gLayout[2];
1116 layout = &gLayout[0];
1118 if (layout == NULL) {
1126 nbTouchableControls = 0;
1131 if (description->
modal) {
1145 layout->
container->obj.area.width = SCREEN_WIDTH;
1146 layout->
container->obj.area.height = SCREEN_HEIGHT;
1163 obj->
tuneId = description->tapTuneId;
1171 footerDesc.
text.tuneId = description->tapTuneId;
1190 uint16_t swipesMask,
1193 tune_index_e tuneId)
1198 if (layout == NULL) {
1205 layoutInt->
tapText->text = PIC(text);
1207 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1211 layoutInt->
tapText->obj.alignmentMarginY = TAP_TO_CONTINUE_MARGIN;
1229 tune_index_e tuneId)
1236 if (layout == NULL) {
1245 button->obj.area.width = BUTTON_DIAMETER;
1246 button->obj.area.height = BUTTON_DIAMETER;
1247 button->radius = BUTTON_RADIUS;
1248 button->obj.alignmentMarginX = BORDER_MARGIN;
1249 button->obj.alignmentMarginY = BORDER_MARGIN;
1250 button->foregroundColor =
BLACK;
1251 button->innerColor =
WHITE;
1253 button->obj.touchMask = (1 <<
TOUCHED);
1255 button->icon = PIC(icon);
1300 bool separationLine,
1301 tune_index_e tuneId)
1311 footerDesc.
button.tuneId = tuneId;
1330 if (layout == NULL) {
1334 if (barLayout->
text == NULL) {
1343 itemDesc.tuneId = barLayout->tuneId;
1347 container = addListItem(layoutInt, &itemDesc);
1349 if (container == NULL) {
1352 return container->obj.area.height;
1369 if (layout == NULL) {
1373 if (switchLayout->
text == NULL) {
1379 itemDesc.
text = switchLayout->
text;
1382 itemDesc.tuneId = switchLayout->tuneId;
1384 itemDesc.
large =
false;
1386 container = addListItem(layoutInt, &itemDesc);
1388 if (container == NULL) {
1391 return container->obj.area.height;
1405 return addText(layout, text, subText, 0, 0,
false);
1421 const char *subText,
1426 return addText(layout, text, subText, token, index,
true);
1442 if (layout == NULL) {
1447 textArea->textColor =
BLACK;
1448 textArea->text = PIC(text);
1449 textArea->textAlignment =
MID_LEFT;
1450 textArea->fontId = SMALL_REGULAR_FONT;
1452 textArea->wrapping =
true;
1454 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1457 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1458 textArea->obj.area.height += SUB_HEADER_MARGIN;
1463 return textArea->obj.area.height;
1480 if (layout == NULL) {
1486 textArea->text = PIC(text);
1487 textArea->textAlignment =
MID_LEFT;
1488 textArea->fontId = LARGE_MEDIUM_FONT;
1490 textArea->wrapping =
true;
1492 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1495 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1496 if (layoutInt->
container->nbChildren == 0) {
1498 textArea->obj.alignmentMarginY += PRE_FIRST_TEXT_MARGIN;
1501 textArea->obj.alignmentMarginY = INTER_PARAGRAPHS_MARGIN;
1524 const char *description,
1531 if (layout == NULL) {
1537 textArea->textColor =
BLACK;
1538 textArea->text = PIC(title);
1539 textArea->textAlignment =
MID_LEFT;
1540 textArea->fontId = LARGE_MEDIUM_FONT;
1542 textArea->wrapping =
true;
1544 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1545 textArea->obj.alignmentMarginY = PRE_TITLE_MARGIN;
1548 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1554 textArea->textColor =
BLACK;
1555 textArea->text = PIC(description);
1556 textArea->fontId = SMALL_REGULAR_FONT;
1558 textArea->wrapping =
true;
1561 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1562 textArea->textAlignment =
MID_LEFT;
1564 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1565 textArea->obj.alignmentMarginY = PRE_DESCRIPTION_MARGIN;
1572 textArea->text = PIC(info);
1573 textArea->fontId = SMALL_REGULAR_FONT;
1575 textArea->wrapping =
true;
1578 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1579 textArea->textAlignment =
MID_LEFT;
1581 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1582 textArea->obj.alignmentMarginY = 40;
1586 return layoutInt->
container->obj.area.height;
1603 if (layout == NULL) {
1606 for (i = 0; i < choices->
nbChoices; i++) {
1617 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1623 container->nbChildren = 2;
1626 container->obj.area.height = RADIO_CHOICE_HEIGHT;
1628 container->obj.alignmentMarginX = BORDER_MARGIN;
1629 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1632 button->activeColor =
BLACK;
1634 button->obj.alignTo = (
nbgl_obj_t *) container;
1637 container->children[1] = (
nbgl_obj_t *) button;
1641#ifdef HAVE_LANGUAGE_PACK
1642 textArea->text = get_ux_loc_string(choices->nameIds[i]);
1646 textArea->text = PIC(choices->
names[i]);
1648 textArea->textAlignment =
MID_LEFT;
1649 textArea->obj.area.width = container->obj.area.width - RADIO_WIDTH;
1651 textArea->obj.alignment =
MID_LEFT;
1652 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1653 container->children[0] = (
nbgl_obj_t *) textArea;
1656 container->obj.touchMask = (1 <<
TOUCHED);
1657 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1658 nbTouchableControls++;
1663 textArea->textColor =
BLACK;
1664 textArea->fontId = SMALL_BOLD_FONT;
1669 textArea->fontId = SMALL_REGULAR_FONT;
1673 line = createHorizontalLine(layoutInt->
layer);
1674 line->obj.alignmentMarginY = -4;
1700 if (layout == NULL) {
1707 if (info->
text1 != NULL) {
1715 if (info->
text2 != NULL) {
1723 if (info->
text3 != NULL) {
1731 container = addContentCenter(layoutInt, ¢eredInfo);
1734 container->obj.alignmentMarginX = BORDER_MARGIN;
1735 container->obj.alignmentMarginY = BORDER_MARGIN + info->
offsetY;
1739 container->obj.alignmentMarginY = info->
offsetY;
1742 return container->obj.area.height;
1759 if (layout == NULL) {
1763 container = addContentCenter(layoutInt, info);
1765 return container->obj.area.height;
1783 if (layout == NULL) {
1789 container->nbChildren = info->
nbRows + 1;
1793 container->obj.alignmentMarginX = BORDER_MARGIN;
1797 textArea->textColor =
BLACK;
1798 textArea->text = PIC(info->
title);
1799 textArea->textAlignment =
MID_LEFT;
1800 textArea->fontId = LARGE_MEDIUM_FONT;
1801 textArea->wrapping =
true;
1803 textArea->obj.alignmentMarginY = 24;
1807 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1809 container->obj.area.height += textArea->obj.area.height;
1811 container->children[0] = (
nbgl_obj_t *) textArea;
1813 for (row = 0; row < info->
nbRows; row++) {
1819 rowContainer->nbChildren = 2;
1824 image->foregroundColor =
BLACK;
1825 image->buffer = info->
rowIcons[row];
1826 rowContainer->children[0] = (
nbgl_obj_t *) image;
1829 textArea->textColor =
BLACK;
1830 textArea->text = info->
rowTexts[row];
1831 textArea->textAlignment =
MID_LEFT;
1832 textArea->fontId = SMALL_REGULAR_FONT;
1833 textArea->wrapping =
true;
1834 textArea->obj.area.width =
AVAILABLE_WIDTH - image->buffer->width - 16;
1836 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1838 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1839 rowContainer->obj.area.height
1840 =
MAX(image->buffer->height, textArea->obj.area.height + LEFT_CONTENT_TEXT_PADDING);
1843 rowContainer->obj.alignmentMarginY = 32;
1846 rowContainer->obj.alignmentMarginY = INTER_ROWS_MARGIN;
1848 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1849 container->obj.area.height
1850 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1854 return container->obj.area.height;
1872 uint16_t fullHeight = 0;
1875 if (layout == NULL) {
1883 container->nbChildren = 0;
1887 if (strlen(PIC(info->
url)) > 62) {
1903 fullHeight +=
qrcode->obj.area.height;
1905 container->nbChildren++;
1907 if (info->
text1 != NULL) {
1909 textArea->textColor =
BLACK;
1910 textArea->text = PIC(info->
text1);
1911 textArea->textAlignment =
CENTER;
1912 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1913 textArea->wrapping =
true;
1916 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1918 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1919 textArea->obj.alignmentMarginY = 24;
1921 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1923 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1924 container->nbChildren++;
1926 if (info->
text2 != NULL) {
1929 textArea->text = PIC(info->
text2);
1930 textArea->textAlignment =
CENTER;
1931 textArea->fontId = SMALL_REGULAR_FONT;
1932 textArea->wrapping =
true;
1935 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1937 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1938 if (info->
text1 != NULL) {
1939 textArea->obj.alignmentMarginY = QR_INTER_TEXTS_MARGIN;
1942 textArea->obj.alignmentMarginY = 32;
1946 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1948 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1949 container->nbChildren++;
1952 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1960 container->obj.area.height = fullHeight;
1963 container->obj.alignment =
CENTER;
1967 container->obj.alignTo
1970 container->obj.alignmentMarginY = info->
offsetY;
2016 .horizontalButtons.leftIcon = info->
leftIcon,
2017 .horizontalButtons.leftToken = info->
leftToken,
2018 .horizontalButtons.rightText = info->
rightText,
2019 .horizontalButtons.rightToken = info->
rightToken,
2020 .horizontalButtons.tuneId = info->tuneId};
2042 if (layout == NULL) {
2046 for (i = 0; i < list->
nbPairs; i++) {
2048 uint16_t fullHeight = 0;
2051 if (list->
pairs != NULL) {
2052 pair = &list->
pairs[i];
2069 itemTextArea->text = PIC(pair->
item);
2070 itemTextArea->textAlignment =
MID_LEFT;
2071 itemTextArea->fontId = SMALL_REGULAR_FONT;
2072 itemTextArea->wrapping =
true;
2075 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2078 itemTextArea->obj.alignmentMarginX = 0;
2079 itemTextArea->obj.alignmentMarginY = 0;
2080 itemTextArea->obj.alignTo = NULL;
2081 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2082 container->nbChildren++;
2084 fullHeight += itemTextArea->obj.area.height;
2087 valueTextArea->textColor =
BLACK;
2088 valueTextArea->text = PIC(pair->
value);
2089 valueTextArea->textAlignment =
MID_LEFT;
2091 valueTextArea->fontId = SMALL_BOLD_FONT;
2094 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2102 valueIcon = &MINI_PUSH_ICON;
2109 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2115 valueTextArea->text,
2116 valueTextArea->obj.area.width,
2124 valueTextArea->obj.area.height = nbLines * font->
line_height;
2127 valueTextArea->obj.alignmentMarginY = 4;
2128 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2129 valueTextArea->wrapping = list->
wrapping;
2130 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2131 container->nbChildren++;
2133 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2134 if (valueIcon != NULL) {
2139 image->foregroundColor =
BLACK;
2140 image->buffer = valueIcon;
2142 image->obj.alignmentMarginX = 12;
2143 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2144 image->obj.touchMask = (1 <<
TOUCHED);
2147 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2148 container->nbChildren++;
2152 container->obj.area.height = fullHeight;
2154 container->obj.alignmentMarginX = BORDER_MARGIN;
2156 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2159 container->obj.alignmentMarginY = PRE_TAG_VALUE_MARGIN;
2183 const char *subText,
2192 if (layout == NULL) {
2199 container->nbChildren = (subText != NULL) ? 3 : 2;
2204 container->obj.alignment =
CENTER;
2208 progress->foregroundColor =
BLACK;
2209 progress->withBorder =
true;
2210 progress->state = percentage;
2211 progress->obj.area.width = PROGRESSBAR_WIDTH;
2212 progress->obj.area.height = PROGRESSBAR_HEIGHT;
2216 container->children[0] = (
nbgl_obj_t *) progress;
2219 container->obj.area.height = progress->obj.alignmentMarginY + progress->obj.area.height;
2223 textArea->textColor =
BLACK;
2224 textArea->text = PIC(text);
2225 textArea->textAlignment =
CENTER;
2226 textArea->fontId = LARGE_MEDIUM_FONT;
2227 textArea->wrapping =
true;
2228 textArea->obj.alignmentMarginY = BAR_TEXT_MARGIN;
2229 textArea->obj.alignTo = (
nbgl_obj_t *) progress;
2233 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2237 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
2240 container->children[1] = (
nbgl_obj_t *) textArea;
2242 if (subText != NULL) {
2246 subTextArea->textColor =
BLACK;
2247 subTextArea->text = PIC(subText);
2248 subTextArea->textAlignment =
CENTER;
2249 subTextArea->fontId = SMALL_REGULAR_FONT;
2250 subTextArea->wrapping =
true;
2251 subTextArea->obj.alignmentMarginY = BAR_INTER_TEXTS_MARGIN;
2252 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
2257 subTextArea->obj.area.width,
2258 subTextArea->wrapping);
2262 container->obj.area.height
2263 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
2266 container->children[2] = (
nbgl_obj_t *) subTextArea;
2269 container->obj.area.height = (container->obj.area.height + 7) & 0xFFF8;
2288 line = createHorizontalLine(layoutInt->
layer);
2289 line->obj.alignmentMarginY = -4;
2309 if (layout == NULL) {
2321 footerDesc.
button.tuneId = buttonInfo->tuneId;
2331 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2340 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2345 button->obj.alignmentMarginX = BORDER_MARGIN;
2346 button->obj.alignmentMarginY = 12;
2349 button->innerColor =
BLACK;
2350 button->foregroundColor =
WHITE;
2353 button->innerColor =
WHITE;
2354 button->foregroundColor =
BLACK;
2357 button->borderColor =
WHITE;
2361 button->borderColor =
BLACK;
2367 button->text = PIC(buttonInfo->
text);
2368 button->fontId = SMALL_BOLD_FONT;
2369 button->icon = PIC(buttonInfo->
icon);
2372 + SMALL_BUTTON_HEIGHT
2373 + ((button->icon) ? (button->icon->width + 12) : 0);
2374 button->obj.area.height = SMALL_BUTTON_HEIGHT;
2375 button->radius = SMALL_BUTTON_RADIUS_INDEX;
2376 if (buttonInfo->
onBottom !=
true) {
2377 button->obj.alignmentMarginX
2378 += (SCREEN_WIDTH - 2 * BORDER_MARGIN - button->obj.area.width) / 2;
2383 button->obj.area.height = BUTTON_DIAMETER;
2384 button->radius = BUTTON_RADIUS;
2386 button->obj.alignTo = NULL;
2387 button->obj.touchMask = (1 <<
TOUCHED);
2407 tune_index_e tuneId)
2410 .longPress.text = text,
2411 .longPress.token = token,
2412 .longPress.tuneId = tuneId};
2415 if (layout == NULL) {
2435 tune_index_e tuneId)
2460 const char *leftText,
2462 const char *rightText,
2464 tune_index_e tuneId)
2495 if (layout == NULL) {
2509 switch (headerDesc->
type) {
2539 button->innerColor =
WHITE;
2541 button->borderColor =
WHITE;
2542 button->obj.area.width = BACK_KEY_WIDTH;
2543 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2544 button->text = NULL;
2545 button->icon = PIC(&LEFT_ARROW_ICON);
2558 image->foregroundColor =
BLACK;
2559 image->obj.alignment =
CENTER;
2574 textArea->obj.touchMask = (1 <<
TOUCHED);
2576 textArea->obj.alignment =
CENTER;
2577 textArea->textColor =
BLACK;
2578 textArea->obj.area.width
2582 textArea->obj.area.width -= 16 + image->buffer->width;
2584 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2585 textArea->text = text;
2586 textArea->fontId = SMALL_BOLD_FONT;
2587 textArea->textAlignment =
CENTER;
2588 textArea->wrapping =
true;
2593 textArea->obj.area.width,
2597 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2608 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2609 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2625 button->obj.touchMask = (1 <<
TOUCHED);
2629 button->innerColor =
WHITE;
2630 button->foregroundColor
2633 button->borderColor =
WHITE;
2634 button->obj.area.width = BACK_KEY_WIDTH;
2635 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2636 button->text = NULL;
2644 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2661 button->innerColor =
WHITE;
2662 button->foregroundColor =
BLACK;
2663 button->borderColor =
WHITE;
2664 button->obj.area.width = BACK_KEY_WIDTH;
2665 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2666 button->text = NULL;
2667 button->icon = PIC(&LEFT_ARROW_ICON);
2668 button->obj.touchMask = (1 <<
TOUCHED);
2685 progress->obj.area.width = 224;
2686 progress->obj.alignment =
CENTER;
2694 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2700 textArea->textColor =
BLACK;
2702 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2703 textArea->text = PIC(headerDesc->
title.
text);
2704 textArea->fontId = SMALL_BOLD_FONT;
2705 textArea->textAlignment =
CENTER;
2706 textArea->wrapping =
true;
2710 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2723 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2724 textArea->textColor =
BLACK;
2726 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2728 textArea->fontId = SMALL_BOLD_FONT;
2730 textArea->obj.touchMask = (1 <<
TOUCHED);
2736 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2744 line = createHorizontalLine(layoutInt->
layer);
2751 if (separationLine != NULL) {
2786 if (layout == NULL) {
2800 switch (footerDesc->
type) {
2818 textArea->obj.area.height
2823 textArea->textAlignment =
CENTER;
2824 textArea->obj.touchMask = (1 <<
TOUCHED);
2829 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2842 textArea->textColor =
BLACK;
2844 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2846 textArea->fontId = SMALL_BOLD_FONT;
2847 textArea->textAlignment =
CENTER;
2848 textArea->obj.touchMask = (1 <<
TOUCHED);
2866 textArea->textColor =
BLACK;
2868 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2870 textArea->fontId = SMALL_BOLD_FONT;
2871 textArea->textAlignment =
CENTER;
2872 textArea->obj.touchMask = (1 <<
TOUCHED);
2878 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2883 separationLine->obj.area.width = 1;
2884 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2885 separationLine->direction =
VERTICAL;
2886 separationLine->thickness = 1;
2887 separationLine->obj.alignment =
MID_LEFT;
2888 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2889 separationLine->obj.alignmentMarginX = -1;
2905 textArea->textColor =
BLACK;
2906 textArea->obj.area.width = FOOTER_TEXT_AND_NAV_WIDTH;
2907 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2909 textArea->fontId = SMALL_BOLD_FONT;
2910 textArea->textAlignment =
CENTER;
2911 textArea->obj.touchMask = (1 <<
TOUCHED);
2923 navContainer->nbChildren = 4;
2924 navContainer->children
2927 navContainer->obj.area.width = SCREEN_WIDTH - textArea->obj.area.width;
2928 navContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT;
2941 separationLine->obj.area.width = 1;
2942 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2943 separationLine->direction =
VERTICAL;
2944 separationLine->thickness = 1;
2945 separationLine->obj.alignment =
MID_LEFT;
2946 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2947 separationLine->obj.alignmentMarginX = -1;
2980 footerDesc->
button.tuneId);
2985 button->obj.alignment =
CENTER;
2987 button->innerColor =
BLACK;
2988 button->foregroundColor =
WHITE;
2991 button->innerColor =
WHITE;
2992 button->foregroundColor =
BLACK;
2996 button->borderColor =
WHITE;
3000 button->borderColor =
BLACK;
3007 button->fontId = SMALL_BOLD_FONT;
3009 button->radius = BUTTON_RADIUS;
3010 button->obj.area.height = BUTTON_DIAMETER;
3013 button->obj.area.width = BUTTON_DIAMETER;
3018 button->obj.touchMask = (1 <<
TOUCHED);
3046 button->innerColor =
WHITE;
3048 button->obj.alignmentMarginY
3049 = BOTTOM_BORDER_MARGIN;
3053 button->obj.alignmentMarginY = 4;
3054 button->borderColor =
WHITE;
3056 button->foregroundColor =
BLACK;
3058 button->obj.area.height = BUTTON_DIAMETER;
3059 button->radius = BUTTON_RADIUS;
3061 button->fontId = SMALL_BOLD_FONT;
3062 button->obj.touchMask = (1 <<
TOUCHED);
3072 line = createHorizontalLine(layoutInt->
layer);
3074 line->obj.alignmentMarginY = 4;
3093 button->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN;
3095 button->innerColor =
WHITE;
3097 button->foregroundColor =
BLACK;
3100 button->innerColor =
BLACK;
3101 button->borderColor =
BLACK;
3102 button->foregroundColor =
WHITE;
3105 button->obj.area.height = BUTTON_DIAMETER;
3106 button->radius = BUTTON_RADIUS;
3111 button->fontId = SMALL_BOLD_FONT;
3112 button->obj.touchMask = (1 <<
TOUCHED);
3120 layoutInt->
footerContainer->obj.area.height = ACTION_AND_FOOTER_FOOTER_HEIGHT;
3123 layoutInt->
footerContainer->obj.area.height = ROUNDED_AND_FOOTER_FOOTER_HEIGHT;
3134 addSwipeInternal(layoutInt,
3145 line = createHorizontalLine(layoutInt->
layer);
3151 if (separationLine != NULL) {
3184 if (layout == NULL) {
3201 switch (upFooterDesc->
type) {
3220 button->obj.alignmentMarginX = BORDER_MARGIN;
3222 button->innerColor =
BLACK;
3223 button->foregroundColor =
WHITE;
3224 button->borderColor =
BLACK;
3225 button->obj.area.width = BUTTON_DIAMETER;
3226 button->obj.area.height = BUTTON_DIAMETER;
3227 button->radius = BUTTON_RADIUS;
3228 button->icon = PIC(&VALIDATE_ICON);
3232 textArea->textColor =
BLACK;
3234 textArea->textAlignment =
MID_LEFT;
3235 textArea->fontId = LARGE_MEDIUM_FONT;
3236 textArea->wrapping =
true;
3237 textArea->obj.area.width = SCREEN_WIDTH - 3 * BORDER_MARGIN - button->obj.area.width;
3239 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3241 textArea->obj.alignment =
MID_LEFT;
3242 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3245 line = createHorizontalLine(layoutInt->
layer);
3251 progressBar->obj.area.width = SCREEN_WIDTH;
3252 progressBar->obj.area.height = 8;
3254 progressBar->obj.alignmentMarginY = 4;
3255 progressBar->resetIfOverriden =
true;
3264 upFooterDesc->
button.tuneId);
3271 button->obj.alignment =
CENTER;
3274 button->innerColor =
BLACK;
3275 button->foregroundColor =
WHITE;
3278 button->innerColor =
WHITE;
3279 button->foregroundColor =
BLACK;
3282 button->borderColor =
WHITE;
3286 button->borderColor =
BLACK;
3292 button->text = PIC(upFooterDesc->
button.
text);
3293 button->fontId = SMALL_BOLD_FONT;
3294 button->icon = PIC(upFooterDesc->
button.
icon);
3296 button->obj.area.height = BUTTON_DIAMETER;
3297 button->radius = BUTTON_RADIUS;
3299 button->obj.alignTo = NULL;
3300 button->obj.touchMask = (1 <<
TOUCHED);
3327 button->obj.alignmentMarginX = BORDER_MARGIN;
3329 button->innerColor =
WHITE;
3330 button->foregroundColor =
BLACK;
3331 button->obj.area.width = BUTTON_DIAMETER;
3332 button->obj.area.height = BUTTON_DIAMETER;
3333 button->radius = BUTTON_RADIUS;
3335 button->fontId = SMALL_BOLD_FONT;
3336 button->obj.touchMask = (1 <<
TOUCHED);
3352 button->obj.alignmentMarginX = BORDER_MARGIN;
3353 button->innerColor =
BLACK;
3354 button->borderColor =
BLACK;
3355 button->foregroundColor =
WHITE;
3357 button->obj.area.height = BUTTON_DIAMETER;
3358 button->radius = BUTTON_RADIUS;
3360 button->fontId = SMALL_BOLD_FONT;
3361 button->obj.touchMask = (1 <<
TOUCHED);
3374 upFooterDesc->
tipBox.tuneId);
3383 textArea->textColor =
BLACK;
3384 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3385 textArea->textAlignment =
MID_LEFT;
3386 textArea->fontId = SMALL_REGULAR_FONT;
3387 textArea->wrapping =
true;
3390 textArea->obj.area.width
3395 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3396 textArea->obj.alignment =
MID_LEFT;
3397 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3401 line = createHorizontalLine(layoutInt->
layer);
3408 image->obj.alignmentMarginX = BORDER_MARGIN;
3410 image->foregroundColor =
BLACK;
3411 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3424 upFooterDesc->
text.token,
3425 upFooterDesc->
text.tuneId);
3436 textArea->text = PIC(upFooterDesc->
text.text);
3437 textArea->textAlignment =
CENTER;
3438 textArea->fontId = SMALL_REGULAR_FONT;
3439 textArea->wrapping =
true;
3442 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3443 textArea->obj.alignment =
CENTER;
3479 tune_index_e tuneId)
3482 .separationLine =
false,
3483 .progressAndBack.activePage = activePage,
3484 .progressAndBack.nbPages = nbPages,
3485 .progressAndBack.token = backToken,
3486 .progressAndBack.tuneId = tuneId,
3487 .progressAndBack.withBack = withBack,
3488 .progressAndBack.actionIcon = NULL,
3507 const char *subText,
3508 uint8_t initPosition)
3516 if (layout == NULL) {
3522 container->nbChildren = 3;
3527 container->obj.alignment =
CENTER;
3531 spinner->position = initPosition;
3534 container->children[0] = (
nbgl_obj_t *) spinner;
3537 container->obj.area.height += SPINNER_HEIGHT;
3541 textArea->textColor =
BLACK;
3542 textArea->text = PIC(text);
3543 textArea->textAlignment =
CENTER;
3544 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3545 textArea->wrapping =
true;
3546 textArea->obj.alignmentMarginY = SPINNER_TEXT_MARGIN;
3547 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3551 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3555 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3558 container->children[1] = (
nbgl_obj_t *) textArea;
3560 if (subText != NULL) {
3564 subTextArea->textColor =
BLACK;
3565 subTextArea->text = PIC(subText);
3566 subTextArea->textAlignment =
CENTER;
3567 subTextArea->fontId = SMALL_REGULAR_FONT;
3568 subTextArea->wrapping =
true;
3569 subTextArea->obj.alignmentMarginY = SPINNER_INTER_TEXTS_MARGIN;
3570 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3575 subTextArea->obj.area.width,
3576 subTextArea->wrapping);
3580 container->obj.area.height
3581 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3584 container->children[2] = (
nbgl_obj_t *) subTextArea;
3594 tickerCfg.tickerCallback = &spinnerTickerCallback;
3614 const char *subText,
3624 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3629 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3634 if (spinner->obj.type !=
SPINNER) {
3638 if (spinner->position != position) {
3639 spinner->position = position;
3649 const char *newText = PIC(text);
3650 size_t newTextLen = strlen(newText);
3652 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3653 textArea->text = newText;
3658 if (subText != NULL) {
3661 if (container->nbChildren != 3) {
3665 if (subTextArea->obj.type !=
TEXT_AREA) {
3668 const char *newSubText = PIC(subText);
3669 size_t newSubTextLen = strlen(newSubText);
3671 if ((newSubTextLen != strlen(subTextArea->text))
3672 || memcmp(subTextArea->text, newSubText, newSubTextLen)) {
3673 subTextArea->text = newSubText;
3692 if (layout == NULL) {
3696 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3723 if (layout == NULL) {
3727 if (layout->
modal) {
Random Number Generation.
@ ANIM_ILLUSTRATION
animation
@ ICON_ILLUSTRATION
simple icon
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
#define LOG_FATAL(__logger,...)
Middle Level API of the new BOLOS Graphical Library.
#define QR_V10_NB_PIX_SIZE
#define QR_V4_NB_PIX_SIZE
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
return the height in pixels of the font with the given font ID
uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text)
return the max width in pixels of the given text (can be multiline)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
return the height of the given multiline text, with the given font.
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
compute the number of lines of the given text fitting in the given maxWidth
const nbgl_font_t * nbgl_getFont(nbgl_font_id_e fontId)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
return the height in pixels of the line of font with the given font ID
Font screen low-Level driver API, to draw elementary forms.
int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list)
Creates a list of [tag,value] pairs.
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
#define HOLD_TO_APPROVE_STEP_PERCENT
int nbgl_layoutAddUpFooter(nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *upFooterDesc)
Creates a touchable area on top of the footer of the screen, containing various controls,...
int nbgl_layoutDraw(nbgl_layout_t *layoutParam)
Applies given layout. The screen will be redrawn.
#define NB_MAX_CONTAINER_CHILDREN
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, const char *title, const char *description, const char *info)
Creates in the main container three text areas:
int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText)
Creates an area with given text (in bold) and sub text (in regular)
int nbgl_layoutAddProgressIndicator(nbgl_layout_t *layout, uint8_t activePage, uint8_t nbPages, bool withBack, uint8_t backToken, tune_index_e tuneId)
Creates a kind of navigation bar with an optional <- arrow on the left. This widget is placed on top ...
int nbgl_layoutAddNavigationBar(nbgl_layout_t *layout, const nbgl_layoutNavigationBar_t *info)
Creates a navigation bar on bottom of main container.
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout)
adds a separation line on bottom of the last added item
int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info)
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under...
int nbgl_layoutAddRadioChoice(nbgl_layout_t *layout, const nbgl_layoutRadioChoice_t *choices)
Creates a list of radio buttons (on the right)
int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
Creates an area on the center of the main panel, with a possible icon/image, a possible text in black...
int nbgl_layoutAddSplitFooter(nbgl_layout_t *layout, const char *leftText, uint8_t leftToken, const char *rightText, uint8_t rightToken, tune_index_e tuneId)
Creates 2 touchable texts at the footer of the screen, separated with a thin line from the rest of th...
int nbgl_layoutAddSubHeaderText(nbgl_layout_t *layout, const char *text)
Creates an area with given text in small regular font, under the header.
int nbgl_layoutAddTextWithAlias(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t token, uint8_t index)
Creates an area with given text (in bold) and sub text (in regular), with a icon on right of text to...
int nbgl_layoutAddTouchableBar(nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout)
Creates a touchable bar in main panel.
#define SPINNER_REFRESH_PERIOD
int nbgl_layoutAddTopRightButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId)
Creates a Top-right button in the top right corner of the top panel.
int nbgl_layoutAddSwipe(nbgl_layout_t *layout, uint16_t swipesMask, const char *text, uint8_t token, tune_index_e tuneId)
Creates a swipe interaction on the main container.
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates a switch with the given text and its state.
int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon a...
int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
Creates a rounded button in the main container.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
Creates an area with a title, and rows of icon + text, left aligned.
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutRelease(nbgl_layout_t *layoutParam)
Release the layout obtained with nbgl_layoutGet()
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
int nbgl_layoutUpdateSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t position)
Update an existing spinner (must be the only object of the layout)
int nbgl_layoutAddLongPressButton(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a long press button in the main container.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
int nbgl_layoutAddProgressBar(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t percentage)
Creates an area in main panel to display a progress bar, with a title text and a subtext if needed.
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
int nbgl_layoutAddBottomButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, bool separationLine, tune_index_e tuneId)
Creates a centered button at bottom of main container.
#define HOLD_TO_APPROVE_STEP_DURATION_MS
int nbgl_layoutAddFooter(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the...
int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool grayedOut)
Creates an area with given text in 32px font (in Black or Light Gray)
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
@ NO_BORDER
simple clickable text, in black
@ BLACK_BACKGROUND
rounded bordered button, with text/icon in white, on black background
@ UP_FOOTER_TEXT
grayed-out text, for example "Tap to continue"
@ UP_FOOTER_BUTTON
simple button
@ UP_FOOTER_LONG_PRESS
long-press button
@ UP_FOOTER_TIP_BOX
Tip-box.
@ UP_FOOTER_HORIZONTAL_BUTTONS
2 buttons, on the same line
void * nbgl_layout_t
type shared externally
@ HEADER_TITLE
simple centered text
@ HEADER_BACK_AND_PROGRESS
optional back key and progress indicator (only on Stax)
@ HEADER_EMPTY
empty space, to have a better vertical centering of centered info
@ HEADER_EXTENDED_BACK
back key, centered text and touchable key on the right
@ HEADER_BACK_AND_TEXT
back key and optional text
@ HEADER_RIGHT_TEXT
touchable text on the right, with a vertical separation line
@ HEADER_BACK_ICON_AND_TEXT
back key and optional icon and text
#define NBGL_INVALID_TOKEN
#define SPINNER_FIXED
position to use for a "fixed" spinner
@ SOFT_ACTION_AND_FOOTER_STYLE
A white button on top of a footer, with a separation line.
@ BOTH_ROUNDED_STYLE
A black button on top of a white button.
@ ROUNDED_AND_FOOTER_STYLE
A black background button on top of a footer.
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
@ FOOTER_SIMPLE_TEXT
simple touchable text in bold
@ FOOTER_NAV
navigation bar
@ FOOTER_SIMPLE_BUTTON
simple black or white button (see nbgl_layoutButtonStyle_t)
@ FOOTER_DOUBLE_TEXT
2 touchable texts in bold, separated by a vertical line (only on Stax)
@ FOOTER_EMPTY
empty space, to have a better vertical centering of centered info
@ FOOTER_CHOICE_BUTTONS
double buttons (see nbgl_layoutChoiceButtonsStyle_t)
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
void layoutNavigationPopulate(nbgl_container_t *navContainer, const nbgl_layoutNavigationBar_t *navConfig, uint8_t layer)
This function creates a full navigation bar "object", with buttons and returns it as a container.
#define LAYOUT_OBJ_POOL_LEN
Max number of complex objects with callback retrievable from pool.
bool layoutNavigationCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType, uint8_t nbPages, uint8_t *activePage)
function to be called when any of the controls in navigation bar is touched
API to draw all basic graphic objects.
struct PACKED__ nbgl_line_s nbgl_line_t
struct to represent a vertical or horizontal line
struct PACKED__ nbgl_navigation_bar_s nbgl_page_indicator_t
struct to represent a navigation bar (PAGE_INDICATOR type) There can be up to 5 page indicators,...
struct PACKED__ nbgl_radio_s nbgl_radio_t
struct to represent a radio button (RADIO_BUTTON type)
#define NB_SPINNER_POSITIONS
void(* nbgl_touchCallback_t)(void *obj, nbgl_touchType_t eventType)
prototype of function to be called when a touch event is received by an object
struct PACKED__ nbgl_text_area_s nbgl_text_area_t
struct to represent a text area (TEXT_AREA type)
void nbgl_objDraw(nbgl_obj_t *obj)
This function draws or redraws the given object and its children (recursive version)
struct PACKED__ nbgl_progress_bar_s nbgl_progress_bar_t
struct to represent a progress bar (PROGRESS_BAR type)
nbgl_obj_t ** nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer)
Gets a new container from the pool, with the given number of obj pointers.
nbgl_obj_t * nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer)
Gets a new graphic object from the pool, with the given type. The type field of the object is set.
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
This functions refreshes the actual screen on display with what has changed since the last refresh,...
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
struct PACKED__ nbgl_button_s nbgl_button_t
struct to represent a button (BUTTON type) that can contain a text and/or an icon
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
struct PACKED__ nbgl_switch_s nbgl_switch_t
struct to represent a switch (size is fixed) (SWITCH type)
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
struct PACKED__ nbgl_spinner_s nbgl_spinner_t
struct to represent a "spinner", represented by the Ledger corners, in gray, with one of the corners ...
struct PACKED__ nbgl_qrcode_s nbgl_qrcode_t
struct to represent a QR code (QR_CODE type), whose size is fixed
int nbgl_screenSet(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_touchCallback_t touchCallback)
Configures the lowest layer screen. To be used by applications A nbgl_screenRedraw() can be called af...
int nbgl_screenPush(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_touchCallback_t touchCallback)
Pushes a screen on top of the stack, with the given number of elements, if possible....
void nbgl_wait_pipeline(void)
int nbgl_screenUpdateTicker(uint8_t screenIndex, const nbgl_screenTickerConfiguration_t *ticker)
Updates the ticker configuration of the screen at the given screenIndex, always set at WHITE in.
int nbgl_screenPop(uint8_t screenIndex)
Release the screen at the given index in screen array (index returned by nbgl_screenPush())....
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
This function redraws the whole screen on top of stack and its children.
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj)
nbgl_state_t
to represent a boolean state.
@ POST_REFRESH_FORCE_POWER_OFF
Force screen power off after refresh.
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
@ POST_REFRESH_FORCE_POWER_ON_WITH_PIPELINE
Force screen power on and enable pipeline.
nbgl_touchType_t
The different types of Touchscreen events.
@ TOUCHING
corresponding to an object that is currently touched
@ QRCODE_V10
QRCode V10, can encode text len up to 1500 chars, display size = 228*228.
@ QRCODE_V4_SMALL
QRCode V4, can encode text len up to 1500 chars, display size = 132*132.
@ QRCODE_V4
QRCode V4, can encode text len up to 62 chars, display size = 264*264.
@ VERTICAL
from top to bottom
@ HORIZONTAL
from left to right
@ LOOP_PARSING
0, 1, 2, 0, 1, 2, ...
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
@ NO_ALIGNMENT
used when parent container layout is used
@ RIGHT_TOP
on outside right
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
@ SWITCH
Switch to turn on/off something.
@ RADIO_BUTTON
Indicator to inform whether something is on or off.
@ BUTTON
Rounded rectangle button with icon and/or text.
@ PROGRESS_BAR
horizontal bar to indicate progression of something (between 0% and 100%)
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
@ LINE
Vertical or Horizontal line.
@ CONTAINER
Empty container.
@ TEXT_AREA
Area to contain text line(s)
@ NBGL_BPP_1
1 bit per pixel
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
const nbgl_icon_details_t * iconRight
const nbgl_icon_details_t * iconLeft
uint16_t delayMs
delay between 2 drawings
uint8_t nbIcons
number of icons in icons array
const nbgl_icon_details_t ** icons
array of nbIcons pointers on icons
nbgl_parsingType_t parsing
This structure contains info to build a centered (vertically and horizontally) area,...
uint16_t iconHug
vertical margin to apply on top and bottom of the icon
const nbgl_icon_details_t * icon
the icon (can be null)
const char * title
title in black large (can be null)
const char * description
description in black small regular case (can be null)
const char * subText
sub-text in dark gray regular small case
uint16_t animOffsetY
vertical offset of animation in icon if integrated (but usually 0)
bool padding
if true, apply a padding of 40px at the bottom
const nbgl_animation_t * animation
the animation (can be null), used if illustrType is ANIM_ILLUSTRATION
const char * smallTitle
sub-title in black small bold case (can be null)
uint16_t animOffsetX
horizontal offset of animation in icon if integrated (but usually 0)
nbgl_contentIllustrationType_t illustrType
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * text1
first text (can be null)
bool onTop
if set to true, align only horizontally
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
int16_t offsetY
vertical shift to apply to this info (if >0, shift to bottom)
const char * text3
third text (can be null)
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t token
the token that will be used as argument of the callback
bool localized
if set to true, use nameIds and not names
uint8_t initChoice
index of the current choice
const char *const * names
array of strings giving the choices (nbChoices)
uint8_t nbChoices
number of choices
This structure contains info to build a switch (on the right) with a description (on the left),...
const char * text
main text for the switch
uint8_t token
the token that will be used as argument of the callback (unused on Nano)
nbgl_state_t initState
initial state of the switch
const char * subText
description under main text (NULL terminated, single line, may be null)
This structure contains a list of [tag,value] pairs.
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
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
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....)
uint8_t activePage
index of active page for navigation bar
uint8_t layer
layer in screen stack
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
uint8_t nbChildren
number of children in above array
nbgl_layoutHeaderType_t headerType
type of header
nbgl_container_t * upFooterContainer
uint8_t incrementAnim
if true, means that animation index is currently incrementing
uint8_t nbPages
number of pages for navigation bar
nbgl_layoutUpFooterType_t upFooterType
type of up-footer
uint8_t modal
if true, means the screen is a modal
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