mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_group_remove_obj: fix when delete the last object from the group
This commit is contained in:
parent
31b3a2a350
commit
4ac1c29ca9
@ -58,7 +58,7 @@ lv_group_t * lv_group_create(void)
|
|||||||
*/
|
*/
|
||||||
void lv_group_del(lv_group_t * group)
|
void lv_group_del(lv_group_t * group)
|
||||||
{
|
{
|
||||||
/*Defocus the the currently focussed object*/
|
/*Defocus the the currently focused object*/
|
||||||
if(group->obj_focus != NULL) {
|
if(group->obj_focus != NULL) {
|
||||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||||
lv_obj_invalidate(*group->obj_focus);
|
lv_obj_invalidate(*group->obj_focus);
|
||||||
@ -81,6 +81,8 @@ void lv_group_del(lv_group_t * group)
|
|||||||
*/
|
*/
|
||||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
if(group == NULL) return;
|
||||||
|
|
||||||
obj->group_p = group;
|
obj->group_p = group;
|
||||||
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
|
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
|
||||||
*next = obj;
|
*next = obj;
|
||||||
@ -100,10 +102,17 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
|||||||
{
|
{
|
||||||
lv_group_t * g = obj->group_p;
|
lv_group_t * g = obj->group_p;
|
||||||
if(g == NULL) return;
|
if(g == NULL) return;
|
||||||
|
if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/
|
||||||
|
|
||||||
if(*g->obj_focus == obj) {
|
if(*g->obj_focus == obj) {
|
||||||
lv_group_focus_next(g);
|
lv_group_focus_next(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the focuses object is still the same then it was the only object in the group but it will be deleted.
|
||||||
|
* Set the `obj_focus` to NULL to get back to the initial state of the group with zero objects*/
|
||||||
|
if(*g->obj_focus == obj) {
|
||||||
|
g->obj_focus = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*Search the object and remove it from its group */
|
/*Search the object and remove it from its group */
|
||||||
lv_obj_t ** i;
|
lv_obj_t ** i;
|
||||||
|
@ -45,7 +45,7 @@ typedef struct _lv_group_t
|
|||||||
{
|
{
|
||||||
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
|
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
|
||||||
lv_obj_t ** obj_focus; /*The object in focus*/
|
lv_obj_t ** obj_focus; /*The object in focus*/
|
||||||
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
|
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
|
||||||
lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
|
lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
|
||||||
lv_style_t style_tmp; /*Stores the modified style of the focused object */
|
lv_style_t style_tmp; /*Stores the modified style of the focused object */
|
||||||
uint8_t frozen:1; /*1: can't focus to new object*/
|
uint8_t frozen:1; /*1: can't focus to new object*/
|
||||||
|
@ -367,6 +367,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
lv_group_send_data(i->group, data->key);
|
lv_group_send_data(i->group, data->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
|
||||||
|
|
||||||
i->proc.pr_timestamp = 0;
|
i->proc.pr_timestamp = 0;
|
||||||
i->proc.long_pr_sent = 0;
|
i->proc.long_pr_sent = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user