Skip to content

Commit e274f12

Browse files
Automatic computation of number of items per settings page
1 parent de5b995 commit e274f12

File tree

4 files changed

+268
-64
lines changed

4 files changed

+268
-64
lines changed

lib_nbgl/include/nbgl_layout.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ extern "C" {
6767

6868
#define NB_MAX_LINES NB_MAX_LINES_IN_DETAILS
6969

70+
#ifdef TARGET_STAX
71+
#define PRE_TEXT_MARGIN 32
72+
#define TEXT_SUBTEXT_MARGIN 16
73+
#define POST_SUBTEXT_MARGIN 28
74+
#else // TARGET_STAX
75+
#define PRE_TEXT_MARGIN 28
76+
#define TEXT_SUBTEXT_MARGIN 14
77+
#define POST_SUBTEXT_MARGIN 26
78+
#endif // TARGET_STAX
79+
7080
#else // HAVE_SE_TOUCH
7181
// 7 pixels on each side
7282
#define AVAILABLE_WIDTH (SCREEN_WIDTH - 2 * 7)

lib_nbgl/include/nbgl_use_case.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ extern "C" {
6363
*/
6464
#define TAG_VALUE_AREA_HEIGHT (SCREEN_HEIGHT - SMALL_CENTERING_HEADER - SIMPLE_FOOTER_HEIGHT)
6565

66+
/**
67+
* @brief height available for infos pairs display
68+
*/
69+
#define INFOS_AREA_HEIGHT (SCREEN_HEIGHT - TOUCHABLE_HEADER_BAR_HEIGHT)
70+
6671
/**
6772
* @brief Default strings used in the Home tagline
6873
*/
@@ -303,6 +308,22 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPai
303308
const nbgl_contentTagValueList_t *tagValueList,
304309
uint8_t startIndex,
305310
bool *requireSpecificDisplay);
311+
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos,
312+
const nbgl_contentInfoList_t *infosList,
313+
uint8_t startIndex,
314+
bool withNav);
315+
uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwitches,
316+
const nbgl_contentSwitchesList_t *switchesList,
317+
uint8_t startIndex,
318+
bool withNav);
319+
uint8_t nbgl_useCaseGetNbBarsInPage(uint8_t nbBars,
320+
const nbgl_contentBarsList_t *barsList,
321+
uint8_t startIndex,
322+
bool withNav);
323+
uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoices,
324+
const nbgl_contentRadioChoice_t *choicesList,
325+
uint8_t startIndex,
326+
bool withNav);
306327
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList);
307328

308329
// use case drawing

lib_nbgl/src/nbgl_layout.c

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,20 +1212,16 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT
12121212
if (text != NULL) {
12131213
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
12141214

1215-
textArea->textColor = BLACK;
1216-
textArea->text = PIC(text);
1217-
textArea->textAlignment = MID_LEFT;
1218-
textArea->fontId = SMALL_BOLD_FONT;
1219-
textArea->style = NO_STYLE;
1220-
textArea->wrapping = true;
1221-
textArea->obj.alignment = NO_ALIGNMENT;
1222-
#ifdef TARGET_STAX
1223-
textArea->obj.alignmentMarginY = 32;
1224-
#else // TARGET_STAX
1225-
textArea->obj.alignmentMarginY = 28;
1226-
#endif // TARGET_STAX
1227-
textArea->obj.area.width = container->obj.area.width;
1228-
textArea->obj.area.height = nbgl_getTextHeightInWidth(
1215+
textArea->textColor = BLACK;
1216+
textArea->text = PIC(text);
1217+
textArea->textAlignment = MID_LEFT;
1218+
textArea->fontId = SMALL_BOLD_FONT;
1219+
textArea->style = NO_STYLE;
1220+
textArea->wrapping = true;
1221+
textArea->obj.alignment = NO_ALIGNMENT;
1222+
textArea->obj.alignmentMarginY = PRE_TEXT_MARGIN;
1223+
textArea->obj.area.width = container->obj.area.width;
1224+
textArea->obj.area.height = nbgl_getTextHeightInWidth(
12291225
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
12301226
fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
12311227
container->children[container->nbChildren] = (nbgl_obj_t *) textArea;
@@ -1246,13 +1242,8 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT
12461242
subTextArea->textAlignment = MID_LEFT;
12471243
subTextArea->obj.alignment = NO_ALIGNMENT;
12481244
if (text != NULL) {
1249-
#ifdef TARGET_STAX
1250-
subTextArea->obj.alignmentMarginY = 16;
1251-
fullHeight += 28; // under the subText
1252-
#else // TARGET_STAX
1253-
subTextArea->obj.alignmentMarginY = 14;
1254-
fullHeight += 26; // under the subText
1255-
#endif // TARGET_STAX
1245+
subTextArea->obj.alignmentMarginY = TEXT_SUBTEXT_MARGIN;
1246+
fullHeight += POST_SUBTEXT_MARGIN; // under the subText
12561247
}
12571248
else {
12581249
#ifdef TARGET_STAX
@@ -1268,11 +1259,7 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT
12681259
fullHeight += subTextArea->obj.area.height + subTextArea->obj.alignmentMarginY;
12691260
}
12701261
else {
1271-
#ifdef TARGET_STAX
1272-
fullHeight += 32;
1273-
#else // TARGET_STAX
1274-
fullHeight += 28;
1275-
#endif // TARGET_STAX
1262+
fullHeight += PRE_TEXT_MARGIN;
12761263
}
12771264
container->obj.area.height = fullHeight;
12781265
container->layout = VERTICAL;

0 commit comments

Comments
 (0)