23#include "os_helpers.h"
36#if defined(TARGET_STAX)
37#define ENTRY_DIGITS_LINE_WIDTH 288
38#define ENTRY_DIGITS_CONTAINER_HEIGHT 52
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_CONTAINER_HEIGHT 64
44#define INTER_ENTRY_DIGITS 12
45#define TITLE_MARGIN_Y 8
46#define TITLE_MARGIN_Y_SMALL 8
47#elif defined(TARGET_APEX)
48#define ENTRY_DIGITS_CONTAINER_HEIGHT 40
49#define INTER_ENTRY_DIGITS 8
50#define TITLE_MARGIN_Y 13
51#define TITLE_MARGIN_Y_SMALL 2
101 keypad->obj.alignmentMarginY = 0;
103 keypad->obj.alignTo = NULL;
105 keypad->obj.area.height = 4 * KEYPAD_KEY_HEIGHT;
106 keypad->callback = PIC(callback);
107 keypad->enableDigits =
true;
108 keypad->enableBackspace =
false;
109 keypad->enableValidate =
false;
110 keypad->shuffled = shuffled;
111 keypad->digitsChanged =
true;
112 keypad->validateChanged =
true;
150 bool enableBackspace,
157 "nbgl_layoutUpdateKeypad(): enableValidate = %d, enableBackspace = %d\n",
160 if (layout == NULL) {
167 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;
191int nbgl_layoutUpdateKeypadValidation(
nbgl_layout_t *layout,
bool softValidation)
197 if (layout == NULL) {
204 if ((keypad == NULL) || (keypad->obj.type !=
KEYPAD)) {
208 keypad->softValidation = softValidation;
240 if (layout == NULL) {
245 container->nbChildren = NB_CHILDREN;
252 textArea->textColor =
BLACK;
253 textArea->text = title;
254 textArea->textAlignment =
CENTER;
255 textArea->fontId = SMALL_REGULAR_FONT;
256 textArea->wrapping =
true;
260 textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);
262 container->obj.alignmentMarginY = TITLE_MARGIN_Y_SMALL;
265 container->obj.alignmentMarginY = TITLE_MARGIN_Y;
267 container->children[TITLE_INDEX] = (
nbgl_obj_t *) textArea;
268 container->obj.area.height += textArea->obj.area.height;
276 "nbgl_layoutAddKeypadContent(): nbDigits %d > KEYPAD_MAX_DIGITS %d\n",
286 space = INTER_ENTRY_DIGITS;
291 digitsContainer->nbChildren = nbDigits;
294 digitsContainer->nbChildren++;
296 digitsContainer->children
301 digitsContainer->obj.area.width = ENTRY_DIGITS_LINE_WIDTH;
303 digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space;
305 digitsContainer->obj.area.height = ENTRY_DIGITS_CONTAINER_HEIGHT;
307 digitsContainer->obj.alignTo = container->children[0];
309 container->children[INPUT_INDEX] = (
nbgl_obj_t *) digitsContainer;
310 container->obj.area.height += digitsContainer->obj.area.height;
315 for (
int i = 0; i < nbDigits; i++) {
317 image->buffer = &DIGIT_ICON;
318 image->foregroundColor =
WHITE;
321 image->obj.alignTo = (
nbgl_obj_t *) digitsContainer->children[i - 1];
322 image->obj.alignmentMarginX = space;
333 line->obj.alignTo = container->children[INPUT_INDEX];
335 line->obj.area.width = ENTRY_DIGITS_LINE_WIDTH;
336 line->obj.area.height = 4;
340 digitsContainer->children[nbDigits] = (
nbgl_obj_t *) line;
341 digitsContainer->children[0]->alignmentMarginX
342 = (line->obj.area.width - (nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space)) / 2;
348 textArea->textColor =
BLACK;
349 textArea->text = text;
351 textArea->fontId = LARGE_MEDIUM_1BPP_FONT;
352 textArea->obj.area.width = container->obj.area.width;
354 textArea->autoHideLongLine =
true;
356 textArea->obj.alignTo = container->children[TITLE_INDEX];
359 textArea->obj.alignmentMarginY = 24;
361 container->children[INPUT_INDEX] = (
nbgl_obj_t *) textArea;
362 container->obj.area.height += textArea->obj.area.height;
369 return container->obj.area.height;
386 uint8_t nbActiveDigits,
394 if (layout == NULL) {
405 if ((container == NULL) || (container->obj.type !=
CONTAINER)) {
409 if (nbActiveDigits > container->nbChildren) {
411 "nbgl_layoutUpdateKeypadContent(): nbActive %d > nbChildren %d\n",
413 container->nbChildren);
416 if (nbActiveDigits == 0) {
419 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
423 image->foregroundColor =
WHITE;
426 image = (
nbgl_image_t *) container->children[nbActiveDigits - 1];
427 if ((image == NULL) || (image->obj.type !=
IMAGE)) {
433 if (image->foregroundColor ==
BLACK) {
435 if (nbActiveDigits == container->nbChildren) {
439 image = (
nbgl_image_t *) container->children[nbActiveDigits];
440 image->foregroundColor =
WHITE;
444 image->foregroundColor =
BLACK;
455 if ((textArea == NULL) || (textArea->obj.type !=
TEXT_AREA)) {
459 textArea->text = text;
460 textArea->textColor =
BLACK;
#define LOG_WARN(__logger,...)
#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)
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
Font screen low-Level driver API, to draw elementary forms.
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace)
Updates an existing keypad on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, 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...
void * nbgl_layout_t
type shared externally
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, const char *text, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
Internal functions/constants of NBGL layout layer.
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the layout
#define KEYPAD_FOOTER_TYPE
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)
nbgl_obj_t ** nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer)
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)
#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)
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