diff --git a/include/syscalls.h b/include/syscalls.h index 59f277b2e..ea6de4f19 100644 --- a/include/syscalls.h +++ b/include/syscalls.h @@ -304,6 +304,7 @@ #define SYSCALL_nbgl_get_font_ID 0x01fa000c #define SYSCALL_nbgl_screen_reinit_ID 0x00fa000d #define SYSCALL_nbgl_front_draw_img_rle_ID 0x05fa0010 +#define SYSCALL_nbgl_front_control_area_masking_ID 0x03fa0012 #ifdef HAVE_SE_EINK_DISPLAY #define SYSCALL_nbgl_wait_pipeline_ID 0x00fa0011 diff --git a/lib_nbgl/include/nbgl_front.h b/lib_nbgl/include/nbgl_front.h index 08ed39345..8f0056b3d 100644 --- a/lib_nbgl/include/nbgl_front.h +++ b/lib_nbgl/include/nbgl_front.h @@ -45,6 +45,7 @@ void nbgl_frontDrawImageRle(const nbgl_area_t *area, void nbgl_frontRefreshArea(const nbgl_area_t *area, nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh); +void nbgl_frontControlAreaMasking(uint8_t mask_index, nbgl_area_t *masked_area_or_null); /********************** * MACROS diff --git a/lib_nbgl/include/nbgl_obj.h b/lib_nbgl/include/nbgl_obj.h index cd3d13626..eeacb2911 100644 --- a/lib_nbgl/include/nbgl_obj.h +++ b/lib_nbgl/include/nbgl_obj.h @@ -448,6 +448,12 @@ typedef struct PACKED__ nbgl_text_entry_s { const char *text; ///< text to display (up to nbChars chars). } nbgl_text_entry_t; +typedef struct PACKED__ nbgl_mask_control_s { + nbgl_obj_t obj; ///< common part + bool enableMasking; ///< true: Enable masking of area / false: Disable masking of area + uint8_t maskIndex; ///< index of mask +} nbgl_mask_control_t; + /** * @brief struct to represent a "spinner", represented by the Ledger corners, in gray, with one of * the corners in black (@ref SPINNER type) diff --git a/lib_nbgl/include/nbgl_types.h b/lib_nbgl/include/nbgl_types.h index 116d757de..c378011ad 100644 --- a/lib_nbgl/include/nbgl_types.h +++ b/lib_nbgl/include/nbgl_types.h @@ -128,7 +128,8 @@ typedef enum { KEYPAD, ///< Keypad SPINNER, ///< Spinner IMAGE_FILE, ///< Image file (with Ledger compression) - TEXT_ENTRY ///< area for entered text, only for Nanos + TEXT_ENTRY, ///< area for entered text, only for Nanos + MASK_CONTROL, ///< OS-specific object to enable/disable masked area } nbgl_obj_type_t; /** diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index 0887362e9..1029069e5 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -1365,6 +1365,26 @@ static void draw_image_file(nbgl_image_file_t *obj, nbgl_obj_t *prevObj, bool co nbgl_frontDrawImageFile((nbgl_area_t *) obj, obj->buffer, BLACK, ramBuffer); } +#ifdef NBGL_MASKING +static void draw_mask_control(nbgl_mask_control_t *obj, nbgl_obj_t *prevObj, bool computePosition) +{ + if (computePosition) { + compute_position((nbgl_obj_t *) obj, prevObj); + } + + if (objDrawingDisabled) { + return; + } + + if (obj->enableMasking) { + nbgl_frontControlAreaMasking(obj->maskIndex, &obj->obj.area); + } + else { + nbgl_frontControlAreaMasking(obj->maskIndex, NULL); + } +} +#endif // NBGL_MASKING + /** * @brief internal function used to draw an object of any type * @@ -1447,6 +1467,11 @@ draw_object(nbgl_obj_t *obj, nbgl_obj_t *prevObj, bool computePosition) draw_textEntry((nbgl_text_entry_t *) obj, prevObj, computePosition); break; #endif // HAVE_SE_TOUCH +#ifdef NBGL_MASKING + case MASK_CONTROL: + draw_mask_control((nbgl_mask_control_t *) obj, prevObj, computePosition); + break; +#endif // NBGL_MASKING default: LOG_DEBUG(OBJ_LOGGER, "Not existing object type\n"); break; diff --git a/src/syscalls.c b/src/syscalls.c index b5df1932a..f5dcc2f2d 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -103,6 +103,17 @@ void nbgl_frontDrawImageRle(nbgl_area_t *area, return; } +#ifdef NBGL_MASKING +void nbgl_frontControlAreaMasking(uint8_t mask_index, nbgl_area_t *masked_area_or_null) +{ + unsigned int parameters[2]; + parameters[0] = (unsigned int) mask_index; + parameters[1] = (unsigned int) masked_area_or_null; + SVC_Call(SYSCALL_nbgl_front_control_area_masking_ID, parameters); + return; +} +#endif // NBGL_MASKING + void nbgl_frontDrawImageFile(nbgl_area_t *area, uint8_t *buffer, nbgl_color_map_t colorMap,