LV_INDEV_TYPE_ENCODER added
This commit is contained in:
@@ -526,19 +526,36 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
ext->label = NULL;
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
|
||||
/*Open the list if editing*/
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = true;
|
||||
if(lv_group_get_edit_enable(g)) editing = lv_group_get_editing(g);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
if(ext->opened == false && editing) {
|
||||
ext->opened = true;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*Open the list if editing*/
|
||||
if(editing) {
|
||||
ext->opened = true;
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
/*Close the lift if navigating*/
|
||||
else {
|
||||
ext->opened = false;
|
||||
ext->sel_opt_id = ext->sel_opt_id_ori;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*Open the list if closed*/
|
||||
if(!ext->opened) {
|
||||
ext->opened = true;
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
if(ext->opened != false) {
|
||||
if(ext->opened) {
|
||||
ext->opened = false;
|
||||
ext->sel_opt_id = ext->sel_opt_id_ori;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
@@ -571,6 +588,10 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
ext->opened = 0;
|
||||
if(ext->action) ext->action(ddlist);
|
||||
|
||||
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*/
|
||||
} else {
|
||||
ext->opened = 1;
|
||||
}
|
||||
|
||||
@@ -316,17 +316,27 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = true;
|
||||
if(lv_group_get_edit_enable(g)) editing = lv_group_get_editing(g);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
if(editing) ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id;
|
||||
else {
|
||||
/*Revert the original state. Important when moving from edit->navigate mode*/
|
||||
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
|
||||
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
|
||||
refr_position(roller, true);
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*In navigate mode revert the original value*/
|
||||
if(!editing) {
|
||||
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
|
||||
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
|
||||
refr_position(roller, true);
|
||||
}
|
||||
}
|
||||
/*Save the current state when entered to edit mode*/
|
||||
else {
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id;
|
||||
}
|
||||
} else {
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
|
||||
|
||||
}
|
||||
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
/*Revert the original state*/
|
||||
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
|
||||
@@ -347,6 +357,10 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
|
||||
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*/
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
|
||||
@@ -486,7 +486,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_ENTER) {
|
||||
lv_group_t * g = lv_obj_get_group(slider);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER && c == LV_GROUP_KEY_ENTER) {
|
||||
if(editing) lv_group_set_editing(g, false);
|
||||
}
|
||||
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1);
|
||||
if(ext->action != NULL) ext->action(slider);
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
|
||||
Reference in New Issue
Block a user