From 2d00a3fc1714b9b71e1cd9e86947fc5e3a8527ba Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 24 Apr 2021 21:35:05 +0200 Subject: [PATCH] feat(obj) remove LV_OBJ_FLAG_FOCUS_BUBBLE as it can be easily mimiced by events --- src/core/lv_indev.c | 2 +- src/core/lv_obj.c | 21 --------------------- src/core/lv_obj.h | 14 +++----------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/core/lv_indev.c b/src/core/lv_indev.c index 34a176ccd..058c55ea5 100644 --- a/src/core/lv_indev.c +++ b/src/core/lv_indev.c @@ -972,7 +972,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev) static void indev_click_focus(lv_indev_proc_t * proc) { /*Handle click focus*/ - lv_obj_t * obj_to_focus = lv_obj_get_focused_obj(indev_obj_act); + lv_obj_t * obj_to_focus = indev_obj_act; if(lv_obj_has_flag(obj_to_focus, LV_OBJ_FLAG_CLICK_FOCUSABLE) && proc->types.pointer.last_pressed != obj_to_focus) { lv_group_t * g_act = lv_obj_get_group(obj_to_focus); diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index c1ed11e5b..102c8bfdd 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -352,17 +352,6 @@ void lv_obj_allocate_spec_attr(lv_obj_t * obj) } } -lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj) -{ - if(obj == NULL) return NULL; - const lv_obj_t * focus_obj = obj; - while(lv_obj_has_flag(focus_obj, LV_OBJ_FLAG_FOCUS_BUBBLE) != false && focus_obj != NULL) { - focus_obj = lv_obj_get_parent(focus_obj); - } - - return (lv_obj_t *)focus_obj; -} - bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p) { if(obj == NULL) return false; @@ -677,16 +666,9 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e) if(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) state |= LV_STATE_FOCUS_KEY; if(editing) { state |= LV_STATE_EDITED; - - /*if using focus mode, change target to parent*/ - obj = lv_obj_get_focused_obj(obj); - lv_obj_add_state(obj, state); } else { - /*if using focus mode, change target to parent*/ - obj = lv_obj_get_focused_obj(obj); - lv_obj_add_state(obj, state); lv_obj_clear_state(obj, LV_STATE_EDITED); } @@ -698,9 +680,6 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_obj_clear_state(obj, LV_STATE_SCROLLED); } else if(code == LV_EVENT_DEFOCUSED) { - /*if using focus mode, change target to parent*/ - obj = lv_obj_get_focused_obj(obj); - lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY); } else if(code == LV_EVENT_SIZE_CHANGED) { diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index 59189160c..e31bf3a24 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -101,10 +101,9 @@ enum { LV_OBJ_FLAG_PRESS_LOCK = (1 << 11), /**< Keep the object pressed even if the press slid from the object*/ LV_OBJ_FLAG_EVENT_BUBBLE = (1 << 12), /**< Propagate the events to the parent too*/ LV_OBJ_FLAG_GESTURE_BUBBLE = (1 << 13), /**< Propagate the gestures to the parent*/ - LV_OBJ_FLAG_FOCUS_BUBBLE = (1 << 14), /**< Propagate the focus to the parent*/ - LV_OBJ_FLAG_ADV_HITTEST = (1 << 15), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/ - LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 16), /**< Make the object position-able by the layouts*/ - LV_OBJ_FLAG_FLOATING = (1 << 17), /**< Do not scroll the object when the parent scrolls and ignore layout*/ + LV_OBJ_FLAG_ADV_HITTEST = (1 << 14), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/ + LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 15), /**< Make the object position-able by the layouts*/ + LV_OBJ_FLAG_FLOATING = (1 << 16), /**< Do not scroll the object when the parent scrolls and ignore layout*/ LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /** Custom flag, free to use by layouts*/ LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** Custom flag, free to use by layouts*/ @@ -324,13 +323,6 @@ void * lv_obj_get_group(const lv_obj_t * obj); */ void lv_obj_allocate_spec_attr(lv_obj_t * obj); -/** - * Get the focused object by taking `LV_OBJ_FLAG_FOCUS_BUBBLE` into account. - * @param obj the start object - * @return the object to to really focus - */ -lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj); - /** * Get object's and its ancestors type. Put their name in `type_buf` starting with the current type. * E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"