Skip to content

Commit

Permalink
Merge pull request #827 from LedgerHQ/nbgl-extensions-for-charon
Browse files Browse the repository at this point in the history
NBGL extensions for future UX screens
  • Loading branch information
nroggeman-ledger authored Nov 29, 2024
2 parents d59b21f + 59f9125 commit e8f68a6
Show file tree
Hide file tree
Showing 11 changed files with 316 additions and 85 deletions.
20 changes: 17 additions & 3 deletions lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ typedef struct {
#endif // HAVE_SE_TOUCH
} nbgl_contentCenteredInfo_t;

/**
* @brief possible types of illustration, for example in @ref nbgl_contentCenter_t
*
*/
typedef enum {
ICON_ILLUSTRATION, ///< simple icon
ANIM_ILLUSTRATION, ///< animation
} nbgl_contentIllustrationType_t;

/**
* @brief This structure contains info to build a centered (vertically and horizontally) area, with
* many fields (if NULL, not used):
Expand All @@ -79,9 +88,14 @@ typedef struct {
* - a padding on the bottom
*/
typedef struct {
const nbgl_icon_details_t *icon; ///< the icon (can be null)
const char *title; ///< title in black large (can be null)
const char *smallTitle; ///< sub-title in black small bold case (can be null)
nbgl_contentIllustrationType_t illustrType;
const nbgl_icon_details_t *icon; ///< the icon (can be null)
const nbgl_animation_t
*animation; ///< the animation (can be null), used if illustrType is @ref ANIM_ILLUSTRATION
uint16_t animOffsetX; ///< horizontal offset of animation in icon if integrated (but usually 0)
uint16_t animOffsetY; ///< vertical offset of animation in icon if integrated (but usually 0)
const char *title; ///< title in black large (can be null)
const char *smallTitle; ///< sub-title in black small bold case (can be null)
const char *description; ///< description in black small regular case (can be null)
const char *subText; ///< sub-text in dark gray regular small case
uint16_t iconHug; ///< vertical margin to apply on top and bottom of the icon
Expand Down
22 changes: 12 additions & 10 deletions lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,10 @@ typedef struct {
typedef enum {
ROUNDED_AND_FOOTER_STYLE = 0, ///< A black background button on top of a footer
STRONG_ACTION_AND_FOOTER_STYLE, ///< A black button on top of a footer, with a separation line
SOFT_ACTION_AND_FOOTER_STYLE ///< A white button on top of a footer, with a separation line
SOFT_ACTION_AND_FOOTER_STYLE, ///< A white button on top of a footer, with a separation line
BOTH_ROUNDED_STYLE ///< A black button on top of a white button
} nbgl_layoutChoiceButtonsStyle_t;

// for backward compatibility
#define BOTH_ROUNDED_STYLE SOFT_ACTION_AND_FOOTER_STYLE

/**
* @brief This structure contains info to build a pair of buttons, one on top of the other.
*
Expand Down Expand Up @@ -416,10 +414,11 @@ typedef struct {
typedef enum {
HEADER_EMPTY = 0, ///< empty space, to have a better vertical centering of centered info
HEADER_BACK_AND_TEXT, ///< back key and optional text
HEADER_BACK_AND_PROGRESS, ///< optional back key and progress indicator (only on Stax)
HEADER_TITLE, ///< simple centered text
HEADER_EXTENDED_BACK, ///< back key, centered text and touchable key on the right
HEADER_RIGHT_TEXT, ///< touchable text on the right, with a vertical separation line
HEADER_BACK_ICON_AND_TEXT, ///< back key and optional icon and text
HEADER_BACK_AND_PROGRESS, ///< optional back key and progress indicator (only on Stax)
HEADER_TITLE, ///< simple centered text
HEADER_EXTENDED_BACK, ///< back key, centered text and touchable key on the right
HEADER_RIGHT_TEXT, ///< touchable text on the right, with a vertical separation line
NB_HEADER_TYPES
} nbgl_layoutHeaderType_t;

Expand All @@ -435,10 +434,12 @@ typedef struct {
uint16_t height;
} emptySpace; ///< if type is @ref HEADER_EMPTY
struct {
const nbgl_icon_details_t
*icon; ///< icon on left of text (only if @ref HEADER_BACK_ICON_AND_TEXT)
const char *text; ///< can be NULL if no text
uint8_t token; ///< when back key is pressed
tune_index_e tuneId; ///< when back key is pressed
} backAndText; ///< if type is @ref HEADER_BACK_AND_TEXT
} backAndText; ///< if type is @ref HEADER_BACK_ICON_AND_TEXT or @ref HEADER_BACK_AND_TEXT
struct {
const nbgl_icon_details_t *actionIcon; ///< right button icon
uint8_t activePage;
Expand Down Expand Up @@ -654,7 +655,7 @@ int nbgl_layoutAddProgressIndicator(nbgl_layout_t *layout,
bool withBack,
uint8_t backToken,
tune_index_e tuneId);
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, bool fixed);
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, bool fixed);
int nbgl_layoutAddSwipe(nbgl_layout_t *layout,
uint16_t swipesMask,
const char *text,
Expand Down Expand Up @@ -729,6 +730,7 @@ int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout,
bool enableValidate,
bool enableBackspace,
bool enableDigits);
int nbgl_layoutUpdateKeypadValidation(nbgl_layout_t *layout, bool softValidation);
DEPRECATED int nbgl_layoutAddHiddenDigits(nbgl_layout_t *layout, uint8_t nbDigits);
DEPRECATED int nbgl_layoutUpdateHiddenDigits(nbgl_layout_t *layout,
uint8_t index,
Expand Down
3 changes: 2 additions & 1 deletion lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ typedef struct PACKED__ nbgl_keyboard_s {
typedef struct PACKED__ nbgl_keypad_s {
nbgl_obj_t obj; ///< common part
#ifdef HAVE_SE_TOUCH
color_t textColor; ///< color set to digits.
color_t borderColor; ///< color set to key borders
bool softValidation; ///< if true, the "check icon" is replaced by an arrow
bool enableDigits; ///< if true, Digit keys are enabled
bool partial; ///< if true, means that only some keys have changed
uint8_t digitIndexes[5]; ///< array of digits indexes, 4 bits per digit
Expand Down Expand Up @@ -552,6 +552,7 @@ enum {
EXTRA_BUTTON_ID,
CHOICE_1_ID,
CHOICE_2_ID,
CHOICE_3_ID,
KEYPAD_ID,
KEYBOARD_ID,
ENTERED_TEXT_ID,
Expand Down
20 changes: 20 additions & 0 deletions lib_nbgl/include/nbgl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,26 @@ typedef struct PACKED__ nbgl_icon_details_s {
const uint8_t *bitmap; ///< buffer containing pixel values
} nbgl_icon_details_t;

/**
* @brief possible parsings of icons to create animation
*
*/
typedef enum {
LOOP_PARSING, ///< 0, 1, 2, 0, 1, 2, ...
BACK_AND_FORTH_PARSING ///< 0, 1, 2, 1, 2, 0, ...
} nbgl_parsingType_t;

/**
* @brief Represents all information about an animation (succession of icons)
*
*/
typedef struct nbgl_animation_s {
const nbgl_icon_details_t **icons; ///< array of nbIcons pointers on icons
uint8_t nbIcons; ///< number of icons in icons array
nbgl_parsingType_t parsing; // type of parsing of icons
uint16_t delayMs; ///< delay between 2 drawings
} nbgl_animation_t;

#ifdef __cplusplus
} /* extern "C" */
#endif
Expand Down
Loading

0 comments on commit e8f68a6

Please sign in to comment.