From 66e70afbb4873a7dd1fd34aa273f2fa86cb7ed39 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 6 Mar 2019 16:13:04 +0100 Subject: [PATCH] use the obj->top on focus to bring the obj. to the foregorund --- lv_core/lv_group.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 46b71d15f..3fd4120f6 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -24,6 +24,7 @@ static void style_mod_def(lv_style_t * style); static void style_mod_edit_def(lv_style_t * style); static void lv_group_refocus(lv_group_t *g); +static void obj_to_foreground(lv_obj_t * obj); /********************** * STATIC VARIABLES @@ -181,6 +182,9 @@ void lv_group_focus_obj(lv_obj_t * obj) (*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL); if(g->focus_cb) g->focus_cb(g); lv_obj_invalidate(*g->obj_focus); + + /*If the object or its parent has `top == true` bring it to the foregorund*/ + obj_to_foreground(*g->obj_focus); } break; } @@ -215,6 +219,9 @@ void lv_group_focus_next(lv_group_t * group) lv_obj_invalidate(*group->obj_focus); if(group->focus_cb) group->focus_cb(group); + + /*If the object or its parent has `top == true` bring it to the foregorund*/ + obj_to_foreground(*group->obj_focus); } } @@ -246,6 +253,9 @@ void lv_group_focus_prev(lv_group_t * group) lv_obj_invalidate(*group->obj_focus); if(group->focus_cb) group->focus_cb(group); + + /*If the object or its parent has `top == true` bring it to the foregorund*/ + obj_to_foreground(*group->obj_focus); } } @@ -522,4 +532,23 @@ static void style_mod_edit_def(lv_style_t * style) } +static void obj_to_foreground(lv_obj_t * obj) +{ + /*Search for 'top' attribute*/ + lv_obj_t * i = obj; + lv_obj_t * last_top = NULL; + while(i != NULL) { + if(i->top != 0) last_top = i; + i = lv_obj_get_parent(i); + } + + if(last_top != NULL) { + /*Move the last_top object to the foreground*/ + lv_obj_t * par = lv_obj_get_parent(last_top); + /*After list change it will be the new head*/ + lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top); + lv_obj_invalidate(last_top); + } +} + #endif /*USE_LV_GROUP != 0*/