lv_group related updates mainly with ENCODER indev
This commit is contained in:
@@ -154,6 +154,9 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
|
||||
if(g->frozen != 0) return;
|
||||
|
||||
/*On defocus edit mode must be leaved*/
|
||||
lv_group_set_editing(g, false);
|
||||
|
||||
lv_obj_t ** i;
|
||||
LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
@@ -295,8 +298,15 @@ void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
|
||||
*/
|
||||
void lv_group_set_editing(lv_group_t * group, bool edit)
|
||||
{
|
||||
group->editing = edit ? 1 : 0;
|
||||
uint8_t en_val = edit ? 1 : 0;
|
||||
|
||||
if(en_val == group->editing) return; /*Do not set the same mode again*/
|
||||
|
||||
group->editing = en_val;
|
||||
lv_obj_t * focused = lv_group_get_focused(group);
|
||||
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
|
||||
|
||||
lv_obj_invalidate(focused);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,11 +384,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
/* Edit mode is not used by KEYPAD devices.
|
||||
* So leave edit mode if we are in it before focusing on the next/prev object*/
|
||||
if(data->key == LV_GROUP_KEY_NEXT || data->key == LV_GROUP_KEY_PREV) {
|
||||
if(lv_group_get_editing(i->group)) {
|
||||
lv_group_set_editing(i->group, false);
|
||||
lv_obj_t * focused = lv_group_get_focused(i->group);
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
|
||||
}
|
||||
lv_group_set_editing(i->group, false);
|
||||
}
|
||||
|
||||
if(data->key == LV_GROUP_KEY_NEXT) {
|
||||
@@ -465,10 +461,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
|
||||
if(editable) {
|
||||
i->group->editing = i->group->editing ? 0 : 1;
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/
|
||||
LV_LOG_INFO("Edit mode changed");
|
||||
if(focused) lv_obj_invalidate(focused);
|
||||
lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/
|
||||
}
|
||||
/*If not editable then just send a long press signal*/
|
||||
else {
|
||||
@@ -493,10 +486,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
/*If the focused object is editable and now in navigate mode then enter edit mode*/
|
||||
else if(editable && !i->group->editing && !i->proc.long_pr_sent) {
|
||||
i->group->editing = i->group->editing ? 0 : 1;
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/
|
||||
LV_LOG_INFO("Edit mode changed (edit)");
|
||||
if(focused) lv_obj_invalidate(focused);
|
||||
lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/
|
||||
}
|
||||
|
||||
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
|
||||
@@ -699,7 +689,6 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
lv_group_t * act_g = lv_obj_get_group(proc->act_obj);
|
||||
if(lv_group_get_editing(act_g)) {
|
||||
lv_group_set_editing(act_g, false);
|
||||
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
|
||||
}
|
||||
|
||||
/*Check, if the parent is in a group focus on it.*/
|
||||
|
||||
@@ -586,14 +586,16 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(ext->opened) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
ext->opened = 0;
|
||||
if(ext->action) res = ext->action(ddlist);
|
||||
#if USE_LV_GROUP
|
||||
if(res == LV_RES_OK) {
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ext->opened = 1;
|
||||
}
|
||||
|
||||
@@ -358,15 +358,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
|
||||
#endif
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
if(ext->ddlist.action) res = ext->ddlist.action(roller);
|
||||
#if USE_LV_GROUP
|
||||
if(res == LV_RES_OK) {
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
|
||||
@@ -577,9 +577,27 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
tabview_realign(tabview);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
/* The button matrix is not in a group (the tab view is in it) but it should handle the group signals.
|
||||
* So propagate the related signals to the button matrix manually*/
|
||||
if(ext->btns) {
|
||||
ext->btns->signal_func(ext->btns, sign, param);
|
||||
}
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
lv_group_t * g = lv_obj_get_group(tabview);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
} else {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
*editable = true;
|
||||
|
||||
Reference in New Issue
Block a user