Skip to content

Commit

Permalink
Define new content type BARS_LIST_ICONS
Browse files Browse the repository at this point in the history
  • Loading branch information
cedelavergne-ledger committed Feb 26, 2024
1 parent 3f3aae1 commit 55680e3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ typedef struct {
#endif // HAVE_PIEZO_SOUND
} nbgl_contentBarsList_t;

/**
* @brief This structure contains data to build a @ref BARS_LIST_ICONS content
*/
typedef struct nbgl_contentBarsListIcons_s {
const char *const *barTexts; ///< array of texts for each bar (nbBars items, in black/bold)
const nbgl_icon_details_t *const *barIcons; ///< a buffer containing the 1BPP icons
const uint8_t *tokens; ///< array of tokens, one for each bar (nbBars items)
uint8_t nbBars; ///< number of elements in barTexts and tokens array
#ifdef HAVE_PIEZO_SOUND
tune_index_e tuneId; ///< if not @ref NBGL_NO_TUNE, a tune will be played when a bar is touched
#endif // HAVE_PIEZO_SOUND
} nbgl_contentBarsListIcons_t;

/**
* @brief The different types of predefined contents
*
Expand All @@ -255,11 +268,15 @@ typedef enum {
SWITCHES_LIST, ///< list of switches with descriptions
INFOS_LIST, ///< list of infos with titles
CHOICES_LIST, ///< list of choices through radio buttons
BARS_LIST ///< list of touchable bars (with > on the right to go to sub-pages)
BARS_LIST, ///< list of touchable bars (with > on the right to go to sub-pages)
BARS_LIST_ICONS ///< list of touchable bars (with > on the right and icon on the left)
} nbgl_contentType_t;

/**
* @brief Union of the different type of contents
*
* @note This union is duplicated in nbgl_page.h: @ref nbgl_pageContent_t
*
*/
typedef union {
nbgl_contentCenteredInfo_t centeredInfo; ///< @ref CENTERED_INFO type
Expand All @@ -272,6 +289,7 @@ typedef union {
nbgl_contentInfoList_t infosList; ///< @ref INFOS_LIST type
nbgl_contentRadioChoice_t choicesList; ///< @ref CHOICES_LIST type
nbgl_contentBarsList_t barsList; ///< @ref BARS_LIST type
nbgl_contentBarsListIcons_t barsListIcons; ///< @ref BARS_LIST_ICONS type
} nbgl_content_u;

/**
Expand Down
4 changes: 4 additions & 0 deletions lib_nbgl/include/nbgl_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ typedef nbgl_contentInfoLongPress_t nbgl_pageInfoLongPress_t;
/**
* @brief This structure contains data to build a page in multi-pages mode (@ref
* nbgl_pageDrawGenericContent)
*
* @note This union is duplicated in nbgl_content.h: @ref nbgl_content_u
*
*/
typedef struct nbgl_pageContent_s {
const char *title; ///< text for the title of the page (if NULL, no title)
Expand All @@ -67,6 +70,7 @@ typedef struct nbgl_pageContent_s {
nbgl_contentInfoList_t infosList; ///< @ref INFOS_LIST type
nbgl_contentRadioChoice_t choicesList; ///< @ref CHOICES_LIST type
nbgl_contentBarsList_t barsList; ///< @ref BARS_LIST type
nbgl_contentBarsListIcons_t barsListIcons; ///< @ref BARS_LIST_ICONS type
};
} nbgl_pageContent_t;

Expand Down
16 changes: 16 additions & 0 deletions lib_nbgl/src/nbgl_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ static void addContent(nbgl_pageContent_t *content, nbgl_layout_t *layout)
}
break;
}
case BARS_LIST_ICONS: {
uint8_t i;
for (i = 0; i < content->barsListIcons.nbBars; i++) {
nbgl_layoutBar_t bar;
bar.text = content->barsListIcons.barTexts[i];
bar.subText = NULL;
bar.iconRight = &C_Next32px;
bar.iconLeft = content->barsListIcons.barIcons[i];
bar.token = content->barsListIcons.tokens[i];
bar.centered = false;
bar.tuneId = content->barsListIcons.tuneId;
nbgl_layoutAddTouchableBar(layout, &bar);
nbgl_layoutAddSeparationLine(layout);
}
break;
}
}
}

Expand Down

0 comments on commit 55680e3

Please sign in to comment.