example(btnmatrix): update lv_example_btnmatrix_2 to expicitly check which part is drawn
related to https://forum.lvgl.io/t/style-messagebox-buttons-causes-outline-around-all-buttons-in-the-button-matrix/9170
This commit is contained in:
@@ -9,7 +9,9 @@ static void event_cb(lv_event_t * e)
|
|||||||
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
if(code == LV_EVENT_DRAW_PART_BEGIN) {
|
||||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||||
|
|
||||||
/*Change the draw descriptor the 2nd button*/
|
/*When the button matrix draws the buttons...*/
|
||||||
|
if(dsc->class_p == &lv_btnmatrix_class && dsc->type == LV_BTNMATRIX_DRAW_PART_BTN) {
|
||||||
|
/*Change the draw descriptor of the 2nd button*/
|
||||||
if(dsc->id == 1) {
|
if(dsc->id == 1) {
|
||||||
dsc->rect_dsc->radius = 0;
|
dsc->rect_dsc->radius = 0;
|
||||||
if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE, 3);
|
if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE, 3);
|
||||||
@@ -20,7 +22,7 @@ static void event_cb(lv_event_t * e)
|
|||||||
dsc->rect_dsc->shadow_ofs_y = 3;
|
dsc->rect_dsc->shadow_ofs_y = 3;
|
||||||
dsc->label_dsc->color = lv_color_white();
|
dsc->label_dsc->color = lv_color_white();
|
||||||
}
|
}
|
||||||
/*Change the draw descriptor the 3rd button*/
|
/*Change the draw descriptor of the 3rd button*/
|
||||||
else if(dsc->id == 2) {
|
else if(dsc->id == 2) {
|
||||||
dsc->rect_dsc->radius = LV_RADIUS_CIRCLE;
|
dsc->rect_dsc->radius = LV_RADIUS_CIRCLE;
|
||||||
if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_RED, 3);
|
if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_RED, 3);
|
||||||
@@ -33,9 +35,12 @@ static void event_cb(lv_event_t * e)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(code == LV_EVENT_DRAW_PART_END) {
|
if(code == LV_EVENT_DRAW_PART_END) {
|
||||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||||
|
|
||||||
|
/*When the button matrix draws the buttons...*/
|
||||||
|
if(dsc->class_p == &lv_btnmatrix_class && dsc->type == LV_BTNMATRIX_DRAW_PART_BTN) {
|
||||||
/*Add custom content to the 4th button when the button itself was drawn*/
|
/*Add custom content to the 4th button when the button itself was drawn*/
|
||||||
if(dsc->id == 3) {
|
if(dsc->id == 3) {
|
||||||
LV_IMG_DECLARE(img_star);
|
LV_IMG_DECLARE(img_star);
|
||||||
@@ -57,6 +62,7 @@ static void event_cb(lv_event_t * e)
|
|||||||
lv_draw_img(dsc->draw_ctx, &img_draw_dsc, &a, &img_star);
|
lv_draw_img(dsc->draw_ctx, &img_draw_dsc, &a, &img_star);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user