16#ifdef BUILD_SCREENSHOTS
17#include "json_scenario.h"
24#define TMP_STRING_MAX_LEN 24
27#define NB_MAX_LAYERS 3
91#ifdef BUILD_SCREENSHOTS
93extern uint16_t last_nb_lines;
94extern uint16_t last_nb_pages;
95extern bool last_bold_state;
117 if (contexts[i].layout == NULL) {
142 if (contexts[i].layout == layout) {
155static const char *getTextPageAt(
StepContext_t *ctx, uint8_t textPage)
159 while (page < textPage) {
168 currentChar = currentChar + len;
176static const char *getSubTextPageAt(
StepContext_t *ctx, uint8_t textPage)
180 while (page < textPage) {
189 currentChar = currentChar + len;
204 if (currentPage > 0) {
207 if (currentPage < (nbPages - 1)) {
224static void displayTextPage(
StepContext_t *ctx, uint8_t textPage)
227 char intermediateString[36];
231 if (textPage <= ctx->textContext.currentPage) {
234 txt = getTextPageAt(ctx, textPage);
237 txt = getSubTextPageAt(ctx, textPage);
269 layoutDescription.
ticker.tickerCallback = ctx->
ticker.tickerCallback;
270 layoutDescription.
ticker.tickerIntervale = ctx->
ticker.tickerIntervale;
271 layoutDescription.
ticker.tickerValue = ctx->
ticker.tickerValue;
309 SPRINTF(intermediateString,
386 = {.
modal = ctx->
modal, .onActionCallback = menuListActionCallback};
389 layoutDescription.
ticker.tickerCallback = ctx->
ticker.tickerCallback;
390 layoutDescription.
ticker.tickerIntervale = ctx->
ticker.tickerIntervale;
391 layoutDescription.
ticker.tickerValue = ctx->
ticker.tickerValue;
424 displayMenuList(ctx);
430 displayMenuList(ctx);
464#ifdef BUILD_SCREENSHOTS
467 area.x0 = area.y0 = 0;
478 ctx->
ticker.tickerCallback = ticker->tickerCallback;
479 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
480 ctx->
ticker.tickerValue = ticker->tickerValue;
484 if (subText == NULL) {
487#ifdef BUILD_SCREENSHOTS
488 store_string_infos(text,
498#ifdef BUILD_SCREENSHOTS
499 uint16_t nb_lines_title;
503 nb_lines_title = last_nb_lines;
505 if (nb_lines_title > 3) {
510 store_string_infos(text,
521#ifdef BUILD_SCREENSHOTS
525 store_string_infos(subText,
535 "nbgl_stepDrawText: ctx = %p, nbPages = %d, pos = 0x%X\n",
583 ctx->
ticker.tickerCallback = ticker->tickerCallback;
584 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
585 ctx->
ticker.tickerValue = ticker->tickerValue;
586 layoutDescription.
ticker.tickerCallback = ticker->tickerCallback;
587 layoutDescription.
ticker.tickerIntervale = ticker->tickerIntervale;
588 layoutDescription.
ticker.tickerValue = ticker->tickerValue;
631 ctx->
ticker.tickerCallback = ticker->tickerCallback;
632 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
633 ctx->
ticker.tickerValue = ticker->tickerValue;
641 displayMenuList(ctx);
694 ctx->
ticker.tickerCallback = ticker->tickerCallback;
695 ctx->
ticker.tickerIntervale = ticker->tickerIntervale;
696 ctx->
ticker.tickerValue = ticker->tickerValue;
697 layoutDescription.
ticker.tickerCallback = ticker->tickerCallback;
698 layoutDescription.
ticker.tickerIntervale = ticker->tickerIntervale;
699 layoutDescription.
ticker.tickerValue = ticker->tickerValue;
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
#define LOG_FATAL(__logger,...)
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.
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
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()
@ 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
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.
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
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
struct MenuListContext_s MenuListContext_t
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
Step construction API of NBGL.
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
#define ACTION_ON_ANY_BUTTON
When action callback applies only on both button press.
@ 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
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.
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.
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
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)
uint8_t currentPage
current page for this text step
const char * subTxtStart
pointer on the start point of sub-text (first page)
bool actionOnAnyButton
if true, action applies on any button
uint8_t nbPages
number of pages for this text step
nbgl_stepButtonCallback_t onActionCallback
This structure contains info to build a centered (vertically and horizontally) area,...
This structure contains info to build a switch (on the right) with a description (on the left),...
Structure containing all information when creating a layout. This structure must be passed as argumen...
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_layoutNavDirection_t direction
vertical or horizontal navigation
nbgl_layoutNavIndication_t indication
specifies which arrows to use (left or right)