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 Oct 21, 2024
1 parent 4215a52 commit 10df78e
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 @@ -1366,13 +1366,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 @@ -1383,7 +1384,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 @@ -1394,12 +1395,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 @@ -308,6 +308,7 @@ void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t c
nbgl_touchType_t swipe = nbgl_detectSwipe(touchStatePosition, &firstTouchedPosition);
bool consumed = false;

lastState = touchStatePosition->state;
if (swipe != NB_TOUCH_TYPES) {
// Swipe detected
nbgl_obj_t *swipedObj = getSwipableObject(
Expand Down Expand Up @@ -336,6 +337,7 @@ void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t c
}
else { // PRESSED
if ((lastState == PRESSED) && (lastPressedObj != NULL)) {
lastState = touchStatePosition->state;
if (foundObj != lastPressedObj) {
// finger has moved out of an object
// make sure lastPressedObj still belongs to current screen before warning it
Expand All @@ -350,15 +352,14 @@ void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t c
}
}
else if (lastState == RELEASED) {
lastState = touchStatePosition->state;
// newly touched object
lastPressedObj = foundObj;
lastPressedTime = currentTime;
applytouchStatePosition(foundObj, TOUCH_PRESSED);
applytouchStatePosition(foundObj, TOUCHING);
}
}

lastState = touchStatePosition->state;
}

bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj,
Expand Down

0 comments on commit 10df78e

Please sign in to comment.