7 #include "app_config.h"
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
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
52 #define RADIO_CHOICE_HEIGHT 92
53 #define FOOTER_HEIGHT 80
54 #define BAR_INTERVALE 16
55 #define BACK_KEY_WIDTH 104
56 #define FOOTER_BUTTON_HEIGHT 136
57 #define UP_FOOTER_BUTTON_HEIGHT 136
58 #define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
59 #define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
63 #define SPINNER_REFRESH_PERIOD 400
66 #define FIRST_BUTTON_INDEX 0
103 #ifdef HAVE_PIEZO_SOUND
119 static uint8_t nbTouchableControls = 0;
126 #ifdef HAVE_FAST_HOLD_TO_APPROVE
128 #define HOLD_TO_APPROVE_STEP_PERCENT (7)
132 #define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
134 #define HOLD_TO_APPROVE_STEP_PERCENT (25)
135 #define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
138 static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
140 #ifdef HAVE_FAST_HOLD_TO_APPROVE
149 static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
159 if (gLayout[i].nbChildren > 0) {
164 if (obj == gLayout[i].callbackObjPool[j].obj) {
166 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
167 "nbUsedCallbackObjs = %d\n",
170 gLayout[i].nbUsedCallbackObjs);
171 *layout = &gLayout[i];
182 static void radioTouchCallback(
nbgl_obj_t *obj,
185 static void longTouchCallback(
nbgl_obj_t *obj,
195 bool needRefresh =
false;
201 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
203 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
206 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
224 layoutObj->
index = eventType;
273 layoutObj->
index = lSwitch->state;
279 radioTouchCallback(obj, eventType, layout);
286 longTouchCallback(obj, eventType, layout, layoutObj);
291 #ifdef HAVE_PIEZO_SOUND
293 io_seproxyhal_play_tune(layoutObj->
tuneId);
304 static void longTouchCallback(
nbgl_obj_t *obj,
314 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
317 gLayout[1].nbChildren);
324 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
328 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
331 if (new_state >= 100) {
336 if (new_state != progressBar->state) {
337 progressBar->partialRedraw =
true;
338 progressBar->state = new_state;
347 if (trigger_callback) {
358 progressBar->partialRedraw =
true;
359 progressBar->state = 0;
366 static void radioTouchCallback(
nbgl_obj_t *obj,
378 while (i < layout->nbUsedCallbackObjs) {
388 foundRadioIndex = radioIndex;
390 textArea->textColor =
BLACK;
391 textArea->fontId = SMALL_BOLD_FONT;
413 textArea->fontId = SMALL_REGULAR_FONT;
421 if (foundRadio != 0xFF) {
423 #ifdef HAVE_PIEZO_SOUND
435 static void spinnerTickerCallback(
void)
442 if (gLayout[1].nbChildren > 0) {
443 layout = &gLayout[1];
446 layout = &gLayout[0];
450 while (i < layout->container->nbChildren) {
453 if (container->children[0]->type ==
SPINNER) {
456 spinner->position &= 3;
467 static void animTickerCallback(
void)
474 if (gLayout[1].nbChildren > 0) {
475 layout = &gLayout[1];
478 layout = &gLayout[0];
486 while (i < layout->container->nbChildren) {
489 if (container->children[1]->type ==
IMAGE) {
535 line->obj.area.height = 4;
547 line->obj.area.width = 1;
567 layoutObj->
obj = obj;
568 layoutObj->
token = token;
569 layoutObj->
tuneId = tuneId;
618 layoutInt->
container->obj.touchMask = swipesMask;
645 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
652 container->nbChildren = 0;
659 container->obj.alignTo = NULL;
664 container->obj.touchMask = (1 <<
TOUCHED);
665 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
666 nbTouchableControls++;
671 textArea->textColor = color;
672 textArea->text = PIC(itemDesc->
text);
673 textArea->onDrawCallback = NULL;
674 textArea->fontId = SMALL_BOLD_FONT;
675 textArea->wrapping =
true;
676 textArea->obj.area.width = container->obj.area.width;
679 textArea->obj.area.width
684 textArea->obj.area.width
691 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
692 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
696 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
697 container->nbChildren++;
702 imageLeft->foregroundColor = color;
703 imageLeft->buffer = PIC(itemDesc->
iconLeft);
705 imageLeft->obj.alignment =
MID_LEFT;
706 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
708 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
709 container->nbChildren++;
711 textArea->obj.alignmentMarginX = imageLeft->buffer->width +
BAR_INTERVALE;
713 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
718 imageRight->foregroundColor = color;
719 imageRight->buffer = PIC(itemDesc->
iconRight);
723 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
725 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
726 container->nbChildren++;
728 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
732 switchObj->onColor =
BLACK;
734 switchObj->state = itemDesc->
state;
737 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
739 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
740 container->nbChildren++;
743 if (itemDesc->
subText != NULL) {
747 subTextArea->textColor = color;
748 subTextArea->text = PIC(itemDesc->
subText);
749 subTextArea->textAlignment =
MID_LEFT;
750 subTextArea->fontId = SMALL_REGULAR_FONT;
752 subTextArea->wrapping =
true;
753 subTextArea->obj.alignment =
MID_LEFT;
754 subTextArea->obj.area.width = container->obj.area.width;
757 subTextArea->obj.area.width,
758 subTextArea->wrapping);
759 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
760 container->nbChildren++;
761 container->obj.area.height += subTextArea->obj.area.height + 12;
764 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
765 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
793 container->nbChildren = 0;
798 if (info->
icon != NULL) {
800 image->foregroundColor =
BLACK;
801 image->buffer = PIC(info->
icon);
803 image->obj.alignmentMarginY = info->
iconHug;
805 fullHeight += image->buffer->height + info->
iconHug;
806 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
807 container->nbChildren++;
812 anim->foregroundColor =
BLACK;
818 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
819 container->nbChildren++;
830 tickerCfg.tickerCallback = &animTickerCallback;
835 if (info->
title != NULL) {
837 textArea->textColor =
BLACK;
838 textArea->text = PIC(info->
title);
839 textArea->textAlignment =
CENTER;
840 textArea->fontId = LARGE_MEDIUM_FONT;
841 textArea->wrapping =
true;
844 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
847 if (container->nbChildren > 0) {
856 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
858 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
859 container->nbChildren++;
864 textArea->textColor =
BLACK;
866 textArea->textAlignment =
CENTER;
867 textArea->fontId = SMALL_BOLD_FONT;
868 textArea->wrapping =
true;
871 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
874 if (container->nbChildren > 0) {
876 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
878 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
882 textArea->obj.alignmentMarginY = 16;
889 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
891 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
892 container->nbChildren++;
897 textArea->textColor =
BLACK;
899 textArea->textAlignment =
CENTER;
900 textArea->fontId = SMALL_REGULAR_FONT;
901 textArea->wrapping =
true;
904 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
907 if (container->nbChildren > 0) {
909 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
910 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
912 textArea->obj.alignmentMarginY = 16;
922 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
924 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
925 container->nbChildren++;
931 textArea->text = PIC(info->
subText);
932 textArea->textAlignment =
CENTER;
933 textArea->fontId = SMALL_REGULAR_FONT;
934 textArea->wrapping =
true;
937 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
939 textArea->obj.area.height += 2 * 8;
941 if (container->nbChildren > 0) {
943 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
944 textArea->obj.alignmentMarginY = 16;
945 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
946 textArea->obj.alignmentMarginY += info->
iconHug;
953 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
955 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
956 container->nbChildren++;
959 container->obj.alignment =
CENTER;
961 container->obj.area.height = fullHeight;
963 container->obj.area.height += 40;
985 if (layout == NULL) {
997 textArea->textColor =
BLACK;
998 textArea->text = PIC(text);
1000 textArea->fontId = SMALL_BOLD_FONT;
1002 textArea->wrapping =
true;
1005 textArea->obj.area.width = container->obj.area.width;
1006 if (withAlias ==
true) {
1010 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1011 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1012 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1013 container->nbChildren++;
1014 if (withAlias ==
true) {
1020 image->foregroundColor =
BLACK;
1023 image->obj.alignmentMarginX = 12;
1024 image->obj.alignTo = (
nbgl_obj_t *) textArea;
1025 container->obj.touchMask = (1 <<
TOUCHED);
1028 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
1029 container->nbChildren++;
1032 if (subText != NULL) {
1034 subTextArea->textColor =
BLACK;
1035 subTextArea->text = PIC(subText);
1036 subTextArea->fontId = SMALL_REGULAR_FONT;
1038 subTextArea->wrapping =
true;
1039 subTextArea->obj.area.width = container->obj.area.width;
1042 subTextArea->obj.area.width,
1043 subTextArea->wrapping);
1044 subTextArea->textAlignment =
MID_LEFT;
1055 subTextArea->obj.alignmentMarginY = 26;
1059 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
1060 container->nbChildren++;
1061 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
1066 container->obj.area.height = fullHeight;
1073 return container->obj.area.height;
1091 if (description->
modal) {
1092 if (gLayout[1].nbChildren == 0) {
1093 layout = &gLayout[1];
1095 else if (gLayout[2].nbChildren == 0) {
1096 layout = &gLayout[2];
1102 layout = &gLayout[0];
1104 if (layout == NULL) {
1112 nbTouchableControls = 0;
1117 if (description->
modal) {
1149 obj->
tuneId = description->tapTuneId;
1157 footerDesc.
text.tuneId = description->tapTuneId;
1179 tune_index_e tuneId)
1184 if (layout == NULL) {
1191 layoutInt->
tapText->text = PIC(text);
1193 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1200 layoutInt->
tapText->obj.alignmentMarginY = 30;
1219 tune_index_e tuneId)
1226 if (layout == NULL) {
1240 button->foregroundColor =
BLACK;
1241 button->innerColor =
WHITE;
1243 button->obj.touchMask = (1 <<
TOUCHED);
1245 button->icon = PIC(icon);
1290 bool separationLine,
1291 tune_index_e tuneId)
1301 footerDesc.
button.tuneId = tuneId;
1320 if (layout == NULL) {
1324 if (barLayout->
text == NULL) {
1333 itemDesc.tuneId = barLayout->tuneId;
1337 container = addListItem(layoutInt, &itemDesc);
1339 if (container == NULL) {
1342 return container->obj.area.height;
1359 if (layout == NULL) {
1363 if (switchLayout->
text == NULL) {
1369 itemDesc.
text = switchLayout->
text;
1372 itemDesc.tuneId = switchLayout->tuneId;
1374 itemDesc.
large =
false;
1376 container = addListItem(layoutInt, &itemDesc);
1378 if (container == NULL) {
1381 return container->obj.area.height;
1395 return addText(layout, text, subText, 0, 0,
false);
1411 const char *subText,
1416 return addText(layout, text, subText, token, index,
true);
1432 if (layout == NULL) {
1437 textArea->textColor =
BLACK;
1438 textArea->text = PIC(text);
1439 textArea->textAlignment =
MID_LEFT;
1440 textArea->fontId = SMALL_REGULAR_FONT;
1442 textArea->wrapping =
true;
1447 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1449 textArea->obj.area.height += 2 * 24;
1451 textArea->obj.area.height += 2 * 28;
1457 return textArea->obj.area.height;
1474 if (layout == NULL) {
1480 textArea->text = PIC(text);
1481 textArea->textAlignment =
MID_LEFT;
1482 textArea->fontId = LARGE_MEDIUM_FONT;
1484 textArea->wrapping =
true;
1486 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1490 if (layoutInt->
container->nbChildren == 0) {
1498 textArea->obj.alignmentMarginY = 40;
1500 textArea->obj.alignmentMarginY = 24;
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;
1546 textArea->obj.alignmentMarginY = 24;
1548 textArea->obj.alignmentMarginY = 16;
1552 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1558 textArea->textColor =
BLACK;
1559 textArea->text = PIC(description);
1560 textArea->fontId = SMALL_REGULAR_FONT;
1562 textArea->wrapping =
true;
1565 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1566 textArea->textAlignment =
MID_LEFT;
1570 textArea->obj.alignmentMarginY = 16;
1572 textArea->obj.alignmentMarginY = 24;
1580 textArea->text = PIC(info);
1581 textArea->fontId = SMALL_REGULAR_FONT;
1583 textArea->wrapping =
true;
1586 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1587 textArea->textAlignment =
MID_LEFT;
1590 textArea->obj.alignmentMarginY = 40;
1594 return layoutInt->
container->obj.area.height;
1611 if (layout == NULL) {
1614 for (i = 0; i < choices->
nbChoices; i++) {
1625 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1631 container->nbChildren = 2;
1637 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1640 button->activeColor =
BLACK;
1642 button->obj.alignTo = (
nbgl_obj_t *) container;
1645 container->children[1] = (
nbgl_obj_t *) button;
1649 #ifdef HAVE_LANGUAGE_PACK
1654 textArea->text = PIC(choices->
names[i]);
1656 textArea->textAlignment =
MID_LEFT;
1657 textArea->obj.area.width = container->obj.area.width -
RADIO_WIDTH;
1659 textArea->obj.alignment =
MID_LEFT;
1660 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1661 container->children[0] = (
nbgl_obj_t *) textArea;
1664 container->obj.touchMask = (1 <<
TOUCHED);
1665 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1666 nbTouchableControls++;
1671 textArea->textColor =
BLACK;
1672 textArea->fontId = SMALL_BOLD_FONT;
1677 textArea->fontId = SMALL_REGULAR_FONT;
1681 line = createHorizontalLine(layoutInt->
layer);
1682 line->obj.alignmentMarginY = -4;
1708 if (layout == NULL) {
1715 if (info->
text1 != NULL) {
1723 if (info->
text2 != NULL) {
1731 if (info->
text3 != NULL) {
1739 container = addContentCenter(layoutInt, ¢eredInfo);
1747 container->obj.alignmentMarginY = info->
offsetY;
1750 return container->obj.area.height;
1767 if (layout == NULL) {
1771 container = addContentCenter(layoutInt, info);
1773 return container->obj.area.height;
1791 if (layout == NULL) {
1797 container->nbChildren = info->
nbRows + 1;
1805 textArea->textColor =
BLACK;
1806 textArea->text = PIC(info->
title);
1807 textArea->textAlignment =
MID_LEFT;
1808 textArea->fontId = LARGE_MEDIUM_FONT;
1809 textArea->wrapping =
true;
1812 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1814 container->obj.area.height += textArea->obj.area.height;
1816 container->children[0] = (
nbgl_obj_t *) textArea;
1818 for (row = 0; row < info->
nbRows; row++) {
1824 rowContainer->nbChildren = 2;
1829 image->foregroundColor =
BLACK;
1830 image->buffer = info->
rowIcons[row];
1831 rowContainer->children[0] = (
nbgl_obj_t *) image;
1834 textArea->textColor =
BLACK;
1835 textArea->text = info->
rowTexts[row];
1836 textArea->textAlignment =
MID_LEFT;
1837 textArea->fontId = SMALL_REGULAR_FONT;
1838 textArea->wrapping =
true;
1839 textArea->obj.alignmentMarginX = 16;
1840 textArea->obj.area.width
1841 =
AVAILABLE_WIDTH - image->buffer->width - textArea->obj.alignmentMarginX;
1843 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1845 textArea->obj.alignTo = (
nbgl_obj_t *) image;
1846 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1847 rowContainer->obj.area.height =
MAX(image->buffer->height, textArea->obj.area.height);
1850 rowContainer->obj.alignmentMarginY = 32;
1854 rowContainer->obj.alignmentMarginY = 16;
1856 rowContainer->obj.alignmentMarginY = 26;
1859 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1860 container->obj.area.height
1861 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1865 return container->obj.area.height;
1886 if (layout == NULL) {
1894 container->nbChildren = 0;
1898 if (strlen(PIC(info->
url)) > 62) {
1914 fullHeight +=
qrcode->obj.area.height;
1916 container->nbChildren++;
1918 if (info->
text1 != NULL) {
1920 textArea->textColor =
BLACK;
1921 textArea->text = PIC(info->
text1);
1922 textArea->textAlignment =
CENTER;
1923 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1924 textArea->wrapping =
true;
1927 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1929 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1930 textArea->obj.alignmentMarginY = 24;
1932 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1934 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1935 container->nbChildren++;
1937 if (info->
text2 != NULL) {
1940 textArea->text = PIC(info->
text2);
1941 textArea->textAlignment =
CENTER;
1942 textArea->fontId = SMALL_REGULAR_FONT;
1943 textArea->wrapping =
true;
1946 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1948 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1949 if (info->
text1 != NULL) {
1951 textArea->obj.alignmentMarginY = 40;
1953 textArea->obj.alignmentMarginY = 28;
1957 textArea->obj.alignmentMarginY = 32;
1961 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1963 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1964 container->nbChildren++;
1967 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1975 container->obj.area.height = fullHeight;
1978 container->obj.alignment =
CENTER;
1982 container->obj.alignTo
1985 container->obj.alignmentMarginY = info->
offsetY;
2031 .horizontalButtons.leftIcon = info->
leftIcon,
2032 .horizontalButtons.leftToken = info->
leftToken,
2033 .horizontalButtons.rightText = info->
rightText,
2034 .horizontalButtons.rightToken = info->
rightToken,
2035 .horizontalButtons.tuneId = info->tuneId};
2057 if (layout == NULL) {
2061 for (i = 0; i < list->
nbPairs; i++) {
2066 if (list->
pairs != NULL) {
2067 pair = &list->
pairs[i];
2084 itemTextArea->text = PIC(pair->
item);
2085 itemTextArea->textAlignment =
MID_LEFT;
2086 itemTextArea->fontId = SMALL_REGULAR_FONT;
2087 itemTextArea->wrapping =
true;
2090 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2093 itemTextArea->obj.alignmentMarginX = 0;
2094 itemTextArea->obj.alignmentMarginY = 0;
2095 itemTextArea->obj.alignTo = NULL;
2096 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2097 container->nbChildren++;
2099 fullHeight += itemTextArea->obj.area.height;
2102 valueTextArea->textColor =
BLACK;
2103 valueTextArea->text = PIC(pair->
value);
2104 valueTextArea->textAlignment =
MID_LEFT;
2106 valueTextArea->fontId = SMALL_BOLD_FONT;
2109 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2124 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2130 valueTextArea->text,
2131 valueTextArea->obj.area.width,
2139 valueTextArea->obj.area.height = nbLines * font->
line_height;
2142 valueTextArea->obj.alignmentMarginY = 4;
2143 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2144 valueTextArea->wrapping = list->
wrapping;
2145 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2146 container->nbChildren++;
2148 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2149 if (valueIcon != NULL) {
2154 image->foregroundColor =
BLACK;
2155 image->buffer = valueIcon;
2157 image->obj.alignmentMarginX = 12;
2158 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2159 image->obj.touchMask = (1 <<
TOUCHED);
2162 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2163 container->nbChildren++;
2167 container->obj.area.height = fullHeight;
2173 container->obj.alignmentMarginY = 12;
2176 container->obj.alignmentMarginY = 24;
2181 container->obj.alignmentMarginY = 24;
2206 if (layout == NULL) {
2209 if (barLayout->
text != NULL) {
2214 textArea->textColor =
BLACK;
2215 textArea->text = PIC(barLayout->
text);
2216 textArea->textAlignment =
MID_LEFT;
2217 textArea->fontId = SMALL_REGULAR_FONT;
2218 textArea->wrapping =
true;
2221 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2230 progress->foregroundColor =
BLACK;
2231 progress->withBorder =
true;
2233 progress->obj.area.width = 120;
2234 progress->obj.area.height = 12;
2236 progress->obj.alignmentMarginX = (
AVAILABLE_WIDTH - progress->obj.area.width) / 2;
2240 if (barLayout->
subText != NULL) {
2246 subTextArea->text = PIC(barLayout->
subText);
2247 subTextArea->textAlignment =
MID_LEFT;
2248 subTextArea->fontId = SMALL_REGULAR_FONT;
2249 subTextArea->wrapping =
true;
2253 subTextArea->obj.area.width,
2254 subTextArea->wrapping);
2277 line = createHorizontalLine(layoutInt->
layer);
2278 line->obj.alignmentMarginY = -4;
2298 if (layout == NULL) {
2310 footerDesc.
button.tuneId = buttonInfo->tuneId;
2320 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2329 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2335 button->obj.alignmentMarginY = 12;
2338 button->innerColor =
BLACK;
2339 button->foregroundColor =
WHITE;
2342 button->innerColor =
WHITE;
2343 button->foregroundColor =
BLACK;
2346 button->borderColor =
WHITE;
2350 button->borderColor =
BLACK;
2356 button->text = PIC(buttonInfo->
text);
2357 button->fontId = SMALL_BOLD_FONT;
2358 button->icon = PIC(buttonInfo->
icon);
2362 + ((button->icon) ? (button->icon->width + 12) : 0);
2365 if (buttonInfo->
onBottom !=
true) {
2366 button->obj.alignmentMarginX
2375 button->obj.alignTo = NULL;
2376 button->obj.touchMask = (1 <<
TOUCHED);
2396 tune_index_e tuneId)
2399 .longPress.text = text,
2400 .longPress.token = token,
2401 .longPress.tuneId = tuneId};
2404 if (layout == NULL) {
2424 tune_index_e tuneId)
2449 const char *leftText,
2451 const char *rightText,
2453 tune_index_e tuneId)
2461 footerDesc.
doubleText.rightToken = rightToken;
2484 if (layout == NULL) {
2498 switch (headerDesc->
type) {
2523 button->innerColor =
WHITE;
2524 button->foregroundColor =
BLACK;
2525 button->borderColor =
WHITE;
2528 button->text = NULL;
2530 button->obj.touchMask = (1 <<
TOUCHED);
2541 image->buffer = PIC(headerDesc->
backAndText.icon);
2542 image->foregroundColor =
BLACK;
2543 image->obj.alignment =
CENTER;
2558 textArea->obj.touchMask = (1 <<
TOUCHED);
2560 textArea->obj.alignment =
CENTER;
2561 textArea->textColor =
BLACK;
2562 textArea->obj.area.width
2566 textArea->obj.area.width -= 16 + image->buffer->width;
2569 textArea->text = text;
2570 textArea->fontId = SMALL_BOLD_FONT;
2571 textArea->textAlignment =
CENTER;
2572 textArea->wrapping =
true;
2577 textArea->obj.area.width,
2581 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2592 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2593 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2609 button->obj.touchMask = (1 <<
TOUCHED);
2613 button->innerColor =
WHITE;
2614 button->foregroundColor
2617 button->borderColor =
WHITE;
2620 button->text = NULL;
2621 button->icon = PIC(headerDesc->
extendedBack.actionIcon);
2645 button->innerColor =
WHITE;
2646 button->foregroundColor =
BLACK;
2647 button->borderColor =
WHITE;
2650 button->text = NULL;
2652 button->obj.touchMask = (1 <<
TOUCHED);
2669 progress->obj.area.width = 224;
2670 progress->obj.alignment =
CENTER;
2684 textArea->textColor =
BLACK;
2687 textArea->text = PIC(headerDesc->
title.text);
2688 textArea->fontId = SMALL_BOLD_FONT;
2689 textArea->textAlignment =
CENTER;
2690 textArea->wrapping =
true;
2694 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2708 textArea->textColor =
BLACK;
2711 textArea->text = PIC(headerDesc->
rightText.text);
2712 textArea->fontId = SMALL_BOLD_FONT;
2714 textArea->obj.touchMask = (1 <<
TOUCHED);
2720 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2728 line = createHorizontalLine(layoutInt->
layer);
2735 if (separationLine != NULL) {
2770 if (layout == NULL) {
2784 switch (footerDesc->
type) {
2802 textArea->obj.area.height
2804 textArea->text = PIC(footerDesc->
simpleText.text);
2806 = (footerDesc->
simpleText.mutedOut) ? SMALL_REGULAR_FONT : SMALL_BOLD_FONT;
2807 textArea->textAlignment =
CENTER;
2808 textArea->obj.touchMask = (1 <<
TOUCHED);
2813 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2826 textArea->textColor =
BLACK;
2829 textArea->text = PIC(footerDesc->
doubleText.leftText);
2830 textArea->fontId = SMALL_BOLD_FONT;
2831 textArea->textAlignment =
CENTER;
2832 textArea->obj.touchMask = (1 <<
TOUCHED);
2850 textArea->textColor =
BLACK;
2853 textArea->text = PIC(footerDesc->
doubleText.rightText);
2854 textArea->fontId = SMALL_BOLD_FONT;
2855 textArea->textAlignment =
CENTER;
2856 textArea->obj.touchMask = (1 <<
TOUCHED);
2862 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2867 separationLine->obj.area.width = 1;
2868 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2869 separationLine->direction =
VERTICAL;
2870 separationLine->thickness = 1;
2871 separationLine->obj.alignment =
MID_LEFT;
2872 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2873 separationLine->obj.alignmentMarginX = -1;
2889 textArea->textColor =
BLACK;
2891 textArea->obj.area.width = 160;
2893 textArea->obj.area.width = 192;
2896 textArea->text = PIC(footerDesc->
textAndNav.text);
2897 textArea->fontId = SMALL_BOLD_FONT;
2898 textArea->textAlignment =
CENTER;
2899 textArea->obj.touchMask = (1 <<
TOUCHED);
2911 navContainer->nbChildren = 4;
2912 navContainer->children
2915 navContainer->obj.area.width =
SCREEN_WIDTH - textArea->obj.area.width;
2929 separationLine->obj.area.width = 1;
2930 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2931 separationLine->direction =
VERTICAL;
2932 separationLine->thickness = 1;
2933 separationLine->obj.alignment =
MID_LEFT;
2934 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2935 separationLine->obj.alignmentMarginX = -1;
2968 footerDesc->
button.tuneId);
2973 button->obj.alignment =
CENTER;
2975 button->innerColor =
BLACK;
2976 button->foregroundColor =
WHITE;
2979 button->innerColor =
WHITE;
2980 button->foregroundColor =
BLACK;
2984 button->borderColor =
WHITE;
2988 button->borderColor =
BLACK;
2995 button->fontId = SMALL_BOLD_FONT;
3006 button->obj.touchMask = (1 <<
TOUCHED);
3034 button->innerColor =
WHITE;
3036 button->obj.alignmentMarginY
3041 button->obj.alignmentMarginY = 4;
3042 button->borderColor =
WHITE;
3044 button->foregroundColor =
BLACK;
3049 button->fontId = SMALL_BOLD_FONT;
3050 button->obj.touchMask = (1 <<
TOUCHED);
3060 line = createHorizontalLine(layoutInt->
layer);
3062 line->obj.alignmentMarginY = 4;
3083 button->innerColor =
WHITE;
3085 button->foregroundColor =
BLACK;
3088 button->innerColor =
BLACK;
3089 button->borderColor =
BLACK;
3090 button->foregroundColor =
WHITE;
3099 button->fontId = SMALL_BOLD_FONT;
3100 button->obj.touchMask = (1 <<
TOUCHED);
3122 addSwipeInternal(layoutInt,
3133 line = createHorizontalLine(layoutInt->
layer);
3139 if (separationLine != NULL) {
3172 if (layout == NULL) {
3189 switch (upFooterDesc->
type) {
3210 button->innerColor =
BLACK;
3211 button->foregroundColor =
WHITE;
3212 button->borderColor =
BLACK;
3220 textArea->textColor =
BLACK;
3221 textArea->text = PIC(upFooterDesc->
longPress.text);
3222 textArea->textAlignment =
MID_LEFT;
3223 textArea->fontId = LARGE_MEDIUM_FONT;
3224 textArea->wrapping =
true;
3227 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3229 textArea->obj.alignment =
MID_LEFT;
3233 line = createHorizontalLine(layoutInt->
layer);
3239 progressBar->withBorder =
false;
3241 progressBar->obj.area.height = 8;
3243 progressBar->obj.alignmentMarginY = 4;
3244 progressBar->obj.alignTo = NULL;
3253 upFooterDesc->
button.tuneId);
3260 button->obj.alignment =
CENTER;
3263 button->innerColor =
BLACK;
3264 button->foregroundColor =
WHITE;
3267 button->innerColor =
WHITE;
3268 button->foregroundColor =
BLACK;
3271 button->borderColor =
WHITE;
3275 button->borderColor =
BLACK;
3281 button->text = PIC(upFooterDesc->
button.
text);
3282 button->fontId = SMALL_BOLD_FONT;
3283 button->icon = PIC(upFooterDesc->
button.
icon);
3288 button->obj.alignTo = NULL;
3289 button->obj.touchMask = (1 <<
TOUCHED);
3318 button->innerColor =
WHITE;
3319 button->foregroundColor =
BLACK;
3324 button->fontId = SMALL_BOLD_FONT;
3325 button->obj.touchMask = (1 <<
TOUCHED);
3342 button->innerColor =
BLACK;
3343 button->borderColor =
BLACK;
3344 button->foregroundColor =
WHITE;
3349 button->fontId = SMALL_BOLD_FONT;
3350 button->obj.touchMask = (1 <<
TOUCHED);
3363 upFooterDesc->
tipBox.tuneId);
3372 textArea->textColor =
BLACK;
3373 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3374 textArea->textAlignment =
MID_LEFT;
3375 textArea->fontId = SMALL_REGULAR_FONT;
3376 textArea->wrapping =
true;
3379 textArea->obj.area.width
3384 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3385 textArea->obj.alignment =
MID_LEFT;
3390 line = createHorizontalLine(layoutInt->
layer);
3399 image->foregroundColor =
BLACK;
3400 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3413 upFooterDesc->
text.token,
3414 upFooterDesc->
text.tuneId);
3425 textArea->text = PIC(upFooterDesc->
text.text);
3426 textArea->textAlignment =
CENTER;
3427 textArea->fontId = SMALL_REGULAR_FONT;
3428 textArea->wrapping =
true;
3431 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3432 textArea->obj.alignment =
CENTER;
3468 tune_index_e tuneId)
3471 .separationLine =
false,
3472 .progressAndBack.activePage = activePage,
3473 .progressAndBack.nbPages = nbPages,
3474 .progressAndBack.token = backToken,
3475 .progressAndBack.tuneId = tuneId,
3476 .progressAndBack.withBack = withBack,
3477 .progressAndBack.actionIcon = NULL,
3501 if (layout == NULL) {
3507 container->nbChildren = 3;
3512 container->obj.alignment =
CENTER;
3516 spinner->position = fixed ? 0xFF : 0;
3519 container->children[0] = (
nbgl_obj_t *) spinner;
3526 textArea->textColor =
BLACK;
3527 textArea->text = PIC(text);
3528 textArea->textAlignment =
CENTER;
3529 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3530 textArea->wrapping =
true;
3532 textArea->obj.alignmentMarginY = 20;
3534 textArea->obj.alignmentMarginY = 24;
3536 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3540 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3544 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3547 container->children[1] = (
nbgl_obj_t *) textArea;
3549 if (subText != NULL) {
3553 subTextArea->textColor =
BLACK;
3554 subTextArea->text = PIC(subText);
3555 subTextArea->textAlignment =
CENTER;
3556 subTextArea->fontId = SMALL_REGULAR_FONT;
3557 subTextArea->wrapping =
true;
3559 subTextArea->obj.alignmentMarginY = 20;
3561 subTextArea->obj.alignmentMarginY = 16;
3563 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3568 subTextArea->obj.area.width,
3569 subTextArea->wrapping);
3573 container->obj.area.height
3574 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3577 container->children[2] = (
nbgl_obj_t *) subTextArea;
3587 tickerCfg.tickerCallback = &spinnerTickerCallback;
3604 if (layout == NULL) {
3608 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3635 if (layout == NULL) {
3639 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.
#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT
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...
#define ACTION_AND_FOOTER_FOOTER_HEIGHT
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.
const char * get_ux_loc_string(uint32_t index)
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.
#define RADIO_CHOICE_HEIGHT
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, bool fixed)
Creates a centered (vertically & horizontally) spinner with a text under it.
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.
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_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
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
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
#define FOOTER_BUTTON_HEIGHT
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)
#define UP_FOOTER_BUTTON_HEIGHT
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
#define SIMPLE_FOOTER_HEIGHT
#define LONG_PRESS_BUTTON_HEIGHT
#define TOUCHABLE_MAIN_BAR_HEIGHT
#define TEXT_SUBTEXT_MARGIN
#define TOUCHABLE_BAR_HEIGHT
@ 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 SMALL_FOOTER_HEIGHT
#define NBGL_INVALID_TOKEN
@ 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.
#define POST_SUBTEXT_MARGIN
@ 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)
#define TOUCHABLE_HEADER_BAR_HEIGHT
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
#define SMALL_BUTTON_HEIGHT
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)
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.
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)
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.
#define BOTTOM_BORDER_MARGIN
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.
@ RADIUS_32_PIXELS
32 pixels
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