1 /** 2 * @file lv_draw_rect.h 3 * 4 */ 5 6 #ifndef LV_DRAW_RECT_H 7 #define LV_DRAW_RECT_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "lv_draw.h" 17 #include "../misc/lv_color.h" 18 #include "../misc/lv_area.h" 19 #include "../misc/lv_style.h" 20 #include "sw/lv_draw_sw_gradient.h" 21 22 /********************* 23 * DEFINES 24 *********************/ 25 #define LV_RADIUS_CIRCLE 0x7FFF /**< A very big radius to always draw as circle*/ 26 LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE); 27 28 /********************** 29 * TYPEDEFS 30 **********************/ 31 32 typedef struct { 33 lv_draw_dsc_base_t base; 34 35 int32_t radius; 36 37 /*Background*/ 38 lv_opa_t bg_opa; 39 lv_color_t bg_color; /**< First element of a gradient is a color, so it maps well here*/ 40 lv_grad_dsc_t bg_grad; 41 42 /*Background img*/ 43 const void * bg_image_src; 44 const void * bg_image_symbol_font; 45 lv_color_t bg_image_recolor; 46 lv_opa_t bg_image_opa; 47 lv_opa_t bg_image_recolor_opa; 48 uint8_t bg_image_tiled; 49 50 /*Border*/ 51 lv_color_t border_color; 52 int32_t border_width; 53 lv_opa_t border_opa; 54 lv_border_side_t border_side : 5; 55 uint8_t border_post : 1; /*The border will be drawn later*/ 56 57 /*Outline*/ 58 lv_color_t outline_color; 59 int32_t outline_width; 60 int32_t outline_pad; 61 lv_opa_t outline_opa; 62 63 /*Shadow*/ 64 lv_color_t shadow_color; 65 int32_t shadow_width; 66 int32_t shadow_offset_x; 67 int32_t shadow_offset_y; 68 int32_t shadow_spread; 69 lv_opa_t shadow_opa; 70 } lv_draw_rect_dsc_t; 71 72 typedef struct { 73 lv_draw_dsc_base_t base; 74 75 int32_t radius; 76 77 lv_opa_t opa; 78 lv_color_t color; 79 lv_grad_dsc_t grad; 80 } lv_draw_fill_dsc_t; 81 82 typedef struct { 83 lv_draw_dsc_base_t base; 84 85 int32_t radius; 86 87 lv_color_t color; 88 int32_t width; 89 lv_opa_t opa; 90 lv_border_side_t side : 5; 91 92 } lv_draw_border_dsc_t; 93 94 typedef struct { 95 lv_draw_dsc_base_t base; 96 97 int32_t radius; 98 99 lv_color_t color; 100 int32_t width; 101 int32_t spread; 102 int32_t ofs_x; 103 int32_t ofs_y; 104 lv_opa_t opa; 105 uint8_t bg_cover : 1; 106 } lv_draw_box_shadow_dsc_t; 107 108 /********************** 109 * GLOBAL PROTOTYPES 110 **********************/ 111 112 /** 113 * Initialize a rectangle draw descriptor. 114 * @param dsc pointer to a draw descriptor 115 */ 116 void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); 117 118 /** 119 * Initialize a fill draw descriptor. 120 * @param dsc pointer to a draw descriptor 121 */ 122 void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc); 123 124 /** 125 * Try to get a fill draw descriptor from a draw task. 126 * @param task draw task 127 * @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_FILL 128 */ 129 lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task); 130 131 /** 132 * Initialize a border draw descriptor. 133 * @param dsc pointer to a draw descriptor 134 */ 135 void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc); 136 137 /** 138 * Try to get a border draw descriptor from a draw task. 139 * @param task draw task 140 * @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BORDER 141 */ 142 lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task); 143 144 /** 145 * Initialize a box shadow draw descriptor. 146 * @param dsc pointer to a draw descriptor 147 */ 148 void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc); 149 150 /** 151 * Try to get a box shadow draw descriptor from a draw task. 152 * @param task draw task 153 * @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BOX_SHADOW 154 */ 155 lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task); 156 157 /** 158 * The rectangle is a wrapper for fill, border, bg. image and box shadow. 159 * Internally fill, border, image and box shadow draw tasks will be created. 160 * @param layer pointer to a layer 161 * @param dsc pointer to an initialized draw descriptor variable 162 * @param coords the coordinates of the rectangle 163 */ 164 void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords); 165 166 /********************** 167 * MACROS 168 **********************/ 169 170 #ifdef __cplusplus 171 } /*extern "C"*/ 172 #endif 173 174 #endif /*LV_DRAW_RECT_H*/ 175