Skip to content

Commit c95491e

Browse files
Update margins to fill Apex requirements
1 parent ba03695 commit c95491e

File tree

7 files changed

+94
-118
lines changed

7 files changed

+94
-118
lines changed

lib_nbgl/include/nbgl_obj.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
#elif defined(TARGET_FLEX)
3535
#define KEYBOARD_KEY_HEIGHT 72
3636
#elif defined(TARGET_APEX)
37-
#define KEYBOARD_KEY_HEIGHT 40
37+
#define KEYBOARD_KEY_HEIGHT 51
3838
#endif // TARGETS
3939

4040
// index of keys for keyMask field of nbgl_keyboard_t
@@ -85,7 +85,7 @@ extern "C" {
8585
#elif defined(TARGET_FLEX)
8686
#define BACK_BUTTON_HEADER_HEIGHT 96
8787
#elif defined(TARGET_APEX)
88-
#define BACK_BUTTON_HEADER_HEIGHT 64
88+
#define BACK_BUTTON_HEADER_HEIGHT 60
8989
#endif // TARGETS
9090

9191
// common dimensions for buttons
@@ -106,8 +106,8 @@ extern "C" {
106106
#define SPINNER_WIDTH 64
107107
#define SPINNER_HEIGHT 48
108108
#elif defined(TARGET_APEX)
109-
#define SPINNER_WIDTH 64
110-
#define SPINNER_HEIGHT 48
109+
#define SPINNER_WIDTH 40
110+
#define SPINNER_HEIGHT 32
111111
#endif // TARGETS
112112

113113
// width & height for radio button

lib_nbgl/src/nbgl_draw.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,16 @@ void nbgl_drawRoundedBorderedRect(const nbgl_area_t *area,
408408
// border
409409
// 4 rectangles (with last pixel of each corner not set)
410410
#ifdef SCREEN_SIZE_WALLET
411-
rectArea.x0 = area->x0;
412-
rectArea.y0 = area->y0;
413-
rectArea.width = area->width;
414-
rectArea.height = stroke;
415-
nbgl_frontDrawLine(&rectArea, 0, borderColor); // top
416-
rectArea.x0 = area->x0;
417-
rectArea.y0 = area->y0 + area->height - 1;
418-
nbgl_frontDrawLine(&rectArea, 0, borderColor); // bottom
411+
if ((2 * radius) < area->width) {
412+
rectArea.x0 = area->x0;
413+
rectArea.y0 = area->y0;
414+
rectArea.width = area->width;
415+
rectArea.height = stroke;
416+
nbgl_frontDrawLine(&rectArea, 0, borderColor); // top
417+
rectArea.x0 = area->x0;
418+
rectArea.y0 = area->y0 + area->height - 1;
419+
nbgl_frontDrawLine(&rectArea, 0, borderColor); // bottom
420+
}
419421
if ((2 * radius) < area->height) {
420422
rectArea.x0 = area->x0;
421423
rectArea.y0 = area->y0;

lib_nbgl/src/nbgl_layout.c

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define BACK_KEY_WIDTH 88
4646
#define FOOTER_BUTTON_HEIGHT 128
4747
#define UP_FOOTER_BUTTON_HEIGHT 120
48+
#define FOOTER_IN_PAIR_HEIGHT 80
4849
#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 192
4950
#define ACTION_AND_FOOTER_FOOTER_HEIGHT 216
5051
#define FOOTER_TEXT_AND_NAV_WIDTH 160
@@ -68,12 +69,16 @@
6869
#define SINGLE_BUTTON_MARGIN 24
6970
#define LONG_PRESS_PROGRESS_HEIGHT 8
7071
#define LONG_PRESS_PROGRESS_ALIGN 4
72+
#define ICON_TITLE_MARGIN 24
73+
#define TITLE_DESC_MARGIN 16
74+
#define LEFT_CONTENT_ICON_TEXT_X 16
7175
#elif defined(TARGET_FLEX)
7276
#define RADIO_CHOICE_HEIGHT 92
7377
#define BAR_INTERVALE 16
7478
#define BACK_KEY_WIDTH 104
7579
#define FOOTER_BUTTON_HEIGHT 136
7680
#define UP_FOOTER_BUTTON_HEIGHT 136
81+
#define FOOTER_IN_PAIR_HEIGHT 88
7782
#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208
7883
#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232
7984
#define FOOTER_TEXT_AND_NAV_WIDTH 192
@@ -84,7 +89,7 @@
8489
#define PRE_TITLE_MARGIN 16
8590
#define PRE_DESCRIPTION_MARGIN 24
8691
#define PRE_FIRST_ROW_MARGIN 32
87-
#define INTER_ROWS_MARGIN 26
92+
#define INTER_ROWS_MARGIN 24
8893
#define QR_PRE_TEXT_MARGIN 24
8994
#define QR_INTER_TEXTS_MARGIN 28
9095
#define SPINNER_TEXT_MARGIN 24
@@ -97,12 +102,16 @@
97102
#define SINGLE_BUTTON_MARGIN 24
98103
#define LONG_PRESS_PROGRESS_HEIGHT 8
99104
#define LONG_PRESS_PROGRESS_ALIGN 4
105+
#define ICON_TITLE_MARGIN 24
106+
#define TITLE_DESC_MARGIN 16
107+
#define LEFT_CONTENT_ICON_TEXT_X 16
100108
#elif defined(TARGET_APEX)
101109
#define RADIO_CHOICE_HEIGHT 68
102110
#define BAR_INTERVALE 8
103-
#define BACK_KEY_WIDTH 60
111+
#define BACK_KEY_WIDTH 56
104112
#define FOOTER_BUTTON_HEIGHT 72
105113
#define UP_FOOTER_BUTTON_HEIGHT 72
114+
#define FOOTER_IN_PAIR_HEIGHT 60
106115
#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 128
107116
#define ACTION_AND_FOOTER_FOOTER_HEIGHT 128
108117
#define FOOTER_TEXT_AND_NAV_WIDTH 120
@@ -113,7 +122,7 @@
113122
#define PRE_TITLE_MARGIN 16
114123
#define PRE_DESCRIPTION_MARGIN 12
115124
#define PRE_FIRST_ROW_MARGIN 24
116-
#define INTER_ROWS_MARGIN 14
125+
#define INTER_ROWS_MARGIN 12
117126
#define QR_PRE_TEXT_MARGIN 16
118127
#define QR_INTER_TEXTS_MARGIN 20
119128
#define SPINNER_TEXT_MARGIN 16
@@ -123,9 +132,12 @@
123132
#define LEFT_CONTENT_TEXT_PADDING 4
124133
#define BUTTON_FROM_BOTTOM_MARGIN 0
125134
#define TOP_BUTTON_MARGIN 12
126-
#define SINGLE_BUTTON_MARGIN 12
135+
#define SINGLE_BUTTON_MARGIN 16
127136
#define LONG_PRESS_PROGRESS_HEIGHT 4
128137
#define LONG_PRESS_PROGRESS_ALIGN 4
138+
#define ICON_TITLE_MARGIN 16
139+
#define TITLE_DESC_MARGIN 12
140+
#define LEFT_CONTENT_ICON_TEXT_X 8
129141
#else // TARGETS
130142
#error Undefined target
131143
#endif // TARGETS
@@ -919,7 +931,7 @@ static nbgl_container_t *addContentCenter(nbgl_layoutInternal_t *layoutInt,
919931
if (container->nbChildren > 0) {
920932
textArea->obj.alignment = BOTTOM_MIDDLE;
921933
textArea->obj.alignTo = (nbgl_obj_t *) image;
922-
textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN + info->iconHug;
934+
textArea->obj.alignmentMarginY = ICON_TITLE_MARGIN + info->iconHug;
923935
}
924936
else {
925937
textArea->obj.alignment = TOP_MIDDLE;
@@ -981,7 +993,7 @@ static nbgl_container_t *addContentCenter(nbgl_layoutInternal_t *layoutInt,
981993
textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1];
982994
if (container->children[container->nbChildren - 1]->type == TEXT_AREA) {
983995
// if previous element is text, only space of 16 px
984-
textArea->obj.alignmentMarginY = 16;
996+
textArea->obj.alignmentMarginY = TITLE_DESC_MARGIN;
985997
}
986998
else {
987999
textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN + info->iconHug;
@@ -1873,13 +1885,14 @@ int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftConten
18731885
image->buffer = info->rowIcons[row];
18741886
rowContainer->children[0] = (nbgl_obj_t *) image;
18751887

1876-
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, 0);
1877-
textArea->textColor = BLACK;
1878-
textArea->text = info->rowTexts[row];
1879-
textArea->textAlignment = MID_LEFT;
1880-
textArea->fontId = SMALL_REGULAR_FONT;
1881-
textArea->wrapping = true;
1882-
textArea->obj.area.width = AVAILABLE_WIDTH - image->buffer->width - 16;
1888+
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, 0);
1889+
textArea->textColor = BLACK;
1890+
textArea->text = info->rowTexts[row];
1891+
textArea->textAlignment = MID_LEFT;
1892+
textArea->fontId = SMALL_REGULAR_FONT;
1893+
textArea->wrapping = true;
1894+
textArea->obj.area.width
1895+
= AVAILABLE_WIDTH - image->buffer->width - LEFT_CONTENT_ICON_TEXT_X;
18831896
textArea->obj.area.height = nbgl_getTextHeightInWidth(
18841897
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
18851898
textArea->obj.alignment = MID_RIGHT;
@@ -3189,7 +3202,7 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_
31893202
}
31903203
button->foregroundColor = BLACK;
31913204
button->obj.area.width = AVAILABLE_WIDTH;
3192-
button->obj.area.height = BUTTON_DIAMETER;
3205+
button->obj.area.height = FOOTER_IN_PAIR_HEIGHT;
31933206
button->radius = BUTTON_RADIUS;
31943207
button->text = PIC(footerDesc->choiceButtons.bottomText);
31953208
button->fontId = SMALL_BOLD_FONT;

lib_nbgl/src/nbgl_layout_keyboard.c

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,26 @@ enum {
5252
#define BOTTOM_COMPACT_MARGIN 24
5353
#define TOP_NORMAL_MARGIN 20
5454
#define TOP_COMPACT_MARGIN 20
55+
#define TITLE_ENTRY_MARGIN_Y 4
56+
#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
5557
#elif defined(TARGET_FLEX)
5658
#define TEXT_ENTRY_NORMAL_HEIGHT 72
5759
#define TEXT_ENTRY_COMPACT_HEIGHT 56
5860
#define BOTTOM_NORMAL_MARGIN 24
5961
#define BOTTOM_COMPACT_MARGIN 12
6062
#define TOP_NORMAL_MARGIN 20
6163
#define TOP_COMPACT_MARGIN 12
64+
#define TITLE_ENTRY_MARGIN_Y 4
65+
#define TEXT_ENTRY_FONT LARGE_MEDIUM_1BPP_FONT
6266
#elif defined(TARGET_APEX)
63-
#define TEXT_ENTRY_NORMAL_HEIGHT 64
64-
#define TEXT_ENTRY_COMPACT_HEIGHT 64
65-
#define BOTTOM_NORMAL_MARGIN 24
66-
#define BOTTOM_COMPACT_MARGIN 24
67-
#define TOP_NORMAL_MARGIN 20
67+
#define TEXT_ENTRY_NORMAL_HEIGHT 40
68+
#define TEXT_ENTRY_COMPACT_HEIGHT 40
69+
#define BOTTOM_NORMAL_MARGIN 16
70+
#define BOTTOM_COMPACT_MARGIN 20
71+
#define TOP_NORMAL_MARGIN 12
6872
#define TOP_COMPACT_MARGIN 20
73+
#define TITLE_ENTRY_MARGIN_Y 0
74+
#define TEXT_ENTRY_FONT SMALL_BOLD_FONT
6975
#endif // TARGETS
7076

7177
#ifdef USE_PARTIAL_BUTTONS
@@ -289,7 +295,7 @@ static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt,
289295
textArea->obj.area.height = nbgl_getTextHeightInWidth(
290296
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
291297
mainContainer->children[0] = (nbgl_obj_t *) textArea;
292-
mainContainer->obj.area.height = textArea->obj.area.height + 4;
298+
mainContainer->obj.area.height = textArea->obj.area.height + TITLE_ENTRY_MARGIN_Y;
293299
}
294300

295301
// create a text-entry container number, entered text and underline
@@ -306,10 +312,10 @@ static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt,
306312
snprintf(numText, sizeof(numText), "%d.", number);
307313
textArea->text = numText;
308314
textArea->textAlignment = CENTER;
309-
textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
315+
textArea->fontId = TEXT_ENTRY_FONT;
310316
textArea->obj.area.width = NUMBER_WIDTH;
311317
textArea->obj.alignment = MID_LEFT;
312-
textArea->obj.area.height = nbgl_getFontHeight(LARGE_MEDIUM_1BPP_FONT);
318+
textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
313319
// set this text area as child of the container
314320
container->children[0] = (nbgl_obj_t *) textArea;
315321
}
@@ -319,7 +325,7 @@ static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt,
319325
textArea->textColor = grayedOut ? INACTIVE_TEXT_COLOR : BLACK;
320326
textArea->text = text;
321327
textArea->textAlignment = MID_LEFT;
322-
textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
328+
textArea->fontId = TEXT_ENTRY_FONT;
323329
textArea->obj.area.width = AVAILABLE_WIDTH;
324330
if (numbered) {
325331
textArea->obj.alignmentMarginX = NUMBER_TEXT_SPACE;
@@ -330,7 +336,7 @@ static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt,
330336
else {
331337
textArea->obj.alignment = MID_LEFT;
332338
}
333-
textArea->obj.area.height = nbgl_getFontHeight(LARGE_MEDIUM_1BPP_FONT);
339+
textArea->obj.area.height = nbgl_getFontHeight(textArea->fontId);
334340
textArea->autoHideLongLine = true;
335341

336342
obj = layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) textArea, textToken, NBGL_NO_TUNE);
@@ -386,7 +392,7 @@ static nbgl_container_t *addSuggestionButtons(nbgl_layoutInternal_t *layoutInt,
386392
suggestionsContainer->children
387393
= (nbgl_obj_t **) nbgl_containerPoolGet(NB_SUGGESTION_CHILDREN, layoutInt->layer);
388394

389-
// put suggestionsContainer at 24px of the bottom of main container
395+
// put suggestionsContainer at the bottom of main container
390396
suggestionsContainer->obj.alignmentMarginY
391397
= compactMode ? BOTTOM_COMPACT_MARGIN : BOTTOM_NORMAL_MARGIN;
392398
suggestionsContainer->obj.alignment = BOTTOM_MIDDLE;
@@ -463,7 +469,7 @@ static nbgl_button_t *addConfirmationButton(nbgl_layoutInternal_t *layoutInt,
463469
return NULL;
464470
}
465471

466-
// put button at 24px/12px of the keyboard
472+
// put button at the bottom of the main container
467473
button->obj.alignmentMarginY = compactMode ? BOTTOM_COMPACT_MARGIN : BOTTOM_NORMAL_MARGIN;
468474
button->obj.alignment = BOTTOM_MIDDLE;
469475
button->foregroundColor = WHITE;
@@ -627,60 +633,6 @@ bool nbgl_layoutKeyboardNeedsRefresh(nbgl_layout_t *layout, uint8_t index)
627633
return false;
628634
}
629635

630-
/**
631-
* @brief Adds up to 4 black suggestion buttons under the previously added object
632-
* @deprecated Use @ref nbgl_layoutAddKeyboardContent instead
633-
*
634-
* @param layout the current layout
635-
* @param nbUsedButtons the number of actually used buttons
636-
* @param buttonTexts array of 4 strings for buttons (last ones can be NULL)
637-
* @param firstButtonToken first token used for buttons, provided in onActionCallback (the next 3
638-
* values will be used for other buttons)
639-
* @param tuneId tune to play when any button is pressed
640-
* @return >= 0 if OK
641-
*/
642-
int nbgl_layoutAddSuggestionButtons(nbgl_layout_t *layout,
643-
uint8_t nbUsedButtons,
644-
const char *buttonTexts[NB_MAX_SUGGESTION_BUTTONS],
645-
int firstButtonToken,
646-
tune_index_e tuneId)
647-
{
648-
nbgl_container_t *container;
649-
nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
650-
// if a centered info has be used for title, entered text is the second child
651-
uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1;
652-
653-
LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddSuggestionButtons():\n");
654-
if (layout == NULL) {
655-
return -1;
656-
}
657-
658-
container = addSuggestionButtons(
659-
layoutInt, nbUsedButtons, buttonTexts, firstButtonToken, tuneId, false);
660-
// set this container as 2nd or 3rd child of the main layout container
661-
layoutInt->container->children[enteredTextIndex + 1] = (nbgl_obj_t *) container;
662-
if (layoutInt->container->children[enteredTextIndex] != NULL) {
663-
((nbgl_container_t *) layoutInt->container->children[enteredTextIndex])
664-
->obj.alignmentMarginY
665-
-= (container->obj.area.height + container->obj.alignmentMarginY + 20) / 2;
666-
}
667-
#ifdef USE_PARTIAL_BUTTONS
668-
// the main container is swipable on Flex
669-
if (layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) layoutInt->container, 0, NBGL_NO_TUNE)
670-
== NULL) {
671-
return -1;
672-
}
673-
layoutInt->container->obj.touchMask = (1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT);
674-
layoutInt->container->obj.touchId = CONTROLS_ID;
675-
layoutInt->swipeUsage = SWIPE_USAGE_SUGGESTIONS;
676-
#endif // USE_PARTIAL_BUTTONS
677-
// set this new container as child of the main container
678-
layoutAddObject(layoutInt, (nbgl_obj_t *) container);
679-
680-
// return index of container to be modified later on
681-
return (layoutInt->container->nbChildren - 1);
682-
}
683-
684636
/**
685637
* @brief Updates the number and/or the text suggestion buttons created with @ref
686638
* nbgl_layoutAddSuggestionButtons()

lib_nbgl/src/nbgl_layout_keypad.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ enum {
3737
#define ENTRY_DIGITS_HEIGHT 50
3838
#define ENTRY_DIGITS_CONTAINER_HEIGHT 44
3939
#define INTER_ENTRY_DIGITS 10
40+
#define TITLE_MARGIN_Y 8
4041
#elif defined(TARGET_FLEX)
4142
#define ENTRY_DIGITS_HEIGHT 64
4243
#define ENTRY_DIGITS_CONTAINER_HEIGHT 64
4344
#define INTER_ENTRY_DIGITS 12
45+
#define TITLE_MARGIN_Y 8
4446
#elif defined(TARGET_APEX)
45-
#define ENTRY_DIGITS_HEIGHT 50
46-
#define ENTRY_DIGITS_CONTAINER_HEIGHT 28
47-
#define INTER_ENTRY_DIGITS 4
47+
#define ENTRY_DIGITS_HEIGHT 40
48+
#define ENTRY_DIGITS_CONTAINER_HEIGHT 40
49+
#define INTER_ENTRY_DIGITS 8
50+
#define TITLE_MARGIN_Y 13
4851
#endif // TARGETS
4952

5053
/**********************
@@ -388,7 +391,7 @@ int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout,
388391
container->children = nbgl_containerPoolGet(container->nbChildren, layoutInt->layer);
389392
container->obj.area.width = AVAILABLE_WIDTH;
390393
container->obj.alignment = TOP_MIDDLE;
391-
container->obj.alignmentMarginY = 8;
394+
container->obj.alignmentMarginY = TITLE_MARGIN_Y;
392395

393396
// create text area for title
394397
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);

0 commit comments

Comments
 (0)