23 #include "os_helpers.h"
29 #define DIGIT_ICON C_round_24px
31 #define DIGIT_ICON C_pin_24
87 keypad->obj.alignmentMarginY = 0;
89 keypad->obj.alignTo = NULL;
93 keypad->callback = PIC(callback);
94 keypad->enableDigits =
true;
95 keypad->enableBackspace =
false;
96 keypad->enableValidate =
false;
97 keypad->shuffled = shuffled;
135 bool enableBackspace,
142 "nbgl_layoutUpdateKeypad(): enableValidate = %d, enableBackspace = %d\n",
145 if (layout == NULL) {
152 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
156 keypad->partial = (keypad->enableDigits == enableDigits);
157 keypad->enableValidate = enableValidate;
158 keypad->enableBackspace = enableBackspace;
159 keypad->enableDigits = enableDigits;
180 if (layout == NULL) {
187 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
190 keypad->softValidation = softValidation;
215 if (layout == NULL) {
230 container->nbChildren = nbDigits;
232 container->nbChildren++;
237 container->obj.area.width = nbDigits *
DIGIT_ICON.width + (nbDigits - 1) * space;
239 container->obj.area.height = 50;
241 container->obj.area.height = 64;
245 container->obj.alignTo = layoutInt->
container->children[layoutInt->
container->nbChildren - 2];
253 for (
int i = 0; i < nbDigits; i++) {
256 image->foregroundColor =
WHITE;
259 image->obj.alignTo = (
nbgl_obj_t *) container->children[i - 1];
260 image->obj.alignmentMarginX = space;
271 line->obj.alignmentMarginY = 0;
272 line->obj.alignTo = NULL;
274 line->obj.area.width = container->obj.area.width;
275 line->obj.area.height = 4;
279 container->children[nbDigits] = (
nbgl_obj_t *) line;
283 return (layoutInt->
container->nbChildren - 1);
302 if (layout == NULL) {
309 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
312 if (nbActive > container->nbChildren) {
318 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
321 image->foregroundColor =
WHITE;
324 image = (
nbgl_image_t *) container->children[nbActive - 1];
325 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
330 if (image->foregroundColor ==
BLACK) {
332 if (nbActive == container->nbChildren) {
337 image->foregroundColor =
WHITE;
341 image->foregroundColor =
BLACK;
377 if (layout == NULL) {
386 container->obj.alignmentMarginY = 8;
390 textArea->textColor =
BLACK;
391 textArea->text = title;
392 textArea->textAlignment =
CENTER;
393 textArea->fontId = SMALL_REGULAR_FONT;
394 textArea->wrapping =
true;
398 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
400 container->obj.area.height += textArea->obj.area.height;
423 digitsContainer->nbChildren = nbDigits;
424 digitsContainer->children
428 digitsContainer->obj.area.width = nbDigits *
DIGIT_ICON.width + (nbDigits - 1) * space;
430 digitsContainer->obj.area.height = 44;
432 digitsContainer->obj.area.height = 64;
435 digitsContainer->obj.alignTo = container->children[0];
438 digitsContainer->obj.alignmentMarginY = 28;
441 container->obj.area.height += digitsContainer->obj.area.height;
446 for (
int i = 0; i < nbDigits; i++) {
449 image->foregroundColor =
WHITE;
452 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
453 image->obj.alignmentMarginX = space;
463 textArea->textColor =
BLACK;
464 textArea->text = text;
466 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
467 textArea->obj.area.width = container->obj.area.width;
469 textArea->autoHideLongLine =
true;
471 textArea->obj.alignTo = container->children[
TITLE_INDEX];
474 textArea->obj.alignmentMarginY = 24;
477 container->obj.area.height += textArea->obj.area.height;
487 line->obj.alignTo = container->children[
INPUT_INDEX];
489 line->obj.area.width = 288;
490 line->obj.area.height = 4;
498 return container->obj.area.height;
523 if (layout == NULL) {
534 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
537 if (nbActiveDigits > container->nbChildren) {
540 if (nbActiveDigits == 0) {
543 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
546 image->foregroundColor =
WHITE;
549 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
550 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
555 if (image->foregroundColor ==
BLACK) {
557 if (nbActiveDigits == container->nbChildren) {
561 image = (
nbgl_image_t *) container->children[nbActiveDigits];
562 image->foregroundColor =
WHITE;
566 image->foregroundColor =
BLACK;
577 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
580 textArea->text = text;
581 textArea->textColor =
BLACK;
#define LOG_DEBUG(__logger,...)
Middle Level API of the new BOLOS Graphical Library.
uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
return the max width in pixels of the given text until the first or \0 is encountered
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
return the height of the given multiline text, with the given font.
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
return the height in pixels of the line of font with the given font ID
Font screen low-Level driver API, to draw elementary forms.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the main container
void * nbgl_layout_t
type shared externally
Internal functions/constants of NBGL layout layer.
#define KEYPAD_FOOTER_TYPE
int nbgl_layoutAddHiddenDigits(nbgl_layout_t *layout, uint8_t nbDigits)
Adds a placeholder for hidden digits on top of a keypad, to represent the entered digits,...
int nbgl_layoutUpdateHiddenDigits(nbgl_layout_t *layout, uint8_t index, uint8_t nbActive)
Updates an existing set of hidden digits, with the given configuration.
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace, bool enableDigits)
Updates an existing keypad on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeypadValidation(nbgl_layout_t *layout, bool softValidation)
Updates an existing keypad on bottom of the screen, with the given configuration, without redraw.
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, const char *title, bool hidden, uint8_t nbDigits, const char *text)
Adds an area with a title and a placeholder for hidden digits on top of a keypad, to represent the en...
int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout, bool hidden, uint8_t nbActiveDigits, const char *text)
Updates an existing set of hidden digits, with the given configuration.
int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
API to draw all basic graphic objects.
struct PACKED__ nbgl_line_s nbgl_line_t
struct to represent a vertical or horizontal line
struct PACKED__ nbgl_text_area_s nbgl_text_area_t
struct to represent a text area (TEXT_AREA type)
void nbgl_objDraw(nbgl_obj_t *obj)
This function draws or redraws the given object and its children (recursive version)
nbgl_obj_t ** nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer)
Gets a new container from the pool, with the given number of obj pointers.
struct PACKED__ nbgl_keypad_s nbgl_keypad_t
struct to represent a keypad (KEYPAD type)
#define KEYPAD_MAX_DIGITS
struct PACKED__ nbgl_image_s nbgl_image_t
struct to represent an image (IMAGE type)
int nbgl_objPoolGetArray(nbgl_obj_type_t type, uint8_t nbObjs, uint8_t layer, nbgl_obj_t **objArray)
Gets nbObjects new graphic object from the pool, with the given type, for the given layer (screen)....
nbgl_obj_t * nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer)
Gets a new graphic object from the pool, with the given type. The type field of the object is set.
void(* keyboardCallback_t)(char touchedKey)
prototype of function to be called when a valid key is pressed on keyboard Backspace is equal to 0x8 ...
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
#define KEYPAD_KEY_HEIGHT
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
@ VERTICAL
from top to bottom
@ HORIZONTAL
from left to right
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
@ LINE
Vertical or Horizontal line.
@ CONTAINER
Empty container.
@ TEXT_AREA
Area to contain text line(s)
Structure containing all information about the current layout.
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
nbgl_container_t * container
nbgl_layoutFooterType_t footerType
type of footer
nbgl_obj_t ** children
children for main screen