17#ifdef BUILD_SCREENSHOTS
18#include "json_scenario.h"
25#define TMP_STRING_MAX_LEN 24
28#define NB_MAX_LAYERS 3
95#ifdef BUILD_SCREENSHOTS
97extern uint16_t last_nb_lines;
98extern uint16_t last_nb_pages;
99extern bool last_bold_state;
165 if (ctx->
layout != NULL) {
170 if (ctx->
layout == NULL) {
186 uint16_t rowLen, rowWidth;
218 && (txt[len] ==
'\n')) {
231 while (page < textPage) {
233 currentChar = currentChar +
getPageLen(ctx, currentChar);
243 uint16_t currentPage)
248 if (currentPage > 0) {
251 if (currentPage < (nbPages - 1)) {
271 char intermediateString[36];
275 if (textPage <= ctx->textContext.currentPage) {
299 layoutDescription.
ticker.tickerCallback = ctx->
ticker.tickerCallback;
300 layoutDescription.
ticker.tickerIntervale = ctx->
ticker.tickerIntervale;
301 layoutDescription.
ticker.tickerValue = ctx->
ticker.tickerValue;
339 SPRINTF(intermediateString,
428 layoutDescription.
ticker.tickerCallback = ctx->
ticker.tickerCallback;
429 layoutDescription.
ticker.tickerIntervale = ctx->
ticker.tickerIntervale;
430 layoutDescription.
ticker.tickerValue = ctx->
ticker.tickerValue;
506 return stepDrawText(pos, onActionCallback, ticker, text, subText, style, modal, 0);
531 uint8_t nbMaxLinesForSubText)
533#ifdef BUILD_SCREENSHOTS
536 area.x0 = area.y0 = 0;
548 subText = PIC(subText);
554 ctx->
ticker.tickerCallback = ticker->tickerCallback;
555 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
556 ctx->
ticker.tickerValue = ticker->tickerValue;
560 if (subText == NULL) {
563#ifdef BUILD_SCREENSHOTS
564 store_string_infos(text,
574#ifdef BUILD_SCREENSHOTS
575 uint16_t nb_lines_title;
579 nb_lines_title = last_nb_lines;
581 if (nb_lines_title > 3) {
586 store_string_infos(text,
594 if (nbMaxLinesForSubText > 0) {
602 const char *pageStart = subText;
606 }
while (*pageStart !=
'\0');
613#ifdef BUILD_SCREENSHOTS
614 if ((nbMaxLinesForSubText > 0) || (style ==
BUTTON_INFO)) {
625 store_string_infos(subText,
629 ((style !=
BUTTON_INFO) && (nbMaxLinesForSubText > 0)
630 && (last_nb_lines > nbMaxLinesForSubText))
631 ? nbMaxLinesForSubText
633 ((style ==
BUTTON_INFO) || (nbMaxLinesForSubText > 0))
640 "nbgl_stepDrawText: ctx = %p, nbPages = %d, pos = 0x%X\n",
688 ctx->
ticker.tickerCallback = ticker->tickerCallback;
689 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
690 ctx->
ticker.tickerValue = ticker->tickerValue;
691 layoutDescription.
ticker.tickerCallback = ticker->tickerCallback;
692 layoutDescription.
ticker.tickerIntervale = ticker->tickerIntervale;
693 layoutDescription.
ticker.tickerValue = ticker->tickerValue;
737 ctx->
ticker.tickerCallback = ticker->tickerCallback;
738 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
739 ctx->
ticker.tickerValue = ticker->tickerValue;
801 ctx->
ticker.tickerCallback = ticker->tickerCallback;
802 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
803 ctx->
ticker.tickerValue = ticker->tickerValue;
804 layoutDescription.
ticker.tickerCallback = ticker->tickerCallback;
805 layoutDescription.
ticker.tickerIntervale = ticker->tickerIntervale;
806 layoutDescription.
ticker.tickerValue = ticker->tickerValue;
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
@ BUTTON_INFO
bold is used for text1 and text2 as a white button
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
#define LOG_FATAL(__logger,...)
#define NB_MAX_LAYERS
< Maximum number of layers for flow, cannot be greater than max number of step layers
static void actionCallback(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
static FlowContext_t contexts[NB_MAX_LAYERS]
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
@ BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
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 b...
@ VERTICAL_NAV
'\/' and '/\' are displayed, to navigate in a list (vertical scrolling)
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
nbgl_layoutNavIndication_t
possible styles for Navigation arrows (it's a bit field)
@ LEFT_ARROW
left arrow is used
@ RIGHT_ARROW
right arrow is used
int nbgl_layoutAddNavigation(nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
Creates navigation arrows on side(s) of the screen.
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...
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.
nbgl_contentSwitch_t nbgl_layoutSwitch_t
Deprecated, kept for retro compatibility.
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
void * nbgl_layout_t
type shared externally
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates an area in main panel to display a switch.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
struct nbgl_layoutDescription_s nbgl_layoutDescription_t
Structure containing all information when creating a layout. This structure must be passed as argumen...
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
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet().
nbgl_contentCenteredInfo_t nbgl_layoutCenteredInfo_t
Deprecated, kept for retro compatibility.
Internal functions/constants of NBGL layout layer.
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 s...
#define NB_MAX_BUTTON_ROWS
Maximum number of buttons used to display the sub text in BUTTON_INFO style.
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....
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
static void displayMenuList(StepContext_t *ctx)
uint8_t nbgl_stepGetMenuListCurrent(nbgl_step_t step)
Get the index of the currently selected item in the menulist.
#define TMP_STRING_MAX_LEN
Maximum number of layers for steps, cannot be greater than max number of layout layers.
struct StepContext_s StepContext_t
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.
static bool getStepLayout(StepContext_t *ctx, const nbgl_layoutDescription_t *layoutDescription)
static StepContext_t * getFreeContext(StepStype_t type, bool modal)
struct TextContext_s TextContext_t
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
static uint16_t getSubTextPageLen(StepContext_t *ctx, const char *subText)
static void displayTextPage(StepContext_t *ctx, uint16_t textPage)
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.
static nbgl_layoutNavIndication_t getNavigationInfo(nbgl_stepPosition_t pos, uint16_t nbPages, uint16_t currentPage)
int nbgl_stepRelease(nbgl_step_t step)
Release the step obtained with any of the nbgl_stepDrawXXX() functions.
@ CENTERED_INFO_STEP
for a centered info step
@ MENU_LIST_STEP
for a menu list step
@ TEXT_STEP
for a simple text step
static void menuListActionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
static const char * getPageAt(StepContext_t *ctx, uint16_t textPage)
static uint16_t getPageLen(StepContext_t *ctx, const char *txt)
struct MenuListContext_s MenuListContext_t
static StepContext_t * getContextFromLayout(nbgl_layout_t layout)
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....
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
void(* nbgl_stepButtonCallback_t)(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
void * nbgl_step_t
type shared externally
uint8_t nbgl_stepPosition_t
this type is a bitfield containing:
#define STEP_POSITION_MASK
@ NEITHER_FIRST_NOR_LAST_STEP
neither first nor last in a multiple steps flow
@ LAST_STEP
last in a multiple steps flow
@ FIRST_STEP
first in a multiple steps flow
#define ACTION_ON_ANY_BUTTON
When action callback applies only on both button press.
void(* nbgl_stepMenuListCallback_t)(uint8_t choiceIndex)
prototype of chosen menu list item callback
#define BACKWARD_DIRECTION
When action callback applies on any button press.
Internal functions of NBGL step layer.
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.
size_t strlcpy(char *dst, const char *src, size_t size)
StepStype_t type
type of step
TextContext_t textContext
if type is TEXT_STEP or CENTERED_INFO_STEP
nbgl_layout_t * layout
handler of the used layout
nbgl_screenTickerConfiguration_t ticker
structure containing information about ticker
MenuListContext_t menuListContext
if type is MENU_LIST_STEP
const char * nextPageStart
pointer on the start point of text at the next page
uint16_t currentPage
current page for this text step
char tmpString[TMP_STRING_MAX_LEN]
nbgl_contentCenteredInfoStyle_t style
style to be used with a CENTERED_INFO_STEP step
const char * txtStart
pointer on the start point of text (first page)
nbgl_stepPosition_t pos
position of the step within a flow (used for navigation arrows)
const char * subTxtStart
pointer on the start point of sub-text (first page)
bool actionOnAnyButton
if true, action applies on any button
uint8_t nbMaxLinesForSubText
nbgl_stepButtonCallback_t onActionCallback
nbgl_screenTickerConfiguration_t ticker
nbgl_layoutButtonCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build a navigation bar at the bottom of the screen.
nbgl_layoutNavIndication_t indication
specifies which arrows to use (left or right)