Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API_LEVEL_19 #663

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,8 @@ typedef struct {
const char *text1; ///< first text (can be null)
const char *text2; ///< second text (can be null)
#ifdef HAVE_SE_TOUCH
const char *text3; ///< third text (can be null)
#endif // HAVE_SE_TOUCH
#ifdef BUILD_SCREENSHOTS
uint16_t textId1; ///< first text ID (can be 0)
uint16_t textId2; ///< second text ID (can be 0)
#ifdef HAVE_SE_TOUCH
uint16_t textId3; ///< third text ID (can be 0)
const char *text3; ///< third text (can be null)
#endif // HAVE_SE_TOUCH
#endif // BUILD_SCREENSHOTS
const nbgl_icon_details_t *icon; ///< a buffer containing the 1BPP icon
bool onTop; ///< if set to true, align only horizontally
nbgl_contentCenteredInfoStyle_t style; ///< style to apply to this info
Expand Down
17 changes: 7 additions & 10 deletions lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,9 @@ typedef const char *(*nbgl_menuListCallback_t)(uint8_t choiceIndex);
* a description (names array)
*/
typedef struct {
nbgl_menuListCallback_t callback; ///< function to call to retrieve a menu list item text
#ifdef BUILD_SCREENSHOTS
const uint16_t (*getStringID)(uint8_t choiceIndex); ///< return the string ID of choice
#endif // BUILD_SCREENSHOTS
uint8_t nbChoices; ///< total number of choices in the menu list
uint8_t selectedChoice; ///< index of the selected choice (centered, in bold)
nbgl_menuListCallback_t callback; ///< function to call to retrieve a menu list item text
uint8_t nbChoices; ///< total number of choices in the menu list
uint8_t selectedChoice; ///< index of the selected choice (centered, in bold)

} nbgl_layoutMenuList_t;

Expand Down Expand Up @@ -670,10 +667,10 @@ int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout,

#else // HAVE_SE_TOUCH
/* layout objects for pages with keypad (nanos) */
int nbgl_layoutAddKeypad(nbgl_layout_t *layout,
keyboardCallback_t callback,
UX_LOC_STRINGS_INDEX textId,
bool shuffled);
int nbgl_layoutAddKeypad(nbgl_layout_t *layout,
keyboardCallback_t callback,
const char *text,
bool shuffled);
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout,
uint8_t index,
bool enableValidate,
Expand Down
6 changes: 3 additions & 3 deletions lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ typedef enum {
BUTTON_RIGHT_PRESSED, ///< Send when Right button is released
BUTTON_LEFT_CONTINUOUS_PRESSED, ///< Send when Left button is continuouly pressed (sent every
///< 300ms after the first 800ms)
BUTTON_RIGHT_CONTINUOUS_PRESSED, ///< Send when Left button is continuouly pressed (sent every
BUTTON_RIGHT_CONTINUOUS_PRESSED, ///< Send when Right button is continuouly pressed (sent every
///< 300ms after the first 800ms)
BUTTON_BOTH_PRESSED, ///< Sent when both buttons are released
BUTTON_BOTH_TOUCHED, ///< Sent when both buttons are touched
Expand Down Expand Up @@ -391,7 +391,7 @@ typedef struct PACKED__ nbgl_button_s {
nbgl_font_id_e fontId; ///< id of the font to use, if any
bool localized; ///< if set to true, means the following 'text' field is considered as a
const char *text; ///< single line UTF-8 text (NULL terminated)
#if (defined(HAVE_LANGUAGE_PACK) || defined(BUILD_SCREENSHOTS))
#ifdef HAVE_LANGUAGE_PACK
UX_LOC_STRINGS_INDEX textId; ///< id of the text single line UTF-8 text
#endif // HAVE_LANGUAGE_PACK
onTextDrawCallback_t onDrawCallback; ///< function called if not NULL, with above token as
Expand All @@ -418,7 +418,7 @@ typedef struct PACKED__ nbgl_text_area_s {
///< stop display here
const char *text; ///< ASCII text to draw (NULL terminated). Can be NULL.
uint16_t len; ///< number of bytes to write (if 0, max number of chars or strlen is used)
#if (defined(HAVE_LANGUAGE_PACK) || defined(BUILD_SCREENSHOTS))
#ifdef HAVE_LANGUAGE_PACK
UX_LOC_STRINGS_INDEX textId; ///< id of the UTF-8 text
#endif // HAVE_LANGUAGE_PACK
onTextDrawCallback_t
Expand Down
12 changes: 4 additions & 8 deletions lib_nbgl/include/nbgl_step.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ typedef uint8_t nbgl_stepPosition_t;
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t *ticker,
#ifdef BUILD_SCREENSHOTS
uint16_t txtId,
uint16_t subTxtId,
#endif // BUILD_SCREENSHOTS
const char *text,
const char *subText,
nbgl_contentCenteredInfoStyle_t style,
bool modal);
const char *text,
const char *subText,
nbgl_contentCenteredInfoStyle_t style,
bool modal);
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t *ticker,
Expand Down
53 changes: 9 additions & 44 deletions lib_nbgl/src/nbgl_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ static void drawStep(FlowContext_t *ctx,
nbgl_stepPosition_t pos,
bool modal,
const nbgl_icon_details_t *icon,
#ifdef BUILD_SCREENSHOTS
uint16_t txtId,
uint16_t subTxtId,
#endif // BUILD_SCREENSHOTS
const char *txt,
const char *subTxt)
const char *txt,
const char *subTxt)
{
nbgl_layoutCenteredInfo_t info;
if ((ctx->loop) && (ctx->nbSteps > 1)) {
Expand All @@ -114,26 +110,13 @@ static void drawStep(FlowContext_t *ctx,
}

if (icon == NULL) {
ctx->stepCtx = nbgl_stepDrawText(pos,
actionCallback,
NULL,
#ifdef BUILD_SCREENSHOTS
txtId,
subTxtId,
#endif // BUILD_SCREENSHOTS
txt,
subTxt,
REGULAR_INFO,
modal);
ctx->stepCtx
= nbgl_stepDrawText(pos, actionCallback, NULL, txt, subTxt, REGULAR_INFO, modal);
}
else {
info.icon = icon;
info.text1 = txt;
info.text2 = subTxt;
#ifdef BUILD_SCREENSHOTS
info.textId1 = txtId;
info.textId2 = subTxtId;
#endif // BUILD_SCREENSHOTS
info.icon = icon;
info.text1 = txt;
info.text2 = subTxt;
info.onTop = false;
info.style = REGULAR_INFO;
ctx->stepCtx = nbgl_stepDrawCenteredInfo(pos, actionCallback, NULL, &info, modal);
Expand Down Expand Up @@ -184,16 +167,7 @@ static void actionCallback(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
if (step->init != NULL) {
step->init();
}
drawStep(ctx,
pos,
ctx->modal,
step->icon,
#ifdef BUILD_SCREENSHOTS
step->textId,
step->subTextId,
#endif // BUILD_SCREENSHOTS
txt,
step->subText);
drawStep(ctx, pos, ctx->modal, step->icon, txt, step->subText);
nbgl_refresh();
}

Expand Down Expand Up @@ -240,16 +214,7 @@ nbgl_flow_t nbgl_flowDraw(const nbgl_stepDesc_t *steps,
step->init();
}

drawStep(ctx,
pos,
ctx->modal,
step->icon,
#ifdef BUILD_SCREENSHOTS
step->textId,
step->subTextId,
#endif // BUILD_SCREENSHOTS
txt,
step->subText);
drawStep(ctx, pos, ctx->modal, step->icon, txt, step->subText);
nbgl_refresh();
return (nbgl_flow_t) ctx;
}
Expand Down
80 changes: 47 additions & 33 deletions lib_nbgl/src/nbgl_fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const unsigned int C_unicode_characters_count
uint16_t last_nb_lines = 0;
uint16_t last_nb_pages = 0;
bool last_bold_state = false;
void store_string_infos(char *text, uint16_t nb_lines, uint16_t nb_pages, bool bold);
#endif // BUILD_SCREENSHOTS

/**********************
Expand Down Expand Up @@ -589,9 +590,7 @@ bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId,

// if \n, reset width
if (unicode == '\n') {
if (width != 0) {
maxNbLines--;
}
maxNbLines--;
width = 0;
continue;
}
Expand Down Expand Up @@ -713,13 +712,17 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
uint16_t maxWidth,
bool wrapping)
{
const nbgl_font_t *font = nbgl_getFont(fontId);
uint16_t width = 0;
uint16_t nbLines = 0;
uint16_t textLen = strlen(text);
const char *lastDelimiter = NULL;
uint32_t lenAtLastDelimiter = 0;
const char *prevText = NULL;
const nbgl_font_t *font = nbgl_getFont(fontId);
uint16_t width = 0;
#ifdef SCREEN_SIZE_NANO
uint16_t nbLines = 0;
#else // SCREEN_SIZE_NANO
uint16_t nbLines = 1;
#endif // SCREEN_SIZE_NANO
uint16_t textLen = strlen(text);
const char *lastDelimiter = NULL;
uint32_t lenAtLastDelimiter = 0;
const char *prevText = NULL;

#ifdef BUILD_SCREENSHOTS
last_nb_lines = 0;
Expand Down Expand Up @@ -751,9 +754,13 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
#ifdef BUILD_SCREENSHOTS
// Continue parsing the string, to find the real nb_lines & nb_pages!
++last_nb_pages;
#ifdef SCREEN_SIZE_NANO
if (width != 0) {
#endif // SCREEN_SIZE_NANO
++nbLines;
#ifdef SCREEN_SIZE_NANO
}
#endif // SCREEN_SIZE_NANO
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
Expand All @@ -766,18 +773,18 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
}
// if \n, increment the number of lines
else if (unicode == '\n') {
if (width != 0) {
nbLines++;
nbLines++;
#ifdef BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
if (nbLines == 4) {
++last_nb_pages;
nbLines = 0;
}
#endif // BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
#ifdef SCREEN_SIZE_NANO
if (nbLines == 4) {
++last_nb_pages;
nbLines = 0;
}
#endif // SCREEN_SIZE_NANO
#endif // BUILD_SCREENSHOTS
width = 0;
lastDelimiter = NULL;
continue;
Expand Down Expand Up @@ -832,16 +839,19 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
#ifdef SCREEN_SIZE_NANO
if (nbLines == 4) {
++last_nb_pages;
nbLines = 0;
}
#endif // SCREEN_SIZE_NANO
#endif // BUILD_SCREENSHOTS
}
else {
width += char_width;
}
}
#ifdef SCREEN_SIZE_NANO
if (width != 0) {
++nbLines;
}
Expand All @@ -850,6 +860,7 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
last_nb_lines = nbLines;
}
#endif // BUILD_SCREENSHOTS
#endif // SCREEN_SIZE_NANO
return nbLines;
}

Expand Down Expand Up @@ -905,9 +916,13 @@ uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId,
if (unicode == '\f') {
nbPages++;
#ifdef BUILD_SCREENSHOTS
#ifdef SCREEN_SIZE_NANO
if (width != 0) {
#endif // SCREEN_SIZE_NANO
++nbLines;
#ifdef SCREEN_SIZE_NANO
}
#endif // SCREEN_SIZE_NANO
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
Expand All @@ -918,18 +933,17 @@ uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId,
}
// if \n, increment the number of lines
else if (unicode == '\n') {
if (width != 0) {
nbLines++;
nbLines++;
#ifdef BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
#endif // BUILD_SCREENSHOTS
if (nbLines == nbLinesPerPage && textLen) {
nbPages++;
nbLines = 0;
}
if (nbLines == nbLinesPerPage && textLen) {
nbPages++;
nbLines = 0;
}

width = 0;
lastDelimiter = NULL;
continue;
Expand Down Expand Up @@ -996,9 +1010,11 @@ uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId,
}
}
#ifdef BUILD_SCREENSHOTS
#ifdef SCREEN_SIZE_NANO
if (width != 0) {
++nbLines;
}
#endif // SCREEN_SIZE_NANO
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
Expand Down Expand Up @@ -1062,10 +1078,8 @@ void nbgl_textWrapOnNbLines(nbgl_font_id_e fontId, char *text, uint16_t maxWidth
unicode = nbgl_popUnicodeChar((const uint8_t **) &text, &textLen, &is_unicode);
// if \n, reset width
if (unicode == '\n') {
if (width != 0) {
currentNbLines++;
}
width = 0;
width = 0;
currentNbLines++;
lastDelimiter = NULL;
continue;
}
Expand Down
Loading
Loading