Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
nbgl_layout.h File Reference

API of the Advanced BOLOS Graphical Library, for predefined layouts. More...

#include "nbgl_obj.h"
#include "nbgl_screen.h"
#include "nbgl_types.h"
#include "nbgl_content.h"
Include dependency graph for nbgl_layout.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nbgl_layoutNavigationBar_t
 This structure contains info to build a navigation bar at the bottom of the screen. More...
 
struct  nbgl_layoutNavigation_t
 This structure contains info to build a navigation bar at the bottom of the screen. More...
 
struct  nbgl_layoutDescription_s
 Structure containing all information when creating a layout. This structure must be passed as argument to nbgl_layoutGet. More...
 
struct  nbgl_layoutBar_t
 This structure contains info to build a clickable "bar" with a text and an icon. More...
 
struct  nbgl_layoutTextContent_t
 This structure contains info for Text content, to be set with nbgl_layoutAddTextContent(). More...
 
struct  nbgl_layoutMenuList_t
 This structure contains a list of names to build a menu list on Nanos, with for each item a description (names array) More...
 
struct  nbgl_layoutLeftContent_t
 This structure contains info to build a left content area. More...
 
struct  nbgl_layoutSuggestionButtons_t
 This structure contains info to build suggestion buttons. More...
 
struct  nbgl_layoutConfirmationButton_t
 This structure contains info to build a confirmation button. More...
 
struct  nbgl_layoutKeyboardContent_t
 This structure contains info to build a keyboard content (controls that are linked to keyboard) More...
 
struct  nbgl_layoutButton_t
 This structure contains info to build a single button. More...
 
struct  nbgl_layoutProgressBar_t
 This structure contains info to build a progress bar with info. The progress bar itself is 120px width * 12px height. More...
 
struct  nbgl_layoutKbd_t
 This structure contains info to build a keyboard with nbgl_layoutAddKeyboard() More...
 

Macros

#define NBGL_NO_TUNE   NB_TUNES
 
#define NBGL_NO_PROGRESS_INDICATOR   0xFF
 To be used when a control token shall not be used.
 
#define NBGL_INVALID_TOKEN   0xFF
 
#define NB_MAX_SUGGESTION_BUTTONS   8
 
#define AVAILABLE_WIDTH   (SCREEN_WIDTH - 2 * 7)
 
#define NB_MAX_LINES   4
 
#define SPINNER_FIXED   0xFF
 position to use for a "fixed" spinner
 
#define NB_MAX_DESCRIPTIONS   3
 max number of descriptions in nbgl_layoutTextContent_t
 

Typedefs

typedef void * nbgl_layout_t
 type shared externally
 
typedef void(* nbgl_layoutTouchCallback_t) (int token, uint8_t index)
 prototype of function to be called when an object is touched
 
typedef void(* nbgl_layoutButtonCallback_t) (nbgl_layout_t *layout, nbgl_buttonEvent_t event)
 prototype of function to be called when buttons are touched on a screen
 
typedef struct nbgl_layoutDescription_s nbgl_layoutDescription_t
 Structure containing all information when creating a layout. This structure must be passed as argument to nbgl_layoutGet.
 
typedef nbgl_contentSwitch_t nbgl_layoutSwitch_t
 Deprecated, kept for retro compatibility.
 
typedef nbgl_contentRadioChoice_t nbgl_layoutRadioChoice_t
 Deprecated, kept for retro compatibility.
 
typedef const char *(* nbgl_menuListCallback_t) (uint8_t choiceIndex)
 prototype of menu list item retrieval callback
 
typedef nbgl_contentTagValue_t nbgl_layoutTagValue_t
 Deprecated, kept for retro compatibility.
 
typedef nbgl_contentTagValueList_t nbgl_layoutTagValueList_t
 Deprecated, kept for retro compatibility.
 
typedef nbgl_contentCenteredInfo_t nbgl_layoutCenteredInfo_t
 Deprecated, kept for retro compatibility.
 

Enumerations

