18#include "localization.h"
28#include "os_io_seph_ux.h"
30#include "os_helpers.h"
37#define INTERNAL_SPACE 16
39#define INNER_MARGIN 12
41#define NB_MAX_LAYOUTS 3
44#define NB_MAX_CONTAINER_CHILDREN 20
46#define TAG_VALUE_ICON_WIDTH 32
48#if defined(TARGET_STAX)
49#define RADIO_CHOICE_HEIGHT 96
50#define BAR_INTERVALE 12
51#define FOOTER_BUTTON_HEIGHT 128
52#define FOOTER_IN_PAIR_HEIGHT 80
53#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 192
54#define FOOTER_TEXT_AND_NAV_WIDTH 160
55#define TAP_TO_CONTINUE_MARGIN 24
56#define SUB_HEADER_MARGIN 24
57#define PRE_FIRST_TEXT_MARGIN 24
58#define INTER_PARAGRAPHS_MARGIN 40
59#define PRE_TITLE_MARGIN 24
60#define PRE_DESCRIPTION_MARGIN 16
61#define INTER_DESCRIPTIONS_MARGIN 16
62#define PRE_FIRST_ROW_MARGIN 32
63#define INTER_ROWS_MARGIN 16
64#define QR_PRE_TEXT_MARGIN 24
65#define QR_INTER_TEXTS_MARGIN 40
66#define SPINNER_TEXT_MARGIN 20
67#define SPINNER_INTER_TEXTS_MARGIN 20
68#define BAR_TEXT_MARGIN 24
69#define BAR_INTER_TEXTS_MARGIN 16
70#define LEFT_CONTENT_TEXT_PADDING 0
71#define BUTTON_FROM_BOTTOM_MARGIN 4
72#define TOP_BUTTON_MARGIN VERTICAL_BORDER_MARGIN
73#define TOP_BUTTON_MARGIN_WITH_ACTION VERTICAL_BORDER_MARGIN
74#define SINGLE_BUTTON_MARGIN 24
75#define LONG_PRESS_PROGRESS_HEIGHT 8
76#define LONG_PRESS_PROGRESS_ALIGN 1
77#define LEFT_CONTENT_ICON_TEXT_X 16
78#define TIP_BOX_MARGIN_Y 24
79#define TIP_BOX_TEXT_ICON_MARGIN 24
80#elif defined(TARGET_FLEX) || defined(TARGET_APOLLO)
81#define RADIO_CHOICE_HEIGHT 92
82#define BAR_INTERVALE 16
83#define FOOTER_BUTTON_HEIGHT 136
84#define FOOTER_IN_PAIR_HEIGHT 88
85#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
86#define FOOTER_TEXT_AND_NAV_WIDTH 192
87#define TAP_TO_CONTINUE_MARGIN 30
88#define SUB_HEADER_MARGIN 28
89#define PRE_FIRST_TEXT_MARGIN 0
90#define INTER_PARAGRAPHS_MARGIN 24
91#define PRE_TITLE_MARGIN 16
92#define PRE_DESCRIPTION_MARGIN 24
93#define INTER_DESCRIPTIONS_MARGIN 24
94#define PRE_FIRST_ROW_MARGIN 32
95#define INTER_ROWS_MARGIN 24
96#define QR_PRE_TEXT_MARGIN 24
97#define QR_INTER_TEXTS_MARGIN 28
98#define SPINNER_TEXT_MARGIN 24
99#define SPINNER_INTER_TEXTS_MARGIN 16
100#define BAR_TEXT_MARGIN 24
101#define BAR_INTER_TEXTS_MARGIN 16
102#define LEFT_CONTENT_TEXT_PADDING 4
103#define BUTTON_FROM_BOTTOM_MARGIN 4
104#define TOP_BUTTON_MARGIN VERTICAL_BORDER_MARGIN
105#define TOP_BUTTON_MARGIN_WITH_ACTION VERTICAL_BORDER_MARGIN
106#define SINGLE_BUTTON_MARGIN 24
107#define LONG_PRESS_PROGRESS_HEIGHT 8
108#define LONG_PRESS_PROGRESS_ALIGN 1
109#define LEFT_CONTENT_ICON_TEXT_X 16
110#define TIP_BOX_MARGIN_Y 24
111#define TIP_BOX_TEXT_ICON_MARGIN 32
112#elif defined(TARGET_APEX)
113#define RADIO_CHOICE_HEIGHT 68
114#define BAR_INTERVALE 8
115#define FOOTER_BUTTON_HEIGHT 88
116#define FOOTER_IN_PAIR_HEIGHT 60
117#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 128
118#define FOOTER_TEXT_AND_NAV_WIDTH 120
119#define TAP_TO_CONTINUE_MARGIN 30
120#define SUB_HEADER_MARGIN 16
121#define PRE_FIRST_TEXT_MARGIN 0
122#define INTER_PARAGRAPHS_MARGIN 16
123#define PRE_TITLE_MARGIN 16
124#define PRE_DESCRIPTION_MARGIN 12
125#define INTER_DESCRIPTIONS_MARGIN 12
126#define PRE_FIRST_ROW_MARGIN 24
127#define INTER_ROWS_MARGIN 12
128#define QR_PRE_TEXT_MARGIN 16
129#define QR_INTER_TEXTS_MARGIN 20
130#define SPINNER_TEXT_MARGIN 16
131#define SPINNER_INTER_TEXTS_MARGIN 16
132#define BAR_TEXT_MARGIN 16
133#define BAR_INTER_TEXTS_MARGIN 12
134#define LEFT_CONTENT_TEXT_PADDING 4
135#define BUTTON_FROM_BOTTOM_MARGIN 0
136#define TOP_BUTTON_MARGIN 12
137#define TOP_BUTTON_MARGIN_WITH_ACTION 0
138#define SINGLE_BUTTON_MARGIN 16
139#define LONG_PRESS_PROGRESS_HEIGHT 4
140#define LONG_PRESS_PROGRESS_ALIGN 0
141#define LEFT_CONTENT_ICON_TEXT_X 8
142#define TIP_BOX_MARGIN_Y 12
143#define TIP_BOX_TEXT_ICON_MARGIN 20
145#error Undefined target
149#define SPINNER_REFRESH_PERIOD 400
196static uint8_t nbTouchableControls = 0;
204#if defined(TARGET_FLEX) || defined(TARGET_APOLLO)
206#define HOLD_TO_APPROVE_STEP_PERCENT (7)
208#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
210#define HOLD_TO_APPROVE_FIRST_STEP (0)
211#elif defined(TARGET_STAX)
212#define HOLD_TO_APPROVE_STEP_PERCENT (25)
213#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
214#define HOLD_TO_APPROVE_FIRST_STEP (1)
215#elif defined(TARGET_APEX)
216#define HOLD_TO_APPROVE_STEP_PERCENT (20)
217#define HOLD_TO_APPROVE_STEP_DURATION_MS (300)
218#define HOLD_TO_APPROVE_FIRST_STEP (1)
221static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
223 uint8_t current_step_nb
224 = (touch_duration / HOLD_TO_APPROVE_STEP_DURATION_MS) + HOLD_TO_APPROVE_FIRST_STEP;
225 return (current_step_nb * HOLD_TO_APPROVE_STEP_PERCENT);
229static bool getLayoutAndLayoutObj(
nbgl_obj_t *obj,
236 if ((topLayout) && (topLayout->
isUsed)) {
243 "getLayoutAndLayoutObj(): obj found in layout %p "
244 "nbUsedCallbackObjs = %d\n",
257static void radioTouchCallback(
nbgl_obj_t *obj,
270 bool needRefresh =
false;
277 if (getLayoutAndLayoutObj(obj, &layout, &layoutObj) ==
false) {
279 if (getLayoutAndLayoutObj(obj->parent, &layout, &layoutObj) ==
false) {
282 "touchCallback(): eventType = %d, obj = %p, no active layout or obj not found\n",
300 layoutObj->
index = eventType;
308 else if (layout->
footerType == FOOTER_TEXT_AND_NAV) {
330 && (layout->
footerType == FOOTER_TEXT_AND_NAV))) {
349 layoutObj->
index = lSwitch->state;
355 radioTouchCallback(obj, eventType, layout);
362 longTouchCallback(obj, eventType, layout, layoutObj);
367#ifdef HAVE_PIEZO_SOUND
369 os_io_seph_cmd_piezo_play_tune(layoutObj->
tuneId);
396 uint8_t new_state = get_hold_to_approve_percent(touchDuration);
400 bool trigger_callback = (new_state >= 100) && (progressBar->state < 100);
403 if (new_state >= 100) {
408 if (new_state != progressBar->state) {
409 progressBar->partialRedraw =
true;
410 progressBar->state = new_state;
419 if (trigger_callback) {
429#ifdef HAVE_SE_EINK_DISPLAY
432 progressBar->partialRedraw =
true;
433 progressBar->state = 0;
443static void radioTouchCallback(
nbgl_obj_t *obj,
447 uint8_t i =
NB_MAX_LAYOUTS, radioIndex = 0, foundRadio = 0xFF, foundRadioIndex;
455 while (i < layout->nbUsedCallbackObjs) {
465 foundRadioIndex = radioIndex;
467 textArea->textColor =
BLACK;
468 textArea->fontId = SMALL_BOLD_FONT;
490 textArea->fontId = SMALL_REGULAR_FONT;
498 if (foundRadio != 0xFF) {
500#ifdef HAVE_PIEZO_SOUND
512static void spinnerTickerCallback(
void)
517 if (!topLayout || !topLayout->
isUsed) {
522 while (i < topLayout->container->nbChildren) {
525 if (container->nbChildren && (container->children[0]->type ==
SPINNER)) {
529 if (spinner->position == NB_SPINNER_POSITIONS) {
530 spinner->position = 0;
542static void animTickerCallback(
void)
553 while (i < layout->container->nbChildren) {
556 if (container->children[1]->type ==
IMAGE) {
595static nbgl_line_t *createHorizontalLine(uint8_t layer)
602 line->obj.area.height = 1;
609static nbgl_line_t *createLeftVerticalLine(uint8_t layer)
615 line->obj.area.width = 1;
636 layoutObj->
obj = obj;
637 layoutObj->
token = token;
638 layoutObj->
tuneId = tuneId;
657 if (layout == NULL) {
670 if (layoutObj->
obj == obj) {
671 layoutObj->
token = token;
685 if (layout->
container->nbChildren >= NB_MAX_CONTAINER_CHILDREN) {
722 layoutInt->
container->obj.touchMask = swipesMask;
743 if ((itemDesc->type == TOUCHABLE_BAR_ITEM) && (itemDesc->state ==
OFF_STATE)) {
748 common_color =
BLACK;
749 right_icon_color =
BLACK;
753 = ((itemDesc->type == TOUCHABLE_BAR_ITEM) && (itemDesc->state ==
OFF_STATE))
761 layoutInt, (
nbgl_obj_t *) container, itemDesc->token, itemDesc->tuneId);
766 obj->
index = itemDesc->index;
770 container->nbChildren = 0;
773 container->obj.area.height
774 = LIST_ITEM_MIN_TEXT_HEIGHT
775 + 2 * (itemDesc->large ? LIST_ITEM_PRE_HEADING_LARGE : LIST_ITEM_PRE_HEADING);
777 container->obj.alignmentMarginX = BORDER_MARGIN;
779 container->obj.alignTo = NULL;
782 if (((itemDesc->type == TOUCHABLE_BAR_ITEM) && (itemDesc->state ==
ON_STATE))
783 || (itemDesc->type == SWITCH_ITEM)) {
784 container->obj.touchMask = (1 <<
TOUCHED);
785 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
786 nbTouchableControls++;
790 if (itemDesc->text != NULL) {
792 textArea->textColor = common_color;
793 textArea->text = PIC(itemDesc->text);
794 textArea->onDrawCallback = NULL;
795 textArea->fontId = fontId;
796 textArea->wrapping =
true;
797 textArea->obj.area.width = container->obj.area.width;
798 if (itemDesc->iconLeft != NULL) {
800 textArea->obj.area.width
803 if (itemDesc->iconRight != NULL) {
805 textArea->obj.area.width
808 else if (itemDesc->type == SWITCH_ITEM) {
809 textArea->obj.area.width -= SWITCH_ICON.width + BAR_INTERVALE;
811 textArea->obj.area.height =
MAX(
812 LIST_ITEM_MIN_TEXT_HEIGHT,
814 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping));
817 textArea->obj.alignmentMarginY
818 = itemDesc->large ? LIST_ITEM_PRE_HEADING_LARGE : LIST_ITEM_PRE_HEADING;
819 if (textArea->obj.area.height > LIST_ITEM_MIN_TEXT_HEIGHT) {
820 textArea->obj.alignmentMarginY
821 -= (textArea->obj.area.height - LIST_ITEM_MIN_TEXT_HEIGHT) / 2;
824 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
825 container->nbChildren++;
829 if (itemDesc->iconLeft != NULL) {
831 imageLeft->foregroundColor = common_color;
832 imageLeft->buffer = PIC(itemDesc->iconLeft);
834 imageLeft->obj.alignment =
MID_LEFT;
835 imageLeft->obj.alignTo = (
nbgl_obj_t *) textArea;
836 imageLeft->obj.alignmentMarginX = BAR_INTERVALE;
837 container->children[container->nbChildren] = (
nbgl_obj_t *) imageLeft;
838 container->nbChildren++;
840 if (textArea != NULL) {
841 textArea->obj.alignmentMarginX = imageLeft->buffer->width + BAR_INTERVALE;
845 if (itemDesc->iconRight != NULL) {
847 imageRight->foregroundColor = right_icon_color;
848 imageRight->buffer = PIC(itemDesc->iconRight);
851 imageRight->obj.alignmentMarginX = BAR_INTERVALE;
852 imageRight->obj.alignTo = (
nbgl_obj_t *) textArea;
854 container->children[container->nbChildren] = (
nbgl_obj_t *) imageRight;
855 container->nbChildren++;
857 else if (itemDesc->type == SWITCH_ITEM) {
859 switchObj->onColor =
BLACK;
861 switchObj->state = itemDesc->state;
863 switchObj->obj.alignmentMarginX = BAR_INTERVALE;
864 switchObj->obj.alignTo = (
nbgl_obj_t *) textArea;
866 container->children[container->nbChildren] = (
nbgl_obj_t *) switchObj;
867 container->nbChildren++;
870 if (itemDesc->subText != NULL) {
874 subTextArea->textColor = common_color;
875 subTextArea->text = PIC(itemDesc->subText);
876 subTextArea->textAlignment =
MID_LEFT;
877 subTextArea->fontId = SMALL_REGULAR_FONT;
879 subTextArea->wrapping =
true;
880 if (itemDesc->text != NULL) {
882 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
883 subTextArea->obj.alignmentMarginY = LIST_ITEM_HEADING_SUB_TEXT;
886 subTextArea->obj.alignment =
TOP_LEFT;
887 subTextArea->obj.alignmentMarginY = SUB_HEADER_MARGIN;
888 container->obj.area.height = SUB_HEADER_MARGIN;
890 if (itemDesc->iconLeft != NULL) {
891 subTextArea->obj.alignmentMarginX
894 subTextArea->obj.area.width = container->obj.area.width;
897 subTextArea->obj.area.width,
898 subTextArea->wrapping);
899 container->children[container->nbChildren] = (
nbgl_obj_t *) subTextArea;
900 container->nbChildren++;
901 container->obj.area.height
902 += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
924 uint16_t fullHeight = 0;
929 container->nbChildren = 0;
934 if (info->
icon != NULL) {
937 image->buffer = PIC(info->
icon);
939 image->obj.alignmentMarginY = info->
iconHug;
941 fullHeight += image->buffer->height + info->
iconHug;
942 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
943 container->nbChildren++;
954 container->children[container->nbChildren] = (
nbgl_obj_t *) anim;
955 container->nbChildren++;
966 tickerCfg.tickerCallback = &animTickerCallback;
971 if (info->
title != NULL) {
974 textArea->text = PIC(info->
title);
975 textArea->textAlignment =
CENTER;
976 textArea->fontId = LARGE_MEDIUM_FONT;
977 textArea->wrapping =
true;
980 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
983 if (container->nbChildren > 0) {
986 textArea->obj.alignmentMarginY = ICON_TITLE_MARGIN + info->
iconHug;
992 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
994 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
995 container->nbChildren++;
1002 textArea->textAlignment =
CENTER;
1003 textArea->fontId = SMALL_BOLD_FONT;
1004 textArea->wrapping =
true;
1007 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1010 if (container->nbChildren > 0) {
1012 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1013 textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN;
1014 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
1015 textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN + info->
iconHug;
1018 textArea->obj.alignmentMarginY = TITLE_DESC_MARGIN;
1025 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1027 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1028 container->nbChildren++;
1035 textArea->textAlignment =
CENTER;
1036 textArea->fontId = SMALL_REGULAR_FONT;
1037 textArea->wrapping =
true;
1040 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1043 if (container->nbChildren > 0) {
1045 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1046 if (container->children[container->nbChildren - 1]->type ==
TEXT_AREA) {
1048 textArea->obj.alignmentMarginY = TITLE_DESC_MARGIN;
1051 textArea->obj.alignmentMarginY = ICON_TITLE_MARGIN + info->
iconHug;
1058 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1060 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1061 container->nbChildren++;
1067 textArea->text = PIC(info->
subText);
1068 textArea->textAlignment =
CENTER;
1069 textArea->fontId = SMALL_REGULAR_FONT;
1070 textArea->wrapping =
true;
1073 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1075 textArea->obj.area.height += 2 * 8;
1077 if (container->nbChildren > 0) {
1079 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
1080 textArea->obj.alignmentMarginY = 16;
1081 if (container->children[container->nbChildren - 1]->type ==
IMAGE) {
1082 textArea->obj.alignmentMarginY += info->
iconHug;
1089 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1091 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
1092 container->nbChildren++;
1095 container->obj.alignment =
CENTER;
1097 container->obj.area.height = fullHeight;
1099 container->obj.area.height += 40;
1122 if (description->
modal) {
1134 if (topLayout == NULL) {
1138 if (layout == NULL) {
1147 if (description->
modal) {
1148 if (topLayout != NULL) {
1150 topLayout->
top = layout;
1151 layout->
bottom = topLayout;
1162 gLayout[0].top = backgroundTop;
1165 nbTouchableControls = 0;
1170 if (description->
modal) {
1195 if (description->tapActionText != NULL) {
1197 const char *tapActionText = PIC(description->tapActionText);
1202 obj->
token = description->tapActionToken;
1203 obj->
tuneId = description->tapTuneId;
1207 if (strlen(tapActionText) > 0) {
1208 nbgl_layoutUpFooter_t footerDesc = {0};
1209 footerDesc.type = UP_FOOTER_TEXT;
1210 footerDesc.text.text = tapActionText;
1211 footerDesc.text.token = description->tapActionToken;
1212 footerDesc.text.tuneId = description->tapTuneId;
1213 nbgl_layoutAddUpFooter((
nbgl_layout_t *) layout, &footerDesc);
1231 uint16_t swipesMask,
1234 tune_index_e tuneId)
1239 if (layout == NULL) {
1246 layoutInt->
tapText->text = PIC(text);
1248 layoutInt->
tapText->fontId = SMALL_REGULAR_FONT;
1252 layoutInt->
tapText->obj.alignmentMarginY = TAP_TO_CONTINUE_MARGIN;
1270 if (layout == NULL) {
1300 tune_index_e tuneId)
1307 if (layout == NULL) {
1317 button->obj.area.width = BUTTON_WIDTH;
1318 button->obj.area.height = BUTTON_DIAMETER;
1319 button->radius = BUTTON_RADIUS;
1320 button->obj.alignmentMarginX = BORDER_MARGIN;
1321 button->obj.alignmentMarginY = BORDER_MARGIN;
1322 button->foregroundColor =
BLACK;
1323 button->innerColor =
WHITE;
1325 button->obj.touchMask = (1 <<
TOUCHED);
1327 button->icon = PIC(icon);
1345 nbgl_layoutFooter_t footerDesc = {0};
1346 footerDesc.type = FOOTER_NAV;
1348 footerDesc.navigation.activePage = info->
activePage;
1349 footerDesc.navigation.nbPages = info->
nbPages;
1350 footerDesc.navigation.withExitKey = info->
withExitKey;
1351 footerDesc.navigation.withBackKey = info->
withBackKey;
1352 footerDesc.navigation.token = info->
token;
1353 footerDesc.navigation.tuneId = info->
tuneId;
1354 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
1371 bool separationLine,
1372 tune_index_e tuneId)
1375 nbgl_layoutFooter_t footerDesc = {0};
1376 footerDesc.type = FOOTER_SIMPLE_BUTTON;
1377 footerDesc.separationLine = separationLine;
1378 footerDesc.button.icon = PIC(icon);
1379 footerDesc.button.token = token;
1380 footerDesc.button.tuneId = tuneId;
1382 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
1396 listItem_t itemDesc = {0};
1399 if (layout == NULL) {
1403 if (barLayout->
text == NULL) {
1407 itemDesc.iconLeft = barLayout->
iconLeft;
1408 itemDesc.iconRight = barLayout->
iconRight;
1409 itemDesc.text = barLayout->
text;
1410 itemDesc.subText = barLayout->
subText;
1411 itemDesc.token = barLayout->
token;
1412 itemDesc.tuneId = barLayout->
tuneId;
1414 itemDesc.large = barLayout->
large;
1415 itemDesc.type = TOUCHABLE_BAR_ITEM;
1416 container = addListItem(layoutInt, &itemDesc);
1418 if (container == NULL) {
1422 return container->obj.area.height;
1436 listItem_t itemDesc = {0};
1439 if (layout == NULL) {
1443 if (switchLayout->
text == NULL) {
1447 itemDesc.text = switchLayout->
text;
1448 itemDesc.subText = switchLayout->
subText;
1449 itemDesc.token = switchLayout->
token;
1450 itemDesc.tuneId = switchLayout->
tuneId;
1451 itemDesc.state = switchLayout->
initState;
1452 itemDesc.type = SWITCH_ITEM;
1453 container = addListItem(layoutInt, &itemDesc);
1455 if (container == NULL) {
1459 return container->obj.area.height;
1474 listItem_t itemDesc = {0};
1477 if (layout == NULL) {
1481 itemDesc.text = text;
1482 itemDesc.subText = subText;
1485 itemDesc.type = TEXT_ITEM;
1486 container = addListItem(layoutInt, &itemDesc);
1488 if (container == NULL) {
1492 return container->obj.area.height;
1508 const char *subText,
1514 listItem_t itemDesc = {0};
1516 if (layout == NULL) {
1520 itemDesc.text = text;
1521 itemDesc.subText = subText;
1522 itemDesc.iconRight = &MINI_PUSH_ICON;
1523 itemDesc.token = token;
1525 itemDesc.type = TOUCHABLE_BAR_ITEM;
1526 itemDesc.index = index;
1528 container = addListItem(layoutInt, &itemDesc);
1530 if (container == NULL) {
1534 return container->obj.area.height;
1545int nbgl_layoutAddLargeCaseText(
nbgl_layout_t *layout,
const char *text,
bool grayedOut)
1551 if (layout == NULL) {
1557 textArea->text = PIC(text);
1558 textArea->textAlignment =
MID_LEFT;
1559 textArea->fontId = LARGE_MEDIUM_FONT;
1561 textArea->wrapping =
true;
1563 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1566 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1567 if (layoutInt->
container->nbChildren == 0) {
1569 textArea->obj.alignmentMarginY += PRE_FIRST_TEXT_MARGIN;
1572 textArea->obj.alignmentMarginY = INTER_PARAGRAPHS_MARGIN;
1598 if (layout == NULL) {
1603 if (content->
title != NULL) {
1605 textArea->textColor =
BLACK;
1606 textArea->text = PIC(content->
title);
1607 textArea->textAlignment =
MID_LEFT;
1608 textArea->fontId = LARGE_MEDIUM_FONT;
1610 textArea->wrapping =
true;
1612 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1613 textArea->obj.alignmentMarginY = PRE_TITLE_MARGIN;
1616 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1624 textArea->textColor =
BLACK;
1626 textArea->fontId = SMALL_REGULAR_FONT;
1628 textArea->wrapping =
true;
1631 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1632 textArea->textAlignment =
MID_LEFT;
1634 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1635 textArea->obj.alignmentMarginY
1636 = (i == 0) ? PRE_DESCRIPTION_MARGIN : INTER_DESCRIPTIONS_MARGIN;
1642 if (content->
info != NULL) {
1645 textArea->text = PIC(content->
info);
1646 textArea->fontId = SMALL_REGULAR_FONT;
1648 textArea->wrapping =
true;
1651 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1652 textArea->textAlignment =
MID_LEFT;
1654 textArea->obj.alignmentMarginX = BORDER_MARGIN;
1655 textArea->obj.alignmentMarginY = 40;
1660 return layoutInt->
container->obj.area.height;
1677 if (layout == NULL) {
1680 for (i = 0; i < choices->
nbChoices; i++) {
1698 container->nbChildren = 2;
1701 container->obj.area.height = RADIO_CHOICE_HEIGHT;
1703 container->obj.alignmentMarginX = BORDER_MARGIN;
1704 container->obj.alignTo = (
nbgl_obj_t *) NULL;
1707 button->activeColor =
BLACK;
1709 button->obj.alignTo = (
nbgl_obj_t *) container;
1712 container->children[1] = (
nbgl_obj_t *) button;
1716#ifdef HAVE_LANGUAGE_PACK
1717 textArea->text = get_ux_loc_string(choices->nameIds[i]);
1721 textArea->text = PIC(choices->
names[i]);
1723 textArea->textAlignment =
MID_LEFT;
1724 textArea->obj.area.width = container->obj.area.width - RADIO_WIDTH;
1726 textArea->obj.alignment =
MID_LEFT;
1727 textArea->obj.alignTo = (
nbgl_obj_t *) container;
1728 container->children[0] = (
nbgl_obj_t *) textArea;
1731 container->obj.touchMask = (1 <<
TOUCHED);
1732 container->obj.touchId =
CONTROLS_ID + nbTouchableControls;
1733 nbTouchableControls++;
1738 textArea->textColor =
BLACK;
1739 textArea->fontId = SMALL_BOLD_FONT;
1744 textArea->fontId = SMALL_REGULAR_FONT;
1748 line = createHorizontalLine(layoutInt->
layer);
1749 line->obj.alignmentMarginY = -1;
1774 if (layout == NULL) {
1781 if (info->
text1 != NULL) {
1782 if (info->
style != NORMAL_INFO) {
1789 if (info->
text2 != NULL) {
1790 if (info->
style != LARGE_CASE_BOLD_INFO) {
1797 if (info->text3 != NULL) {
1798 if (info->
style == LARGE_CASE_GRAY_INFO) {
1799 centeredInfo.
subText = info->text3;
1805 container = addContentCenter(layoutInt, ¢eredInfo);
1808 container->obj.alignmentMarginX = BORDER_MARGIN;
1809 container->obj.alignmentMarginY = BORDER_MARGIN + info->offsetY;
1813 container->obj.alignmentMarginY = info->offsetY;
1816 return container->obj.area.height;
1833 if (layout == NULL) {
1837 container = addContentCenter(layoutInt, info);
1839 return container->obj.area.height;
1857 if (layout == NULL) {
1863 container->nbChildren = info->
nbRows + 1;
1867 container->obj.alignmentMarginX = BORDER_MARGIN;
1871 textArea->textColor =
BLACK;
1872 textArea->text = PIC(info->
title);
1873 textArea->textAlignment =
MID_LEFT;
1874 textArea->fontId = LARGE_MEDIUM_FONT;
1875 textArea->wrapping =
true;
1877 textArea->obj.alignmentMarginY = 24;
1881 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1883 container->obj.area.height += textArea->obj.area.height + textArea->obj.alignmentMarginY;
1885 container->children[0] = (
nbgl_obj_t *) textArea;
1887 for (row = 0; row < info->
nbRows; row++) {
1893 rowContainer->nbChildren = 2;
1898 image->foregroundColor =
BLACK;
1899 image->buffer = PIC(info->
rowIcons[row]);
1900 rowContainer->children[0] = (
nbgl_obj_t *) image;
1903 textArea->textColor =
BLACK;
1904 textArea->text = PIC(info->
rowTexts[row]);
1905 textArea->textAlignment =
MID_LEFT;
1906 textArea->fontId = SMALL_REGULAR_FONT;
1907 textArea->wrapping =
true;
1908 textArea->obj.area.width
1911 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1913 rowContainer->children[1] = (
nbgl_obj_t *) textArea;
1914 rowContainer->obj.area.height
1915 =
MAX(image->buffer->height, textArea->obj.area.height + LEFT_CONTENT_TEXT_PADDING);
1918 rowContainer->obj.alignmentMarginY = PRE_FIRST_ROW_MARGIN;
1921 rowContainer->obj.alignmentMarginY = INTER_ROWS_MARGIN;
1923 container->children[1 + row] = (
nbgl_obj_t *) rowContainer;
1924 container->obj.area.height
1925 += rowContainer->obj.area.height + rowContainer->obj.alignmentMarginY;
1929 return container->obj.area.height;
1941int nbgl_layoutAddQRCode(
nbgl_layout_t *layout,
const nbgl_layoutQRCode_t *info)
1947 uint16_t fullHeight = 0;
1950 if (layout == NULL) {
1958 container->nbChildren = 0;
1962 if (strlen(PIC(info->url)) > 62) {
1968 qrcode->foregroundColor =
BLACK;
1974 qrcode->obj.area.width
1977 qrcode->obj.area.width
1980 qrcode->obj.area.height = qrcode->obj.area.width;
1981 qrcode->text = PIC(info->url);
1985 fullHeight += qrcode->obj.area.height;
1986 container->children[container->nbChildren] = (
nbgl_obj_t *) qrcode;
1987 container->nbChildren++;
1989 if (info->text1 != NULL) {
1991 textArea->textColor =
BLACK;
1992 textArea->text = PIC(info->text1);
1993 textArea->textAlignment =
CENTER;
1994 textArea->fontId = (info->largeText1 ==
true) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
1995 textArea->wrapping =
true;
1998 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2000 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
2001 textArea->obj.alignmentMarginY = QR_PRE_TEXT_MARGIN;
2003 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
2005 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
2006 container->nbChildren++;
2008 if (info->text2 != NULL) {
2011 textArea->text = PIC(info->text2);
2012 textArea->textAlignment =
CENTER;
2013 textArea->fontId = SMALL_REGULAR_FONT;
2014 textArea->wrapping =
true;
2017 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2019 textArea->obj.alignTo = (
nbgl_obj_t *) container->children[container->nbChildren - 1];
2020 if (info->text1 != NULL) {
2021 textArea->obj.alignmentMarginY = QR_INTER_TEXTS_MARGIN;
2024 textArea->obj.alignmentMarginY = QR_PRE_TEXT_MARGIN + 8;
2027 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY + 8;
2029 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
2030 container->nbChildren++;
2033 if ((fullHeight >= (layoutInt->
container->obj.area.height - 16))
2038 qrcode->obj.area.height = qrcode->obj.area.width;
2041 container->obj.area.height = fullHeight;
2043 if (info->centered) {
2044 container->obj.alignment =
CENTER;
2048 container->obj.alignTo
2051 container->obj.alignmentMarginY = info->offsetY;
2070int nbgl_layoutAddChoiceButtons(
nbgl_layout_t *layout,
const nbgl_layoutChoiceButtons_t *info)
2072 nbgl_layoutFooter_t footerDesc = {0};
2073 footerDesc.type = FOOTER_CHOICE_BUTTONS;
2074 footerDesc.choiceButtons.bottomText = info->bottomText;
2075 footerDesc.choiceButtons.token = info->token;
2076 footerDesc.choiceButtons.topText = info->topText;
2077 footerDesc.choiceButtons.topIcon = info->topIcon;
2078 footerDesc.choiceButtons.style = info->style;
2079 footerDesc.choiceButtons.tuneId = info->tuneId;
2080 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
2093 const nbgl_layoutHorizontalButtons_t *info)
2095 nbgl_layoutUpFooter_t upFooterDesc = {.type = UP_FOOTER_HORIZONTAL_BUTTONS,
2096 .horizontalButtons.leftIcon = info->leftIcon,
2097 .horizontalButtons.leftToken = info->leftToken,
2098 .horizontalButtons.rightText = info->rightText,
2099 .horizontalButtons.rightToken = info->rightToken,
2100 .horizontalButtons.tuneId = info->tuneId};
2103 return nbgl_layoutAddUpFooter(layout, &upFooterDesc);
2120 if (layout == NULL) {
2128 if ((list->
pairs == NULL)
2134 for (i = 0; i < list->
nbPairs; i++) {
2136 uint16_t fullHeight = 0;
2140 uint8_t nbChildren = 2;
2143 if (list->
pairs != NULL) {
2144 pair = &list->
pairs[i];
2150 "nbgl_layoutAddTagValueList(): callback returned NULL for index %d\n",
2162 if (valueIcon != NULL) {
2178 itemTextArea->text = PIC(pair->
item);
2179 itemTextArea->textAlignment =
MID_LEFT;
2180 itemTextArea->fontId = SMALL_REGULAR_FONT;
2181 itemTextArea->wrapping =
true;
2184 itemTextArea->fontId, itemTextArea->text,
AVAILABLE_WIDTH, itemTextArea->wrapping);
2185 container->children[container->nbChildren] = (
nbgl_obj_t *) itemTextArea;
2186 container->nbChildren++;
2188 fullHeight += itemTextArea->obj.area.height;
2191 valueTextArea->textColor =
BLACK;
2192 valueTextArea->text = PIC(pair->
value);
2193 valueTextArea->textAlignment =
MID_LEFT;
2206 valueTextArea->text,
2207 valueTextArea->obj.area.width,
2210 if ((nbMaxLines > 0) && (nbLines > nbMaxLines)) {
2211 nbLines = nbMaxLines;
2212 valueTextArea->nbMaxLines = nbMaxLines;
2216 valueTextArea->obj.area.height = nbLines * font->
line_height;
2218 valueTextArea->obj.alignmentMarginY = TAG_VALUE_INTERVALE;
2219 valueTextArea->obj.alignTo = (
nbgl_obj_t *) itemTextArea;
2220 valueTextArea->wrapping = list->
wrapping;
2221 container->children[container->nbChildren] = (
nbgl_obj_t *) valueTextArea;
2222 container->nbChildren++;
2224 fullHeight += valueTextArea->obj.area.height + valueTextArea->obj.alignmentMarginY;
2225 if (valueIcon != NULL) {
2231 image->foregroundColor =
BLACK;
2232 image->buffer = valueIcon;
2234 image->obj.alignmentMarginX = VALUE_ICON_INTERVALE;
2235 image->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2237 container->obj.touchMask = (1 <<
TOUCHED);
2240 container->children[container->nbChildren] = (
nbgl_obj_t *) image;
2241 container->nbChildren++;
2248 textArea->textColor =
BLACK;
2250 textArea->textAlignment =
MID_LEFT;
2251 textArea->nbMaxLines = 1;
2252 textArea->fontId = SMALL_REGULAR_FONT;
2254 textArea->obj.area.width = valueTextArea->obj.area.width;
2256 textArea->obj.alignmentMarginY = TAG_VALUE_INTERVALE;
2257 textArea->obj.alignTo = (
nbgl_obj_t *) valueTextArea;
2258 textArea->wrapping = list->
wrapping;
2259 textArea->hideEndOfLastLine
2261 > textArea->obj.area.width);
2262 container->children[container->nbChildren] = (
nbgl_obj_t *) textArea;
2263 container->nbChildren++;
2264 fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
2269 container->obj.area.height = fullHeight;
2271 container->obj.alignmentMarginX = BORDER_MARGIN;
2273 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2281 container->obj.alignmentMarginY = INTER_TAG_VALUE_MARGIN;
2284 container->obj.alignmentMarginY = PRE_TAG_VALUE_MARGIN;
2309 const char *subText,
2318 if (layout == NULL) {
2325 container->nbChildren = (subText != NULL) ? 3 : 2;
2330 container->obj.alignment =
CENTER;
2334 progress->foregroundColor =
BLACK;
2335 progress->withBorder =
true;
2336 progress->state = percentage;
2337 progress->obj.area.width = PROGRESSBAR_WIDTH;
2338 progress->obj.area.height = PROGRESSBAR_HEIGHT;
2342 container->children[0] = (
nbgl_obj_t *) progress;
2345 container->obj.area.height = progress->obj.alignmentMarginY + progress->obj.area.height;
2349 textArea->textColor =
BLACK;
2350 textArea->text = PIC(text);
2351 textArea->textAlignment =
CENTER;
2352 textArea->fontId = LARGE_MEDIUM_FONT;
2353 textArea->wrapping =
true;
2354 textArea->obj.alignmentMarginY = BAR_TEXT_MARGIN;
2355 textArea->obj.alignTo = (
nbgl_obj_t *) progress;
2359 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
2363 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
2366 container->children[1] = (
nbgl_obj_t *) textArea;
2368 if (subText != NULL) {
2372 subTextArea->textColor =
BLACK;
2373 subTextArea->text = PIC(subText);
2374 subTextArea->textAlignment =
CENTER;
2375 subTextArea->fontId = SMALL_REGULAR_FONT;
2376 subTextArea->wrapping =
true;
2377 subTextArea->obj.alignmentMarginY = BAR_INTER_TEXTS_MARGIN;
2378 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
2383 subTextArea->obj.area.width,
2384 subTextArea->wrapping);
2388 container->obj.area.height
2389 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
2392 container->children[2] = (
nbgl_obj_t *) subTextArea;
2395 container->obj.area.height = (container->obj.area.height + 7) & 0xFFF8;
2414 line = createHorizontalLine(layoutInt->
layer);
2415 line->obj.alignmentMarginY = -1;
2434 if (layout == NULL) {
2439 if ((buttonInfo->onBottom) && (!buttonInfo->fittingContent)) {
2441 nbgl_layoutFooter_t footerDesc = {0};
2442 footerDesc.type = FOOTER_SIMPLE_BUTTON;
2443 footerDesc.button.text = buttonInfo->
text;
2444 footerDesc.button.token = buttonInfo->token;
2445 footerDesc.button.tuneId = buttonInfo->tuneId;
2446 footerDesc.button.
icon = buttonInfo->
icon;
2447 footerDesc.button.style = buttonInfo->
style;
2448 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
2451 nbgl_layoutUpFooter_t upFooterDesc = {0};
2452 upFooterDesc.type = UP_FOOTER_BUTTON;
2453 upFooterDesc.button.text = buttonInfo->
text;
2454 upFooterDesc.button.token = buttonInfo->token;
2455 upFooterDesc.button.tuneId = buttonInfo->tuneId;
2456 upFooterDesc.button.
icon = buttonInfo->
icon;
2457 upFooterDesc.button.style = buttonInfo->
style;
2458 return nbgl_layoutAddUpFooter(layout, &upFooterDesc);
2464 layoutInt, (
nbgl_obj_t *) button, buttonInfo->token, buttonInfo->tuneId);
2470 button->obj.alignmentMarginX = BORDER_MARGIN;
2471 button->obj.alignmentMarginY = 12;
2473 if (buttonInfo->
style == BLACK_BACKGROUND) {
2474 button->innerColor =
BLACK;
2475 button->foregroundColor =
WHITE;
2478 button->innerColor =
WHITE;
2479 button->foregroundColor =
BLACK;
2481 if (buttonInfo->
style == NO_BORDER) {
2482 button->borderColor =
WHITE;
2485 if (buttonInfo->
style == BLACK_BACKGROUND) {
2486 button->borderColor =
BLACK;
2492 button->text = PIC(buttonInfo->
text);
2493 button->fontId = SMALL_BOLD_FONT;
2494 button->icon = PIC(buttonInfo->
icon);
2495 if (buttonInfo->fittingContent ==
true) {
2497 + SMALL_BUTTON_HEIGHT
2498 + ((button->icon) ? (button->icon->width + 12) : 0);
2499 button->obj.area.height = SMALL_BUTTON_HEIGHT;
2500 button->radius = SMALL_BUTTON_RADIUS_INDEX;
2501 if (buttonInfo->onBottom !=
true) {
2502 button->obj.alignmentMarginX += (
AVAILABLE_WIDTH - button->obj.area.width) / 2;
2507 button->obj.area.height = BUTTON_DIAMETER;
2508 button->radius = BUTTON_RADIUS;
2510 button->obj.alignTo = NULL;
2511 button->obj.touchMask = (1 <<
TOUCHED);
2531 tune_index_e tuneId)
2533 nbgl_layoutUpFooter_t upFooterDesc = {.type = UP_FOOTER_LONG_PRESS,
2534 .longPress.text = text,
2535 .longPress.token = token,
2536 .longPress.tuneId = tuneId};
2539 if (layout == NULL) {
2543 return nbgl_layoutAddUpFooter(layout, &upFooterDesc);
2559 tune_index_e tuneId)
2561 nbgl_layoutFooter_t footerDesc = {0};
2562 footerDesc.type = FOOTER_SIMPLE_TEXT;
2563 footerDesc.separationLine =
true;
2564 footerDesc.simpleText.text = text;
2565 footerDesc.simpleText.token = token;
2566 footerDesc.simpleText.tuneId = tuneId;
2567 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
2583 const char *leftText,
2585 const char *rightText,
2587 tune_index_e tuneId)
2589 nbgl_layoutFooter_t footerDesc = {0};
2590 footerDesc.type = FOOTER_DOUBLE_TEXT;
2591 footerDesc.separationLine =
true;
2592 footerDesc.doubleText.leftText = leftText;
2593 footerDesc.doubleText.leftToken = leftToken;
2594 footerDesc.doubleText.rightText = rightText;
2595 footerDesc.doubleText.rightToken = rightToken;
2596 footerDesc.doubleText.tuneId = tuneId;
2597 return nbgl_layoutAddExtendedFooter(layout, &footerDesc);
2608int nbgl_layoutAddHeader(
nbgl_layout_t *layout,
const nbgl_layoutHeader_t *headerDesc)
2618 if (layout == NULL) {
2621 if ((headerDesc == NULL) || (headerDesc->type >= NB_HEADER_TYPES)) {
2632 switch (headerDesc->type) {
2633 case HEADER_EMPTY: {
2634 layoutInt->
headerContainer->obj.area.height = headerDesc->emptySpace.height;
2637 case HEADER_BACK_AND_TEXT:
2638 case HEADER_BACK_ICON_AND_TEXT:
2639 case HEADER_EXTENDED_BACK: {
2640 const char *text = (headerDesc->type == HEADER_EXTENDED_BACK)
2641 ? PIC(headerDesc->extendedBack.text)
2642 : PIC(headerDesc->backAndText.text);
2643 uint8_t backToken = (headerDesc->type == HEADER_EXTENDED_BACK)
2644 ? headerDesc->extendedBack.backToken
2645 : headerDesc->backAndText.token;
2653 (headerDesc->type == HEADER_EXTENDED_BACK)
2654 ? headerDesc->extendedBack.tuneId
2655 : headerDesc->backAndText.tuneId);
2658 "nbgl_layoutAddHeader(): no more callback obj for type %d\n",
2663 button->innerColor =
WHITE;
2664 button->foregroundColor =
BLACK;
2665 button->borderColor =
WHITE;
2666 button->obj.area.width = BACK_KEY_WIDTH;
2667 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2668 button->text = NULL;
2669 button->icon = PIC(&LEFT_ARROW_ICON);
2670 button->obj.touchMask = (1 <<
TOUCHED);
2680 if (headerDesc->type == HEADER_BACK_ICON_AND_TEXT) {
2682 image->buffer = PIC(headerDesc->backAndText.icon);
2683 image->foregroundColor =
BLACK;
2684 image->obj.alignment =
CENTER;
2690 if ((headerDesc->type == HEADER_EXTENDED_BACK)
2694 headerDesc->extendedBack.textToken,
2695 headerDesc->extendedBack.tuneId);
2698 "nbgl_layoutAddHeader(): no more callback obj for type %d\n",
2702 textArea->obj.touchMask = (1 <<
TOUCHED);
2704 textArea->obj.alignment =
CENTER;
2705 textArea->textColor =
BLACK;
2706 textArea->obj.area.width
2709 if (headerDesc->type == HEADER_BACK_ICON_AND_TEXT) {
2710 textArea->obj.area.width -= 16 + image->buffer->width;
2712 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2713 textArea->text = text;
2714 textArea->fontId = SMALL_BOLD_FONT;
2715 textArea->textAlignment =
CENTER;
2716 textArea->wrapping =
true;
2717 uint8_t nbMaxLines = (headerDesc->type == HEADER_BACK_ICON_AND_TEXT) ? 1 : 2;
2721 textArea->obj.area.width,
2724 textArea->obj.area.height
2726#ifndef BUILD_SCREENSHOTS
2728 "nbgl_layoutAddHeader: text [%s] is too long for header\n",
2732 if (headerDesc->type == HEADER_BACK_ICON_AND_TEXT) {
2739 if (headerDesc->type == HEADER_BACK_ICON_AND_TEXT) {
2740 textArea->obj.alignmentMarginX = 8 + image->buffer->width / 2;
2741 image->obj.alignmentMarginX = -8 - textArea->obj.area.width / 2;
2745 if ((headerDesc->type == HEADER_EXTENDED_BACK)
2746 && (headerDesc->extendedBack.actionIcon)) {
2752 headerDesc->extendedBack.actionToken,
2753 headerDesc->extendedBack.tuneId);
2756 "nbgl_layoutAddHeader(): no more callback obj for type %d\n",
2760 actionButton->obj.touchMask = (1 <<
TOUCHED);
2763 actionButton->obj.alignment =
MID_RIGHT;
2764 actionButton->innerColor =
WHITE;
2765 actionButton->foregroundColor
2768 actionButton->borderColor =
WHITE;
2769 actionButton->obj.area.width = BACK_KEY_WIDTH;
2770 actionButton->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2771 actionButton->text = NULL;
2772 actionButton->icon = PIC(headerDesc->extendedBack.actionIcon);
2779 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2781 if ((headerDesc->type == HEADER_EXTENDED_BACK)
2782 && (headerDesc->extendedBack.subText != NULL)) {
2785 line = createHorizontalLine(layoutInt->
layer);
2787 line->obj.alignmentMarginY = TOUCHABLE_HEADER_BAR_HEIGHT;
2793 subTextArea->textColor =
BLACK;
2794 subTextArea->text = PIC(headerDesc->extendedBack.subText);
2795 subTextArea->textAlignment =
MID_LEFT;
2796 subTextArea->fontId = SMALL_REGULAR_FONT;
2797 subTextArea->wrapping =
true;
2799 subTextArea->obj.alignmentMarginY = SUB_HEADER_MARGIN;
2801 subTextArea->obj.area.height
2804 subTextArea->obj.area.width,
2805 subTextArea->wrapping);
2810 += subTextArea->obj.area.height + 2 * SUB_HEADER_MARGIN;
2812 if (button != NULL) {
2813 button->obj.alignmentMarginY
2814 -= (subTextArea->obj.area.height + 2 * SUB_HEADER_MARGIN) / 2;
2816 if (textArea != NULL) {
2817 textArea->obj.alignmentMarginY
2818 -= (subTextArea->obj.area.height + 2 * SUB_HEADER_MARGIN) / 2;
2820 if (actionButton != NULL) {
2821 actionButton->obj.alignmentMarginY
2822 -= (subTextArea->obj.area.height + 2 * SUB_HEADER_MARGIN) / 2;
2827 case HEADER_BACK_AND_PROGRESS: {
2830 if (headerDesc->progressAndBack.withBack) {
2834 headerDesc->progressAndBack.token,
2835 headerDesc->progressAndBack.tuneId);
2838 "nbgl_layoutAddHeader(): no more callback obj for type %d\n",
2844 button->innerColor =
WHITE;
2845 button->foregroundColor =
BLACK;
2846 button->borderColor =
WHITE;
2847 button->obj.area.width = BACK_KEY_WIDTH;
2848 button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2849 button->text = NULL;
2850 button->icon = PIC(&LEFT_ARROW_ICON);
2851 button->obj.touchMask = (1 <<
TOUCHED);
2860 if (headerDesc->progressAndBack.nbPages > 1
2866 progress->activePage = headerDesc->progressAndBack.activePage;
2867 progress->nbPages = headerDesc->progressAndBack.nbPages;
2868 progress->obj.area.width = 224;
2869 progress->obj.alignment =
CENTER;
2875 layoutInt->
activePage = headerDesc->progressAndBack.activePage;
2876 layoutInt->
nbPages = headerDesc->progressAndBack.nbPages;
2877 layoutInt->
headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2881 case HEADER_TITLE: {
2883 textArea->textColor =
BLACK;
2885 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2886 textArea->text = PIC(headerDesc->title.text);
2887 textArea->fontId = SMALL_BOLD_FONT;
2888 textArea->textAlignment =
CENTER;
2889 textArea->wrapping =
true;
2893 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2896 case HEADER_RIGHT_TEXT: {
2900 headerDesc->rightText.token,
2901 headerDesc->rightText.tuneId);
2904 "nbgl_layoutAddHeader(): no more callback obj for type %d\n",
2909 textArea->obj.alignmentMarginX = BORDER_MARGIN;
2910 textArea->textColor =
BLACK;
2912 textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
2913 textArea->text = PIC(headerDesc->rightText.text);
2914 textArea->fontId = SMALL_BOLD_FONT;
2916 textArea->obj.touchMask = (1 <<
TOUCHED);
2922 layoutInt->
headerContainer->obj.area.height = textArea->obj.area.height;
2929 if (headerDesc->separationLine) {
2930 line = createHorizontalLine(layoutInt->
layer);
2957int nbgl_layoutAddExtendedFooter(
nbgl_layout_t *layout,
const nbgl_layoutFooter_t *footerDesc)
2966 if (layout == NULL) {
2969 if ((footerDesc == NULL) || (footerDesc->type >= NB_FOOTER_TYPES)) {
2980 switch (footerDesc->type) {
2981 case FOOTER_EMPTY: {
2982 layoutInt->
footerContainer->obj.area.height = footerDesc->emptySpace.height;
2985 case FOOTER_SIMPLE_TEXT: {
2989 footerDesc->simpleText.token,
2990 footerDesc->simpleText.tuneId);
2999 textArea->obj.area.height
3000 = (footerDesc->simpleText.mutedOut) ? SMALL_FOOTER_HEIGHT : SIMPLE_FOOTER_HEIGHT;
3001 textArea->text = PIC(footerDesc->simpleText.text);
3003 = (footerDesc->simpleText.mutedOut) ? SMALL_REGULAR_FONT : SMALL_BOLD_FONT;
3004 textArea->textAlignment =
CENTER;
3005 textArea->obj.touchMask = (1 <<
TOUCHED);
3010 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
3013 case FOOTER_DOUBLE_TEXT: {
3017 footerDesc->doubleText.leftToken,
3018 footerDesc->doubleText.tuneId);
3024 textArea->textColor =
BLACK;
3026 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
3027 textArea->text = PIC(footerDesc->doubleText.leftText);
3028 textArea->fontId = SMALL_BOLD_FONT;
3029 textArea->textAlignment =
CENTER;
3030 textArea->obj.touchMask = (1 <<
TOUCHED);
3041 footerDesc->doubleText.rightToken,
3042 footerDesc->doubleText.tuneId);
3049 textArea->textColor =
BLACK;
3051 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
3052 textArea->text = PIC(footerDesc->doubleText.rightText);
3053 textArea->fontId = SMALL_BOLD_FONT;
3054 textArea->textAlignment =
CENTER;
3055 textArea->obj.touchMask = (1 <<
TOUCHED);
3061 layoutInt->
footerContainer->obj.area.height = textArea->obj.area.height;
3066 separationLine->obj.area.width = 1;
3067 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
3068 separationLine->direction =
VERTICAL;
3069 separationLine->thickness = 1;
3070 separationLine->obj.alignment =
MID_LEFT;
3071 separationLine->obj.alignTo = (
nbgl_obj_t *) textArea;
3072 separationLine->obj.alignmentMarginX = -1;
3075 case FOOTER_TEXT_AND_NAV: {
3081 footerDesc->textAndNav.token,
3082 footerDesc->textAndNav.tuneId);
3088 textArea->textColor =
BLACK;
3089 textArea->obj.area.width = FOOTER_TEXT_AND_NAV_WIDTH;
3090 textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT;
3091 textArea->text = PIC(footerDesc->textAndNav.text);
3092 textArea->fontId = SMALL_BOLD_FONT;
3093 textArea->textAlignment =
CENTER;
3094 textArea->obj.touchMask = (1 <<
TOUCHED);
3106 navContainer->nbChildren = 4;
3107 navContainer->children
3110 navContainer->obj.area.width =
SCREEN_WIDTH - textArea->obj.area.width;
3111 navContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT;
3115 footerDesc->textAndNav.navigation.token,
3116 footerDesc->textAndNav.navigation.tuneId);
3125 separationLine->obj.area.width = 1;
3126 separationLine->obj.area.height = layoutInt->
footerContainer->obj.area.height;
3127 separationLine->direction =
VERTICAL;
3128 separationLine->thickness = 1;
3129 separationLine->obj.alignment =
MID_LEFT;
3130 separationLine->obj.alignTo = (
nbgl_obj_t *) navContainer;
3131 separationLine->obj.alignmentMarginX = -1;
3133 layoutInt->
activePage = footerDesc->textAndNav.navigation.activePage;
3134 layoutInt->
nbPages = footerDesc->textAndNav.navigation.nbPages;
3148 footerDesc->navigation.token,
3149 footerDesc->navigation.tuneId);
3155 layoutInt->
activePage = footerDesc->navigation.activePage;
3156 layoutInt->
nbPages = footerDesc->navigation.nbPages;
3159 case FOOTER_SIMPLE_BUTTON: {
3163 footerDesc->button.token,
3164 footerDesc->button.tuneId);
3171 button->obj.alignmentMarginY = SINGLE_BUTTON_MARGIN;
3172 if (footerDesc->button.style == BLACK_BACKGROUND) {
3173 button->innerColor =
BLACK;
3174 button->foregroundColor =
WHITE;
3177 button->innerColor =
WHITE;
3178 button->foregroundColor =
BLACK;
3181 if (footerDesc->button.style == NO_BORDER) {
3182 button->borderColor =
WHITE;
3185 if (footerDesc->button.style == BLACK_BACKGROUND) {
3186 button->borderColor =
BLACK;
3192 button->text = PIC(footerDesc->button.text);
3193 button->fontId = SMALL_BOLD_FONT;
3194 button->icon = PIC(footerDesc->button.icon);
3195 button->radius = BUTTON_RADIUS;
3196 button->obj.area.height = BUTTON_DIAMETER;
3198 if (footerDesc->button.text == NULL) {
3199 button->obj.area.width = BUTTON_DIAMETER;
3204 button->obj.touchMask = (1 <<
TOUCHED);
3212 case FOOTER_CHOICE_BUTTONS: {
3214 if ((footerDesc->choiceButtons.bottomText == NULL)
3215 || (footerDesc->choiceButtons.topText == NULL)) {
3217 "nbgl_layoutAddFooter(): FOOTER_CHOICE_BUTTONS texts cannot be NULL\n");
3225 footerDesc->choiceButtons.token,
3226 footerDesc->choiceButtons.tuneId);
3235 button->innerColor =
WHITE;
3236 if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) {
3237 button->obj.alignmentMarginY
3238 = SINGLE_BUTTON_MARGIN;
3240 button->obj.area.height = BUTTON_DIAMETER;
3243 button->obj.alignmentMarginY
3244 = BUTTON_FROM_BOTTOM_MARGIN;
3245 button->borderColor =
WHITE;
3246 button->obj.area.height = FOOTER_IN_PAIR_HEIGHT;
3248 button->foregroundColor =
BLACK;
3250 button->radius = BUTTON_RADIUS;
3251 button->text = PIC(footerDesc->choiceButtons.bottomText);
3252 button->fontId = SMALL_BOLD_FONT;
3253 button->obj.touchMask = (1 <<
TOUCHED);
3261 if ((footerDesc->choiceButtons.style != ROUNDED_AND_FOOTER_STYLE)
3262 && (footerDesc->choiceButtons.style != BOTH_ROUNDED_STYLE)) {
3263 line = createHorizontalLine(layoutInt->
layer);
3275 footerDesc->choiceButtons.token,
3276 footerDesc->choiceButtons.tuneId);
3284 if (footerDesc->choiceButtons.style == ROUNDED_AND_FOOTER_STYLE) {
3285 button->obj.alignmentMarginY = TOP_BUTTON_MARGIN;
3287 else if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) {
3288 button->obj.alignmentMarginY
3289 = SINGLE_BUTTON_MARGIN;
3292 button->obj.alignmentMarginY
3293 = TOP_BUTTON_MARGIN_WITH_ACTION;
3295 if (footerDesc->choiceButtons.style == SOFT_ACTION_AND_FOOTER_STYLE) {
3296 button->innerColor =
WHITE;
3298 button->foregroundColor =
BLACK;
3301 button->innerColor =
BLACK;
3302 button->borderColor =
BLACK;
3303 button->foregroundColor =
WHITE;
3306 button->obj.area.height = BUTTON_DIAMETER;
3307 button->radius = BUTTON_RADIUS;
3308 button->text = PIC(footerDesc->choiceButtons.topText);
3309 button->icon = (footerDesc->choiceButtons.style != ROUNDED_AND_FOOTER_STYLE)
3310 ? PIC(footerDesc->choiceButtons.topIcon)
3312 button->fontId = SMALL_BOLD_FONT;
3313 button->obj.touchMask = (1 <<
TOUCHED);
3320 if (footerDesc->choiceButtons.style == ROUNDED_AND_FOOTER_STYLE) {
3321 layoutInt->
footerContainer->obj.area.height = ROUNDED_AND_FOOTER_FOOTER_HEIGHT;
3323 else if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) {
3324 layoutInt->
footerContainer->obj.area.height = BOTH_ROUNDED_FOOTER_HEIGHT;
3327 layoutInt->
footerContainer->obj.area.height = ACTION_AND_FOOTER_FOOTER_HEIGHT;
3337 if ((footerDesc->type == FOOTER_NAV) || (footerDesc->type == FOOTER_TEXT_AND_NAV)) {
3338 addSwipeInternal(layoutInt,
3341 (footerDesc->type == FOOTER_NAV) ? footerDesc->navigation.token
3342 : footerDesc->textAndNav.navigation.token,
3343 (footerDesc->type == FOOTER_NAV)
3344 ? footerDesc->navigation.tuneId
3345 : footerDesc->textAndNav.navigation.tuneId);
3348 if (footerDesc->separationLine) {
3349 line = createHorizontalLine(layoutInt->
layer);
3355 if (separationLine != NULL) {
3379int nbgl_layoutAddUpFooter(
nbgl_layout_t *layout,
const nbgl_layoutUpFooter_t *upFooterDesc)
3388 if (layout == NULL) {
3391 if ((upFooterDesc == NULL) || (upFooterDesc->type >= NB_UP_FOOTER_TYPES)) {
3405 switch (upFooterDesc->type) {
3406 case UP_FOOTER_LONG_PRESS: {
3411 upFooterDesc->longPress.token,
3412 upFooterDesc->longPress.tuneId);
3425 button->obj.alignmentMarginX = BORDER_MARGIN;
3427 button->innerColor =
BLACK;
3428 button->foregroundColor =
WHITE;
3429 button->borderColor =
BLACK;
3430 button->obj.area.width = BUTTON_DIAMETER;
3431 button->obj.area.height = BUTTON_DIAMETER;
3432 button->radius = BUTTON_RADIUS;
3437 textArea->textColor =
BLACK;
3438 textArea->text = PIC(upFooterDesc->longPress.text);
3439 textArea->textAlignment =
MID_LEFT;
3440 textArea->fontId = LARGE_MEDIUM_FONT;
3441 textArea->wrapping =
true;
3442 textArea->obj.area.width =
SCREEN_WIDTH - 3 * BORDER_MARGIN - button->obj.area.width;
3444 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3446 textArea->obj.alignment =
MID_LEFT;
3447 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3450 line = createHorizontalLine(layoutInt->
layer);
3456 progressBar->obj.area.height = LONG_PRESS_PROGRESS_HEIGHT;
3458 progressBar->obj.alignmentMarginY = LONG_PRESS_PROGRESS_ALIGN;
3459 progressBar->resetIfOverriden =
true;
3460 progressBar->partialRedraw =
true;
3464 case UP_FOOTER_BUTTON: {
3468 upFooterDesc->button.token,
3469 upFooterDesc->button.tuneId);
3477 button->obj.alignment =
CENTER;
3479 if (upFooterDesc->button.style == BLACK_BACKGROUND) {
3480 button->innerColor =
BLACK;
3481 button->foregroundColor =
WHITE;
3484 button->innerColor =
WHITE;
3485 button->foregroundColor =
BLACK;
3487 if (upFooterDesc->button.style == NO_BORDER) {
3488 button->borderColor =
WHITE;
3491 if (upFooterDesc->button.style == BLACK_BACKGROUND) {
3492 button->borderColor =
BLACK;
3498 button->text = PIC(upFooterDesc->button.text);
3499 button->fontId = SMALL_BOLD_FONT;
3500 button->icon = PIC(upFooterDesc->button.icon);
3502 button->obj.area.height = BUTTON_DIAMETER;
3503 button->radius = BUTTON_RADIUS;
3505 button->obj.alignTo = NULL;
3506 button->obj.touchMask = (1 <<
TOUCHED);
3511 case UP_FOOTER_HORIZONTAL_BUTTONS: {
3513 if ((upFooterDesc->horizontalButtons.leftIcon == NULL)
3514 || (upFooterDesc->horizontalButtons.rightText == NULL)) {
3516 "nbgl_layoutAddUpFooter(): UP_FOOTER_HORIZONTAL_BUTTONS fields cannot be "
3528 upFooterDesc->horizontalButtons.leftToken,
3529 upFooterDesc->horizontalButtons.tuneId);
3537 button->obj.alignmentMarginX = BORDER_MARGIN;
3539 button->innerColor =
WHITE;
3540 button->foregroundColor =
BLACK;
3541 button->obj.area.width = BUTTON_WIDTH;
3542 button->obj.area.height = BUTTON_DIAMETER;
3543 button->radius = BUTTON_RADIUS;
3544 button->icon = PIC(upFooterDesc->horizontalButtons.leftIcon);
3545 button->fontId = SMALL_BOLD_FONT;
3546 button->obj.touchMask = (1 <<
TOUCHED);
3554 upFooterDesc->horizontalButtons.rightToken,
3555 upFooterDesc->horizontalButtons.tuneId);
3563 button->obj.alignmentMarginX = BORDER_MARGIN;
3564 button->innerColor =
BLACK;
3565 button->borderColor =
BLACK;
3566 button->foregroundColor =
WHITE;
3567 button->obj.area.width =
AVAILABLE_WIDTH - BUTTON_WIDTH - LEFT_CONTENT_ICON_TEXT_X;
3568 button->obj.area.height = BUTTON_DIAMETER;
3569 button->radius = BUTTON_RADIUS;
3570 button->text = PIC(upFooterDesc->horizontalButtons.rightText);
3571 button->fontId = SMALL_BOLD_FONT;
3572 button->obj.touchMask = (1 <<
TOUCHED);
3577 case UP_FOOTER_TIP_BOX: {
3579 if (upFooterDesc->tipBox.text == NULL) {
3581 "nbgl_layoutAddUpFooter(): UP_FOOTER_TIP_BOX text cannot be NULL\n");
3586 upFooterDesc->tipBox.token,
3587 upFooterDesc->tipBox.tuneId);
3597 textArea->textColor =
BLACK;
3598 textArea->text = PIC(upFooterDesc->tipBox.text);
3599 textArea->textAlignment =
MID_LEFT;
3600 textArea->fontId = SMALL_REGULAR_FONT;
3601 textArea->wrapping =
true;
3603 if (upFooterDesc->tipBox.icon != NULL) {
3604 textArea->obj.area.width
3606 + TIP_BOX_TEXT_ICON_MARGIN;
3609 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3610 textArea->obj.alignment =
MID_LEFT;
3611 textArea->obj.alignmentMarginX = BORDER_MARGIN;
3615 line = createHorizontalLine(layoutInt->
layer);
3619 if (upFooterDesc->tipBox.icon != NULL) {
3621 image->obj.alignmentMarginX = BORDER_MARGIN;
3623 image->foregroundColor =
BLACK;
3624 image->buffer = PIC(upFooterDesc->tipBox.icon);
3634 case UP_FOOTER_TEXT: {
3637 upFooterDesc->text.token,
3638 upFooterDesc->text.tuneId);
3649 if (strlen(PIC(upFooterDesc->text.text))) {
3652 textArea->text = PIC(upFooterDesc->text.text);
3653 textArea->textAlignment =
CENTER;
3654 textArea->fontId = SMALL_REGULAR_FONT;
3655 textArea->wrapping =
true;
3658 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3659 textArea->obj.alignment =
CENTER;
3696 tune_index_e tuneId)
3698 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_PROGRESS,
3699 .separationLine =
false,
3700 .progressAndBack.activePage = activePage,
3701 .progressAndBack.nbPages = nbPages,
3702 .progressAndBack.token = backToken,
3703 .progressAndBack.tuneId = tuneId,
3704 .progressAndBack.withBack = withBack,
3705 .progressAndBack.actionIcon = NULL,
3709 return nbgl_layoutAddHeader(layout, &headerDesc);
3724 const char *subText,
3725 uint8_t initPosition)
3733 if (layout == NULL) {
3739 container->nbChildren = 3;
3744 container->obj.alignment =
CENTER;
3748 spinner->position = initPosition;
3751 container->children[0] = (
nbgl_obj_t *) spinner;
3754 container->obj.area.height += SPINNER_HEIGHT;
3758 textArea->textColor =
BLACK;
3759 textArea->text = PIC(text);
3760 textArea->textAlignment =
CENTER;
3761 textArea->fontId = (subText != NULL) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT;
3762 textArea->wrapping =
true;
3763 textArea->obj.alignmentMarginY = SPINNER_TEXT_MARGIN;
3764 textArea->obj.alignTo = (
nbgl_obj_t *) spinner;
3768 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
3772 container->obj.area.height += textArea->obj.alignmentMarginY + textArea->obj.area.height;
3775 container->children[1] = (
nbgl_obj_t *) textArea;
3777 if (subText != NULL) {
3781 subTextArea->textColor =
BLACK;
3782 subTextArea->text = PIC(subText);
3783 subTextArea->textAlignment =
CENTER;
3784 subTextArea->fontId = SMALL_REGULAR_FONT;
3785 subTextArea->wrapping =
true;
3786 subTextArea->obj.alignmentMarginY = SPINNER_INTER_TEXTS_MARGIN;
3787 subTextArea->obj.alignTo = (
nbgl_obj_t *) textArea;
3792 subTextArea->obj.area.width,
3793 subTextArea->wrapping);
3797 container->obj.area.height
3798 += subTextArea->obj.alignmentMarginY + subTextArea->obj.area.height;
3801 container->children[2] = (
nbgl_obj_t *) subTextArea;
3809 tickerCfg.tickerIntervale = SPINNER_REFRESH_PERIOD;
3810 tickerCfg.tickerValue = SPINNER_REFRESH_PERIOD;
3811 tickerCfg.tickerCallback = &spinnerTickerCallback;
3831 const char *subText,
3841 if ((layout == NULL) || (layoutInt->
container->nbChildren == 0)) {
3846 if ((container->obj.type !=
CONTAINER) || (container->nbChildren < 2)) {
3852 if (spinner->obj.type !=
SPINNER) {
3854 "nbgl_layoutUpdateSpinner(): expected SPINNER, got type %d\n",
3859 if (spinner->position != position) {
3860 spinner->position = position;
3869 "nbgl_layoutUpdateSpinner(): expected TEXT_AREA, got type %d\n",
3870 textArea->obj.type);
3873 const char *newText = PIC(text);
3874 size_t newTextLen = strlen(newText);
3876 if ((newTextLen != strlen(textArea->text)) || memcmp(textArea->text, newText, newTextLen)) {
3877 textArea->text = newText;
3882 if (subText != NULL) {
3885 if (container->nbChildren != 3) {
3887 "nbgl_layoutUpdateSpinner(): expected 3 children for subText, got %d\n",
3888 container->nbChildren);
3892 if (subTextArea->obj.type !=
TEXT_AREA) {
3894 "nbgl_layoutUpdateSpinner(): expected TEXT_AREA for subText, got type %d\n",
3895 subTextArea->obj.type);
3898 const char *newSubText = PIC(subText);
3899 size_t newSubTextLen = strlen(newSubText);
3901 if ((newSubTextLen != strlen(subTextArea->text))
3902 || memcmp(subTextArea->text, newSubText, newSubTextLen)) {
3903 subTextArea->text = newSubText;
3922 if (layout == NULL) {
3953 if ((layout == NULL) || (!layout->
isUsed)) {
3957 if (layout->
modal) {
3960 if (layout == topLayout) {
3961 topLayout = layout->
bottom;
3962 topLayout->
top = NULL;
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
uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
const nbgl_font_t * nbgl_getFont(nbgl_font_id_e fontId)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
Font screen low-Level driver API, to draw elementary forms.
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
nbgl_contentRadioChoice_t nbgl_layoutRadioChoice_t
Deprecated, kept for retro compatibility.
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_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style)
Creates an area with given text and sub text, using the given style.
nbgl_contentSwitch_t nbgl_layoutSwitch_t
Deprecated, kept for retro compatibility.
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_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
void * nbgl_layout_t
type shared externally
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates an area in main panel to display a switch.
#define NBGL_INVALID_TOKEN
int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
Creates an area in main panel to display a button, with the given style.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
#define SPINNER_FIXED
position to use for a "fixed" spinner
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
struct nbgl_layoutDescription_s nbgl_layoutDescription_t
Structure containing all information when creating a layout. This structure must be passed as argumen...
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet().
nbgl_contentTagValueList_t nbgl_layoutTagValueList_t
Deprecated, kept for retro compatibility.
nbgl_contentTagValue_t nbgl_layoutTagValue_t
Deprecated, kept for retro compatibility.
nbgl_contentCenteredInfo_t nbgl_layoutCenteredInfo_t
Deprecated, kept for retro compatibility.
Internal functions/constants of NBGL layout layer.
@ SWIPE_USAGE_SUGGESTIONS
static nbgl_font_id_e layoutGetTagValueFont(bool smallCaseForValue)
returns the font used to display the values of a list of tag/value pairs
void layoutNavigationPopulate(nbgl_container_t *navContainer, const nbgl_layoutNavigationBar_t *navConfig, uint8_t layer)
static uint8_t layoutGetTagValueMaxLines(uint8_t listMaxLines, const nbgl_contentTagValue_t *pair, bool *forceEllipsis)
returns the max number of lines of the value of the given tag/value pair, which is the smallest non-z...
static uint16_t layoutGetTagValueWidth(const nbgl_icon_details_t *icon)
returns the width of the value of a tag/value pair. Shared by the layout and the use cases,...
bool keyboardSwipeCallback(nbgl_layoutInternal_t *layoutInt, nbgl_obj_t *obj, nbgl_touchType_t eventType)
static const nbgl_icon_details_t * layoutGetTagValueIcon(const nbgl_contentTagValue_t *pair)
returns the icon displayed on the right of the value of the given tag/value pair
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the layout
void layoutUpdateCallbackObjToken(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token)
#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)
struct nbgl_layoutInternal_s nbgl_layoutInternal_t
Structure containing all information about the current layout.
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
#define NB_MAX_SCREEN_CHILDREN
static nbgl_layoutInternal_t gLayout[NB_MAX_LAYOUTS]
array of layouts, if used by modal
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object 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)
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)
nbgl_obj_t * nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer)
#define INACTIVE_ARROW_COLOR
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
#define INACTIVE_SMALL_FONT
struct PACKED__ nbgl_button_s nbgl_button_t
struct to represent a button (BUTTON type) that can contain a text and/or an icon
#define INACTIVE_TEXT_COLOR
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
struct PACKED__ nbgl_switch_s nbgl_switch_t
struct to represent a switch (size is fixed) (SWITCH type)
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
struct PACKED__ nbgl_spinner_s nbgl_spinner_t
struct to represent a "spinner", represented by the Ledger corners, in gray, with one of the corners ...
struct PACKED__ nbgl_qrcode_s nbgl_qrcode_t
struct to represent a QR code (QR_CODE type), whose size is fixed
int nbgl_screenPush(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_buttonCallback_t buttonCallback)
int nbgl_screenSet(nbgl_obj_t ***elements, uint8_t nbElements, const nbgl_screenTickerConfiguration_t *ticker, nbgl_buttonCallback_t buttonCallback)
void nbgl_wait_pipeline(void)
int nbgl_screenUpdateTicker(uint8_t screenIndex, const nbgl_screenTickerConfiguration_t *ticker)
int nbgl_screenPop(uint8_t screenIndex)
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
int nbgl_screenUpdateBackgroundColor(uint8_t screenIndex, color_t color)
void nbgl_screenRedraw(void)
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj)
common types for Graphical Library
nbgl_state_t
to represent a boolean state.
@ POST_REFRESH_FORCE_POWER_OFF
Force screen power off after refresh.
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
@ POST_REFRESH_FORCE_POWER_ON_WITH_PIPELINE
Force screen power on and enable pipeline.
nbgl_touchType_t
The different types of Touchscreen events.
@ TOUCHING
corresponding to an object that is currently touched
@ QRCODE_V10
QRCode V10, can encode text len up to 1500 chars, display size = 228*228.
@ QRCODE_V4_SMALL
QRCode V4, can encode text len up to 1500 chars, display size = 132*132.
@ QRCODE_V4
QRCode V4, can encode text len up to 62 chars, display size = 264*264.
@ VERTICAL
from top to bottom
@ HORIZONTAL
from left to right
@ LOOP_PARSING
0, 1, 2, 0, 1, 2, ...
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
@ NO_ALIGNMENT
used when parent container layout is used
@ RIGHT_TOP
on outside right
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax).
@ SWITCH
Switch to turn on/off something.
@ RADIO_BUTTON
Indicator to inform whether something is on or off.
@ BUTTON
Rounded rectangle button with icon and/or text.
@ PROGRESS_BAR
horizontal bar to indicate progression of something (between 0% and 100%)
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
@ LINE
Vertical or Horizontal line.
@ CONTAINER
Empty container.
@ TEXT_AREA
Area to contain text line(s).
@ NBGL_BPP_1
1 bit per pixel
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
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
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
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when selecting a radio button)
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
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
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
const char * subText
description under main text (NULL terminated, single line, may be null)
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 hideEndOfLastLine
if set to true, replace 3 last chars of last line by "..."
bool wrapping
if set to true, value text will be wrapped on ' ' to avoid cutting words
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const char * value
string giving the value name
const char * item
string giving the tag name
const char * aliasSubName
string displayed under alias and in details view
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)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
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
nbgl_screenTickerConfiguration_t ticker
nbgl_layoutButtonCallback_t onActionCallback
the callback to be called on any action on the layout
uint8_t nbUsedCallbackObjs
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
uint8_t activePage
index of active page for navigation bar
uint8_t layer
layer in screen stack
struct nbgl_layoutInternal_s * top
layout above this one, in stack
nbgl_swipe_usage_t swipeUsage
nbgl_layoutTouchCallback_t callback
user callback for all controls
struct nbgl_layoutInternal_s * bottom
layout under this one, in stack
uint8_t invertedColors
if true, means that background is black
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...)
uint8_t isUsed
if true, means this layout is in use
nbgl_layoutFooterType_t footerType
type of footer
nbgl_layoutHeaderType_t headerType
type of header
nbgl_container_t * upFooterContainer
uint8_t incrementAnim
if true, means that animation index is currently incrementing
uint8_t nbPages
number of pages for navigation bar
nbgl_layoutUpFooterType_t upFooterType
type of up-footer
uint8_t modal
if true, means the screen is a modal
layoutObj_t callbackObjPool[LAYOUT_OBJ_POOL_LEN]
nbgl_text_area_t * tapText
nbgl_obj_t ** children
children for main screen
const nbgl_animation_t * animation
current animation (if not NULL)
This structure contains info to build a left content area.
uint8_t nbRows
number of rows in the area
const char * title
title of area in bold
const nbgl_icon_details_t ** rowIcons
array of nbRows icon
const char ** rowTexts
array of nbRows texts (displayed in regular)
This structure contains info to build a navigation bar at the bottom of the screen.
uint8_t activePage
index of active page (from 0 to nbPages-1).
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when pressing keys)
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 for Text content, to be set with nbgl_layoutAddTextContent().
const char * descriptions[NB_MAX_DESCRIPTIONS]
uint8_t nbDescriptions
number of used descriptions in above array
const char * info
description at bottom (in small gray)
const char * title
main text (in large bold font)