1 /** 2 * @file lv_obj_draw.h 3 * 4 */ 5 6 #ifndef LV_OBJ_DRAW_H 7 #define LV_OBJ_DRAW_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../draw/lv_draw.h" 17 18 /********************* 19 * DEFINES 20 *********************/ 21 22 /********************** 23 * TYPEDEFS 24 **********************/ 25 26 struct _lv_obj_t; 27 struct _lv_obj_class_t; 28 29 /** Cover check results.*/ 30 typedef enum { 31 LV_COVER_RES_COVER = 0, 32 LV_COVER_RES_NOT_COVER = 1, 33 LV_COVER_RES_MASKED = 2, 34 } lv_cover_res_t; 35 36 typedef enum { 37 LV_LAYER_TYPE_NONE, 38 LV_LAYER_TYPE_SIMPLE, 39 LV_LAYER_TYPE_TRANSFORM, 40 } lv_layer_type_t; 41 42 typedef struct { 43 lv_draw_ctx_t * draw_ctx; /**< Draw context*/ 44 const struct _lv_obj_class_t * class_p; /**< The class that sent the event */ 45 uint32_t type; /**< The type if part being draw. Element of `lv_<name>_draw_part_type_t` */ 46 lv_area_t * draw_area; /**< The area of the part being drawn*/ 47 lv_draw_rect_dsc_t * 48 rect_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for rectangle-like parts*/ 49 lv_draw_label_dsc_t * 50 label_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for text-like parts*/ 51 lv_draw_line_dsc_t * 52 line_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for line-like parts*/ 53 lv_draw_img_dsc_t * 54 img_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for image-like parts*/ 55 lv_draw_arc_dsc_t * 56 arc_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for arc-like parts*/ 57 const lv_point_t * 58 p1; /**< A point calculated during drawing. E.g. a point of chart or the center of an arc.*/ 59 const lv_point_t * p2; /**< A point calculated during drawing. E.g. a point of chart.*/ 60 char * text; /**< A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.*/ 61 uint32_t text_length; /**< Size of the text buffer containing null-terminated text string calculated during drawing.*/ 62 uint32_t part; /**< The current part for which the event is sent*/ 63 uint32_t id; /**< The index of the part. E.g. a button's index on button matrix or table cell index.*/ 64 lv_coord_t radius; /**< E.g. the radius of an arc (not the corner radius).*/ 65 int32_t value; /**< A value calculated during drawing. E.g. Chart's tick line value.*/ 66 const void * sub_part_ptr; /**< A pointer the identifies something in the part. E.g. chart series. */ 67 } lv_obj_draw_part_dsc_t; 68 69 /********************** 70 * GLOBAL PROTOTYPES 71 **********************/ 72 73 /** 74 * Initialize a rectangle draw descriptor from an object's styles in its current state 75 * @param obj pointer to an object 76 * @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc 77 * @param draw_dsc the descriptor to initialize. 78 * If an `..._opa` field is set to `LV_OPA_TRANSP` the related properties won't be initialized. 79 * Should be initialized with `lv_draw_rect_dsc_init(draw_dsc)`. 80 * @note Only the relevant fields will be set. 81 * E.g. if `border width == 0` the other border properties won't be evaluated. 82 */ 83 void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc); 84 85 /** 86 * Initialize a label draw descriptor from an object's styles in its current state 87 * @param obj pointer to an object 88 * @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc 89 * @param draw_dsc the descriptor to initialize. 90 * If the `opa` field is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized. 91 * Should be initialized with `lv_draw_label_dsc_init(draw_dsc)`. 92 */ 93 void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc); 94 95 /** 96 * Initialize an image draw descriptor from an object's styles in its current state 97 * @param obj pointer to an object 98 * @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc 99 * @param draw_dsc the descriptor to initialize. 100 * Should be initialized with `lv_draw_image_dsc_init(draw_dsc)`. 101 */ 102 void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc); 103 104 /** 105 * Initialize a line draw descriptor from an object's styles in its current state 106 * @param obj pointer to an object 107 * @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc 108 * @param draw_dsc the descriptor to initialize. 109 * Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`. 110 */ 111 void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc); 112 113 /** 114 * Initialize an arc draw descriptor from an object's styles in its current state 115 * @param obj pointer to an object 116 * @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc 117 * @param draw_dsc the descriptor to initialize. 118 * Should be initialized with `lv_draw_arc_dsc_init(draw_dsc)`. 119 */ 120 void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc); 121 122 /** 123 * Get the required extra size (around the object's part) to draw shadow, outline, value etc. 124 * @param obj pointer to an object 125 * @param part part of the object 126 * @return the extra size required around the object 127 */ 128 lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part); 129 130 /** 131 * Initialize a draw descriptor used in events. 132 * @param dsc pointer to a descriptor. Later it should be passed as parameter to an `LV_EVENT_DRAW_PART_BEGIN/END` event. 133 * @param draw the current draw context. (usually returned by `lv_event_get_draw_ctx(e)`) 134 */ 135 void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, lv_draw_ctx_t * draw_ctx); 136 137 /** 138 * Check the type obj a part draw descriptor 139 * @param dsc the descriptor (normally the event parameter) 140 * @param class_p pointer to class to which `type` is related 141 * @param type element of `lv_<name>_draw_part_type_t` 142 * @return true if ::dsc is related to ::class_p and ::type 143 */ 144 bool lv_obj_draw_part_check_type(lv_obj_draw_part_dsc_t * dsc, const struct _lv_obj_class_t * class_p, uint32_t type); 145 146 /** 147 * Send a 'LV_EVENT_REFR_EXT_DRAW_SIZE' Call the ancestor's event handler to the object to refresh the value of the extended draw size. 148 * The result will be saved in `obj`. 149 * @param obj pointer to an object 150 */ 151 void lv_obj_refresh_ext_draw_size(struct _lv_obj_t * obj); 152 153 /** 154 * Get the extended draw area of an object. 155 * @param obj pointer to an object 156 * @return the size extended draw area around the real coordinates 157 */ 158 lv_coord_t _lv_obj_get_ext_draw_size(const struct _lv_obj_t * obj); 159 160 lv_layer_type_t _lv_obj_get_layer_type(const struct _lv_obj_t * obj); 161 162 /********************** 163 * MACROS 164 **********************/ 165 166 #ifdef __cplusplus 167 } /*extern "C"*/ 168 #endif 169 170 #endif /*LV_OBJ_DRAW_H*/ 171