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_obj.h b/lib_nbgl/include/nbgl_obj.h index 134233eae..e457bea36 100644 --- a/lib_nbgl/include/nbgl_obj.h +++ b/lib_nbgl/include/nbgl_obj.h @@ -448,6 +448,11 @@ 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 +} 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..0ce9c5e7d 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, } nbgl_obj_type_t; /** diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index 9e6168c87..ac6140fea 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -1360,6 +1360,24 @@ 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); } +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(0, &obj->obj.area); + } + else { + nbgl_frontControlAreaMasking(0, NULL); + } +} + /** * @brief internal function used to draw an object of any type * @@ -1442,6 +1460,9 @@ 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 + case MASK_CONTROL: + draw_mask_control((nbgl_mask_control_t *) obj, prevObj, computePosition); + break; default: LOG_DEBUG(OBJ_LOGGER, "Not existing object type\n"); break; diff --git a/src/syscalls.c b/src/syscalls.c index b5df1932a..ffc55a97b 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -103,6 +103,15 @@ void nbgl_frontDrawImageRle(nbgl_area_t *area, return; } +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; +} + void nbgl_frontDrawImageFile(nbgl_area_t *area, uint8_t *buffer, nbgl_color_map_t colorMap,