From ba39b9c1bb44ce673e1fe2b10d49b60d80cf6b96 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Mon, 21 Oct 2024 11:38:00 +0200 Subject: [PATCH] Update nbgl_layoutAddLargeCaseText() to enable gray text --- lib_nbgl/include/nbgl_layout.h | 2 +- lib_nbgl/src/nbgl_layout.c | 20 ++++++++++++++------ lib_nbgl/src/nbgl_touch.c | 5 +++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib_nbgl/include/nbgl_layout.h b/lib_nbgl/include/nbgl_layout.h index e7d797d5d..d1c17f497 100644 --- a/lib_nbgl/include/nbgl_layout.h +++ b/lib_nbgl/include/nbgl_layout.h @@ -617,7 +617,7 @@ int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceBu int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout, const nbgl_layoutHorizontalButtons_t *info); int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list); -int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text); +int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool grayedOut); int nbgl_layoutAddTextContent(nbgl_layout_t *layout, const char *title, const char *description, diff --git a/lib_nbgl/src/nbgl_layout.c b/lib_nbgl/src/nbgl_layout.c index 5e775a2bf..c4e96137e 100644 --- a/lib_nbgl/src/nbgl_layout.c +++ b/lib_nbgl/src/nbgl_layout.c @@ -1367,13 +1367,14 @@ int nbgl_layoutAddSubHeaderText(nbgl_layout_t *layout, const char *text) } /** - * @brief Creates an area with given text in 32px font (in Black) + * @brief Creates an area with given text in 32px font (in Black or Light Gray) * * @param layout the current layout * @param text text to be displayed (auto-wrap) + * @param grayedOut if true, use light-gray instead of black * @return >= 0 if OK */ -int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text) +int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool grayedOut) { nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout; nbgl_text_area_t *textArea; @@ -1384,7 +1385,7 @@ int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text) } textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer); - textArea->textColor = BLACK; + textArea->textColor = grayedOut ? LIGHT_GRAY : BLACK; textArea->text = PIC(text); textArea->textAlignment = MID_LEFT; textArea->fontId = LARGE_MEDIUM_FONT; @@ -1395,12 +1396,19 @@ int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text) textArea->style = NO_STYLE; textArea->obj.alignment = NO_ALIGNMENT; textArea->obj.alignmentMarginX = BORDER_MARGIN; -#ifdef TARGET_STAX - // if first object of container, increase the margin from top if (layoutInt->container->nbChildren == 0) { +#ifdef TARGET_STAX + // if first object of container, increase the margin from top textArea->obj.alignmentMarginY += BORDER_MARGIN; - } #endif // TARGET_STAX + } + else { +#ifdef TARGET_STAX + textArea->obj.alignmentMarginY = 40; // 40px between paragraphs +#else // TARGET_STAX + textArea->obj.alignmentMarginY = 24; // 24px between paragraphs +#endif // TARGET_STAX + } // set this new obj as child of main container layoutAddObject(layoutInt, (nbgl_obj_t *) textArea); diff --git a/lib_nbgl/src/nbgl_touch.c b/lib_nbgl/src/nbgl_touch.c index b2f2c25a1..26be441d3 100644 --- a/lib_nbgl/src/nbgl_touch.c +++ b/lib_nbgl/src/nbgl_touch.c @@ -330,6 +330,7 @@ void nbgl_touchHandler(bool fromUx, nbgl_touchType_t swipe = nbgl_detectSwipe(touchStatePosition, &ctx->firstTouchedPosition); bool consumed = false; + ctx->lastState = touchStatePosition->state; if (swipe != NB_TOUCH_TYPES) { // Swipe detected nbgl_obj_t *swipedObj = getSwipableObject( @@ -359,6 +360,7 @@ void nbgl_touchHandler(bool fromUx, } else { // PRESSED if ((ctx->lastState == PRESSED) && (ctx->lastPressedObj != NULL)) { + ctx->lastState = touchStatePosition->state; if (foundObj != ctx->lastPressedObj) { // finger has moved out of an object // make sure lastPressedObj still belongs to current screen before warning it @@ -373,6 +375,7 @@ void nbgl_touchHandler(bool fromUx, } } else if (ctx->lastState == RELEASED) { + ctx->lastState = touchStatePosition->state; // newly touched object ctx->lastPressedObj = foundObj; ctx->lastPressedTime = currentTime; @@ -380,8 +383,6 @@ void nbgl_touchHandler(bool fromUx, applytouchStatePosition(foundObj, TOUCHING); } } - - ctx->lastState = touchStatePosition->state; } bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj,