Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_step.c File Reference

Implementation of predefined pages management for Applications. More...

#include <string.h>
#include "nbgl_debug.h"
#include "nbgl_step_internal.h"
#include "nbgl_layout_internal_nanos.h"
#include "glyphs.h"
#include "os_pic.h"
#include "os_print.h"
Include dependency graph for nbgl_step.c:

Go to the source code of this file.

Classes

struct  TextContext_s
struct  MenuListContext_s
struct  StepContext_s

Macros

#define TMP_STRING_MAX_LEN   24
 Maximum number of layers for steps, cannot be greater than max number of layout layers.
#define NB_MAX_LAYERS   3

Typedefs

typedef struct TextContext_s TextContext_t
typedef struct MenuListContext_s MenuListContext_t
typedef struct StepContext_s StepContext_t

Enumerations

enum  StepStype_t { TEXT_STEP = 0 , CENTERED_INFO_STEP , MENU_LIST_STEP }

Functions

static void actionCallback (nbgl_layout_t *layout, nbgl_buttonEvent_t event)
static void menuListActionCallback (nbgl_layout_t *layout, nbgl_buttonEvent_t event)
static StepContext_t * getFreeContext (StepStype_t type, bool modal)
static StepContext_t * getContextFromLayout (nbgl_layout_t layout)
static bool getStepLayout (StepContext_t *ctx, const nbgl_layoutDescription_t *layoutDescription)
static uint16_t getSubTextPageLen (StepContext_t *ctx, const char *subText)
static uint16_t getPageLen (StepContext_t *ctx, const char *txt)
static const char * getPageAt (StepContext_t *ctx, uint16_t textPage)
static nbgl_layoutNavIndication_t getNavigationInfo (nbgl_stepPosition_t pos, uint16_t nbPages, uint16_t currentPage)
static void displayTextPage (StepContext_t *ctx, uint16_t textPage)
static void displayMenuList (StepContext_t *ctx)
nbgl_step_t nbgl_stepDrawText (nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal)
 draws a text type step, that can be multi-pages, depending of the length of text and subText. The navigation arrows are displayed depending of the given position of this step in a flow, and depending of the page in case of multi-pages
nbgl_step_t stepDrawText (nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal, uint8_t nbMaxLinesForSubText)
 Same as nbgl_stepDrawText(), with the possibility to truncate subText.
