Embedded SDK
Embedded SDK
Macros | Enumerations | Functions
nbgl_layout_keyboard.c File Reference

Implementation of predefined keyboard related layouts management. More...

#include <string.h>
#include <stdlib.h>
#include "nbgl_debug.h"
#include "nbgl_front.h"
#include "nbgl_layout_internal.h"
#include "nbgl_obj.h"
#include "nbgl_draw.h"
#include "nbgl_screen.h"
#include "nbgl_touch.h"
#include "glyphs.h"
#include "os_pic.h"
#include "os_helpers.h"
Include dependency graph for nbgl_layout_keyboard.c:

Go to the source code of this file.

Macros

#define TEXT_ENTRY_NORMAL_HEIGHT   72
 
#define TEXT_ENTRY_COMPACT_HEIGHT   56
 
#define BOTTOM_NORMAL_MARGIN   24
 
#define BOTTOM_COMPACT_MARGIN   12
 
#define TOP_NORMAL_MARGIN   20
 
#define TOP_COMPACT_MARGIN   12
 
#define LINE_REAL_HEIGHT   4
 
#define NUMBER_WIDTH   56
 
#define NUMBER_TEXT_SPACE   8
 

Enumerations

enum  {
  PAGE_INDICATOR_INDEX = 0 , LEFT_HALF_INDEX , RIGHT_HALF_INDEX , FIRST_BUTTON_INDEX ,
  SECOND_BUTTON_INDEX , NB_SUGGESTION_CHILDREN
}
 

Functions

bool keyboardSwipeCallback (nbgl_obj_t *obj, nbgl_touchType_t eventType)
 
