minor fixes related to encoder
This commit is contained in:
@@ -380,6 +380,16 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
/*The user might clear the key when it was released. Always release the pressed key*/
|
||||
data->key = i->proc.last_key;
|
||||
|
||||
/* 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);
|
||||
focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
|
||||
}
|
||||
}
|
||||
|
||||
if(data->key == LV_GROUP_KEY_NEXT)
|
||||
{
|
||||
lv_group_focus_next(i->group);
|
||||
@@ -420,9 +430,6 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*Process the steps first. They are valid only with released button*/
|
||||
if(data->state == LV_INDEV_STATE_REL) {
|
||||
lv_obj_t * focused = lv_group_get_focused(i->group);
|
||||
bool editable = false;
|
||||
focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
/*In edit mode send LEFT/RIGHT keys*/
|
||||
if(lv_group_get_editing(i->group)) {
|
||||
int32_t s;
|
||||
@@ -683,6 +690,13 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
}
|
||||
/*Handle click focus*/
|
||||
#if USE_LV_GROUP
|
||||
/*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/
|
||||
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.*/
|
||||
if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/
|
||||
lv_group_t * g = lv_obj_get_group(proc->act_obj);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_BTNM_PR_NONE 0xFFFF
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -595,11 +594,17 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER) {
|
||||
/*Select the clicked button*/
|
||||
lv_point_t p1;
|
||||
lv_indev_get_point(indev, &p1);
|
||||
uint16_t btn_i = get_button_from_point(btnm, &p1);
|
||||
ext->btn_id_pr = btn_i;
|
||||
} else if (indev_type == LV_INDEV_TYPE_ENCODER){
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
if(lv_group_get_editing(lv_obj_get_group(btnm))) ext->btn_id_pr = 0;
|
||||
else ext->btn_id_pr = LV_BTNM_PR_NONE;
|
||||
} else {
|
||||
ext->btn_id_pr = 0;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ extern "C" {
|
||||
#define LV_BTNM_REPEAT_DISABLE_MASK 0x10
|
||||
#define LV_BTNM_INACTIVE_MASK 0x20
|
||||
|
||||
|
||||
#define LV_BTNM_PR_NONE 0xFFFF
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
@@ -637,6 +637,19 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
|
||||
refr_btn_width(list);
|
||||
} else 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(list);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
|
||||
} else {
|
||||
lv_list_set_btn_selected(list, NULL);
|
||||
}
|
||||
}
|
||||
/*Else select the clicked button*/
|
||||
else {
|
||||
/*Mark the last clicked button (if any) as selected because it triggered the focus*/
|
||||
if(last_clicked_btn) {
|
||||
lv_list_set_btn_selected(list, last_clicked_btn);
|
||||
@@ -644,6 +657,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
/*Get the first button and mark it as selected*/
|
||||
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
/*De-select the selected btn*/
|
||||
lv_list_set_btn_selected(list, NULL);
|
||||
|
||||
@@ -390,11 +390,25 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS ||
|
||||
sign == LV_SIGNAL_CONTROLL || sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
if(ext->btnm) {
|
||||
|
||||
|
||||
|
||||
ext->btnm->signal_func(ext->btnm, sign, param);
|
||||
}
|
||||
|
||||
/* The button matrix with ENCODER input supposes it's in a group but in this case it isn't (Only the message box's container)
|
||||
* So so some actions here instead*/
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if (indev_type == LV_INDEV_TYPE_ENCODER){
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
|
||||
if(lv_group_get_editing(lv_obj_get_group(mbox))) btnm_ext->btn_id_pr = 0;
|
||||
else btnm_ext->btn_id_pr = LV_BTNM_PR_NONE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
||||
@@ -662,9 +662,17 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
} else if((c == LV_GROUP_KEY_UP) && ext->arrow_scroll) {
|
||||
lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
||||
} else if((c == LV_GROUP_KEY_RIGHT) && ext->arrow_scroll) {
|
||||
lv_page_scroll_hor(page, - lv_obj_get_width(page) / 4);
|
||||
/*If the page can be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
||||
if(lv_page_get_scrl_width(page) < lv_obj_get_width(page)) lv_page_scroll_ver(page, - lv_obj_get_height(page) / 4);
|
||||
else lv_page_scroll_hor(page, - lv_obj_get_width(page) / 4);
|
||||
} else if((c == LV_GROUP_KEY_LEFT) && ext->arrow_scroll) {
|
||||
lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
|
||||
/*If the page can be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
||||
if(lv_page_get_scrl_width(page) < lv_obj_get_width(page)) lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
||||
else lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
/*On ENTER leave edit mode*/
|
||||
// lv_group_t * g = lv_obj_get_group(page);
|
||||
// if(lv_group_get_editing(g)) lv_group_set_editing(g, false);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
|
||||
Reference in New Issue
Block a user