enum  nbgl_layoutNavDirection_t { HORIZONTAL_NAV , VERTICAL_NAV }
 possible directions for Navigation arrows More...
 
enum  nbgl_layoutNavIndication_t { NO_ARROWS = 0 , LEFT_ARROW , RIGHT_ARROW }
 possible styles for Navigation arrows (it's a bit field) More...
 
enum  nbgl_layoutKeyboardContentType_t { KEYBOARD_WITH_SUGGESTIONS , KEYBOARD_WITH_BUTTON , NB_KEYBOARD_CONTENT_TYPES }
 The different types of keyboard contents. More...
 
enum  nbgl_layoutButtonStyle_t { WHITE_BACKGROUND = 0 }
 The different styles for a button. More...
 

Functions

nbgl_layout_tnbgl_layoutGet (const nbgl_layoutDescription_t *description)
 returns a layout of the given type. The layout is reset
 
int nbgl_layoutAddCenteredInfo (nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
 Creates an area on the center of the main panel, with a possible icon/image, a possible text in black under it, and a possible text in gray under it.
 
int nbgl_layoutAddContentCenter (nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
 
int nbgl_layoutAddLeftContent (nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
 
int nbgl_layoutAddText (nbgl_layout_t *layout, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style)
 Creates an area with given text and sub text, using the given style.
 
int nbgl_layoutAddProgressBar (nbgl_layout_t *layout, const nbgl_layoutProgressBar_t *barLayout)
 Creates an area in main panel to display a progress bar, with a title text and a description under the progress.
 
int nbgl_layoutAddNavigation (nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
 Creates navigation arrows on side(s) of the screen.
 
int nbgl_layoutAddMenuList (nbgl_layout_t *layout, nbgl_layoutMenuList_t *list)
 Creates a menu list (only for nanos) with the given parameters. The navigation (and selection) must be handled by the caller.
 
int nbgl_layoutAddButton (nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo)
 Creates an area in main panel to display a button, with the given style.
 
int nbgl_layoutAddSwitch (nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
 Creates an area in main panel to display a switch.
 
int nbgl_layoutAddKeyboard (nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
 Creates a keyboard on bottom of the screen, with the given configuration.
 
int nbgl_layoutUpdateKeyboard (nbgl_layout_t *layout, uint8_t index, uint32_t keyMask)
 Updates an existing keyboard on bottom of the screen, with the given configuration.
 
int nbgl_layoutAddEnteredText (nbgl_layout_t *layout, const char *text, bool lettersOnly)
 Adds a "text entry" area under the previously entered object. The max number of really displayable characters is 8, even if there are 9 placeholders (_) If longer than 8 chars, the first ones are replaced by a '..' The 9th placeholder is never filled.
 
int nbgl_layoutAddEnteredTextAdvanced (nbgl_layout_t *layout, const char *text, bool lettersOnly, bool obfuscated)
 Adds a "text entry" area under the previously entered object. The max number of really displayable characters is 8, even if there are 9 placeholders (_) If longer than 8 chars, the first ones are replaced by a '..' The 9th placeholder is never filled.
 
int nbgl_layoutUpdateEnteredText (nbgl_layout_t *layout, uint8_t index, const char *text)
 Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText()
 
int nbgl_layoutAddKeypad (nbgl_layout_t *layout, keyboardCallback_t callback, const char *text, bool shuffled)
 Adds a keypad on bottom of the screen, with the associated callback.
 
int nbgl_layoutUpdateKeypad (nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace)
 Updates an existing keypad on bottom of the screen, with the given configuration.
 
int nbgl_layoutAddHiddenDigits (nbgl_layout_t *layout, uint8_t nbDigits)
 Adds a placeholder for hidden digits on top of a keypad, to represent the entered digits, as full circles.
 
int nbgl_layoutUpdateHiddenDigits (nbgl_layout_t *layout, uint8_t index, uint8_t nbActive)
 Updates an existing set of hidden digits, with the given configuration.
 
int nbgl_layoutAddKeypadContent (nbgl_layout_t *layout, bool hidden, uint8_t nbDigits, const char *text)
 Adds an area with a title and a placeholder for hidden digits on top of a keypad, to represent the entered digits as small discs.
 
int nbgl_layoutUpdateKeypadContent (nbgl_layout_t *layout, bool hidden, uint8_t nbActiveDigits, const char *text)
 Updates an existing set of hidden digits, with the given configuration.
 
int nbgl_layoutDraw (nbgl_layout_t *layout)
 Applies given layout. The screen will be redrawn.
 
int nbgl_layoutRelease (nbgl_layout_t *layout)
 Release the layout obtained with nbgl_layoutGet()
 

Detailed Description

API of the Advanced BOLOS Graphical Library, for predefined layouts.

Definition in file nbgl_layout.h.

Macro Definition Documentation

◆ AVAILABLE_WIDTH

#define AVAILABLE_WIDTH   (SCREEN_WIDTH - 2 * 7)

Definition at line 143 of file nbgl_layout.h.

◆ NB_MAX_DESCRIPTIONS

#define NB_MAX_DESCRIPTIONS   3

max number of descriptions in nbgl_layoutTextContent_t

Definition at line 151 of file nbgl_layout.h.

◆ NB_MAX_LINES

#define NB_MAX_LINES   4

Definition at line 145 of file nbgl_layout.h.

◆ NB_MAX_SUGGESTION_BUTTONS

#define NB_MAX_SUGGESTION_BUTTONS   8

Definition at line 141 of file nbgl_layout.h.

◆ NBGL_INVALID_TOKEN

#define NBGL_INVALID_TOKEN   0xFF

Definition at line 30 of file nbgl_layout.h.

◆ NBGL_NO_PROGRESS_INDICATOR

#define NBGL_NO_PROGRESS_INDICATOR   0xFF

To be used when a control token shall not be used.

Definition at line 29 of file nbgl_layout.h.

◆ NBGL_NO_TUNE

#define NBGL_NO_TUNE   NB_TUNES

Definition at line 26 of file nbgl_layout.h.

◆ SPINNER_FIXED

#define SPINNER_FIXED   0xFF

position to use for a "fixed" spinner

Definition at line 149 of file nbgl_layout.h.

Typedef Documentation

◆ nbgl_layout_t

typedef void* nbgl_layout_t

type shared externally

Definition at line 161 of file nbgl_layout.h.

◆ nbgl_layoutButtonCallback_t

typedef void(* nbgl_layoutButtonCallback_t) (nbgl_layout_t *layout, nbgl_buttonEvent_t event)

prototype of function to be called when buttons are touched on a screen

Parameters
layoutlayout concerned by the event
eventtype of button event

Definition at line 176 of file nbgl_layout.h.

◆ nbgl_layoutCenteredInfo_t

Deprecated, kept for retro compatibility.

Definition at line 328 of file nbgl_layout.h.

◆ nbgl_layoutDescription_t

Structure containing all information when creating a layout. This structure must be passed as argument to nbgl_layoutGet.

Note
It shall not be used

◆ nbgl_layoutRadioChoice_t

Deprecated, kept for retro compatibility.

Definition at line 294 of file nbgl_layout.h.

◆ nbgl_layoutSwitch_t

Deprecated, kept for retro compatibility.

Definition at line 289 of file nbgl_layout.h.

◆ nbgl_layoutTagValue_t

Deprecated, kept for retro compatibility.

Definition at line 317 of file nbgl_layout.h.

◆ nbgl_layoutTagValueList_t

Deprecated, kept for retro compatibility.

Definition at line 322 of file nbgl_layout.h.

◆ nbgl_layoutTouchCallback_t

typedef void(* nbgl_layoutTouchCallback_t) (int token, uint8_t index)

prototype of function to be called when an object is touched

Parameters
tokeninteger passed when registering callback
indexwhen the object touched is a list of radio buttons, gives the index of the activated button

Definition at line 169 of file nbgl_layout.h.

◆ nbgl_menuListCallback_t

typedef const char *(* nbgl_menuListCallback_t) (uint8_t choiceIndex)

prototype of menu list item retrieval callback

Parameters
choiceIndexindex of the menu list item to retrieve (from 0 (to nbChoices-1))
Returns
a pointer on a string

Definition at line 301 of file nbgl_layout.h.

Enumeration Type Documentation

◆ nbgl_layoutButtonStyle_t

The different styles for a button.

Enumerator
WHITE_BACKGROUND 

rounded bordered button, with text/icon in black, on white background

Definition at line 632 of file nbgl_layout.h.

◆ nbgl_layoutKeyboardContentType_t

The different types of keyboard contents.

Enumerator
KEYBOARD_WITH_SUGGESTIONS 

text entry area + suggestion buttons

KEYBOARD_WITH_BUTTON 

text entry area + confirmation button

NB_KEYBOARD_CONTENT_TYPES 

Definition at line 345 of file nbgl_layout.h.

◆ nbgl_layoutNavDirection_t

possible directions for Navigation arrows

Enumerator
HORIZONTAL_NAV 

'<' and '>' are displayed, to navigate between pages and steps

VERTICAL_NAV 

'\/' and '/\' are displayed, to navigate in a list (vertical scrolling)

Definition at line 203 of file nbgl_layout.h.

◆ nbgl_layoutNavIndication_t

possible styles for Navigation arrows (it's a bit field)

Enumerator
NO_ARROWS 
LEFT_ARROW 

left arrow is used

RIGHT_ARROW 

right arrow is used

Definition at line 212 of file nbgl_layout.h.

Function Documentation

◆ nbgl_layoutAddButton()

int nbgl_layoutAddButton ( nbgl_layout_t layout,
const nbgl_layoutButton_t buttonInfo 
)

Creates an area in main panel to display a button, with the given style.

Parameters
layoutthe current layout
buttonInfostructure giving the description of button
Returns
>= 0 if OK

Definition at line 652 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddCenteredInfo()

int nbgl_layoutAddCenteredInfo ( nbgl_layout_t layout,
const nbgl_layoutCenteredInfo_t info 
)

Creates an area on the center of the main panel, with a possible icon/image, a possible text in black under it, and a possible text in gray under it.

Parameters
layoutthe current layout
infostructure giving the description of buttons (texts, icons, layout)
Returns
>= 0 if OK

Definition at line 457 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddContentCenter()

int nbgl_layoutAddContentCenter ( nbgl_layout_t layout,
const nbgl_contentCenter_t info 
)

◆ nbgl_layoutAddEnteredText()

int nbgl_layoutAddEnteredText ( nbgl_layout_t layout,
const char *  text,
bool  lettersOnly 
)

Adds a "text entry" area under the previously entered object. The max number of really displayable characters is 8, even if there are 9 placeholders (_) If longer than 8 chars, the first ones are replaced by a '..' The 9th placeholder is never filled.

Parameters
layoutthe current layout
textstring to display in the area
lettersOnlyif true, display 8 chars placeholders, otherwise 9
Returns
>= 0 if OK

Definition at line 197 of file nbgl_layout_keyboard_nanos.c.

◆ nbgl_layoutAddEnteredTextAdvanced()

int nbgl_layoutAddEnteredTextAdvanced ( nbgl_layout_t layout,
const char *  text,
bool  lettersOnly,
bool  obfuscated 
)

Adds a "text entry" area under the previously entered object. The max number of really displayable characters is 8, even if there are 9 placeholders (_) If longer than 8 chars, the first ones are replaced by a '..' The 9th placeholder is never filled.

Parameters
layoutthe current layout
textstring to display in the area
lettersOnlyif true, display 8 chars placeholders, otherwise 9
obfuscatedif true, entered text is obfuscated
Returns
>= 0 if OK

Definition at line 151 of file nbgl_layout_keyboard_nanos.c.

◆ nbgl_layoutAddHiddenDigits()

int nbgl_layoutAddHiddenDigits ( nbgl_layout_t layout,
uint8_t  nbDigits 
)

Adds a placeholder for hidden digits on top of a keypad, to represent the entered digits, as full circles.

Note
It must be the last added object, after keypad. Vertical positions of title and hidden digits will be computed here
Parameters
layoutthe current layout
nbDigitsnumber of digits to be displayed
Returns
the index of digits set, to use in nbgl_layoutUpdateHiddenDigits()

Definition at line 161 of file nbgl_layout_keypad_nanos.c.

◆ nbgl_layoutAddKeyboard()

int nbgl_layoutAddKeyboard ( nbgl_layout_t layout,
const nbgl_layoutKbd_t kbdInfo 
)

Creates a keyboard on bottom of the screen, with the given configuration.

Parameters
layoutthe current layout
kbdInfoconfiguration of the keyboard to draw (including the callback when touched)
Returns
the index of keyboard, to use in nbgl_layoutUpdateKeyboard()

Definition at line 51 of file nbgl_layout_keyboard_nanos.c.

◆ nbgl_layoutAddKeypad()

int nbgl_layoutAddKeypad ( nbgl_layout_t layout,
keyboardCallback_t  callback,
const char *  text,
bool  shuffled 
)

Adds a keypad on bottom of the screen, with the associated callback.

Note
Validate and Backspace keys are not enabled at start-up
Parameters
layoutthe current layout
callbackfunction called when any of the key is touched
texttext to use as title for the keypad
shuffledif set to true, digits are shuffled in keypad
Returns
the index of keypad in layout, to use in nbgl_layoutUpdateKeypad()

Definition at line 59 of file nbgl_layout_keypad_nanos.c.

◆ nbgl_layoutAddKeypadContent()

int nbgl_layoutAddKeypadContent ( nbgl_layout_t layout,
bool  hidden,
uint8_t  nbDigits,
const char *  text 
)

Adds an area with a title and a placeholder for hidden digits on top of a keypad, to represent the entered digits as small discs.

Note
It must be the only object added in the layout, after the keypad itself
Parameters
layoutthe current layout
hiddenif set to true, digits appear as discs, otherwise as visible digits (given in text param)
nbDigitsnumber of digits to be displayed (only used if hidden is true)
textonly used if hidden is false
Returns
the height of this area, if no error, < 0 otherwise

Definition at line 196 of file nbgl_layout_keypad_nanos.c.

◆ nbgl_layoutAddLeftContent()

int nbgl_layoutAddLeftContent ( nbgl_layout_t layout,
const nbgl_layoutLeftContent_t info 
)

◆ nbgl_layoutAddMenuList()

int nbgl_layoutAddMenuList ( nbgl_layout_t layout,
nbgl_layoutMenuList_t list 
)

Creates a menu list (only for nanos) with the given parameters. The navigation (and selection) must be handled by the caller.

Parameters
layoutthe current layout
liststructure giving the list of choices and the current selected one
Returns
>= 0 if OK

Definition at line 403 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddNavigation()

int nbgl_layoutAddNavigation ( nbgl_layout_t layout,
nbgl_layoutNavigation_t info 
)

Creates navigation arrows on side(s) of the screen.

Parameters
layoutthe current layout
infostructure giving the description of the navigation
Returns
>= 0 if OK

Definition at line 186 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddProgressBar()

int nbgl_layoutAddProgressBar ( nbgl_layout_t layout,
const nbgl_layoutProgressBar_t barLayout 
)

Creates an area in main panel to display a progress bar, with a title text and a description under the progress.

Parameters
layoutthe current layout
barLayoutstructure giving the description of progress bar
Returns
>= 0 if OK

Definition at line 587 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddSwitch()

int nbgl_layoutAddSwitch ( nbgl_layout_t layout,
const nbgl_layoutSwitch_t switchLayout 
)

Creates an area in main panel to display a switch.

Parameters
layoutthe current layout
switchLayoutstructure giving the description of switch
Returns
>= 0 if OK

Definition at line 683 of file nbgl_layout_nanos.c.

◆ nbgl_layoutAddText()

int nbgl_layoutAddText ( nbgl_layout_t layout,
const char *  text,
const char *  subText,
nbgl_contentCenteredInfoStyle_t  style 
)

Creates an area with given text and sub text, using the given style.

Parameters
layoutthe current layout
textmain text, must be single line if subText
subTextdescription under main text (NULL terminated, in regular, 3 lines max, may be null)
styleif REGULAR_INFO, use regular font for text, otherwise use bold font for text
Returns
>= 0 if OK

Definition at line 225 of file nbgl_layout_nanos.c.

◆ nbgl_layoutDraw()

int nbgl_layoutDraw ( nbgl_layout_t layoutParam)

Applies given layout. The screen will be redrawn.

Parameters
layoutParamlayout to redraw
Returns
a pointer to the corresponding layout

Definition at line 760 of file nbgl_layout_nanos.c.

◆ nbgl_layoutGet()

nbgl_layout_t * nbgl_layoutGet ( const nbgl_layoutDescription_t description)

returns a layout of the given type. The layout is reset

Parameters
descriptiondescription of layout
Returns
a pointer to the corresponding layout

Definition at line 134 of file nbgl_layout_nanos.c.

◆ nbgl_layoutRelease()

int nbgl_layoutRelease ( nbgl_layout_t layoutParam)

Release the layout obtained with nbgl_layoutGet()

Parameters
layoutParamlayout to release
Returns
>= 0 if OK

Definition at line 779 of file nbgl_layout_nanos.c.

◆ nbgl_layoutUpdateEnteredText()

int nbgl_layoutUpdateEnteredText ( nbgl_layout_t layout,
uint8_t  index,
const char *  text 
)

Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText()

Parameters
layoutthe current layout
indexindex of the text (return value of nbgl_layoutAddEnteredText())
textstring to display in the area
Returns
<0 if error, 0 if OK with text fitting the area, 1 of 0K with text not fitting the area

Definition at line 211 of file nbgl_layout_keyboard_nanos.c.

◆ nbgl_layoutUpdateHiddenDigits()

int nbgl_layoutUpdateHiddenDigits ( nbgl_layout_t layout,
uint8_t  index,
uint8_t  nbActive 
)

Updates an existing set of hidden digits, with the given configuration.

Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddHiddenDigits()
nbActivenumber of "active" digits (represented by discs instead of circles)
Returns
>=0 if OK

Definition at line 174 of file nbgl_layout_keypad_nanos.c.

◆ nbgl_layoutUpdateKeyboard()

int nbgl_layoutUpdateKeyboard ( nbgl_layout_t layout,
uint8_t  index,
uint32_t  keyMask 
)

Updates an existing keyboard on bottom of the screen, with the given configuration.

Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddKeyboard()
keyMaskmask of keys to activate/deactivate on keyboard
Returns
>=0 if OK

Definition at line 98 of file nbgl_layout_keyboard_nanos.c.

◆ nbgl_layoutUpdateKeypad()

int nbgl_layoutUpdateKeypad ( nbgl_layout_t layout,
uint8_t  index,
bool  enableValidate,
bool  enableBackspace 
)

Updates an existing keypad on bottom of the screen, with the given configuration.

Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddKeypad()
enableValidateif true, enable Validate key
enableBackspaceif true, enable Backspace key
Returns
>=0 if OK

Definition at line 112 of file nbgl_layout_keypad_nanos.c.

◆ nbgl_layoutUpdateKeypadContent()

int nbgl_layoutUpdateKeypadContent ( nbgl_layout_t layout,
bool  hidden,
uint8_t  nbActiveDigits,
const char *  text 
)

Updates an existing set of hidden digits, with the given configuration.

Parameters
layoutthe current layout
hiddenif set to true, digits appear as discs, otherwise as visible digits (given in text param)
nbActiveDigitsnumber of "active" digits (represented by discs instead of circles) (only used if hidden is true)
textonly used if hidden is false
Returns
>=0 if OK

Definition at line 277 of file nbgl_layout_keypad_nanos.c.