Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_layout_internal.h
Go to the documentation of this file.
1
6
7#ifndef NBGL_LAYOUT_INTERNAL_H
8#define NBGL_LAYOUT_INTERNAL_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include "nbgl_layout.h"
15#include "glyphs.h"
16#include "os_pic.h"
17
18/*********************
19 * INCLUDES
20 *********************/
21
22/*********************
23 * DEFINES
24 *********************/
25// internal margin, between sub-items
26#define INTERNAL_MARGIN 8
27
28#ifdef SCREEN_SIZE_WALLET
29#if SMALL_BUTTON_RADIUS == 32
30#define SMALL_BUTTON_HEIGHT 64
31#define SMALL_BUTTON_RADIUS_INDEX RADIUS_32_PIXELS
32#elif SMALL_BUTTON_RADIUS == 20
33#define SMALL_BUTTON_HEIGHT 40
34#define SMALL_BUTTON_RADIUS_INDEX RADIUS_20_PIXELS
35#endif // SMALL_BUTTON_RADIUS
36#endif // SCREEN_SIZE_WALLET
37
42#define LAYOUT_OBJ_POOL_LEN 16
43
44#define KEYBOARD_FOOTER_TYPE 99
45#define KEYPAD_FOOTER_TYPE 98
46
47/**********************
48 * TYPEDEFS
49 **********************/
50typedef struct {
52 uint8_t token; // user token, attached to callback
53 uint8_t index; // index within the token
54 tune_index_e tuneId; // if not @ref NBGL_NO_TUNE, a tune will be played
56
63
64// used by screen (top level)
65enum {
66 HEADER_INDEX = 0, // For header container
73};
74
114
115/**********************
116 * GLOBAL PROTOTYPES
117 **********************/
119 nbgl_obj_t *obj,
120 nbgl_touchType_t eventType);
123 nbgl_obj_t *obj,
124 uint8_t token,
125 tune_index_e tuneId);
128 const nbgl_layoutNavigationBar_t *navConfig,
129 uint8_t layer);
131 nbgl_touchType_t eventType,
132 uint8_t nbPages,
133 uint8_t *activePage);
134
135/**********************
136 * INLINE FUNCTIONS
137 **********************/
138
145static inline nbgl_font_id_e layoutGetTagValueFont(bool smallCaseForValue)
146{
147 return smallCaseForValue ? SMALL_BOLD_FONT : LARGE_MEDIUM_FONT;
148}
149
157{
158 // valueIcon is in a union with extension, so aliasValue must be checked first
159 if (pair->aliasValue) {
160 // the (>) icon is automatically displayed for an alias
161 return &MINI_PUSH_ICON;
162 }
163 if (pair->valueIcon != NULL) {
164 return (const nbgl_icon_details_t *) PIC(pair->valueIcon);
165 }
166 return NULL;
167}
168
177static inline uint16_t layoutGetTagValueWidth(const nbgl_icon_details_t *icon)
178{
179 // a value with an icon on its right has a reduced width
180 if (icon != NULL) {
181 return AVAILABLE_WIDTH - icon->width - VALUE_ICON_INTERVALE;
182 }
183 return AVAILABLE_WIDTH;
184}
185
196static inline uint8_t layoutGetTagValueMaxLines(uint8_t listMaxLines,
197 const nbgl_contentTagValue_t *pair,
198 bool *forceEllipsis)
199{
200 if (forceEllipsis != NULL) {
201 *forceEllipsis = (pair->nbMaxLinesForValue > 0);
202 }
203 if ((pair->nbMaxLinesForValue > 0)
204 && ((listMaxLines == 0) || (pair->nbMaxLinesForValue < listMaxLines))) {
205 return pair->nbMaxLinesForValue;
206 }
207 return listMaxLines;
208}
209
210/**********************
211 * MACROS
212 **********************/
213
214#ifdef __cplusplus
215} /* extern "C" */
216#endif
217
218#endif /* NBGL_LAYOUT_INTERNAL_H */
nbgl_font_id_e
Definition nbgl_fonts.h:143
API of the Advanced BOLOS Graphical Library, for predefined layouts.
#define AVAILABLE_WIDTH
nbgl_swipe_usage_t
@ NB_SWIPE_USAGE
@ SWIPE_USAGE_CUSTOM
@ SWIPE_USAGE_SUGGESTIONS
@ SWIPE_USAGE_NAVIGATION
@ UP_FOOTER_INDEX
@ FOOTER_INDEX
@ HEADER_INDEX
@ TOP_RIGHT_BUTTON_INDEX
@ MAIN_CONTAINER_INDEX
@ LEFT_BORDER_INDEX
static nbgl_font_id_e layoutGetTagValueFont(bool smallCaseForValue)
returns the font used to display the values of a list of tag/value pairs
void layoutNavigationPopulate(nbgl_container_t *navContainer, const nbgl_layoutNavigationBar_t *navConfig, uint8_t layer)
static uint8_t layoutGetTagValueMaxLines(uint8_t listMaxLines, const nbgl_contentTagValue_t *pair, bool *forceEllipsis)
returns the max number of lines of the value of the given tag/value pair, which is the smallest non-z...
static uint16_t layoutGetTagValueWidth(const nbgl_icon_details_t *icon)
returns the width of the value of a tag/value pair. Shared by the layout and the use cases,...
bool keyboardSwipeCallback(nbgl_layoutInternal_t *layoutInt, nbgl_obj_t *obj, nbgl_touchType_t eventType)
static const nbgl_icon_details_t * layoutGetTagValueIcon(const nbgl_contentTagValue_t *pair)
returns the icon displayed on the right of the value of the given tag/value pair
void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
adds the given obj to the layout
void layoutUpdateCallbackObjToken(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token)
bool layoutNavigationCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType, uint8_t nbPages, uint8_t *activePage)
struct nbgl_layoutInternal_s nbgl_layoutInternal_t
Structure containing all information about the current layout.
layoutObj_t * layoutAddCallbackObj(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj, uint8_t token, tune_index_e tuneId)
#define LAYOUT_OBJ_POOL_LEN
Max number of complex objects with callback retrievable from pool.
#define NB_MAX_SCREEN_CHILDREN
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
struct PACKED__ nbgl_text_area_s nbgl_text_area_t
struct to represent a text area (TEXT_AREA type)
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.
struct nbgl_animation_s nbgl_animation_t
Represents all information about an animation (succession of icons).
nbgl_touchType_t
The different types of Touchscreen events.
Definition nbgl_types.h:272
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
tune_index_e tuneId
This structure contains a [tag,value] pair and possible extensions.
const nbgl_icon_details_t * valueIcon
Structure containing all information about the current layout.
nbgl_container_t * footerContainer
container used to store footer (buttons, nav....)
uint8_t activePage
index of active page for navigation bar
uint8_t layer
layer in screen stack
struct nbgl_layoutInternal_s * top
layout above this one, in stack
nbgl_swipe_usage_t swipeUsage
nbgl_layoutTouchCallback_t callback
user callback for all controls
struct nbgl_layoutInternal_s * bottom
layout under this one, in stack
uint8_t invertedColors
if true, means that background is black
nbgl_container_t * container
uint8_t iconIdxInAnim
current icon index in animation
nbgl_container_t * headerContainer
container used to store header (progress, back, empty space...)
uint8_t isUsed
if true, means this layout is in use
nbgl_layoutFooterType_t footerType
type of footer
nbgl_layoutHeaderType_t headerType
type of header
nbgl_container_t * upFooterContainer
uint8_t incrementAnim
if true, means that animation index is currently incrementing
uint8_t nbPages
number of pages for navigation bar
nbgl_layoutUpFooterType_t upFooterType
type of up-footer
uint8_t modal
if true, means the screen is a modal
layoutObj_t callbackObjPool[LAYOUT_OBJ_POOL_LEN]
nbgl_text_area_t * tapText
nbgl_obj_t ** children
children for main screen
const nbgl_animation_t * animation
current animation (if not NULL)
This structure contains info to build a navigation bar at the bottom of the screen.