feat(draw): add convenience methods for safely getting correct draw descriptor (#5505)
This commit is contained in:
@@ -517,24 +517,24 @@ static void table_draw_task_event_cb(lv_event_t * e)
|
||||
|
||||
int32_t row = draw_dsc_base->id1;
|
||||
if(row == 0) {
|
||||
if(t->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_fill_dsc_t * draw_dsc_fill = t->draw_dsc;
|
||||
lv_draw_fill_dsc_t * draw_dsc_fill = lv_draw_task_get_fill_dsc(t);
|
||||
if(draw_dsc_fill) {
|
||||
draw_dsc_fill->color = lv_palette_darken(LV_PALETTE_BLUE_GREY, 4);
|
||||
}
|
||||
else if(t->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * draw_dsc_label = t->draw_dsc;
|
||||
lv_draw_label_dsc_t * draw_dsc_label = lv_draw_task_get_label_dsc(t);
|
||||
if(draw_dsc_label) {
|
||||
draw_dsc_label->color = lv_color_white();
|
||||
}
|
||||
}
|
||||
else if(row == 1) {
|
||||
if(t->type == LV_DRAW_TASK_TYPE_BORDER) {
|
||||
lv_draw_border_dsc_t * draw_dsc_border = t->draw_dsc;
|
||||
lv_draw_border_dsc_t * draw_dsc_border = lv_draw_task_get_border_dsc(t);
|
||||
if(draw_dsc_border) {
|
||||
draw_dsc_border->color = lv_palette_darken(LV_PALETTE_BLUE_GREY, 4);
|
||||
draw_dsc_border->width = 2;
|
||||
draw_dsc_border->side = LV_BORDER_SIDE_BOTTOM;
|
||||
}
|
||||
else if(t->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * draw_dsc_label = t->draw_dsc;
|
||||
lv_draw_label_dsc_t * draw_dsc_label = lv_draw_task_get_label_dsc(t);
|
||||
if(draw_dsc_label) {
|
||||
draw_dsc_label->color = lv_palette_darken(LV_PALETTE_BLUE_GREY, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1412,13 +1412,12 @@ static void chart_event_cb(lv_event_t * e)
|
||||
lv_draw_task_t * draw_task = lv_event_get_param(e);
|
||||
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
|
||||
|
||||
if(base_dsc->part == LV_PART_ITEMS && draw_task->type == LV_DRAW_TASK_TYPE_LINE) {
|
||||
lv_draw_line_dsc_t * draw_line_dsc = lv_draw_task_get_line_dsc(draw_task);
|
||||
if(base_dsc->part == LV_PART_ITEMS && draw_line_dsc) {
|
||||
const lv_chart_series_t * ser = lv_chart_get_series_next(obj, NULL);
|
||||
if(base_dsc->id1 == 1) ser = lv_chart_get_series_next(obj, ser);
|
||||
|
||||
lv_draw_line_dsc_t * draw_line_dsc = draw_task->draw_dsc;
|
||||
lv_draw_triangle_dsc_t tri_dsc;
|
||||
|
||||
lv_draw_triangle_dsc_init(&tri_dsc);
|
||||
tri_dsc.p[0].x = (int32_t)draw_line_dsc->p1.x;
|
||||
tri_dsc.p[0].y = (int32_t)draw_line_dsc->p1.y;
|
||||
|
||||
@@ -15,33 +15,36 @@ static void event_cb(lv_event_t * e)
|
||||
|
||||
/*Change the draw descriptor of the 2nd button*/
|
||||
if(base_dsc->id1 == 1) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->radius = 0;
|
||||
if(pressed) rect_draw_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE, 3);
|
||||
else rect_draw_dsc->bg_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
rect_draw_dsc->shadow_width = 6;
|
||||
rect_draw_dsc->shadow_offset_x = 3;
|
||||
rect_draw_dsc->shadow_offset_y = 3;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->radius = 0;
|
||||
if(pressed) fill_draw_dsc->color = lv_palette_darken(LV_PALETTE_BLUE, 3);
|
||||
else fill_draw_dsc->color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
}
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_box_shadow_dsc_t * box_shadow_draw_dsc = lv_draw_task_get_box_shadow_dsc(draw_task);
|
||||
if(box_shadow_draw_dsc) {
|
||||
box_shadow_draw_dsc->width = 6;
|
||||
box_shadow_draw_dsc->ofs_x = 3;
|
||||
box_shadow_draw_dsc->ofs_y = 3;
|
||||
}
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->color = lv_color_white();
|
||||
}
|
||||
|
||||
}
|
||||
/*Change the draw descriptor of the 3rd button*/
|
||||
else if(base_dsc->id1 == 2) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->radius = LV_RADIUS_CIRCLE;
|
||||
if(pressed) rect_draw_dsc->bg_color = lv_palette_darken(LV_PALETTE_RED, 3);
|
||||
else rect_draw_dsc->bg_color = lv_palette_main(LV_PALETTE_RED);
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->radius = LV_RADIUS_CIRCLE;
|
||||
if(pressed) fill_draw_dsc->color = lv_palette_darken(LV_PALETTE_RED, 3);
|
||||
else fill_draw_dsc->color = lv_palette_main(LV_PALETTE_RED);
|
||||
}
|
||||
}
|
||||
else if(base_dsc->id1 == 3) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->opa = 0;
|
||||
}
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
|
||||
@@ -7,9 +7,12 @@ static void draw_event_cb(lv_event_t * e)
|
||||
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
|
||||
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
|
||||
|
||||
if(base_dsc->part == LV_PART_ITEMS && draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_fill_dsc_t * fill_dsc = draw_task->draw_dsc;
|
||||
if(base_dsc->part != LV_PART_ITEMS) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_draw_fill_dsc_t * fill_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_dsc) {
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
int32_t * y_array = lv_chart_get_y_array(chart, lv_chart_get_series_next(chart, NULL));
|
||||
int32_t v = y_array[base_dsc->id2];
|
||||
|
||||
@@ -12,30 +12,30 @@ static void draw_event_cb(lv_event_t * e)
|
||||
|
||||
/*Make the texts in the first cell center aligned*/
|
||||
if(row == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->align = LV_TEXT_ALIGN_CENTER;
|
||||
}
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), rect_draw_dsc->bg_color, LV_OPA_20);
|
||||
rect_draw_dsc->bg_opa = LV_OPA_COVER;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), fill_draw_dsc->color, LV_OPA_20);
|
||||
fill_draw_dsc->opa = LV_OPA_COVER;
|
||||
}
|
||||
}
|
||||
/*In the first column align the texts to the right*/
|
||||
else if(col == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->align = LV_TEXT_ALIGN_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/*Make every 2nd row grayish*/
|
||||
if((row != 0 && row % 2) == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), rect_draw_dsc->bg_color, LV_OPA_10);
|
||||
rect_draw_dsc->bg_opa = LV_OPA_COVER;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), fill_draw_dsc->color, LV_OPA_10);
|
||||
fill_draw_dsc->opa = LV_OPA_COVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,13 +213,11 @@ bool lv_draw_dispatch_layer(lv_display_t * disp, lv_layer_t * layer)
|
||||
lv_free(layer_drawn);
|
||||
}
|
||||
}
|
||||
if(t->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * draw_label_dsc = t->draw_dsc;
|
||||
if(draw_label_dsc->text_local) {
|
||||
lv_draw_label_dsc_t * draw_label_dsc = lv_draw_task_get_label_dsc(t);
|
||||
if(draw_label_dsc && draw_label_dsc->text_local) {
|
||||
lv_free((void *)draw_label_dsc->text);
|
||||
draw_label_dsc->text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
lv_free(t->draw_dsc);
|
||||
lv_free(t);
|
||||
|
||||
@@ -43,6 +43,11 @@ void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc)
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
lv_draw_arc_dsc_t * lv_draw_task_get_arc_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_ARC ? (lv_draw_arc_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_arc(lv_layer_t * layer, const lv_draw_arc_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
@@ -50,6 +50,13 @@ typedef struct {
|
||||
*/
|
||||
void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get an arc draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_ARC
|
||||
*/
|
||||
lv_draw_arc_dsc_t * lv_draw_task_get_arc_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create an arc draw task.
|
||||
* @param layer pointer to a layer
|
||||
|
||||
@@ -54,6 +54,11 @@ void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc)
|
||||
dsc->base.dsc_size = sizeof(lv_draw_image_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_IMAGE ? (lv_draw_image_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, coords);
|
||||
|
||||
@@ -83,6 +83,13 @@ typedef void (*lv_draw_image_core_cb)(lv_draw_unit_t * draw_unit, const lv_draw_
|
||||
*/
|
||||
void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get an image draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_IMAGE
|
||||
*/
|
||||
lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create an image draw task
|
||||
* @param layer pointer to a layer
|
||||
|
||||
@@ -61,6 +61,11 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
|
||||
dsc->base.dsc_size = sizeof(lv_draw_label_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_label_dsc_t * lv_draw_task_get_label_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_LABEL ? (lv_draw_label_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_glyph_dsc_init(lv_draw_glyph_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_glyph_dsc_t));
|
||||
|
||||
@@ -115,6 +115,13 @@ typedef void(*lv_draw_glyph_cb_t)(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a label draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LABEL
|
||||
*/
|
||||
lv_draw_label_dsc_t * lv_draw_task_get_label_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a glyph draw descriptor.
|
||||
* Used internally.
|
||||
|
||||
@@ -43,6 +43,11 @@ void LV_ATTRIBUTE_FAST_MEM lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_LINE ? (lv_draw_line_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_line(lv_layer_t * layer, const lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
@@ -51,6 +51,13 @@ typedef struct {
|
||||
*/
|
||||
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a line draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LINE
|
||||
*/
|
||||
lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a line draw task
|
||||
* @param layer pointer to a layer
|
||||
|
||||
@@ -41,6 +41,11 @@ void LV_ATTRIBUTE_FAST_MEM lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t *
|
||||
lv_memzero(dsc, sizeof(lv_draw_mask_rect_dsc_t));
|
||||
}
|
||||
|
||||
lv_draw_mask_rect_dsc_t * lv_draw_task_get_mask_rect_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_MASK_RECTANGLE ? (lv_draw_mask_rect_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_mask_rect(lv_layer_t * layer, const lv_draw_mask_rect_dsc_t * dsc)
|
||||
{
|
||||
if(!lv_color_format_has_alpha(layer->color_format)) {
|
||||
|
||||
@@ -42,6 +42,13 @@ typedef struct {
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a rectangle mask draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_MASK_RECTANGLE
|
||||
*/
|
||||
lv_draw_mask_rect_dsc_t * lv_draw_task_get_mask_rect_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a draw task to mask a rectangle from the buffer
|
||||
* @param layer pointer to a layer
|
||||
|
||||
@@ -62,6 +62,11 @@ void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc)
|
||||
dsc->base.dsc_size = sizeof(lv_draw_fill_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_FILL ? (lv_draw_fill_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(*dsc));
|
||||
@@ -70,6 +75,11 @@ void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc)
|
||||
dsc->base.dsc_size = sizeof(lv_draw_border_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_BORDER ? (lv_draw_border_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(*dsc));
|
||||
@@ -77,6 +87,11 @@ void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc)
|
||||
dsc->base.dsc_size = sizeof(lv_draw_box_shadow_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_BOX_SHADOW ? (lv_draw_box_shadow_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
|
||||
|
||||
@@ -121,18 +121,39 @@ void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
|
||||
*/
|
||||
void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a fill draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_FILL
|
||||
*/
|
||||
lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a border draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a border draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BORDER
|
||||
*/
|
||||
lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a box shadow draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a box shadow draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BOX_SHADOW
|
||||
*/
|
||||
lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* The rectangle is a wrapper for fill, border, bg. image and box shadow.
|
||||
* Internally fill, border, image and box shadow draw tasks will be created.
|
||||
|
||||
@@ -49,6 +49,11 @@ void lv_draw_triangle_dsc_init(lv_draw_triangle_dsc_t * dsc)
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
lv_draw_triangle_dsc_t * lv_draw_task_get_triangle_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_TRIANGLE ? (lv_draw_triangle_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_triangle(lv_layer_t * layer, const lv_draw_triangle_dsc_t * dsc)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
@@ -42,6 +42,13 @@ typedef struct {
|
||||
*/
|
||||
void lv_draw_triangle_dsc_init(lv_draw_triangle_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Try to get a triangle draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_TRIANGLE
|
||||
*/
|
||||
lv_draw_triangle_dsc_t * lv_draw_task_get_triangle_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a triangle draw task
|
||||
* @param layer pointer to a layer
|
||||
|
||||
@@ -344,8 +344,8 @@ static void draw_from_cached_texture(lv_draw_sdl_unit_t * u)
|
||||
|
||||
SDL_SetRenderTarget(renderer, layer_get_texture(dest_layer));
|
||||
|
||||
if(t->type == LV_DRAW_TASK_TYPE_IMAGE) {
|
||||
lv_draw_image_dsc_t * draw_dsc = t->draw_dsc;
|
||||
lv_draw_image_dsc_t * draw_dsc = lv_draw_task_get_image_dsc(t);
|
||||
if(draw_dsc) {
|
||||
lv_area_t image_area;
|
||||
image_area.x1 = 0;
|
||||
image_area.y1 = 0;
|
||||
|
||||
@@ -300,16 +300,10 @@ static void draw_task_added_event_cb(lv_event_t * e)
|
||||
lv_draw_task_t * draw_task = lv_event_get_param(e);
|
||||
if(((lv_draw_dsc_base_t *)draw_task->draw_dsc)->part != LV_PART_ITEMS) return;
|
||||
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = NULL;
|
||||
lv_draw_border_dsc_t * border_draw_dsc = NULL;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
lv_draw_border_dsc_t * border_draw_dsc = lv_draw_task_get_border_dsc(draw_task);
|
||||
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
fill_draw_dsc = draw_task->draw_dsc;
|
||||
}
|
||||
else if(draw_task->type == LV_DRAW_TASK_TYPE_BORDER) {
|
||||
border_draw_dsc = draw_task->draw_dsc;
|
||||
}
|
||||
else {
|
||||
if(!fill_draw_dsc && !border_draw_dsc) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,30 +139,30 @@ static void draw_part_event_cb(lv_event_t * e)
|
||||
|
||||
/*Make the texts in the first cell center aligned*/
|
||||
if(row == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->align = LV_TEXT_ALIGN_CENTER;
|
||||
}
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), rect_draw_dsc->bg_color, LV_OPA_20);
|
||||
rect_draw_dsc->bg_opa = LV_OPA_COVER;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), fill_draw_dsc->color, LV_OPA_20);
|
||||
fill_draw_dsc->opa = LV_OPA_COVER;
|
||||
}
|
||||
}
|
||||
/*In the first column align the texts to the right*/
|
||||
else if(col == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_LABEL) {
|
||||
lv_draw_label_dsc_t * label_draw_dsc = draw_task->draw_dsc;
|
||||
lv_draw_label_dsc_t * label_draw_dsc = lv_draw_task_get_label_dsc(draw_task);
|
||||
if(label_draw_dsc) {
|
||||
label_draw_dsc->align = LV_TEXT_ALIGN_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/*Make every 2nd row grayish*/
|
||||
if((row != 0 && row % 2) == 0) {
|
||||
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
|
||||
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
|
||||
rect_draw_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), rect_draw_dsc->bg_color, LV_OPA_10);
|
||||
rect_draw_dsc->bg_opa = LV_OPA_COVER;
|
||||
lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task);
|
||||
if(fill_draw_dsc) {
|
||||
fill_draw_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), fill_draw_dsc->color, LV_OPA_10);
|
||||
fill_draw_dsc->opa = LV_OPA_COVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user