int nbgl_layoutAddKeyboard (nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
 Creates a keyboard on bottom of the screen, with the given configuration. More...
 
int nbgl_layoutUpdateKeyboard (nbgl_layout_t *layout, uint8_t index, uint32_t keyMask, bool updateCasing, keyboardCase_t casing)
 Updates an existing keyboard on bottom of the screen, with the given configuration. More...
 
bool nbgl_layoutKeyboardNeedsRefresh (nbgl_layout_t *layout, uint8_t index)
 function called to know whether the keyboard has been redrawn and needs a refresh More...
 
int nbgl_layoutAddSuggestionButtons (nbgl_layout_t *layout, uint8_t nbUsedButtons, const char *buttonTexts[NB_MAX_SUGGESTION_BUTTONS], int firstButtonToken, tune_index_e tuneId)
 Adds up to 4 black suggestion buttons under the previously added object. More...
 
int nbgl_layoutUpdateSuggestionButtons (nbgl_layout_t *layout, uint8_t index, uint8_t nbUsedButtons, const char *buttonTexts[NB_MAX_SUGGESTION_BUTTONS])
 Updates the number and/or the text suggestion buttons created with nbgl_layoutAddSuggestionButtons() More...
 
int nbgl_layoutAddEnteredText (nbgl_layout_t *layout, bool numbered, uint8_t number, const char *text, bool grayedOut, int offsetY, int token)
 Adds a "text entry" area under the previously entered object. This area can be preceded (beginning of line) by an index, indicating for example the entered world. A vertical gray line is placed under the text. This text must be vertical placed in the screen with offsetY. More...
 
int nbgl_layoutUpdateEnteredText (nbgl_layout_t *layout, uint8_t index, bool numbered, uint8_t number, const char *text, bool grayedOut)
 Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText() More...
 
int nbgl_layoutAddConfirmationButton (nbgl_layout_t *layout, bool active, const char *text, int token, tune_index_e tuneId)
 Adds a black full width confirmation button on top of the previously added keyboard. More...
 
int nbgl_layoutUpdateConfirmationButton (nbgl_layout_t *layout, uint8_t index, bool active, const char *text)
 Updates an existing black full width confirmation button on top of the previously added keyboard. More...
 
int nbgl_layoutAddKeyboardContent (nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
 Adds an area containing a potential title, a text entry and either confirmation or suggestion buttons, on top of the keyboard. More...
 
int nbgl_layoutUpdateKeyboardContent (nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
 Updates an area containing a potential title, a text entry and either confirmation or suggestion buttons, on top of the keyboard This area must have been built with nbgl_layoutAddKeyboardContent, and the type must not change. More...
 

Detailed Description

Implementation of predefined keyboard related layouts management.

Note
This file applies only to wallet size products (Stax, Flex...)

Definition in file nbgl_layout_keyboard.c.

Macro Definition Documentation

◆ BOTTOM_COMPACT_MARGIN

#define BOTTOM_COMPACT_MARGIN   12

Definition at line 55 of file nbgl_layout_keyboard.c.

◆ BOTTOM_NORMAL_MARGIN

#define BOTTOM_NORMAL_MARGIN   24

Definition at line 54 of file nbgl_layout_keyboard.c.

◆ LINE_REAL_HEIGHT

#define LINE_REAL_HEIGHT   4

Definition at line 61 of file nbgl_layout_keyboard.c.

◆ NUMBER_TEXT_SPACE

#define NUMBER_TEXT_SPACE   8

Definition at line 66 of file nbgl_layout_keyboard.c.

◆ NUMBER_WIDTH

#define NUMBER_WIDTH   56

Definition at line 63 of file nbgl_layout_keyboard.c.

◆ TEXT_ENTRY_COMPACT_HEIGHT

#define TEXT_ENTRY_COMPACT_HEIGHT   56

Definition at line 53 of file nbgl_layout_keyboard.c.

◆ TEXT_ENTRY_NORMAL_HEIGHT

#define TEXT_ENTRY_NORMAL_HEIGHT   72

Definition at line 52 of file nbgl_layout_keyboard.c.

◆ TOP_COMPACT_MARGIN

#define TOP_COMPACT_MARGIN   12

Definition at line 57 of file nbgl_layout_keyboard.c.

◆ TOP_NORMAL_MARGIN

#define TOP_NORMAL_MARGIN   20

Definition at line 56 of file nbgl_layout_keyboard.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAGE_INDICATOR_INDEX 
LEFT_HALF_INDEX 
RIGHT_HALF_INDEX 
FIRST_BUTTON_INDEX 
SECOND_BUTTON_INDEX 
NB_SUGGESTION_CHILDREN 

Definition at line 29 of file nbgl_layout_keyboard.c.

Function Documentation

◆ keyboardSwipeCallback()

bool keyboardSwipeCallback ( nbgl_obj_t obj,
nbgl_touchType_t  eventType 
)

Definition at line 196 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutAddConfirmationButton()

int nbgl_layoutAddConfirmationButton ( nbgl_layout_t layout,
bool  active,
const char *  text,
int  token,
tune_index_e  tuneId 
)

Adds a black full width confirmation button on top of the previously added keyboard.

Deprecated:
Use nbgl_layoutAddKeyboardContent instead
Parameters
layoutthe current layout
activeif true, button is active, otherwise inactive (grayed-out)
texttext of the button
tokentoken of the button, used in onActionCallback
tuneIdtune to play when button is pressed
Returns
>= 0 if OK

Definition at line 879 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutAddEnteredText()

int nbgl_layoutAddEnteredText ( nbgl_layout_t layout,
bool  numbered,
uint8_t  number,
const char *  text,
bool  grayedOut,
int  offsetY,
int  token 
)

Adds a "text entry" area under the previously entered object. This area can be preceded (beginning of line) by an index, indicating for example the entered world. A vertical gray line is placed under the text. This text must be vertical placed in the screen with offsetY.

Deprecated:
Use nbgl_layoutAddKeyboardContent instead
Note
This area is touchable
Parameters
layoutthe current layout
numberedif true, the "number" param is used as index
numberindex of the text
textstring to display in the area
grayedOutif true, the text is grayed out (but not the potential number)
offsetYvertical offset from the top of the page
tokentoken provided in onActionCallback when this area is touched
Returns
>= 0 if OK

Definition at line 753 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutAddKeyboard()

int nbgl_layoutAddKeyboard ( nbgl_layout_t layout,
const nbgl_layoutKbd_t kbdInfo 
)

Creates a keyboard on bottom of the screen, with the given configuration.

Parameters
layoutthe current layout
kbdInfoconfiguration of the keyboard to draw (including the callback when touched)
Returns
the index of keyboard, to use in nbgl_layoutUpdateKeyboard()

Definition at line 474 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutAddKeyboardContent()

int nbgl_layoutAddKeyboardContent ( nbgl_layout_t layout,
nbgl_layoutKeyboardContent_t content 
)

Adds an area containing a potential title, a text entry and either confirmation or suggestion buttons, on top of the keyboard.

Parameters
layoutthe current layout
contentstructure containing the info
Returns
the height of the area if OK

Definition at line 965 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutAddSuggestionButtons()

int nbgl_layoutAddSuggestionButtons ( nbgl_layout_t layout,
uint8_t  nbUsedButtons,
const char *  buttonTexts[NB_MAX_SUGGESTION_BUTTONS],
int  firstButtonToken,
tune_index_e  tuneId 
)

Adds up to 4 black suggestion buttons under the previously added object.

Deprecated:
Use nbgl_layoutAddKeyboardContent instead
Parameters
layoutthe current layout
nbUsedButtonsthe number of actually used buttons
buttonTextsarray of 4 strings for buttons (last ones can be NULL)
firstButtonTokenfirst token used for buttons, provided in onActionCallback (the next 3 values will be used for other buttons)
tuneIdtune to play when any button is pressed
Returns
>= 0 if OK

Definition at line 616 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutKeyboardNeedsRefresh()

bool nbgl_layoutKeyboardNeedsRefresh ( nbgl_layout_t layout,
uint8_t  index 
)

function called to know whether the keyboard has been redrawn and needs a refresh

Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddKeyboard() (unused)
Returns
true if keyboard needs a refresh

Definition at line 580 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutUpdateConfirmationButton()

int nbgl_layoutUpdateConfirmationButton ( nbgl_layout_t layout,
uint8_t  index,
bool  active,
const char *  text 
)

Updates an existing black full width confirmation button on top of the previously added keyboard.

Deprecated:
Use nbgl_layoutUpdateKeyboardContent instead
Parameters
layoutthe current layout
indexreturned value of nbgl_layoutAddConfirmationButton()
activeif true, button is active
texttext of the button = *
Returns
>= 0 if OK

Definition at line 920 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutUpdateEnteredText()

int nbgl_layoutUpdateEnteredText ( nbgl_layout_t layout,
uint8_t  index,
bool  numbered,
uint8_t  number,
const char *  text,
bool  grayedOut 
)

Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText()

Deprecated:
Use nbgl_layoutUpdateKeyboardContent instead
Parameters
layoutthe current layout
indexindex of the text (return value of nbgl_layoutAddEnteredText())
numberedif set to true, the text is preceded on the left by 'number.'
numberif numbered is true, number used to build 'number.' text
textstring to display in the area
grayedOutif true, the text is grayed out (but not the potential number)
Returns
<0 if error, 0 if OK with text fitting the area, 1 of 0K with text not fitting the area

Definition at line 821 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutUpdateKeyboard()

int nbgl_layoutUpdateKeyboard ( nbgl_layout_t layout,
uint8_t  index,
uint32_t  keyMask,
bool  updateCasing,
keyboardCase_t  casing 
)

Updates an existing keyboard on bottom of the screen, with the given configuration.

Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddKeyboard() (unused)
keyMaskmask of keys to activate/deactivate on keyboard
updateCasingif true, update keyboard casing with given value
casingcasing to use
Returns
>=0 if OK

Definition at line 543 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutUpdateKeyboardContent()

int nbgl_layoutUpdateKeyboardContent ( nbgl_layout_t layout,
nbgl_layoutKeyboardContent_t content 
)

Updates an area containing a potential title, a text entry and either confirmation or suggestion buttons, on top of the keyboard This area must have been built with nbgl_layoutAddKeyboardContent, and the type must not change.

Parameters
layoutthe current layout
contentstructure containing the updated info
Returns
the height of the area if OK

Definition at line 1039 of file nbgl_layout_keyboard.c.

◆ nbgl_layoutUpdateSuggestionButtons()

int nbgl_layoutUpdateSuggestionButtons ( nbgl_layout_t layout,
uint8_t  index,
uint8_t  nbUsedButtons,
const char *  buttonTexts[NB_MAX_SUGGESTION_BUTTONS] 
)

Updates the number and/or the text suggestion buttons created with nbgl_layoutAddSuggestionButtons()

Deprecated:
Use nbgl_layoutUpdateKeyboardContent instead
Parameters
layoutthe current layout
indexindex returned by nbgl_layoutAddSuggestionButtons() (unused)
nbUsedButtonsthe number of actually used buttons
buttonTextsarray of 4 strings for buttons (last ones can be NULL)
Returns
>= 0 if OK

Definition at line 669 of file nbgl_layout_keyboard.c.