feat(draw): add convenience methods for safely getting correct draw descriptor (#5505)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user