feat(draw): add convenience methods for safely getting correct draw descriptor (#5505)

This commit is contained in:
Johannes Marbach
2024-01-29 08:19:58 +01:00
committed by GitHub
parent 019aa8d561
commit 152dc0b2be
23 changed files with 176 additions and 71 deletions

View File

@@ -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);
}
}

View File

@@ -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;