Skip to content

Commit 99bf33d

Browse files
Improvements in some alignments of NBGL Layout
1 parent 9cf5fee commit 99bf33d

File tree

5 files changed

+82
-73
lines changed

5 files changed

+82
-73
lines changed
604 Bytes
Loading
769 Bytes
Loading

lib_nbgl/include/nbgl_layout.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern "C" {
4848
#define SIMPLE_FOOTER_HEIGHT 92
4949
#define SMALL_CENTERING_HEADER 32
5050
#define MEDIUM_CENTERING_HEADER 56
51+
#define MEDIUM_CENTERING_FOOTER 88
5152
#define LONG_PRESS_BUTTON_HEIGHT 128
5253

5354
#define PRE_TEXT_MARGIN 32
@@ -68,6 +69,7 @@ extern "C" {
6869
#define SIMPLE_FOOTER_HEIGHT 96
6970
#define SMALL_CENTERING_HEADER 40
7071
#define MEDIUM_CENTERING_HEADER 64
72+
#define MEDIUM_CENTERING_FOOTER 64
7173
#define LONG_PRESS_BUTTON_HEIGHT 152
7274

7375
#define PRE_TEXT_MARGIN 28

lib_nbgl/include/nbgl_obj.h

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -108,53 +108,55 @@ extern "C" {
108108

109109
// common small icons
110110
#if SMALL_ICON_SIZE == 32
111-
#define SPACE_ICON C_Space_32px
112-
#define BACKSPACE_ICON C_Erase_32px
113-
#define SHIFT_ICON C_Maj_32px
114-
#define SHIFT_LOCKED_ICON C_Maj_Lock_32px
115-
#define VALIDATE_ICON C_Check_32px
116-
#define RADIO_OFF_ICON C_radio_inactive_32px
117-
#define RADIO_ON_ICON C_radio_active_32px
118-
#define PUSH_ICON C_Chevron_32px
119-
#define LEFT_ARROW_ICON C_Back_32px
120-
#define RIGHT_ARROW_ICON C_Next_32px
121-
#define CHEVRON_BACK_ICON C_Chevron_Back_32px
122-
#define CHEVRON_NEXT_ICON C_Chevron_Next_32px
123-
#define CLOSE_ICON C_Close_32px
124-
#define WHEEL_ICON C_Settings_32px
125-
#define INFO_I_ICON C_Info_32px
126-
#define QRCODE_ICON C_QRCode_32px
127-
#define MINI_PUSH_ICON C_Mini_Push_32px
128-
#define WARNING_ICON C_Warning_32px
129-
#define ROUND_WARN_ICON C_Important_Circle_32px
130-
#define PRIVACY_ICON C_Privacy_32px
131-
#define EXCLAMATION_ICON C_Exclamation_32px
132-
#define QUESTION_ICON C_Question_32px
133-
#define DIGIT_ICON C_round_24px
111+
#define SPACE_ICON C_Space_32px
112+
#define BACKSPACE_ICON C_Erase_32px
113+
#define SHIFT_ICON C_Maj_32px
114+
#define SHIFT_LOCKED_ICON C_Maj_Lock_32px
115+
#define VALIDATE_ICON C_Check_32px
116+
#define RADIO_OFF_ICON C_radio_inactive_32px
117+
#define RADIO_ON_ICON C_radio_active_32px
118+
#define PUSH_ICON C_Chevron_32px
119+
#define LEFT_ARROW_ICON C_Back_32px
120+
#define RIGHT_ARROW_ICON C_Next_32px
121+
#define CHEVRON_BACK_ICON C_Chevron_Back_32px
122+
#define CHEVRON_NEXT_ICON C_Chevron_Next_32px
123+
#define CLOSE_ICON C_Close_32px
124+
#define WHEEL_ICON C_Settings_32px
125+
#define INFO_I_ICON C_Info_32px
126+
#define QRCODE_ICON C_QRCode_32px
127+
#define MINI_PUSH_ICON C_Mini_Push_32px
128+
#define WARNING_ICON C_Warning_32px
129+
#define ROUND_WARN_ICON C_Important_Circle_32px
130+
#define PRIVACY_ICON C_Privacy_32px
131+
#define EXCLAMATION_ICON C_Exclamation_32px
132+
#define QUESTION_ICON C_Question_32px
133+
#define DIGIT_ICON C_round_24px
134+
#define QUESTION_CIRCLE_ICON C_Question_Mark_Circle_32px
134135
#elif SMALL_ICON_SIZE == 40
135-
#define SPACE_ICON C_Space_40px
136-
#define BACKSPACE_ICON C_Erase_40px
137-
#define SHIFT_ICON C_Maj_40px
138-
#define SHIFT_LOCKED_ICON C_Maj_Lock_40px
139-
#define VALIDATE_ICON C_Check_40px
140-
#define RADIO_OFF_ICON C_radio_inactive_40px
141-
#define RADIO_ON_ICON C_radio_active_40px
142-
#define PUSH_ICON C_Chevron_40px
143-
#define LEFT_ARROW_ICON C_Back_40px
144-
#define RIGHT_ARROW_ICON C_Next_40px
145-
#define CHEVRON_BACK_ICON C_Chevron_Back_40px
146-
#define CHEVRON_NEXT_ICON C_Chevron_Next_40px
147-
#define CLOSE_ICON C_Close_40px
148-
#define WHEEL_ICON C_Settings_40px
149-
#define INFO_I_ICON C_Info_40px
150-
#define QRCODE_ICON C_QRCode_40px
151-
#define MINI_PUSH_ICON C_Mini_Push_40px
152-
#define WARNING_ICON C_Warning_40px
153-
#define ROUND_WARN_ICON C_Important_Circle_40px
154-
#define PRIVACY_ICON C_Privacy_40px
155-
#define EXCLAMATION_ICON C_Exclamation_40px
156-
#define QUESTION_ICON C_Question_40px
157-
#define DIGIT_ICON C_pin_24
136+
#define SPACE_ICON C_Space_40px
137+
#define BACKSPACE_ICON C_Erase_40px
138+
#define SHIFT_ICON C_Maj_40px
139+
#define SHIFT_LOCKED_ICON C_Maj_Lock_40px
140+
#define VALIDATE_ICON C_Check_40px
141+
#define RADIO_OFF_ICON C_radio_inactive_40px
142+
#define RADIO_ON_ICON C_radio_active_40px
143+
#define PUSH_ICON C_Chevron_40px
144+
#define LEFT_ARROW_ICON C_Back_40px
145+
#define RIGHT_ARROW_ICON C_Next_40px
146+
#define CHEVRON_BACK_ICON C_Chevron_Back_40px
147+
#define CHEVRON_NEXT_ICON C_Chevron_Next_40px
148+
#define CLOSE_ICON C_Close_40px
149+
#define WHEEL_ICON C_Settings_40px
150+
#define INFO_I_ICON C_Info_40px
151+
#define QRCODE_ICON C_QRCode_40px
152+
#define MINI_PUSH_ICON C_Mini_Push_40px
153+
#define WARNING_ICON C_Warning_40px
154+
#define ROUND_WARN_ICON C_Important_Circle_40px
155+
#define PRIVACY_ICON C_Privacy_40px
156+
#define EXCLAMATION_ICON C_Exclamation_40px
157+
#define QUESTION_ICON C_Question_40px
158+
#define DIGIT_ICON C_pin_24
159+
#define QUESTION_CIRCLE_ICON C_Question_Mark_Circle_40px
158160
#endif // SMALL_ICON_SIZE
159161

160162
// common large icons

lib_nbgl/src/nbgl_layout.c

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define BAR_TEXT_MARGIN 24
6363
#define BAR_INTER_TEXTS_MARGIN 16
6464
#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 28
65+
#define LEFT_CONTENT_TEXT_PADDING 0
6566
#elif defined(TARGET_FLEX)
6667
#define RADIO_CHOICE_HEIGHT 92
6768
#define FOOTER_HEIGHT 80
@@ -85,6 +86,7 @@
8586
#define BAR_TEXT_MARGIN 24
8687
#define BAR_INTER_TEXTS_MARGIN 16
8788
#define PROGRESSBAR_ALIGNMENT_MARGIN_Y 32
89+
#define LEFT_CONTENT_TEXT_PADDING 4
8890
#else // TARGETS
8991
#error Undefined target
9092
#endif // TARGETS
@@ -1827,21 +1829,19 @@ int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftConten
18271829
image->buffer = info->rowIcons[row];
18281830
rowContainer->children[0] = (nbgl_obj_t *) image;
18291831

1830-
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, 0);
1831-
textArea->textColor = BLACK;
1832-
textArea->text = info->rowTexts[row];
1833-
textArea->textAlignment = MID_LEFT;
1834-
textArea->fontId = SMALL_REGULAR_FONT;
1835-
textArea->wrapping = true;
1836-
textArea->obj.alignmentMarginX = 16;
1837-
textArea->obj.area.width
1838-
= AVAILABLE_WIDTH - image->buffer->width - textArea->obj.alignmentMarginX;
1832+
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, 0);
1833+
textArea->textColor = BLACK;
1834+
textArea->text = info->rowTexts[row];
1835+
textArea->textAlignment = MID_LEFT;
1836+
textArea->fontId = SMALL_REGULAR_FONT;
1837+
textArea->wrapping = true;
1838+
textArea->obj.area.width = AVAILABLE_WIDTH - image->buffer->width - 16;
18391839
textArea->obj.area.height = nbgl_getTextHeightInWidth(
18401840
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
1841-
textArea->obj.alignment = RIGHT_TOP;
1842-
textArea->obj.alignTo = (nbgl_obj_t *) image;
1843-
rowContainer->children[1] = (nbgl_obj_t *) textArea;
1844-
rowContainer->obj.area.height = MAX(image->buffer->height, textArea->obj.area.height);
1841+
textArea->obj.alignment = MID_RIGHT;
1842+
rowContainer->children[1] = (nbgl_obj_t *) textArea;
1843+
rowContainer->obj.area.height
1844+
= MAX(image->buffer->height, textArea->obj.area.height + LEFT_CONTENT_TEXT_PADDING);
18451845

18461846
if (row == 0) {
18471847
rowContainer->obj.alignmentMarginY = 32;
@@ -2604,31 +2604,36 @@ int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *heade
26042604
case HEADER_BACK_AND_TEXT:
26052605
case HEADER_BACK_ICON_AND_TEXT:
26062606
case HEADER_EXTENDED_BACK: {
2607-
const char *text = (headerDesc->type == HEADER_EXTENDED_BACK)
2608-
? PIC(headerDesc->extendedBack.text)
2609-
: PIC(headerDesc->backAndText.text);
2607+
const char *text = (headerDesc->type == HEADER_EXTENDED_BACK)
2608+
? PIC(headerDesc->extendedBack.text)
2609+
: PIC(headerDesc->backAndText.text);
2610+
uint8_t backToken = (headerDesc->type == HEADER_EXTENDED_BACK)
2611+
? headerDesc->extendedBack.backToken
2612+
: headerDesc->backAndText.token;
26102613
// add back button
26112614
button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer);
2612-
obj = layoutAddCallbackObj(
2613-
layoutInt,
2614-
(nbgl_obj_t *) button,
2615-
(headerDesc->type == HEADER_EXTENDED_BACK) ? headerDesc->extendedBack.backToken
2616-
: headerDesc->backAndText.token,
2617-
(headerDesc->type == HEADER_EXTENDED_BACK) ? headerDesc->extendedBack.tuneId
2618-
: headerDesc->backAndText.tuneId);
2619-
if (obj == NULL) {
2620-
return -1;
2615+
// only make it active if valid token
2616+
if (backToken != NBGL_INVALID_TOKEN) {
2617+
obj = layoutAddCallbackObj(layoutInt,
2618+
(nbgl_obj_t *) button,
2619+
backToken,
2620+
(headerDesc->type == HEADER_EXTENDED_BACK)
2621+
? headerDesc->extendedBack.tuneId
2622+
: headerDesc->backAndText.tuneId);
2623+
if (obj == NULL) {
2624+
return -1;
2625+
}
26212626
}
26222627

26232628
button->obj.alignment = MID_LEFT;
26242629
button->innerColor = WHITE;
2625-
button->foregroundColor = BLACK;
2630+
button->foregroundColor = (backToken != NBGL_INVALID_TOKEN) ? BLACK : WHITE;
26262631
button->borderColor = WHITE;
26272632
button->obj.area.width = BACK_KEY_WIDTH;
26282633
button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT;
26292634
button->text = NULL;
26302635
button->icon = PIC(&LEFT_ARROW_ICON);
2631-
button->obj.touchMask = (1 << TOUCHED);
2636+
button->obj.touchMask = (backToken != NBGL_INVALID_TOKEN) ? (1 << TOUCHED) : 0;
26322637
button->obj.touchId = BACK_BUTTON_ID;
26332638
layoutInt->headerContainer->children[layoutInt->headerContainer->nbChildren]
26342639
= (nbgl_obj_t *) button;

0 commit comments

Comments
 (0)