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#define TITLE_MARGIN_Y 8
41#define TITLE_MARGIN_Y_SMALL 8
42#elif defined(TARGET_FLEX)
43#define ENTRY_DIGITS_HEIGHT 64
44#define ENTRY_DIGITS_CONTAINER_HEIGHT 64
45#define INTER_ENTRY_DIGITS 12
46#define TITLE_MARGIN_Y 8
47#define TITLE_MARGIN_Y_SMALL 8
48#elif defined(TARGET_APEX)
49#define ENTRY_DIGITS_HEIGHT 40
50#define ENTRY_DIGITS_CONTAINER_HEIGHT 40
51#define INTER_ENTRY_DIGITS 8
52#define TITLE_MARGIN_Y 13
53#define TITLE_MARGIN_Y_SMALL 2
102 keypad->obj.alignmentMarginY = 0;
104 keypad->obj.alignTo = NULL;
105 keypad->obj.area.width = SCREEN_WIDTH;
106 keypad->obj.area.height = 4 * KEYPAD_KEY_HEIGHT;
107 keypad->callback = PIC(callback);
108 keypad->enableDigits =
true;
109 keypad->enableBackspace =
false;
110 keypad->enableValidate =
false;
111 keypad->shuffled = shuffled;
112 keypad->digitsChanged =
true;
113 keypad->validateChanged =
true;
151 bool enableBackspace,
158 "nbgl_layoutUpdateKeypad(): enableValidate = %d, enableBackspace = %d\n",
161 if (layout == NULL) {
168 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
172 keypad->digitsChanged = (keypad->enableDigits != enableDigits);
173 keypad->validateChanged = (keypad->enableValidate != enableValidate);
174 keypad->enableValidate = enableValidate;
175 keypad->enableBackspace = enableBackspace;
176 keypad->enableDigits = enableDigits;
197 if (layout == NULL) {
204 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
207 keypad->softValidation = softValidation;
232 if (layout == NULL) {
247 container->nbChildren = nbDigits;
249 container->nbChildren++;
254 container->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
255 container->obj.area.height = ENTRY_DIGITS_HEIGHT;
258 container->obj.alignTo = layoutInt->
container->children[layoutInt->
container->nbChildren - 2];
266 for (
int i = 0; i < nbDigits; i++) {
268 image->buffer = &DIGIT_ICON;
269 image->foregroundColor =
WHITE;
272 image->obj.alignTo = (
nbgl_obj_t *) container->children[i - 1];
273 image->obj.alignmentMarginX = space;
284 line->obj.alignmentMarginY = 0;
285 line->obj.alignTo = NULL;
287 line->obj.area.width = container->obj.area.width;
288 line->obj.area.height = 4;
292 container->children[nbDigits] = (
nbgl_obj_t *) line;
296 return (layoutInt->
container->nbChildren - 1);
315 if (layout == NULL) {
322 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
325 if (nbActive > container->nbChildren) {
331 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
334 image->foregroundColor =
WHITE;
337 image = (
nbgl_image_t *) container->children[nbActive - 1];
338 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
343 if (image->foregroundColor ==
BLACK) {
345 if (nbActive == container->nbChildren) {
350 image->foregroundColor =
WHITE;
353 image->buffer = &DIGIT_ICON;
354 image->foregroundColor =
BLACK;
390 if (layout == NULL) {
402 textArea->textColor =
BLACK;
403 textArea->text = title;
404 textArea->textAlignment =
CENTER;
405 textArea->fontId = SMALL_REGULAR_FONT;
406 textArea->wrapping =
true;
410 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
412 container->obj.alignmentMarginY = TITLE_MARGIN_Y_SMALL;
415 container->obj.alignmentMarginY = TITLE_MARGIN_Y;
418 container->obj.area.height += textArea->obj.area.height;
432 space = INTER_ENTRY_DIGITS;
437 digitsContainer->nbChildren = nbDigits;
438 digitsContainer->children
442 digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
443 digitsContainer->obj.area.height = ENTRY_DIGITS_CONTAINER_HEIGHT;
445 digitsContainer->obj.alignTo = container->children[0];
448 digitsContainer->obj.alignmentMarginY = 28;
451 container->obj.area.height += digitsContainer->obj.area.height;
456 for (
int i = 0; i < nbDigits; i++) {
458 image->buffer = &DIGIT_ICON;
459 image->foregroundColor =
WHITE;
462 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
463 image->obj.alignmentMarginX = space;
473 textArea->textColor =
BLACK;
474 textArea->text = text;
476 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
477 textArea->obj.area.width = container->obj.area.width;
479 textArea->autoHideLongLine =
true;
481 textArea->obj.alignTo = container->children[
TITLE_INDEX];
484 textArea->obj.alignmentMarginY = 24;
487 container->obj.area.height += textArea->obj.area.height;
497 line->obj.alignTo = container->children[
INPUT_INDEX];
499 line->obj.area.width = 288;
500 line->obj.area.height = 4;
508 return container->obj.area.height;
525 uint8_t nbActiveDigits,
533 if (layout == NULL) {
544 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
547 if (nbActiveDigits > container->nbChildren) {
550 if (nbActiveDigits == 0) {
553 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
556 image->foregroundColor =
WHITE;
559 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
560 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
565 if (image->foregroundColor ==
BLACK) {
567 if (nbActiveDigits == container->nbChildren) {
571 image = (
nbgl_image_t *) container->children[nbActiveDigits];
572 image->foregroundColor =
WHITE;
576 image->foregroundColor =
BLACK;
587 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
590 textArea->text = text;
591 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
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
return the height in pixels of the font with the given font ID
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....)
uint8_t layer
layer in screen stack
nbgl_container_t * container
nbgl_layoutFooterType_t footerType
type of footer
nbgl_obj_t ** children
children for main screen