nbgl_step_t nbgl_stepDrawCenteredInfo (nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
 draw a step with a centered info (icon + text). This is always a single page step
nbgl_step_t nbgl_stepDrawMenuList (nbgl_stepMenuListCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutMenuList_t *list, bool modal)
 draw a step page with a menu list and navigation arrows to parse it. This step must be alone
uint8_t nbgl_stepGetMenuListCurrent (nbgl_step_t step)
 Get the index of the currently selected item in the menulist.
nbgl_step_t nbgl_stepDrawSwitch (nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutSwitch_t *switchInfo, bool modal)
 draw a step page with a switch and navigation arrows to navigate to other pages.
int nbgl_stepRelease (nbgl_step_t step)
 Release the step obtained with any of the nbgl_stepDrawXXX() functions.

Variables

static StepContext_t contexts [NB_MAX_LAYERS]
 < array of step contexts. Index 0 is reserved for background

Detailed Description

Implementation of predefined pages management for Applications.

Definition in file nbgl_step.c.

Macro Definition Documentation

◆ NB_MAX_LAYERS

#define NB_MAX_LAYERS   3

Definition at line 28 of file nbgl_step.c.

◆ TMP_STRING_MAX_LEN

#define TMP_STRING_MAX_LEN   24

Maximum number of layers for steps, cannot be greater than max number of layout layers.

Definition at line 25 of file nbgl_step.c.

Typedef Documentation

◆ MenuListContext_t

definition of context for a MENU_LIST_STEP step

◆ StepContext_t

typedef struct StepContext_s StepContext_t

◆ TextContext_t

typedef struct TextContext_s TextContext_t

definition of context for a TEXT_STEP or CENTERED_INFO_STEP step

Enumeration Type Documentation

◆ StepStype_t

type of step

Enumerator
TEXT_STEP 

for a simple text step

CENTERED_INFO_STEP 

for a centered info step

MENU_LIST_STEP 

for a menu list step

Definition at line 36 of file nbgl_step.c.

Function Documentation

◆ actionCallback()

void actionCallback ( nbgl_layout_t * layout,
nbgl_buttonEvent_t event )
static

Definition at line 381 of file nbgl_step.c.

◆ displayMenuList()

void displayMenuList ( StepContext_t * ctx)
static

Definition at line 422 of file nbgl_step.c.

◆ displayTextPage()

void displayTextPage ( StepContext_t * ctx,
uint16_t textPage )
static

Definition at line 268 of file nbgl_step.c.

◆ getContextFromLayout()

StepContext_t * getContextFromLayout ( nbgl_layout_t layout)
static

Definition at line 141 of file nbgl_step.c.

◆ getFreeContext()

StepContext_t * getFreeContext ( StepStype_t type,
bool modal )
static

Definition at line 110 of file nbgl_step.c.

◆ getNavigationInfo()

nbgl_layoutNavIndication_t getNavigationInfo ( nbgl_stepPosition_t pos,
uint16_t nbPages,
uint16_t currentPage )
static

Definition at line 241 of file nbgl_step.c.

◆ getPageAt()

const char * getPageAt ( StepContext_t * ctx,
uint16_t textPage )
static

Definition at line 226 of file nbgl_step.c.

◆ getPageLen()

uint16_t getPageLen ( StepContext_t * ctx,
const char * txt )
static

Definition at line 205 of file nbgl_step.c.

◆ getStepLayout()

bool getStepLayout ( StepContext_t * ctx,
const nbgl_layoutDescription_t * layoutDescription )
static

Definition at line 163 of file nbgl_step.c.

◆ getSubTextPageLen()

uint16_t getSubTextPageLen ( StepContext_t * ctx,
const char * subText )
static

Definition at line 179 of file nbgl_step.c.

◆ menuListActionCallback()

void menuListActionCallback ( nbgl_layout_t * layout,
nbgl_buttonEvent_t event )
static

Definition at line 455 of file nbgl_step.c.

◆ nbgl_stepDrawCenteredInfo()

nbgl_step_t nbgl_stepDrawCenteredInfo ( nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t * ticker,
nbgl_layoutCenteredInfo_t * info,
bool modal )

draw a step with a centered info (icon + text). This is always a single page step

Parameters
posposition of this step in the flow (first, last, single, not_first_nor_last)
onActionCallbackcommon callback for all actions on this page
tickerticker configuration, set to NULL to disable it
infoall information about the centered info to be displayed
modalif true, means this step shall be displayed on top of existing one
Returns
the step context (or NULL if error)

Definition at line 668 of file nbgl_step.c.

◆ nbgl_stepDrawMenuList()

nbgl_step_t nbgl_stepDrawMenuList ( nbgl_stepMenuListCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t * ticker,
nbgl_layoutMenuList_t * list,
bool modal )

draw a step page with a menu list and navigation arrows to parse it. This step must be alone

Parameters
onActionCallbackcommon callback for all actions on this page
tickerticker configuration, set to NULL to disable it
listconfiguration of the menu list
modalif true, means this step shall be displayed on top of existing one
Returns
the step context (or NULL if error)

Definition at line 724 of file nbgl_step.c.

◆ nbgl_stepDrawSwitch()

nbgl_step_t nbgl_stepDrawSwitch ( nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t * ticker,
nbgl_layoutSwitch_t * switchInfo,
bool modal )

draw a step page with a switch and navigation arrows to navigate to other pages.

Note
Switch name must fit in one line, description on 2 lines max.
Parameters
posposition of this step in the flow (first, last, single, not_first_nor_last)
onActionCallbackcommon callback for all actions on this page
tickerticker configuration, set to NULL to disable it
switchInfoall information about the switch to be displayed
modalif true, means this step shall be displayed on top of existing one
Returns
the step context (or NULL if error)

Definition at line 781 of file nbgl_step.c.

◆ nbgl_stepDrawText()

nbgl_step_t nbgl_stepDrawText ( nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t * ticker,
const char * text,
const char * subText,
nbgl_contentCenteredInfoStyle_t style,
bool modal )

draws a text type step, that can be multi-pages, depending of the length of text and subText. The navigation arrows are displayed depending of the given position of this step in a flow, and depending of the page in case of multi-pages

Parameters
posposition of this step in the flow (first, last, single, not_first_nor_last)
onActionCallbackcommon callback for all actions on this page
tickerticker configuration, set to NULL to disable it
texttext to display (depending of style)
subTexttext to display under text (depending of style)
stylestyle to use for text and subText
modalif true, means this step shall be displayed on top of existing one
Returns
the step context (or NULL if error)

Definition at line 498 of file nbgl_step.c.

◆ nbgl_stepGetMenuListCurrent()

uint8_t nbgl_stepGetMenuListCurrent ( nbgl_step_t step)

Get the index of the currently selected item in the menulist.

Parameters
stepstep from which to get the current menulist choice
Returns
current menulist choice

Definition at line 760 of file nbgl_step.c.

◆ nbgl_stepRelease()

int nbgl_stepRelease ( nbgl_step_t step)

Release the step obtained with any of the nbgl_stepDrawXXX() functions.

Parameters
stepstep to release
Returns
>= 0 if OK

Definition at line 833 of file nbgl_step.c.

◆ stepDrawText()

nbgl_step_t stepDrawText ( nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t * ticker,
const char * text,
const char * subText,
nbgl_contentCenteredInfoStyle_t style,
bool modal,
uint8_t nbMaxLinesForSubText )

Same as nbgl_stepDrawText(), with the possibility to truncate subText.

Parameters
posposition of this step in the flow (first, last, single, not_first_nor_last)
onActionCallbackcommon callback for all actions on this page
tickerticker configuration, set to NULL to disable it
texttext to display (depending of style)
subTexttext to display under text (depending of style)
stylestyle to use for text and subText
modalif true, means this step shall be displayed on top of existing one
nbMaxLinesForSubTextif > 0, subText is displayed in a single page, in at most this number of lines (or buttons in BUTTON_INFO style), the last one ending with "..." if it doesn't fit. Otherwise, subText is displayed in as many pages as necessary
Returns
the step context (or NULL if error)

Definition at line 524 of file nbgl_step.c.

Variable Documentation

◆ contexts

StepContext_t contexts[NB_MAX_LAYERS]
static

< array of step contexts. Index 0 is reserved for background

Definition at line 90 of file nbgl_step.c.