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 ROUNDED_AND_FOOTER_FOOTER_HEIGHT 192
49#define ACTION_AND_FOOTER_FOOTER_HEIGHT 216
50#define INTER_ROWS_MARGIN 16
51#define LEFT_CONTENT_TEXT_PADDING 0
53#define RADIO_CHOICE_HEIGHT 92
54#define FOOTER_HEIGHT 80
55#define BAR_INTERVALE 16
56#define BACK_KEY_WIDTH 104
57#define FOOTER_BUTTON_HEIGHT 136
58#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
59#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
60#define INTER_ROWS_MARGIN 26
61#define LEFT_CONTENT_TEXT_PADDING 4
65#define SPINNER_REFRESH_PERIOD 400
68#define FIRST_BUTTON_INDEX 0
105#ifdef HAVE_PIEZO_SOUND
121static uint8_t nbTouchableControls = 0;
128#ifdef HAVE_FAST_HOLD_TO_APPROVE
130#define HOLD_TO_APPROVE_STEP_PERCENT (7)
134#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
136#define HOLD_TO_APPROVE_STEP_PERCENT (25)
137#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
140static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
142#ifdef HAVE_FAST_HOLD_TO_APPROVE
151static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
161 if (gLayout[i].nbChildren > 0) {
166 if (obj == gLayout[i].callbackObjPool[j].obj) {
168 "getLayoutAndLayoutObj(): obj found in layout[%d], index = %d, "
169 "nbUsedCallbackObjs = %d\n",
172 gLayout[i].nbUsedCallbackObjs);
173 *layout = &gLayout[i];
184static void radioTouchCallback(
nbgl_obj_t *obj,
197 bool needRefresh =
false;
203 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
205 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
208 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
226 layoutObj->
index = eventType;
275 layoutObj->
index = lSwitch->state;
281 radioTouchCallback(obj, eventType, layout);
288 longTouchCallback(obj, eventType, layout, layoutObj);
293#ifdef HAVE_PIEZO_SOUND
295 io_seproxyhal_play_tune(layoutObj->
tuneId);
316 "longTouchCallback(): eventType = %d, obj = %p, gLayout[1].nbChildren = %d\n",
319 gLayout[1].nbChildren);
326 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
330 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
333 if (new_state >= 100) {
338 if (new_state != progressBar->state) {
339 progressBar->partialRedraw =
true;
340 progressBar->state = new_state;
349 if (trigger_callback) {
360 progressBar->partialRedraw =
true;
361 progressBar->state = 0;
368static void radioTouchCallback(
nbgl_obj_t *obj,
380 while (i < layout->nbUsedCallbackObjs) {
390 foundRadioIndex = radioIndex;
392 textArea->textColor =
BLACK;
393 textArea->fontId = SMALL_BOLD_FONT;
415 textArea->fontId = SMALL_REGULAR_FONT;
423 if (foundRadio != 0xFF) {
425#ifdef HAVE_PIEZO_SOUND
437static void spinnerTickerCallback(
void)
444 if (gLayout[1].nbChildren > 0) {
445 layout = &gLayout[1];
448 layout = &gLayout[0];
452 while (i < layout->container->nbChildren) {
455 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
460 spinner->position = 0;
478 line->obj.area.height = 4;
490 line->obj.area.width = 1;
510 layoutObj->
obj = obj;
511 layoutObj->
token = token;
512 layoutObj->
tuneId = tuneId;
561 layoutInt->
container->obj.touchMask = swipesMask;
588 layoutInt, (
nbgl_obj_t *) container, itemDesc->
token, itemDesc->tuneId);
595 container->nbChildren = 0;
602 container->obj.alignTo = NULL;
607 container->obj.touchMask = (1 <<
TOUCHED);
608 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
609 nbTouchableControls++;
614 textArea->textColor = color;
615 textArea->text = PIC(itemDesc->
text);
616 textArea->onDrawCallback = NULL;
617 textArea->fontId = SMALL_BOLD_FONT;
618 textArea->wrapping =
true;
619 textArea->obj.area.width = container->obj.area.width;
622 textArea->obj.area.width
627 textArea->obj.area.width
634 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
635 usedHeight =
MAX(usedHeight, textArea->obj.area.height);
639 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
640 container->nbChildren++;
645 imageLeft->foregroundColor = color;
646 imageLeft->buffer = PIC(itemDesc->
iconLeft);
648 imageLeft->obj.alignment =
MID_LEFT;
649 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
651 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
652 container->nbChildren++;
654 textArea->obj.alignmentMarginX = imageLeft->buffer->width +
BAR_INTERVALE;
656 usedHeight =
MAX(usedHeight, imageLeft->buffer->height);
661 imageRight->foregroundColor = color;
662 imageRight->buffer = PIC(itemDesc->
iconRight);
666 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
668 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
669 container->nbChildren++;
671 usedHeight =
MAX(usedHeight, imageRight->buffer->height);
675 switchObj->onColor =
BLACK;
677 switchObj->state = itemDesc->
state;
680 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
682 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
683 container->nbChildren++;
686 if (itemDesc->
subText != NULL) {
690 subTextArea->textColor = color;
691 subTextArea->text = PIC(itemDesc->
subText);
692 subTextArea->textAlignment =
MID_LEFT;
693 subTextArea->fontId = SMALL_REGULAR_FONT;
695 subTextArea->wrapping =
true;
696 subTextArea->obj.alignment =
MID_LEFT;
697 subTextArea->obj.area.width = container->obj.area.width;
700 subTextArea->obj.area.width,
701 subTextArea->wrapping);
702 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
703 container->nbChildren++;
704 container->obj.area.height += subTextArea->obj.area.height + 12;
707 textArea->obj.alignmentMarginY = -(subTextArea->obj.area.height + 12) / 2;
708 subTextArea->obj.alignmentMarginY = (usedHeight + 12) / 2;
736 container->nbChildren = 0;
740 if (info->
icon != NULL) {
742 image->foregroundColor =
BLACK;
743 image->buffer = PIC(info->
icon);
745 image->obj.alignmentMarginY = info->
iconHug;
747 fullHeight += image->buffer->height + info->
iconHug;
748 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
749 container->nbChildren++;
752 if (info->
title != NULL) {
754 textArea->textColor =
BLACK;
755 textArea->text = PIC(info->
title);
756 textArea->textAlignment =
CENTER;
757 textArea->fontId = LARGE_MEDIUM_FONT;
758 textArea->wrapping =
true;
761 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
764 if (container->nbChildren > 0) {
766 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
773 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
775 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
776 container->nbChildren++;
781 textArea->textColor =
BLACK;
783 textArea->textAlignment =
CENTER;
784 textArea->fontId = SMALL_BOLD_FONT;
785 textArea->wrapping =
true;
788 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
791 if (container->nbChildren > 0) {
793 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
795 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
799 textArea->obj.alignmentMarginY = 16;
806 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
808 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
809 container->nbChildren++;
814 textArea->textColor =
BLACK;
816 textArea->textAlignment =
CENTER;
817 textArea->fontId = SMALL_REGULAR_FONT;
818 textArea->wrapping =
true;
821 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
824 if (container->nbChildren > 0) {
826 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
827 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
829 textArea->obj.alignmentMarginY = 16;
839 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
841 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
842 container->nbChildren++;
848 textArea->text = PIC(info->
subText);
849 textArea->textAlignment =
CENTER;
850 textArea->fontId = SMALL_REGULAR_FONT;
851 textArea->wrapping =
true;
854 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
856 textArea->obj.area.height += 2 * 8;
858 if (container->nbChildren > 0) {
860 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
861 textArea->obj.alignmentMarginY = 16;
862 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
863 textArea->obj.alignmentMarginY += info->
iconHug;
870 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
872 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
873 container->nbChildren++;
876 container->obj.alignment =
CENTER;
878 container->obj.area.height = fullHeight;
880 container->obj.area.height += 40;
902 if (layout == NULL) {
914 textArea->textColor =
BLACK;
915 textArea->text = PIC(text);
917 textArea->fontId = SMALL_BOLD_FONT;
919 textArea->wrapping =
true;
922 textArea->obj.area.width = container->obj.area.width;
923 if (withAlias ==
true) {
927 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
928 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
929 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
930 container->nbChildren++;
931 if (withAlias ==
true) {
937 image->foregroundColor =
BLACK;
940 image->obj.alignmentMarginX = 12;
942 container->obj.touchMask = (1 <<
TOUCHED);
945 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
946 container->nbChildren++;
949 if (subText != NULL) {
951 subTextArea->textColor =
BLACK;
952 subTextArea->text = PIC(subText);
953 subTextArea->fontId = SMALL_REGULAR_FONT;
955 subTextArea->wrapping =
true;
956 subTextArea->obj.area.width = container->obj.area.width;
959 subTextArea->obj.area.width,
960 subTextArea->wrapping);
961 subTextArea->textAlignment =
MID_LEFT;
972 subTextArea->obj.alignmentMarginY = 26;
976 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
977 container->nbChildren++;
978 fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
983 container->obj.area.height = fullHeight;
990 return container->obj.area.height;
1008 if (description->
modal) {
1009 if (gLayout[1].nbChildren == 0) {
1010 layout = &gLayout[1];
1012 else if (gLayout[2].nbChildren == 0) {
1013 layout = &gLayout[2];
1019 layout = &gLayout[0];
1021 if (layout == NULL) {
1029 nbTouchableControls = 0;
1034 if (description->
modal) {
1066 obj->
tuneId = description->tapTuneId;
1074 footerDesc.
text.tuneId = description->tapTuneId;
1096 tune_index_e tuneId)
1101 if (layout == NULL) {
1108 layoutInt->
tapText->text = PIC(text);
1110 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1117 layoutInt->
tapText->obj.alignmentMarginY = 30;
1136 tune_index_e tuneId)
1143 if (layout == NULL) {
1157 button->foregroundColor =
BLACK;
1158 button->innerColor =
WHITE;
1160 button->obj.touchMask = (1 <<
TOUCHED);
1162 button->icon = PIC(icon);
1207 bool separationLine,
1208 tune_index_e tuneId)
1218 footerDesc.
button.tuneId = tuneId;
1237 if (layout == NULL) {
1241 if (barLayout->
text == NULL) {
1250 itemDesc.tuneId = barLayout->tuneId;
1254 container = addListItem(layoutInt, &itemDesc);
1256 if (container == NULL) {
1259 return container->obj.area.height;
1276 if (layout == NULL) {
1280 if (switchLayout->
text == NULL) {
1286 itemDesc.
text = switchLayout->
text;
1289 itemDesc.tuneId = switchLayout->tuneId;
1291 itemDesc.
large =
false;
1293 container = addListItem(layoutInt, &itemDesc);
1295 if (container == NULL) {
1298 return container->obj.area.height;
1312 return addText(layout, text, subText, 0, 0,
false);
1328 const char *subText,
1333 return addText(layout, text, subText, token, index,
true);
1349 if (layout == NULL) {
1354 textArea->textColor =
BLACK;
1355 textArea->text = PIC(text);
1356 textArea->textAlignment =
MID_LEFT;
1357 textArea->fontId = SMALL_REGULAR_FONT;
1359 textArea->wrapping =
true;
1364 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1366 textArea->obj.area.height += 2 * 24;
1368 textArea->obj.area.height += 2 * 28;
1374 return textArea->obj.area.height;
1390 if (layout == NULL) {
1395 textArea->textColor =
BLACK;
1396 textArea->text = PIC(text);
1397 textArea->textAlignment =
MID_LEFT;
1398 textArea->fontId = LARGE_MEDIUM_FONT;
1400 textArea->wrapping =
true;
1402 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1408 if (layoutInt->
container->nbChildren == 0) {
1433 const char *description,
1440 if (layout == NULL) {
1446 textArea->textColor =
BLACK;
1447 textArea->text = PIC(title);
1448 textArea->textAlignment =
MID_LEFT;
1449 textArea->fontId = LARGE_MEDIUM_FONT;
1451 textArea->wrapping =
true;
1455 textArea->obj.alignmentMarginY = 24;
1457 textArea->obj.alignmentMarginY = 16;
1461 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1467 textArea->textColor =
BLACK;
1468 textArea->text = PIC(description);
1469 textArea->fontId = SMALL_REGULAR_FONT;
1471 textArea->wrapping =
true;
1474 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1475 textArea->textAlignment =
MID_LEFT;
1479 textArea->obj.alignmentMarginY = 16;
1481 textArea->obj.alignmentMarginY = 24;
1489 textArea->text = PIC(info);
1490 textArea->fontId = SMALL_REGULAR_FONT;
1492 textArea->wrapping =
true;
1495 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1496 textArea->textAlignment =
MID_LEFT;
1499 textArea->obj.alignmentMarginY = 40;
1503 return layoutInt->
container->obj.area.height;
1520 if (layout == NULL) {
1523 for (i = 0; i < choices->
nbChoices; i++) {
1534 layoutInt, (
nbgl_obj_t *) container, choices->
token, choices->tuneId);
1540 container->nbChildren = 2;
1546 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1549 button->activeColor =
BLACK;
1551 button->obj.alignTo = (
nbgl_obj_t *) container;
1554 container->children[1] = (
nbgl_obj_t *) button;
1558#ifdef HAVE_LANGUAGE_PACK
1563 textArea->text = PIC(choices->
names[i]);
1565 textArea->textAlignment =
MID_LEFT;
1566 textArea->obj.area.width = container->obj.area.width -
RADIO_WIDTH;
1568 textArea->obj.alignment =
MID_LEFT;
1569 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1570 container->children[0] = (
nbgl_obj_t *) textArea;
1573 container->obj.touchMask = (1 <<
TOUCHED);
1574 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1575 nbTouchableControls++;
1580 textArea->textColor =
BLACK;
1581 textArea->fontId = SMALL_BOLD_FONT;
1586 textArea->fontId = SMALL_REGULAR_FONT;
1590 line = createHorizontalLine(layoutInt->
layer);
1591 line->obj.alignmentMarginY = -4;
1617 .description = NULL,
1623 if (layout == NULL) {
1627 if (info->
text1 != NULL) {
1635 if (info->
text2 != NULL) {
1643 if (info->
text3 != NULL) {
1651 container = addContentCenter(layoutInt, ¢eredInfo);
1659 container->obj.alignmentMarginY = info->
offsetY;
1662 return container->obj.area.height;
1679 if (layout == NULL) {
1683 container = addContentCenter(layoutInt, info);
1685 return container->obj.area.height;
1703 if (layout == NULL) {
1709 container->nbChildren = info->
nbRows + 1;
1717 textArea->textColor =
BLACK;
1718 textArea->text = PIC(info->
title);
1719 textArea->textAlignment =
MID_LEFT;
1720 textArea->fontId = LARGE_MEDIUM_FONT;
1721 textArea->wrapping =
true;
1724 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1726 container->obj.area.height += textArea->obj.area.height;
1728 container->children[0] = (
nbgl_obj_t *) textArea;
1730 for (row = 0; row < info->
nbRows; row++) {
1736 rowContainer->nbChildren = 2;
1741 image->foregroundColor =
BLACK;
1742 image->buffer = PIC(info->
rowIcons[row]);
1743 rowContainer->children[0] = (
nbgl_obj_t *) image;
1746 textArea->textColor =
BLACK;
1747 textArea->text = PIC(info->
rowTexts[row]);
1748 textArea->textAlignment =
MID_LEFT;
1749 textArea->fontId = SMALL_REGULAR_FONT;
1750 textArea->wrapping =
true;
1751 textArea->obj.area.width =
AVAILABLE_WIDTH - image->buffer->width - 16;
1753 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1755 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1756 rowContainer->obj.area.height
1760 rowContainer->obj.alignmentMarginY = 32;
1765 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1766 container->obj.area.height
1767 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1771 return container->obj.area.height;
1792 if (layout == NULL) {
1800 container->nbChildren = 0;
1804 if (strlen(PIC(info->
url)) > 62) {
1820 fullHeight +=
qrcode->obj.area.height;
1822 container->nbChildren++;
1824 if (info->
text1 != NULL) {
1826 textArea->textColor =
BLACK;
1827 textArea->text = PIC(info->
text1);
1828 textArea->textAlignment =
CENTER;
1829 textArea->fontId = (info->
largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1830 textArea->wrapping =
true;
1833 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1835 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1836 textArea->obj.alignmentMarginY = 24;
1838 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1840 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1841 container->nbChildren++;
1843 if (info->
text2 != NULL) {
1846 textArea->text = PIC(info->
text2);
1847 textArea->textAlignment =
CENTER;
1848 textArea->fontId = SMALL_REGULAR_FONT;
1849 textArea->wrapping =
true;
1852 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1854 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1855 if (info->
text1 != NULL) {
1857 textArea->obj.alignmentMarginY = 40;
1859 textArea->obj.alignmentMarginY = 28;
1863 textArea->obj.alignmentMarginY = 32;
1867 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1869 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1870 container->nbChildren++;
1873 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
1881 container->obj.area.height = fullHeight;
1884 container->obj.alignment =
CENTER;
1888 container->obj.alignTo
1891 container->obj.alignmentMarginY = info->
offsetY;
1937 .horizontalButtons.leftIcon = info->
leftIcon,
1938 .horizontalButtons.leftToken = info->
leftToken,
1939 .horizontalButtons.rightText = info->
rightText,
1940 .horizontalButtons.rightToken = info->
rightToken,
1941 .horizontalButtons.tuneId = info->tuneId};
1963 if (layout == NULL) {
1967 for (i = 0; i < list->
nbPairs; i++) {
1972 if (list->
pairs != NULL) {
1973 pair = &list->
pairs[i];
1990 itemTextArea->text = PIC(pair->
item);
1991 itemTextArea->textAlignment =
MID_LEFT;
1992 itemTextArea->fontId = SMALL_REGULAR_FONT;
1993 itemTextArea->wrapping =
true;
1996 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
1999 itemTextArea->obj.alignmentMarginX = 0;
2000 itemTextArea->obj.alignmentMarginY = 0;
2001 itemTextArea->obj.alignTo = NULL;
2002 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2003 container->nbChildren++;
2005 fullHeight += itemTextArea->obj.area.height;
2008 valueTextArea->textColor =
BLACK;
2009 valueTextArea->text = PIC(pair->
value);
2010 valueTextArea->textAlignment =
MID_LEFT;
2012 valueTextArea->fontId = SMALL_BOLD_FONT;
2015 valueTextArea->fontId = LARGE_MEDIUM_FONT;
2030 valueTextArea->obj.area.width =
AVAILABLE_WIDTH - valueIcon->width - 12;
2036 valueTextArea->text,
2037 valueTextArea->obj.area.width,
2045 valueTextArea->obj.area.height = nbLines * font->
line_height;
2048 valueTextArea->obj.alignmentMarginY = 4;
2049 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2050 valueTextArea->wrapping = list->
wrapping;
2051 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2052 container->nbChildren++;
2054 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2055 if (valueIcon != NULL) {
2060 image->foregroundColor =
BLACK;
2061 image->buffer = valueIcon;
2063 image->obj.alignmentMarginX = 12;
2064 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2065 image->obj.touchMask = (1 <<
TOUCHED);
2068 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2069 container->nbChildren++;
2073 container->obj.area.height = fullHeight;
2079 container->obj.alignmentMarginY = 12;
2082 container->obj.alignmentMarginY = 24;
2087 container->obj.alignmentMarginY = 24;
2112 if (layout == NULL) {
2115 if (barLayout->
text != NULL) {
2120 textArea->textColor =
BLACK;
2121 textArea->text = PIC(barLayout->
text);
2122 textArea->textAlignment =
MID_LEFT;
2123 textArea->fontId = SMALL_REGULAR_FONT;
2124 textArea->wrapping =
true;
2127 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2136 progress->foregroundColor =
BLACK;
2137 progress->withBorder =
true;
2139 progress->obj.area.width = 120;
2140 progress->obj.area.height = 12;
2142 progress->obj.alignmentMarginX = (
AVAILABLE_WIDTH - progress->obj.area.width) / 2;
2146 if (barLayout->
subText != NULL) {
2152 subTextArea->text = PIC(barLayout->
subText);
2153 subTextArea->textAlignment =
MID_LEFT;
2154 subTextArea->fontId = SMALL_REGULAR_FONT;
2155 subTextArea->wrapping =
true;
2159 subTextArea->obj.area.width,
2160 subTextArea->wrapping);
2183 line = createHorizontalLine(layoutInt->
layer);
2184 line->obj.alignmentMarginY = -4;
2204 if (layout == NULL) {
2216 footerDesc.
button.tuneId = buttonInfo->tuneId;
2226 upFooterDesc.
button.tuneId = buttonInfo->tuneId;
2235 layoutInt, (
nbgl_obj_t *) button, buttonInfo->
token, buttonInfo->tuneId);
2241 button->obj.alignmentMarginY = 12;
2244 button->innerColor =
BLACK;
2245 button->foregroundColor =
WHITE;
2248 button->innerColor =
WHITE;
2249 button->foregroundColor =
BLACK;
2252 button->borderColor =
WHITE;
2256 button->borderColor =
BLACK;
2262 button->text = PIC(buttonInfo->
text);
2263 button->fontId = SMALL_BOLD_FONT;
2264 button->icon = PIC(buttonInfo->
icon);
2268 + ((button->icon) ? (button->icon->width + 12) : 0);
2271 if (buttonInfo->
onBottom !=
true) {
2272 button->obj.alignmentMarginX
2281 button->obj.alignTo = NULL;
2282 button->obj.touchMask = (1 <<
TOUCHED);
2302 tune_index_e tuneId)
2305 .longPress.text = text,
2306 .longPress.token = token,
2307 .longPress.tuneId = tuneId};
2310 if (layout == NULL) {
2330 tune_index_e tuneId)
2355 const char *leftText,
2357 const char *rightText,
2359 tune_index_e tuneId)
2390 if (layout == NULL) {
2404 switch (headerDesc->
type) {
2433 button->innerColor =
WHITE;
2435 button->borderColor =
WHITE;
2438 button->text = NULL;
2458 textArea->obj.touchMask = (1 <<
TOUCHED);
2460 textArea->obj.alignment =
CENTER;
2461 textArea->textColor =
BLACK;
2462 textArea->obj.area.width
2465 textArea->text = text;
2466 textArea->fontId = SMALL_BOLD_FONT;
2467 textArea->textAlignment =
CENTER;
2468 textArea->wrapping =
true;
2472 textArea->obj.area.width,
2476 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2496 button->obj.touchMask = (1 <<
TOUCHED);
2500 button->innerColor =
WHITE;
2501 button->foregroundColor
2504 button->borderColor =
WHITE;
2507 button->text = NULL;
2532 button->innerColor =
WHITE;
2533 button->foregroundColor =
BLACK;
2534 button->borderColor =
WHITE;
2537 button->text = NULL;
2539 button->obj.touchMask = (1 <<
TOUCHED);
2556 progress->obj.area.width = 224;
2557 progress->obj.alignment =
CENTER;
2571 textArea->textColor =
BLACK;
2574 textArea->text = PIC(headerDesc->
title.
text);
2575 textArea->fontId = SMALL_BOLD_FONT;
2576 textArea->textAlignment =
CENTER;
2577 textArea->wrapping =
true;
2581 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2595 textArea->textColor =
BLACK;
2599 textArea->fontId = SMALL_BOLD_FONT;
2601 textArea->obj.touchMask = (1 <<
TOUCHED);
2607 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2615 line = createHorizontalLine(layoutInt->
layer);
2622 if (separationLine != NULL) {
2657 if (layout == NULL) {
2671 switch (footerDesc->
type) {
2689 textArea->obj.area.height
2694 textArea->textAlignment =
CENTER;
2695 textArea->obj.touchMask = (1 <<
TOUCHED);
2700 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2713 textArea->textColor =
BLACK;
2717 textArea->fontId = SMALL_BOLD_FONT;
2718 textArea->textAlignment =
CENTER;
2719 textArea->obj.touchMask = (1 <<
TOUCHED);
2737 textArea->textColor =
BLACK;
2741 textArea->fontId = SMALL_BOLD_FONT;
2742 textArea->textAlignment =
CENTER;
2743 textArea->obj.touchMask = (1 <<
TOUCHED);
2749 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
2754 separationLine->obj.area.width = 1;
2755 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2756 separationLine->direction =
VERTICAL;
2757 separationLine->thickness = 1;
2758 separationLine->obj.alignment =
MID_LEFT;
2759 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
2760 separationLine->obj.alignmentMarginX = -1;
2776 textArea->textColor =
BLACK;
2778 textArea->obj.area.width = 160;
2780 textArea->obj.area.width = 192;
2784 textArea->fontId = SMALL_BOLD_FONT;
2785 textArea->textAlignment =
CENTER;
2786 textArea->obj.touchMask = (1 <<
TOUCHED);
2798 navContainer->nbChildren = 4;
2799 navContainer->children
2802 navContainer->obj.area.width =
SCREEN_WIDTH - textArea->obj.area.width;
2816 separationLine->obj.area.width = 1;
2817 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
2818 separationLine->direction =
VERTICAL;
2819 separationLine->thickness = 1;
2820 separationLine->obj.alignment =
MID_LEFT;
2821 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
2822 separationLine->obj.alignmentMarginX = -1;
2855 footerDesc->
button.tuneId);
2860 button->obj.alignment =
CENTER;
2862 button->innerColor =
BLACK;
2863 button->foregroundColor =
WHITE;
2866 button->innerColor =
WHITE;
2867 button->foregroundColor =
BLACK;
2871 button->borderColor =
WHITE;
2875 button->borderColor =
BLACK;
2882 button->fontId = SMALL_BOLD_FONT;
2893 button->obj.touchMask = (1 <<
TOUCHED);
2921 button->obj.alignmentMarginY = 4;
2922 button->borderColor =
WHITE;
2923 button->innerColor =
WHITE;
2924 button->foregroundColor =
BLACK;
2929 button->fontId = SMALL_BOLD_FONT;
2930 button->obj.touchMask = (1 <<
TOUCHED);
2939 line = createHorizontalLine(layoutInt->
layer);
2941 line->obj.alignmentMarginY = 4;
2962 button->innerColor =
WHITE;
2964 button->foregroundColor =
BLACK;
2967 button->innerColor =
BLACK;
2968 button->borderColor =
BLACK;
2969 button->foregroundColor =
WHITE;
2978 button->fontId = SMALL_BOLD_FONT;
2979 button->obj.touchMask = (1 <<
TOUCHED);
3001 addSwipeInternal(layoutInt,
3012 line = createHorizontalLine(layoutInt->
layer);
3018 if (separationLine != NULL) {
3051 if (layout == NULL) {
3068 switch (upFooterDesc->
type) {
3089 button->innerColor =
BLACK;
3090 button->foregroundColor =
WHITE;
3091 button->borderColor =
BLACK;
3099 textArea->textColor =
BLACK;
3101 textArea->textAlignment =
MID_LEFT;
3102 textArea->fontId = LARGE_MEDIUM_FONT;
3103 textArea->wrapping =
true;
3106 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3108 textArea->obj.alignment =
MID_LEFT;
3112 line = createHorizontalLine(layoutInt->
layer);
3118 progressBar->withBorder =
false;
3120 progressBar->obj.area.height = 8;
3122 progressBar->obj.alignmentMarginY = 4;
3123 progressBar->obj.alignTo = NULL;
3132 upFooterDesc->
button.tuneId);
3139 button->obj.alignment =
CENTER;
3142 button->innerColor =
BLACK;
3143 button->foregroundColor =
WHITE;
3146 button->innerColor =
WHITE;
3147 button->foregroundColor =
BLACK;
3150 button->borderColor =
WHITE;
3154 button->borderColor =
BLACK;
3160 button->text = PIC(upFooterDesc->
button.
text);
3161 button->fontId = SMALL_BOLD_FONT;
3162 button->icon = PIC(upFooterDesc->
button.
icon);
3167 button->obj.alignTo = NULL;
3168 button->obj.touchMask = (1 <<
TOUCHED);
3197 button->innerColor =
WHITE;
3198 button->foregroundColor =
BLACK;
3203 button->fontId = SMALL_BOLD_FONT;
3204 button->obj.touchMask = (1 <<
TOUCHED);
3221 button->innerColor =
BLACK;
3222 button->borderColor =
BLACK;
3223 button->foregroundColor =
WHITE;
3228 button->fontId = SMALL_BOLD_FONT;
3229 button->obj.touchMask = (1 <<
TOUCHED);
3242 upFooterDesc->
tipBox.tuneId);
3251 textArea->textColor =
BLACK;
3252 textArea->text = PIC(upFooterDesc->
tipBox.
text);
3253 textArea->textAlignment =
MID_LEFT;
3254 textArea->fontId = SMALL_REGULAR_FONT;
3255 textArea->wrapping =
true;
3258 textArea->obj.area.width
3263 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3264 textArea->obj.alignment =
MID_LEFT;
3269 line = createHorizontalLine(layoutInt->
layer);
3278 image->foregroundColor =
BLACK;
3279 image->buffer = PIC(upFooterDesc->
tipBox.
icon);
3292 upFooterDesc->
text.token,
3293 upFooterDesc->
text.tuneId);
3304 textArea->text = PIC(upFooterDesc->
text.text);
3305 textArea->textAlignment =
CENTER;
3306 textArea->fontId = SMALL_REGULAR_FONT;
3307 textArea->wrapping =
true;
3310 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3311 textArea->obj.alignment =
CENTER;
3347 tune_index_e tuneId)
3350 .separationLine =
false,
3351 .progressAndBack.activePage = activePage,
3352 .progressAndBack.nbPages = nbPages,
3353 .progressAndBack.token = backToken,
3354 .progressAndBack.tuneId = tuneId,
3355 .progressAndBack.withBack = withBack,
3356 .progressAndBack.actionIcon = NULL,
3380 if (layout == NULL) {
3386 container->nbChildren = 2;
3391 container->obj.alignment =
CENTER;
3395 spinner->position = initPosition;
3398 container->children[0] = (
nbgl_obj_t *) spinner;
3405 textArea->textColor =
BLACK;
3406 textArea->text = PIC(text);
3407 textArea->textAlignment =
CENTER;
3408 textArea->fontId = SMALL_REGULAR_FONT;
3409 textArea->wrapping =
true;
3411 textArea->obj.alignmentMarginY = 20;
3413 textArea->obj.alignmentMarginY = 24;
3415 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3419 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3423 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3426 container->children[1] = (
nbgl_obj_t *) textArea;
3436 tickerCfg.tickerCallback = &spinnerTickerCallback;
3462 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3467 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3472 if (spinner->obj.type !=
SPINNER) {
3476 if (spinner->position != position) {
3477 spinner->position = position;
3487 const char *newText = PIC(text);
3488 size_t newTextLen = strlen(newText);
3490 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3491 textArea->text = newText;
3509 if (layout == NULL) {
3513 "nbgl_layoutDraw(): container.nbChildren =%d, layout->nbChildren = %d\n",
3540 if (layout == NULL) {
3544 if (layout->
modal) {
Random Number Generation.
#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)
return the non-unicode font corresponding to the given font ID
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.
#define LEFT_CONTENT_TEXT_PADDING
int nbgl_layoutUpdateSpinner(nbgl_layout_t *layout, const char *text, uint8_t position)
Update an existing spinner (must be the only object of the layout)
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_layoutAddSpinner(nbgl_layout_t *layout, const char *text, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
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.
#define INTER_ROWS_MARGIN
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_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates a switch with the given text and its state.
int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon a...
int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
Creates a rounded button in the main container.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
Creates an area with a title, and rows of icon + text, left aligned.
const char * get_ux_loc_string(uint32_t index)
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutRelease(nbgl_layout_t *layoutParam)
Release the layout obtained with nbgl_layoutGet()
int nbgl_layoutAddLongPressButton(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a long press button in the main container.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
int nbgl_layoutAddBottomButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, bool separationLine, tune_index_e tuneId)
Creates a centered button at bottom of main container.
int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text)
Creates an area with given text in 32px font (in Black)
#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...
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
#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
#define SMALL_FOOTER_HEIGHT
#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.
@ 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 UP_FOOTER_BUTTON_HEIGHT
#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)
#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)
#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_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
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
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
bool padding
if true, apply a padding of 40px at the bottom
const char * smallTitle
sub-title in black small bold case (can be null)
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
nbgl_swipe_usage_t swipeUsage
nbgl_layoutTouchCallback_t callback
nbgl_container_t * container
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
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