23#include "os_helpers.h"
37#if defined(TARGET_STAX)
38#define ENTRY_DIGITS_HEIGHT 50
39#define ENTRY_DIGITS_CONTAINER_HEIGHT 44
40#define INTER_ENTRY_DIGITS 10
41#define TITLE_MARGIN_Y 8
42#define TITLE_MARGIN_Y_SMALL 8
43#elif defined(TARGET_FLEX)
44#define ENTRY_DIGITS_HEIGHT 64
45#define ENTRY_DIGITS_CONTAINER_HEIGHT 64
46#define INTER_ENTRY_DIGITS 12
47#define TITLE_MARGIN_Y 8
48#define TITLE_MARGIN_Y_SMALL 8
49#elif defined(TARGET_APEX)
50#define ENTRY_DIGITS_HEIGHT 40
51#define ENTRY_DIGITS_CONTAINER_HEIGHT 40
52#define INTER_ENTRY_DIGITS 8
53#define TITLE_MARGIN_Y 13
54#define TITLE_MARGIN_Y_SMALL 2
103 keypad->obj.alignmentMarginY = 0;
105 keypad->obj.alignTo = NULL;
106 keypad->obj.area.width = SCREEN_WIDTH;
107 keypad->obj.area.height = 4 * KEYPAD_KEY_HEIGHT;
108 keypad->callback = PIC(callback);
109 keypad->enableDigits =
true;
110 keypad->enableBackspace =
false;
111 keypad->enableValidate =
false;
112 keypad->shuffled = shuffled;
113 keypad->digitsChanged =
true;
114 keypad->validateChanged =
true;
152 bool enableBackspace,
159 "nbgl_layoutUpdateKeypad(): enableValidate = %d, enableBackspace = %d\n",
162 if (layout == NULL) {
169 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
173 keypad->digitsChanged = (keypad->enableDigits != enableDigits);
174 keypad->validateChanged = (keypad->enableValidate != enableValidate);
175 keypad->enableValidate = enableValidate;
176 keypad->enableBackspace = enableBackspace;
177 keypad->enableDigits = enableDigits;
198 if (layout == NULL) {
205 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
208 keypad->softValidation = softValidation;
233 if (layout == NULL) {
248 container->nbChildren = nbDigits;
250 container->nbChildren++;
255 container->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
256 container->obj.area.height = ENTRY_DIGITS_HEIGHT;
259 container->obj.alignTo = layoutInt->
container->children[layoutInt->
container->nbChildren - 2];
267 for (
int i = 0; i < nbDigits; i++) {
269 image->buffer = &DIGIT_ICON;
270 image->foregroundColor =
WHITE;
273 image->obj.alignTo = (
nbgl_obj_t *) container->children[i - 1];
274 image->obj.alignmentMarginX = space;
285 line->obj.alignmentMarginY = 0;
286 line->obj.alignTo = NULL;
288 line->obj.area.width = container->obj.area.width;
289 line->obj.area.height = 4;
293 container->children[nbDigits] = (
nbgl_obj_t *) line;
297 return (layoutInt->
container->nbChildren - 1);
316 if (layout == NULL) {
323 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
326 if (nbActive > container->nbChildren) {
332 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
335 image->foregroundColor =
WHITE;
338 image = (
nbgl_image_t *) container->children[nbActive - 1];
339 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
344 if (image->foregroundColor ==
BLACK) {
346 if (nbActive == container->nbChildren) {
351 image->foregroundColor =
WHITE;
354 image->buffer = &DIGIT_ICON;
355 image->foregroundColor =
BLACK;
391 if (layout == NULL) {
403 textArea->textColor =
BLACK;
404 textArea->text = title;
405 textArea->textAlignment =
CENTER;
406 textArea->fontId = SMALL_REGULAR_FONT;
407 textArea->wrapping =
true;
411 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
413 container->obj.alignmentMarginY = TITLE_MARGIN_Y_SMALL;
416 container->obj.alignmentMarginY = TITLE_MARGIN_Y;
419 container->obj.area.height += textArea->obj.area.height;
433 space = INTER_ENTRY_DIGITS;
438 digitsContainer->nbChildren = nbDigits;
439 digitsContainer->children
443 digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
444 digitsContainer->obj.area.height = ENTRY_DIGITS_CONTAINER_HEIGHT;
446 digitsContainer->obj.alignTo = container->children[0];
449 digitsContainer->obj.alignmentMarginY = 28;
452 container->obj.area.height += digitsContainer->obj.area.height;
457 for (
int i = 0; i < nbDigits; i++) {
459 image->buffer = &DIGIT_ICON;
460 image->foregroundColor =
WHITE;
463 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
464 image->obj.alignmentMarginX = space;
474 textArea->textColor =
BLACK;
475 textArea->text = text;
477 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
478 textArea->obj.area.width = container->obj.area.width;
480 textArea->autoHideLongLine =
true;
482 textArea->obj.alignTo = container->children[
TITLE_INDEX];
485 textArea->obj.alignmentMarginY = 24;
488 container->obj.area.height += textArea->obj.area.height;
498 line->obj.alignTo = container->children[
INPUT_INDEX];
500 line->obj.area.width = 288;
501 line->obj.area.height = 4;
509 return container->obj.area.height;
526 uint8_t nbActiveDigits,
534 if (layout == NULL) {
545 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
548 if (nbActiveDigits > container->nbChildren) {
551 if (nbActiveDigits == 0) {
554 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
557 image->foregroundColor =
WHITE;
560 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
561 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
566 if (image->foregroundColor ==
BLACK) {
568 if (nbActiveDigits == container->nbChildren) {
572 image = (
nbgl_image_t *) container->children[nbActiveDigits];
573 image->foregroundColor =
WHITE;
577 image->foregroundColor =
BLACK;
588 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
591 textArea->text = text;
592 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