Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_layout_nanos.c File Reference
#include <string.h>
#include <stdlib.h>
#include "nbgl_debug.h"
#include "nbgl_front.h"
#include "nbgl_layout_internal_nanos.h"
#include "nbgl_obj.h"
#include "nbgl_draw.h"
#include "nbgl_screen.h"
#include "nbgl_touch.h"
#include "glyphs.h"
#include "os_pic.h"
#include "os_helpers.h"
#include "lcx_rng.h"
Include dependency graph for nbgl_layout_nanos.c:

Go to the source code of this file.

Macros

#define NB_MAX_LAYOUTS   3
#define NB_MAX_SCREEN_CHILDREN   7
#define ELLIPSIS   "..."
#define ELLIPSIS_SIZE   sizeof(ELLIPSIS)

Functions

static void buttonCallback (nbgl_screen_t *screen, nbgl_buttonEvent_t buttonEvent)
void layoutAddObject (nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
 adds the given obj to the layout
static void getButtonTextLen (const char *text, uint16_t maxWidth, uint16_t maxLen, uint16_t *len, uint16_t *width)
 computes the part of the given text fitting in the given width and in the given number of bytes, in the font of the buttons in BUTTON_INFO style
static void addTextWithEllipsis (nbgl_layoutInternal_t *layoutInt, nbgl_container_t *container, nbgl_text_area_t *textArea, uint8_t nbLines, uint16_t areaHeight)
 displays the given number of lines of the text of the given text area, the last line ending with an ellipsis. The text is not copied: the first lines are displayed by the given text area, the last line and the ellipsis by 2 other text areas, aligned under it
uint16_t layoutGetButtonRowLen (const char *text, uint16_t *len, uint16_t *width)
 computes the part of the given text displayed in a single button in BUTTON_INFO style. Used both to draw the buttons and to split the text in pages, so that they always match
nbgl_layout_t * nbgl_layoutGet (const nbgl_layoutDescription_t *description)
 returns a layout of the given type. The layout is reset
int nbgl_layoutAddNavigation (nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
 Creates navigation arrows on side(s) of the screen.
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 layoutAddText (nbgl_layout_t *layout, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, uint8_t nbMaxLines, bool ellipsis)
 Same as nbgl_layoutAddText(), with the choice of the max number of lines (or buttons in BUTTON_INFO style) of the sub text, and of the behavior when the sub text doesn't fit in them.
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_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_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_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_layoutDraw (nbgl_layout_t *layoutParam)
 Applies given layout. The screen will be redrawn.
int nbgl_layoutRelease (nbgl_layout_t *layoutParam)
 Release the layout obtained with nbgl_layoutGet().

Variables

static nbgl_layoutInternal_t gLayout [NB_MAX_LAYOUTS] = {0}
 array of layouts, if used by modal

Macro Definition Documentation

◆ ELLIPSIS

#define ELLIPSIS   "..."

Definition at line 33 of file nbgl_layout_nanos.c.

◆ ELLIPSIS_SIZE

#define ELLIPSIS_SIZE   sizeof(ELLIPSIS)

Definition at line 34 of file nbgl_layout_nanos.c.

◆ NB_MAX_LAYOUTS

#define NB_MAX_LAYOUTS   3

Definition at line 28 of file nbgl_layout_nanos.c.

◆ NB_MAX_SCREEN_CHILDREN

#define NB_MAX_SCREEN_CHILDREN   7

Definition at line 31 of file nbgl_layout_nanos.c.

Function Documentation

◆ addTextWithEllipsis()

void addTextWithEllipsis ( nbgl_layoutInternal_t * layoutInt,
nbgl_container_t * container,
nbgl_text_area_t * textArea,
uint8_t nbLines,
uint16_t areaHeight )
static

displays the given number of lines of the text of the given text area, the last line ending with an ellipsis. The text is not copied: the first lines are displayed by the given text area, the last line and the ellipsis by 2 other text areas, aligned under it

Parameters
layoutIntthe current layout
containercontainer of the text areas
textAreatext area of the sub text, already set at index 1 of container
nbLinesnumber of lines of the sub text
areaHeightheight of the area in which the lines are vertically centered

Definition at line 166 of file nbgl_layout_nanos.c.

◆ buttonCallback()

void buttonCallback ( nbgl_screen_t * screen,
nbgl_buttonEvent_t buttonEvent )
static

Definition at line 58 of file nbgl_layout_nanos.c.

◆ getButtonTextLen()

void getButtonTextLen ( const char * text,
uint16_t maxWidth,
uint16_t maxLen,
uint16_t * len,
uint16_t * width )
static

computes the part of the given text fitting in the given width and in the given number of bytes, in the font of the buttons in BUTTON_INFO style

Parameters
texttext to display, starting at the beginning of the button
maxWidthmax width in pixels of the text
maxLenmax number of bytes of the text
len[out] number of bytes of text fitting
width[out] width in pixels of these bytes

Definition at line 135 of file nbgl_layout_nanos.c.

◆ layoutAddObject()

void layoutAddObject ( nbgl_layoutInternal_t * layout,
nbgl_obj_t * obj )

adds the given obj to the layout

Parameters
layout
obj

Definition at line 114 of file nbgl_layout_nanos.c.

◆ layoutAddText()

int layoutAddText ( nbgl_layout_t * layout,
const char * text,
const char * subText,
nbgl_contentCenteredInfoStyle_t style,
uint8_t nbMaxLines,
bool ellipsis )

Same as nbgl_layoutAddText(), with the choice of the max number of lines (or buttons in BUTTON_INFO style) of the sub text, and of the behavior when the sub text doesn't fit in them.

Parameters
layoutthe current layout
textmain text, must be single line if subText
subTextdescription under main text (may be null)
styleif REGULAR_INFO, use regular font for text, otherwise use bold font for text
nbMaxLinesmax number of lines (or buttons in BUTTON_INFO style) for the sub text. If 0, the max displayable number is used
ellipsisif true, the last line (or button) ends with an ellipsis if the sub text doesn't fit, otherwise the remaining text is simply not displayed (it is displayed by the caller in another page)
Returns
>= 0 if OK

Definition at line 392 of file nbgl_layout_nanos.c.

◆ layoutGetButtonRowLen()

uint16_t layoutGetButtonRowLen ( const char * text,
uint16_t * len,
uint16_t * width )

computes the part of the given text displayed in a single button in BUTTON_INFO style. Used both to draw the buttons and to split the text in pages, so that they always match

Parameters
texttext to display, starting at the beginning of the button
len[out] number of bytes of text displayed in the button
width[out] width in pixels of these bytes
Returns
the number of bytes of text consumed by the button (always > 0 if text is not empty)

Definition at line 246 of file nbgl_layout_nanos.c.

◆ 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 874 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 646 of file nbgl_layout_nanos.c.

◆ 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 592 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 323 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 809 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 905 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, or 2 buttons max in BUTTON_INFO style, may be null)
styleif REGULAR_INFO, use regular font for text, otherwise use bold font for text
Returns
>= 0 if OK

Definition at line 362 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 985 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 271 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 1005 of file nbgl_layout_nanos.c.

Variable Documentation

◆ gLayout

nbgl_layoutInternal_t gLayout[NB_MAX_LAYOUTS] = {0}
static

array of layouts, if used by modal

Definition at line 52 of file nbgl_layout_nanos.c.