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;
186 if (layout == NULL) {
201 container->nbChildren = nbDigits;
203 container->nbChildren++;
208 container->obj.area.width = nbDigits *
DIGIT_ICON.width + (nbDigits - 1) * space;
210 container->obj.area.height = 50;
212 container->obj.area.height = 64;
216 container->obj.alignTo = layoutInt->
container->children[layoutInt->
container->nbChildren - 2];
224 for (
int i = 0; i < nbDigits; i++) {
227 image->foregroundColor =
WHITE;
230 image->obj.alignTo = (
nbgl_obj_t *) container->children[i - 1];
231 image->obj.alignmentMarginX = space;
242 line->obj.alignmentMarginY = 0;
243 line->obj.alignTo = NULL;
245 line->obj.area.width = container->obj.area.width;
246 line->obj.area.height = 4;
250 container->children[nbDigits] = (
nbgl_obj_t *) line;
254 return (layoutInt->
container->nbChildren - 1);
273 if (layout == NULL) {
280 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
283 if (nbActive > container->nbChildren) {
289 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
292 image->foregroundColor =
WHITE;
295 image = (
nbgl_image_t *) container->children[nbActive - 1];
296 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
301 if (image->foregroundColor ==
BLACK) {
303 if (nbActive == container->nbChildren) {
308 image->foregroundColor =
WHITE;
312 image->foregroundColor =
BLACK;
348 if (layout == NULL) {
357 container->obj.alignmentMarginY = 8;
361 textArea->textColor =
BLACK;
362 textArea->text = title;
363 textArea->textAlignment =
CENTER;
364 textArea->fontId = SMALL_REGULAR_FONT;
365 textArea->wrapping =
true;
369 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
371 container->obj.area.height += textArea->obj.area.height;
394 digitsContainer->nbChildren = nbDigits;
395 digitsContainer->children
399 digitsContainer->obj.area.width = nbDigits *
DIGIT_ICON.width + (nbDigits - 1) * space;
401 digitsContainer->obj.area.height = 44;
403 digitsContainer->obj.area.height = 64;
406 digitsContainer->obj.alignTo = container->children[0];
409 digitsContainer->obj.alignmentMarginY = 28;
412 container->obj.area.height += digitsContainer->obj.area.height;
417 for (
int i = 0; i < nbDigits; i++) {
420 image->foregroundColor =
WHITE;
423 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
424 image->obj.alignmentMarginX = space;
434 textArea->textColor =
BLACK;
435 textArea->text = text;
437 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
438 textArea->obj.area.width = container->obj.area.width;
440 textArea->autoHideLongLine =
true;
442 textArea->obj.alignTo = container->children[
TITLE_INDEX];
445 textArea->obj.alignmentMarginY = 24;
448 container->obj.area.height += textArea->obj.area.height;
458 line->obj.alignTo = container->children[
INPUT_INDEX];
460 line->obj.area.width = 288;
461 line->obj.area.height = 4;
469 return container->obj.area.height;
494 if (layout == NULL) {
505 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
508 if (nbActiveDigits > container->nbChildren) {
511 if (nbActiveDigits == 0) {
514 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
517 image->foregroundColor =
WHITE;
520 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
521 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
526 if (image->foregroundColor ==
BLACK) {
528 if (nbActiveDigits == container->nbChildren) {
532 image = (
nbgl_image_t *) container->children[nbActiveDigits];
533 image->foregroundColor =
WHITE;
537 image->foregroundColor =
BLACK;
548 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
551 textArea->text = text;
552 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_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