Skip to content

Commit 1b9b95c

Browse files
Merge pull request #1184 from LedgerHQ/nbgl-adaptations-for-apex-25
Minor NBGL adaptations for new design of Apex (and Stax/Flex)
2 parents 5ee485a + 2b0fdf3 commit 1b9b95c

File tree

6 files changed

+30
-41
lines changed

6 files changed

+30
-41
lines changed

lib_nbgl/glyphs/24px/Settings_24px.png

100644100755
-100 Bytes
Loading

lib_nbgl/include/nbgl_layout.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extern "C" {
6262
#define PROGRESSBAR_HEIGHT 12
6363
#define BACK_KEY_WIDTH 88
6464
#define ICON_TITLE_MARGIN 24
65+
#define TITLE_DESC_MARGIN 16
6566

6667
#elif defined(TARGET_FLEX)
6768
#define NB_MAX_SUGGESTION_BUTTONS 8
@@ -91,6 +92,7 @@ extern "C" {
9192
#define PROGRESSBAR_HEIGHT 12
9293
#define BACK_KEY_WIDTH 104
9394
#define ICON_TITLE_MARGIN 24
95+
#define TITLE_DESC_MARGIN 16
9496

9597
#elif defined(TARGET_APEX)
9698
#define NB_MAX_SUGGESTION_BUTTONS 8
@@ -114,12 +116,13 @@ extern "C" {
114116
#define LIST_ITEM_HEADING_SUB_TEXT 8
115117

116118
#define PRE_TAG_VALUE_MARGIN 0
117-
#define INTER_TAG_VALUE_MARGIN 12
119+
#define INTER_TAG_VALUE_MARGIN 16
118120
// width & height for progress bar
119121
#define PROGRESSBAR_WIDTH 78
120122
#define PROGRESSBAR_HEIGHT 8
121123
#define BACK_KEY_WIDTH 56
122124
#define ICON_TITLE_MARGIN 16
125+
#define TITLE_DESC_MARGIN 12
123126

124127
#else // TARGETS
125128
#error Undefined target

lib_nbgl/src/nbgl_layout.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@
6767
#define TOP_BUTTON_MARGIN_WITH_ACTION VERTICAL_BORDER_MARGIN
6868
#define SINGLE_BUTTON_MARGIN 24
6969
#define LONG_PRESS_PROGRESS_HEIGHT 8
70-
#define LONG_PRESS_PROGRESS_ALIGN 4
71-
#define TITLE_DESC_MARGIN 16
70+
#define LONG_PRESS_PROGRESS_ALIGN 1
7271
#define LEFT_CONTENT_ICON_TEXT_X 16
7372
#define TIP_BOX_MARGIN_Y 24
73+
#define TIP_BOX_TEXT_ICON_MARGIN 24
7474
#elif defined(TARGET_FLEX)
7575
#define RADIO_CHOICE_HEIGHT 92
7676
#define BAR_INTERVALE 16
@@ -98,10 +98,10 @@
9898
#define TOP_BUTTON_MARGIN_WITH_ACTION VERTICAL_BORDER_MARGIN
9999
#define SINGLE_BUTTON_MARGIN 24
100100
#define LONG_PRESS_PROGRESS_HEIGHT 8
101-
#define LONG_PRESS_PROGRESS_ALIGN 4
102-
#define TITLE_DESC_MARGIN 16
101+
#define LONG_PRESS_PROGRESS_ALIGN 1
103102
#define LEFT_CONTENT_ICON_TEXT_X 16
104103
#define TIP_BOX_MARGIN_Y 24
104+
#define TIP_BOX_TEXT_ICON_MARGIN 32
105105
#elif defined(TARGET_APEX)
106106
#define RADIO_CHOICE_HEIGHT 68
107107
#define BAR_INTERVALE 8
@@ -129,10 +129,10 @@
129129
#define TOP_BUTTON_MARGIN_WITH_ACTION 0
130130
#define SINGLE_BUTTON_MARGIN 16
131131
#define LONG_PRESS_PROGRESS_HEIGHT 4
132-
#define LONG_PRESS_PROGRESS_ALIGN 4
133-
#define TITLE_DESC_MARGIN 12
132+
#define LONG_PRESS_PROGRESS_ALIGN 0
134133
#define LEFT_CONTENT_ICON_TEXT_X 8
135134
#define TIP_BOX_MARGIN_Y 12
135+
#define TIP_BOX_TEXT_ICON_MARGIN 20
136136
#else // TARGETS
137137
#error Undefined target
138138
#endif // TARGETS
@@ -697,7 +697,8 @@ static nbgl_container_t *addListItem(nbgl_layoutInternal_t *layoutInt, const lis
697697
? INACTIVE_TEXT_COLOR
698698
: BLACK;
699699
nbgl_font_id_e fontId
700-
= ((itemDesc->type == TOUCHABLE_BAR_ITEM) && (itemDesc->state == OFF_STATE))
700+
= (((itemDesc->type == TOUCHABLE_BAR_ITEM) || (itemDesc->type == SWITCH_ITEM))
701+
&& (itemDesc->state == OFF_STATE))
701702
? INACTIVE_SMALL_FONT
702703
: SMALL_BOLD_FONT;
703704

@@ -961,7 +962,7 @@ static nbgl_container_t *addContentCenter(nbgl_layoutInternal_t *layoutInt,
961962
textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN + info->iconHug;
962963
}
963964
else {
964-
textArea->obj.alignmentMarginY = 16;
965+
textArea->obj.alignmentMarginY = TITLE_DESC_MARGIN;
965966
}
966967
}
967968
else {
@@ -994,7 +995,7 @@ static nbgl_container_t *addContentCenter(nbgl_layoutInternal_t *layoutInt,
994995
textArea->obj.alignmentMarginY = TITLE_DESC_MARGIN;
995996
}
996997
else {
997-
textArea->obj.alignmentMarginY = VERTICAL_BORDER_MARGIN + info->iconHug;
998+
textArea->obj.alignmentMarginY = ICON_TITLE_MARGIN + info->iconHug;
998999
}
9991000
}
10001001
else {
@@ -3319,7 +3320,6 @@ int nbgl_layoutAddUpFooter(nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *u
33193320

33203321
line = createHorizontalLine(layoutInt->layer);
33213322
line->obj.alignment = TOP_MIDDLE;
3322-
line->obj.alignmentMarginY = VERTICAL_ALIGNMENT - 1;
33233323
layoutInt->upFooterContainer->children[2] = (nbgl_obj_t *) line;
33243324

33253325
progressBar = (nbgl_progress_bar_t *) nbgl_objPoolGet(PROGRESS_BAR, layoutInt->layer);
@@ -3465,7 +3465,7 @@ int nbgl_layoutAddUpFooter(nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *u
34653465
if (upFooterDesc->tipBox.icon != NULL) {
34663466
textArea->obj.area.width
34673467
-= ((nbgl_icon_details_t *) PIC(upFooterDesc->tipBox.icon))->width
3468-
+ BORDER_MARGIN;
3468+
+ TIP_BOX_TEXT_ICON_MARGIN;
34693469
}
34703470
textArea->obj.area.height = nbgl_getTextHeightInWidth(
34713471
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);

lib_nbgl/src/nbgl_layout_keyboard.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ enum {
8787
#define NUMBER_WIDTH 56
8888
#define DELETE_ICON C_Close_40px
8989
#elif defined(TARGET_APEX)
90-
#define TEXT_ENTRY_NORMAL_HEIGHT 40
91-
#define TEXT_ENTRY_COMPACT_HEIGHT 40
90+
#define TEXT_ENTRY_NORMAL_HEIGHT 44
91+
#define TEXT_ENTRY_COMPACT_HEIGHT 44
9292
#define BOTTOM_NORMAL_MARGIN 20
9393
#define BOTTOM_CONFIRM_MARGIN 16
9494
#define BOTTOM_COMPACT_MARGIN 8

lib_nbgl/src/nbgl_page.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ nbgl_page_t *nbgl_pageDrawLedgerInfo(nbgl_layoutTouchCallback_t onA
280280
layoutDescription.ticker.tickerValue = ticker->tickerValue;
281281
layout = nbgl_layoutGet(&layoutDescription);
282282

283-
addEmptyHeader(layout, SIMPLE_FOOTER_HEIGHT);
284283
nbgl_layoutAddCenteredInfo(layout, &centeredInfo);
285284

286285
nbgl_layoutDraw(layout);
@@ -355,8 +354,9 @@ nbgl_page_t *nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionC
355354
info->tapActionToken,
356355
info->tuneId);
357356
}
358-
// add an empty header if a top-right button is used
359-
if (info->topRightStyle != NO_BUTTON_STYLE) {
357+
// add an empty header if a top-right button is used or if the tap text is not empty
358+
if ((info->topRightStyle != NO_BUTTON_STYLE)
359+
|| (info->tapActionText && strlen(PIC(info->tapActionText)))) {
360360
addEmptyHeader(layout, SMALL_CENTERING_HEADER);
361361
}
362362
nbgl_layoutAddCenteredInfo(layout, &info->centeredInfo);

lib_nbgl/src/nbgl_use_case.c

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ typedef struct {
209209
nbgl_layout_t backgroundLayout;
210210
const nbgl_contentInfoList_t *currentInfos;
211211
const nbgl_contentTagValueList_t *currentTagValues;
212+
nbgl_tipBox_t tipBox;
212213
} GenericContext_t;
213214

214215
typedef struct {
@@ -274,7 +275,7 @@ static nbgl_page_t *modalPageContext;
274275
static const char *pageTitle;
275276

276277
// context for tip-box
277-
static nbgl_tipBox_t activeTipBox;
278+
#define activeTipBox genericContext.tipBox
278279

279280
// context for navigation use case
280281
static nbgl_pageNavigationInfo_t navInfo;
@@ -3439,6 +3440,7 @@ void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t qui
34393440
nbgl_screenTickerConfiguration_t ticker = {.tickerCallback = &tickerCallback,
34403441
.tickerIntervale = 0, // not periodic
34413442
.tickerValue = STATUS_SCREEN_DURATION};
3443+
nbgl_pageInfoDescription_t info = {0};
34423444

34433445
reset_callbacks_and_context();
34443446

@@ -3447,27 +3449,14 @@ void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t qui
34473449
#ifdef HAVE_PIEZO_SOUND
34483450
os_io_seph_cmd_piezo_play_tune(TUNE_LEDGER_MOMENT);
34493451
#endif // HAVE_PIEZO_SOUND
3450-
3451-
pageContext = nbgl_pageDrawLedgerInfo(&pageCallback, &ticker, message, QUIT_TOKEN);
3452-
}
3453-
else {
3454-
nbgl_pageInfoDescription_t info = {.bottomButtonStyle = NO_BUTTON_STYLE,
3455-
.footerText = NULL,
3456-
.centeredInfo.icon = &DENIED_CIRCLE_ICON,
3457-
.centeredInfo.offsetY = SMALL_FOOTER_HEIGHT / 2,
3458-
.centeredInfo.onTop = false,
3459-
.centeredInfo.style = LARGE_CASE_INFO,
3460-
.centeredInfo.text1 = message,
3461-
.centeredInfo.text2 = NULL,
3462-
.centeredInfo.text3 = NULL,
3463-
.tapActionText = "",
3464-
.isSwipeable = false,
3465-
.tapActionToken = QUIT_TOKEN,
3466-
.topRightStyle = NO_BUTTON_STYLE,
3467-
.actionButtonText = NULL,
3468-
.tuneId = TUNE_TAP_CASUAL};
3469-
pageContext = nbgl_pageDrawInfo(&pageCallback, &ticker, &info);
34703452
}
3453+
info.centeredInfo.icon = isSuccess ? &CHECK_CIRCLE_ICON : &DENIED_CIRCLE_ICON;
3454+
info.centeredInfo.style = LARGE_CASE_INFO;
3455+
info.centeredInfo.text1 = message;
3456+
info.tapActionText = "";
3457+
info.tapActionToken = QUIT_TOKEN;
3458+
info.tuneId = TUNE_TAP_CASUAL;
3459+
pageContext = nbgl_pageDrawInfo(&pageCallback, &ticker, &info);
34713460
nbgl_refreshSpecial(FULL_COLOR_PARTIAL_REFRESH);
34723461
}
34733462

@@ -4000,9 +3989,6 @@ void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType,
40003989
if (tipBox != NULL) {
40013990
memcpy(&activeTipBox, tipBox, sizeof(activeTipBox));
40023991
}
4003-
else {
4004-
memset(&activeTipBox, 0, sizeof(activeTipBox));
4005-
}
40063992
// if no warning at all, it's a simple review
40073993
if ((warning == NULL)
40083994
|| ((warning->predefinedSet == 0) && (warning->introDetails == NULL)

0 commit comments

Comments
 (0)