23#include "os_helpers.h"
36#if defined(TARGET_STAX)
37#define ENTRY_DIGITS_HEIGHT 50
38#define ENTRY_DIGITS_CONTAINER_HEIGHT 44
39#define INTER_ENTRY_DIGITS 10
40#elif defined(TARGET_FLEX)
41#define ENTRY_DIGITS_HEIGHT 64
42#define ENTRY_DIGITS_CONTAINER_HEIGHT 64
43#define INTER_ENTRY_DIGITS 12
92 keypad->obj.alignmentMarginY = 0;
94 keypad->obj.alignTo = NULL;
95 keypad->obj.area.width = SCREEN_WIDTH;
96 keypad->obj.area.height = 4 * KEYPAD_KEY_HEIGHT;
98 keypad->callback = PIC(callback);
99 keypad->enableDigits =
true;
100 keypad->enableBackspace =
false;
101 keypad->enableValidate =
false;
102 keypad->shuffled = shuffled;
140 bool enableBackspace,
147 "nbgl_layoutUpdateKeypad(): enableValidate = %d, enableBackspace = %d\n",
150 if (layout == NULL) {
157 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
161 keypad->partial = (keypad->enableDigits == enableDigits);
162 keypad->enableValidate = enableValidate;
163 keypad->enableBackspace = enableBackspace;
164 keypad->enableDigits = enableDigits;
185 if (layout == NULL) {
192 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
195 keypad->softValidation = softValidation;
220 if (layout == NULL) {
235 container->nbChildren = nbDigits;
237 container->nbChildren++;
242 container->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
243 container->obj.area.height = ENTRY_DIGITS_HEIGHT;
246 container->obj.alignTo = layoutInt->
container->children[layoutInt->
container->nbChildren - 2];
254 for (
int i = 0; i < nbDigits; i++) {
256 image->buffer = &DIGIT_ICON;
257 image->foregroundColor =
WHITE;
260 image->obj.alignTo = (
nbgl_obj_t *) container->children[i - 1];
261 image->obj.alignmentMarginX = space;
272 line->obj.alignmentMarginY = 0;
273 line->obj.alignTo = NULL;
275 line->obj.area.width = container->obj.area.width;
276 line->obj.area.height = 4;
280 container->children[nbDigits] = (
nbgl_obj_t *) line;
284 return (layoutInt->
container->nbChildren - 1);
303 if (layout == NULL) {
310 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
313 if (nbActive > container->nbChildren) {
319 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
322 image->foregroundColor =
WHITE;
325 image = (
nbgl_image_t *) container->children[nbActive - 1];
326 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
331 if (image->foregroundColor ==
BLACK) {
333 if (nbActive == container->nbChildren) {
338 image->foregroundColor =
WHITE;
341 image->buffer = &DIGIT_ICON;
342 image->foregroundColor =
BLACK;
378 if (layout == NULL) {
387 container->obj.alignmentMarginY = 8;
391 textArea->textColor =
BLACK;
392 textArea->text = title;
393 textArea->textAlignment =
CENTER;
394 textArea->fontId = SMALL_REGULAR_FONT;
395 textArea->wrapping =
true;
399 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
401 container->obj.area.height += textArea->obj.area.height;
415 space = INTER_ENTRY_DIGITS;
420 digitsContainer->nbChildren = nbDigits;
421 digitsContainer->children
425 digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
426 digitsContainer->obj.area.height = ENTRY_DIGITS_CONTAINER_HEIGHT;
428 digitsContainer->obj.alignTo = container->children[0];
431 digitsContainer->obj.alignmentMarginY = 28;
434 container->obj.area.height += digitsContainer->obj.area.height;
439 for (
int i = 0; i < nbDigits; i++) {
441 image->buffer = &DIGIT_ICON;
442 image->foregroundColor =
WHITE;
445 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
446 image->obj.alignmentMarginX = space;
456 textArea->textColor =
BLACK;
457 textArea->text = text;
459 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
460 textArea->obj.area.width = container->obj.area.width;
462 textArea->autoHideLongLine =
true;
464 textArea->obj.alignTo = container->children[
TITLE_INDEX];
467 textArea->obj.alignmentMarginY = 24;
470 container->obj.area.height += textArea->obj.area.height;
480 line->obj.alignTo = container->children[
INPUT_INDEX];
482 line->obj.area.width = 288;
483 line->obj.area.height = 4;
491 return container->obj.area.height;
516 if (layout == NULL) {
527 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
530 if (nbActiveDigits > container->nbChildren) {
533 if (nbActiveDigits == 0) {
536 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
539 image->foregroundColor =
WHITE;
542 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
543 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
548 if (image->foregroundColor ==
BLACK) {
550 if (nbActiveDigits == container->nbChildren) {
554 image = (
nbgl_image_t *) container->children[nbActiveDigits];
555 image->foregroundColor =
WHITE;
559 image->foregroundColor =
BLACK;
570 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
573 textArea->text = text;
574 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)
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.
#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)....
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)
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