mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
feat(obj) remove LV_OBJ_FLAG_FOCUS_BUBBLE as it can be easily mimiced by events
This commit is contained in:
parent
6428be5441
commit
2d00a3fc17
@ -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)
|
static void indev_click_focus(lv_indev_proc_t * proc)
|
||||||
{
|
{
|
||||||
/*Handle click focus*/
|
/*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) &&
|
if(lv_obj_has_flag(obj_to_focus, LV_OBJ_FLAG_CLICK_FOCUSABLE) &&
|
||||||
proc->types.pointer.last_pressed != obj_to_focus) {
|
proc->types.pointer.last_pressed != obj_to_focus) {
|
||||||
lv_group_t * g_act = lv_obj_get_group(obj_to_focus);
|
lv_group_t * g_act = lv_obj_get_group(obj_to_focus);
|
||||||
|
@ -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)
|
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||||
{
|
{
|
||||||
if(obj == NULL) return false;
|
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(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) state |= LV_STATE_FOCUS_KEY;
|
||||||
if(editing) {
|
if(editing) {
|
||||||
state |= LV_STATE_EDITED;
|
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);
|
lv_obj_add_state(obj, state);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*if using focus mode, change target to parent*/
|
|
||||||
obj = lv_obj_get_focused_obj(obj);
|
|
||||||
|
|
||||||
lv_obj_add_state(obj, state);
|
lv_obj_add_state(obj, state);
|
||||||
lv_obj_clear_state(obj, LV_STATE_EDITED);
|
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);
|
lv_obj_clear_state(obj, LV_STATE_SCROLLED);
|
||||||
}
|
}
|
||||||
else if(code == LV_EVENT_DEFOCUSED) {
|
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);
|
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY);
|
||||||
}
|
}
|
||||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||||
|
@ -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_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_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_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 << 14), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
|
||||||
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 << 15), /**< Make the object position-able by the layouts*/
|
||||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 16), /**< 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_FLOATING = (1 << 17), /**< 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_1 = (1 << 23), /** Custom flag, free to use by layouts*/
|
||||||
LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** 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);
|
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.
|
* 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"
|
* E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user