Embedded SDK
Embedded SDK
|
Implementation of predefined layouts management for Applications. More...
#include "app_config.h"
#include <string.h>
#include <stdlib.h>
#include "nbgl_debug.h"
#include "nbgl_front.h"
#include "nbgl_layout_internal.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"
Go to the source code of this file.
Classes | |
struct | listItem_t |
Macros | |
#define | INTERNAL_SPACE 16 |
#define | INNER_MARGIN 12 |
#define | NB_MAX_LAYOUTS 3 |
#define | NB_MAX_CONTAINER_CHILDREN 20 |
#define | TAG_VALUE_ICON_WIDTH 32 |
#define | RADIO_CHOICE_HEIGHT 92 |
#define | FOOTER_HEIGHT 80 |
#define | BAR_INTERVALE 16 |
#define | BACK_KEY_WIDTH 104 |
#define | FOOTER_BUTTON_HEIGHT 136 |
#define | UP_FOOTER_BUTTON_HEIGHT 136 |
#define | ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208 |
#define | ACTION_AND_FOOTER_FOOTER_HEIGHT 232 |
#define | SPINNER_REFRESH_PERIOD 400 |
#define | HOLD_TO_APPROVE_STEP_PERCENT (25) |
#define | HOLD_TO_APPROVE_STEP_DURATION_MS (400) |
Enumerations | |
enum | { PAGE_INDICATOR_INDEX = 0 , LEFT_HALF_INDEX , RIGHT_HALF_INDEX , FIRST_BUTTON_INDEX } |
enum | listItemType_t { TOUCHABLE_BAR_ITEM , SWITCH_ITEM , NB_ITEM_TYPES } |
Functions | |
const char * | get_ux_loc_string (uint32_t index) |
layoutObj_t * | layoutAddCallbackObj (nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId) |
void | layoutAddObject (nbgl_layoutInternal_t *layout, nbgl_obj_t *obj) |
adds the given obj to the main container More... | |
nbgl_layout_t * | nbgl_layoutGet (const nbgl_layoutDescription_t *description) |
returns a layout of the given type. The layout is reset More... | |
int | nbgl_layoutAddSwipe (nbgl_layout_t *layout, uint16_t swipesMask, const char *text, uint8_t token, tune_index_e tuneId) |
Creates a swipe interaction on the main container. More... | |
int | nbgl_layoutAddTopRightButton (nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId) |
Creates a Top-right button in the top right corner of the top panel. More... | |
int | nbgl_layoutAddNavigationBar (nbgl_layout_t *layout, const nbgl_layoutNavigationBar_t *info) |
Creates a navigation bar on bottom of main container. More... | |
int | nbgl_layoutAddBottomButton (nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, bool separationLine, tune_index_e tuneId) |
Creates a centered button at bottom of main container. More... | |
int | nbgl_layoutAddTouchableBar (nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout) |
Creates a touchable bar in main panel. More... | |
int | nbgl_layoutAddSwitch (nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout) |
Creates a switch with the given text and its state. More... | |
int | nbgl_layoutAddText (nbgl_layout_t *layout, const char *text, const char *subText) |
Creates an area with given text (in bold) and sub text (in regular) More... | |
int | nbgl_layoutAddTextWithAlias (nbgl_layout_t *layout, const char *text, const char *subText, uint8_t token, uint8_t index) |
Creates an area with given text (in bold) and sub text (in regular), with a More... | |
int | nbgl_layoutAddSubHeaderText (nbgl_layout_t *layout, const char *text) |
Creates an area with given text in small regular font, under the header. More... | |
int | nbgl_layoutAddLargeCaseText (nbgl_layout_t *layout, const char *text) |
Creates an area with given text in 32px font (in Black) More... | |
int | nbgl_layoutAddTextContent (nbgl_layout_t *layout, const char *title, const char *description, const char *info) |
Creates in the main container three text areas: More... | |
int | nbgl_layoutAddRadioChoice (nbgl_layout_t *layout, const nbgl_layoutRadioChoice_t *choices) |
Creates a list of radio buttons (on the right) More... | |
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. More... | |
int | nbgl_layoutAddContentCenter (nbgl_layout_t *layout, const nbgl_contentCenter_t *info) |
Creates an area on the center of the main panel, with a possible icon, and possible texts under it. More... | |
int | nbgl_layoutAddQRCode (nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info) |
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under it, and a possible text in black under it. More... | |
int | nbgl_layoutAddChoiceButtons (nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info) |
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width, one under the other. More... | |
int | nbgl_layoutAddHorizontalButtons (nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info) |
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon and is round, the other contains only a text. More... | |
int | nbgl_layoutAddTagValueList (nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list) |
Creates a list of [tag,value] pairs. More... | |
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. More... | |
int | nbgl_layoutAddSeparationLine (nbgl_layout_t *layout) |
adds a separation line on bottom of the last added item More... | |
int | nbgl_layoutAddButton (nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo) |
Creates a rounded button in the main container. More... | |
int | nbgl_layoutAddLongPressButton (nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId) |
Creates a long press button in the main container. More... | |
int | nbgl_layoutAddFooter (nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId) |
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the screen. More... | |
int | nbgl_layoutAddSplitFooter (nbgl_layout_t *layout, const char *leftText, uint8_t leftToken, const char *rightText, uint8_t rightToken, tune_index_e tuneId) |
Creates 2 touchable texts at the footer of the screen, separated with a thin line from the rest of the screen, and from each other. More... | |
int | nbgl_layoutAddHeader (nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc) |
Creates a touchable (or not) area at the header of the screen, containing various controls, described in the given structure. This header is not part of the main container. More... | |
int | nbgl_layoutAddExtendedFooter (nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc) |
Creates a touchable area at the footer of the screen, containing various controls, described in the given structure. This footer is not part of the main container. More... | |
int | nbgl_layoutAddUpFooter (nbgl_layout_t *layout, const nbgl_layoutUpFooter_t *upFooterDesc) |
Creates a touchable area on top of the footer of the screen, containing various controls, described in the given structure. This up-footer is not part of the main container. More... | |
int | nbgl_layoutAddProgressIndicator (nbgl_layout_t *layout, uint8_t activePage, uint8_t nbPages, bool withBack, uint8_t backToken, tune_index_e tuneId) |
Creates a kind of navigation bar with an optional <- arrow on the left. This widget is placed on top of the main container. More... | |
int | nbgl_layoutAddSpinner (nbgl_layout_t *layout, const char *text, bool fixed) |
Creates a centered (vertically & horizontally) spinner with a text under it. More... | |
int | nbgl_layoutDraw (nbgl_layout_t *layoutParam) |
Applies given layout. The screen will be redrawn. More... | |
int | nbgl_layoutRelease (nbgl_layout_t *layoutParam) |
Release the layout obtained with nbgl_layoutGet() More... | |
Implementation of predefined layouts management for Applications.
Definition in file nbgl_layout.c.
#define ACTION_AND_FOOTER_FOOTER_HEIGHT 232 |
Definition at line 59 of file nbgl_layout.c.
#define BACK_KEY_WIDTH 104 |
Definition at line 55 of file nbgl_layout.c.
#define BAR_INTERVALE 16 |
Definition at line 54 of file nbgl_layout.c.
#define FOOTER_BUTTON_HEIGHT 136 |
Definition at line 56 of file nbgl_layout.c.
#define FOOTER_HEIGHT 80 |
Definition at line 53 of file nbgl_layout.c.
#define HOLD_TO_APPROVE_STEP_DURATION_MS (400) |
Definition at line 135 of file nbgl_layout.c.
#define HOLD_TO_APPROVE_STEP_PERCENT (25) |
Definition at line 134 of file nbgl_layout.c.
#define INNER_MARGIN 12 |
Definition at line 33 of file nbgl_layout.c.
#define INTERNAL_SPACE 16 |
Definition at line 31 of file nbgl_layout.c.
#define NB_MAX_CONTAINER_CHILDREN 20 |
Definition at line 38 of file nbgl_layout.c.
#define NB_MAX_LAYOUTS 3 |
Definition at line 35 of file nbgl_layout.c.
#define RADIO_CHOICE_HEIGHT 92 |
Definition at line 52 of file nbgl_layout.c.
#define ROUNDED_AND_FOOTER_FOOTER_HEIGHT 208 |
Definition at line 58 of file nbgl_layout.c.
#define SPINNER_REFRESH_PERIOD 400 |
Definition at line 63 of file nbgl_layout.c.
#define TAG_VALUE_ICON_WIDTH 32 |
Definition at line 40 of file nbgl_layout.c.
#define UP_FOOTER_BUTTON_HEIGHT 136 |
Definition at line 57 of file nbgl_layout.c.
anonymous enum |
Enumerator | |
---|---|
PAGE_INDICATOR_INDEX | |
LEFT_HALF_INDEX | |
RIGHT_HALF_INDEX | |
FIRST_BUTTON_INDEX |
Definition at line 69 of file nbgl_layout.c.
enum listItemType_t |
Enumerator | |
---|---|
TOUCHABLE_BAR_ITEM | |
SWITCH_ITEM | |
NB_ITEM_TYPES |
Definition at line 85 of file nbgl_layout.c.
const char* get_ux_loc_string | ( | uint32_t | index | ) |
layoutObj_t* layoutAddCallbackObj | ( | nbgl_layoutInternal_t * | layout, |
nbgl_obj_t * | obj, | ||
uint8_t | token, | ||
tune_index_e | tuneId | ||
) |
Definition at line 492 of file nbgl_layout.c.
void layoutAddObject | ( | nbgl_layoutInternal_t * | layout, |
nbgl_obj_t * | obj | ||
) |
adds the given obj to the main container
layout | |
obj |
Definition at line 519 of file nbgl_layout.c.
int nbgl_layoutAddBottomButton | ( | nbgl_layout_t * | layout, |
const nbgl_icon_details_t * | icon, | ||
uint8_t | token, | ||
bool | separationLine, | ||
tune_index_e | tuneId | ||
) |
Creates a centered button at bottom of main container.
incompatible with navigation bar
layout | the current layout |
icon | icon inside the round button |
token | used as parameter of userCallback when button is touched |
separationLine | if set to true, adds a light gray separation line on top of the container |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is pressed |
Definition at line 1195 of file nbgl_layout.c.
int nbgl_layoutAddButton | ( | nbgl_layout_t * | layout, |
const nbgl_layoutButton_t * | buttonInfo | ||
) |
Creates a rounded button in the main container.
layout | the current layout |
buttonInfo | structure giving the description of button (text, icon, layout) |
Definition at line 2102 of file nbgl_layout.c.
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.
layout | the current layout |
info | structure giving the description of buttons (texts, icons, layout) |
Definition at line 1601 of file nbgl_layout.c.
int nbgl_layoutAddChoiceButtons | ( | nbgl_layout_t * | layout, |
const nbgl_layoutChoiceButtons_t * | info | ||
) |
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width, one under the other.
layout | the current layout |
info | structure giving the description of buttons (texts, icons, layout) |
Definition at line 1815 of file nbgl_layout.c.
int nbgl_layoutAddContentCenter | ( | nbgl_layout_t * | layout, |
const nbgl_contentCenter_t * | info | ||
) |
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
layout | the current layout |
info | structure giving the description of the Content Center |
Definition at line 1664 of file nbgl_layout.c.
int nbgl_layoutAddExtendedFooter | ( | nbgl_layout_t * | layout, |
const nbgl_layoutFooter_t * | footerDesc | ||
) |
Creates a touchable area at the footer of the screen, containing various controls, described in the given structure. This footer is not part of the main container.
layout | the current layout |
footerDesc | if not NBGL_NO_TUNE, a tune will be played when button is long pressed |
Definition at line 2548 of file nbgl_layout.c.
int nbgl_layoutAddFooter | ( | nbgl_layout_t * | layout, |
const char * | text, | ||
uint8_t | token, | ||
tune_index_e | tuneId | ||
) |
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the screen.
layout | the current layout |
text | text to used in the footer |
token | token to use when the footer is touched |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is long pressed |
Definition at line 2232 of file nbgl_layout.c.
int nbgl_layoutAddHeader | ( | nbgl_layout_t * | layout, |
const nbgl_layoutHeader_t * | headerDesc | ||
) |
Creates a touchable (or not) area at the header of the screen, containing various controls, described in the given structure. This header is not part of the main container.
layout | the current layout |
headerDesc | description of the header to add |
Definition at line 2285 of file nbgl_layout.c.
int nbgl_layoutAddHorizontalButtons | ( | nbgl_layout_t * | layout, |
const nbgl_layoutHorizontalButtons_t * | info | ||
) |
Creates two buttons to make a choice. Both buttons are mandatory The left one contains only an icon and is round, the other contains only a text.
layout | the current layout |
info | structure giving the description of buttons (text, icon, tokens) |
Definition at line 1838 of file nbgl_layout.c.
int nbgl_layoutAddLargeCaseText | ( | nbgl_layout_t * | layout, |
const char * | text | ||
) |
Creates an area with given text in 32px font (in Black)
layout | the current layout |
text | text to be displayed (auto-wrap) |
Definition at line 1375 of file nbgl_layout.c.
int nbgl_layoutAddLongPressButton | ( | nbgl_layout_t * | layout, |
const char * | text, | ||
uint8_t | token, | ||
tune_index_e | tuneId | ||
) |
Creates a long press button in the main container.
layout | the current layout |
text | text of the button button |
token | token attached to actionCallback when long time of press is elapsed |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is long pressed |
Definition at line 2204 of file nbgl_layout.c.
int nbgl_layoutAddNavigationBar | ( | nbgl_layout_t * | layout, |
const nbgl_layoutNavigationBar_t * | info | ||
) |
Creates a navigation bar on bottom of main container.
layout | the current layout |
info | structure giving the description of the navigation bar |
Definition at line 1169 of file nbgl_layout.c.
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.
layout | the current layout |
barLayout | structure giving the description of progress bar |
Definition at line 2011 of file nbgl_layout.c.
int nbgl_layoutAddProgressIndicator | ( | nbgl_layout_t * | layout, |
uint8_t | activePage, | ||
uint8_t | nbPages, | ||
bool | withBack, | ||
uint8_t | backToken, | ||
tune_index_e | tuneId | ||
) |
Creates a kind of navigation bar with an optional <- arrow on the left. This widget is placed on top of the main container.
layout | the current layout |
activePage | current page [O,(nbPages-1)] |
nbPages | number of pages |
withBack | if true, the back arrow is drawn |
backToken | token used with actionCallback is withBack is true |
tuneId | if not NBGL_NO_TUNE, a tune will be played when back button is pressed |
Definition at line 3242 of file nbgl_layout.c.
int nbgl_layoutAddQRCode | ( | nbgl_layout_t * | layout, |
const nbgl_layoutQRCode_t * | info | ||
) |
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under it, and a possible text in black under it.
layout | the current layout |
info | structure giving the description of buttons (texts, icons, layout) |
Definition at line 1688 of file nbgl_layout.c.
int nbgl_layoutAddRadioChoice | ( | nbgl_layout_t * | layout, |
const nbgl_layoutRadioChoice_t * | choices | ||
) |
Creates a list of radio buttons (on the right)
layout | the current layout |
choices | structure giving the list of choices and the current selected one |
Definition at line 1504 of file nbgl_layout.c.
int nbgl_layoutAddSeparationLine | ( | nbgl_layout_t * | layout | ) |
adds a separation line on bottom of the last added item
layout | the current layout |
Definition at line 2082 of file nbgl_layout.c.
int nbgl_layoutAddSpinner | ( | nbgl_layout_t * | layout, |
const char * | text, | ||
bool | fixed | ||
) |
Creates a centered (vertically & horizontally) spinner with a text under it.
layout | the current layout |
text | text to draw under the spinner |
fixed | if set to true, the spinner won't spin and be entirely black |
Definition at line 3271 of file nbgl_layout.c.
int nbgl_layoutAddSplitFooter | ( | nbgl_layout_t * | layout, |
const char * | leftText, | ||
uint8_t | leftToken, | ||
const char * | rightText, | ||
uint8_t | rightToken, | ||
tune_index_e | tuneId | ||
) |
Creates 2 touchable texts at the footer of the screen, separated with a thin line from the rest of the screen, and from each other.
layout | the current layout |
leftText | text to used in the left part of footer |
leftToken | token to use when the left part of footer is touched |
rightText | text to used in the right part of footer |
rightToken | token to use when the right part of footer is touched |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is long pressed |
Definition at line 2259 of file nbgl_layout.c.
int nbgl_layoutAddSubHeaderText | ( | nbgl_layout_t * | layout, |
const char * | text | ||
) |
Creates an area with given text in small regular font, under the header.
layout | the current layout |
text | main text in small regular font |
Definition at line 1334 of file nbgl_layout.c.
int nbgl_layoutAddSwipe | ( | nbgl_layout_t * | layout, |
uint16_t | swipesMask, | ||
const char * | text, | ||
uint8_t | token, | ||
tune_index_e | tuneId | ||
) |
Creates a swipe interaction on the main container.
layout | the current layout |
swipesMask | the type of swipes to be handled by the container |
text | the text in gray to display at bottom of the main container (can be NULL) |
token | the token that will be used as argument of the callback |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is pressed |
Definition at line 1083 of file nbgl_layout.c.
int nbgl_layoutAddSwitch | ( | nbgl_layout_t * | layout, |
const nbgl_layoutSwitch_t * | switchLayout | ||
) |
Creates a switch with the given text and its state.
layout | the current layout |
switchLayout | description of the parameters of the switch |
Definition at line 1260 of file nbgl_layout.c.
int nbgl_layoutAddTagValueList | ( | nbgl_layout_t * | layout, |
const nbgl_layoutTagValueList_t * | list | ||
) |
Creates a list of [tag,value] pairs.
layout | the current layout |
list | structure giving the list of [tag,value] pairs |
Definition at line 1859 of file nbgl_layout.c.
int nbgl_layoutAddText | ( | nbgl_layout_t * | layout, |
const char * | text, | ||
const char * | subText | ||
) |
Creates an area with given text (in bold) and sub text (in regular)
layout | the current layout |
text | main text (in small bold font), optional |
subText | description under main text (in small regular font), optional |
Definition at line 1300 of file nbgl_layout.c.
int nbgl_layoutAddTextContent | ( | nbgl_layout_t * | layout, |
const char * | title, | ||
const char * | description, | ||
const char * | info | ||
) |
Creates in the main container three text areas:
layout | the current layout |
title | main text (in large bold font) |
description | description under main text (in small regular font) |
info | description at bottom (in small gray) |
Definition at line 1422 of file nbgl_layout.c.
int nbgl_layoutAddTextWithAlias | ( | nbgl_layout_t * | layout, |
const char * | text, | ||
const char * | subText, | ||
uint8_t | token, | ||
uint8_t | index | ||
) |
Creates an area with given text (in bold) and sub text (in regular), with a
icon on right of text to activate an action when touched, with the given token
layout | the current layout |
text | main text (in small bold font), optional |
subText | description under main text (in small regular font), optional |
token | token to use in callback when > icon is touched |
index | index to use in callback when > icon is touched |
Definition at line 1317 of file nbgl_layout.c.
int nbgl_layoutAddTopRightButton | ( | nbgl_layout_t * | layout, |
const nbgl_icon_details_t * | icon, | ||
uint8_t | token, | ||
tune_index_e | tuneId | ||
) |
Creates a Top-right button in the top right corner of the top panel.
layout | the current layout |
icon | icon configuration |
token | the token that will be used as argument of the callback |
tuneId | if not NBGL_NO_TUNE, a tune will be played when button is pressed |
Definition at line 1124 of file nbgl_layout.c.
int nbgl_layoutAddTouchableBar | ( | nbgl_layout_t * | layout, |
const nbgl_layoutBar_t * | barLayout | ||
) |
Creates a touchable bar in main panel.
layout | the current layout |
barLayout | the properties of the bar |
Definition at line 1221 of file nbgl_layout.c.
int nbgl_layoutAddUpFooter | ( | nbgl_layout_t * | layout, |
const nbgl_layoutUpFooter_t * | upFooterDesc | ||
) |
Creates a touchable area on top of the footer of the screen, containing various controls, described in the given structure. This up-footer is not part of the main container.
layout | the current layout |
upFooterDesc | description of the up-footer |
Definition at line 2942 of file nbgl_layout.c.
int nbgl_layoutDraw | ( | nbgl_layout_t * | layoutParam | ) |
Applies given layout. The screen will be redrawn.
layoutParam | layout to redraw |
Definition at line 3336 of file nbgl_layout.c.
nbgl_layout_t* nbgl_layoutGet | ( | const nbgl_layoutDescription_t * | description | ) |
returns a layout of the given type. The layout is reset
description | description of layout |
Definition at line 994 of file nbgl_layout.c.
int nbgl_layoutRelease | ( | nbgl_layout_t * | layoutParam | ) |
Release the layout obtained with nbgl_layoutGet()
layoutParam | layout to release |
Definition at line 3367 of file nbgl_layout.c.