Skip to content

Commit

Permalink
Update nbgl_layoutAddLargeCaseText() to enable gray text
Browse files Browse the repository at this point in the history
  • Loading branch information
nroggeman-ledger committed Nov 7, 2024
1 parent e26b58b commit ba39b9c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 14 additions & 6 deletions lib_nbgl/src/nbgl_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions lib_nbgl/src/nbgl_touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -373,15 +375,14 @@ void nbgl_touchHandler(bool fromUx,
}
}
else if (ctx->lastState == RELEASED) {
ctx->lastState = touchStatePosition->state;
// newly touched object
ctx->lastPressedObj = foundObj;
ctx->lastPressedTime = currentTime;
applytouchStatePosition(foundObj, TOUCH_PRESSED);
applytouchStatePosition(foundObj, TOUCHING);
}
}

ctx->lastState = touchStatePosition->state;
}

bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj,
Expand Down

0 comments on commit ba39b9c

Please sign in to comment.