fixes for encoder usage

This commit is contained in:
Gabor Kiss-Vamosi 2020-04-23 09:50:50 +02:00
parent c340a7b580
commit c149e5de54
9 changed files with 93 additions and 103 deletions

View File

@ -303,28 +303,6 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
return res; return res;
} }
/**
* Set a function for a group which will modify the object's style if it is in focus
* @param group pointer to a group
* @param style_mod_cb the style modifier function pointer
*/
void lv_group_set_style_mod_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_cb)
{
group->style_mod_cb = style_mod_cb;
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
}
/**
* Set a function for a group which will modify the object's style if it is in focus in edit mode
* @param group pointer to a group
* @param style_mod_func the style modifier function pointer
*/
void lv_group_set_style_mod_edit_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_edit_cb)
{
group->style_mod_edit_cb = style_mod_edit_cb;
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
}
/** /**
* Set a function for a group which will be called when a new object is focused * Set a function for a group which will be called when a new object is focused
* @param group pointer to a group * @param group pointer to a group
@ -342,6 +320,7 @@ 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) void lv_group_set_editing(lv_group_t * group, bool edit)
{ {
if(group == NULL) return;
uint8_t en_val = edit ? 1 : 0; uint8_t en_val = edit ? 1 : 0;
if(en_val == group->editing) return; /*Do not set the same mode again*/ if(en_val == group->editing) return; /*Do not set the same mode again*/
@ -383,26 +362,6 @@ void lv_group_set_wrap(lv_group_t * group, bool en)
group->wrap = en ? 1 : 0; group->wrap = en ? 1 : 0;
} }
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
* @param style pointer to a style to modify
* @return a copy of the input style but modified with the 'style_mod' function
*/
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
{
/*Load the current style. It will be modified by the callback*/
lv_style_copy(&group->style_tmp, style);
if(group->editing) {
if(group->style_mod_edit_cb) group->style_mod_edit_cb(group, &group->style_tmp);
}
else {
if(group->style_mod_cb) group->style_mod_cb(group, &group->style_tmp);
}
return &group->style_tmp;
}
/** /**
* Get the focused object or NULL if there isn't one * Get the focused object or NULL if there isn't one
* @param group pointer to a group * @param group pointer to a group
@ -428,28 +387,6 @@ lv_group_user_data_t * lv_group_get_user_data(lv_group_t * group)
} }
#endif #endif
/**
* Get a the style modifier function of a group
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_cb(const lv_group_t * group)
{
if(!group) return NULL;
return group->style_mod_cb;
}
/**
* Get a the style modifier function of a group in edit mode
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_edit_cb(const lv_group_t * group)
{
if(!group) return NULL;
return group->style_mod_edit_cb;
}
/** /**
* Get the focus callback function of a group * Get the focus callback function of a group
* @param group pointer to a group * @param group pointer to a group

View File

@ -55,10 +55,7 @@ typedef struct _lv_group_t {
lv_ll_t obj_ll; /**< Linked list to store the objects in the group */ lv_ll_t obj_ll; /**< Linked list to store the objects in the group */
lv_obj_t ** obj_focus; /**< The object in focus*/ lv_obj_t ** obj_focus; /**< The object in focus*/
lv_group_style_mod_cb_t style_mod_cb; /**< A function to modifies the style of the focused object*/
lv_group_style_mod_cb_t style_mod_edit_cb; /**< A function which modifies the style of the edited object*/
lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/ lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/
lv_style_t style_tmp; /**< Stores the modified style of the focused object */
#if LV_USE_USER_DATA #if LV_USE_USER_DATA
lv_group_user_data_t user_data; lv_group_user_data_t user_data;
#endif #endif

View File

@ -834,10 +834,10 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h)
* @param obj pointer to an object to align * @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum) * @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment * @param x_ofs x coordinate offset after alignment
* @param y_mod y coordinate shift after alignment * @param y_ofs y coordinate offset after alignment
*/ */
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
{ {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@ -852,8 +852,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
lv_obj_t * par = lv_obj_get_parent(obj); lv_obj_t * par = lv_obj_get_parent(obj);
lv_coord_t par_abs_x = par->coords.x1; lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1; lv_coord_t par_abs_y = par->coords.y1;
new_pos.x += x_mod; new_pos.x += x_ofs;
new_pos.y += y_mod; new_pos.y += y_ofs;
new_pos.x -= par_abs_x; new_pos.x -= par_abs_x;
new_pos.y -= par_abs_y; new_pos.y -= par_abs_y;
@ -862,8 +862,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
#if LV_USE_OBJ_REALIGN #if LV_USE_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/ /*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align; obj->realign.align = align;
obj->realign.xofs = x_mod; obj->realign.xofs = x_ofs;
obj->realign.yofs = y_mod; obj->realign.yofs = y_ofs;
obj->realign.base = base; obj->realign.base = base;
obj->realign.origo_align = 0; obj->realign.origo_align = 0;
#endif #endif
@ -874,10 +874,10 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
* @param obj pointer to an object to align * @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum) * @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment * @param x_ofs x coordinate offset after alignment
* @param y_mod y coordinate shift after alignment * @param y_ofs y coordinate offset after alignment
*/ */
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
{ {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@ -1005,8 +1005,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
lv_coord_t base_abs_y = base->coords.y1; lv_coord_t base_abs_y = base->coords.y1;
lv_coord_t par_abs_x = par->coords.x1; lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1; lv_coord_t par_abs_y = par->coords.y1;
new_x += x_mod + base_abs_x; new_x += x_ofs + base_abs_x;
new_y += y_mod + base_abs_y; new_y += y_ofs + base_abs_y;
new_x -= par_abs_x; new_x -= par_abs_x;
new_y -= par_abs_y; new_y -= par_abs_y;
@ -1015,8 +1015,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
#if LV_USE_OBJ_REALIGN #if LV_USE_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/ /*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align; obj->realign.align = align;
obj->realign.xofs = x_mod; obj->realign.xofs = x_ofs;
obj->realign.yofs = y_mod; obj->realign.yofs = y_ofs;
obj->realign.base = base; obj->realign.base = base;
obj->realign.origo_align = 1; obj->realign.origo_align = 1;
#endif #endif
@ -3580,7 +3580,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
} }
else { else {
lv_obj_add_state(obj, LV_STATE_FOCUSED); lv_obj_add_state(obj, LV_STATE_FOCUSED);
lv_obj_clear_state(obj, LV_STATE_EDITED); lv_obj_clear_state(obj, LV_STATE_EDITED | LV_STATE_PRESSED);
} }
} }
else if(sign == LV_SIGNAL_DEFOCUS) { else if(sign == LV_SIGNAL_DEFOCUS) {

View File

@ -447,20 +447,20 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h);
* @param obj pointer to an object to align * @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum) * @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment * @param x_ofs x coordinate offset after alignment
* @param y_mod y coordinate shift after alignment * @param y_ofs y coordinate offset after alignment
*/ */
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/** /**
* Align an object to an other object. * Align an object to an other object.
* @param obj pointer to an object to align * @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum) * @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment * @param x_ofs x coordinate offset after alignment
* @param y_mod y coordinate shift after alignment * @param y_ofs y coordinate offset after alignment
*/ */
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/** /**
* Realign the object based on the last `lv_obj_align` parameters. * Realign the object based on the last `lv_obj_align` parameters.

View File

@ -200,6 +200,7 @@ static void basic_init(void)
lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, COLOR_BG);
lv_style_set_border_color(&bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_color(&bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_color(&bg, LV_STATE_FOCUSED, theme.color_primary); lv_style_set_border_color(&bg, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_border_color(&bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_border_width(&bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_width(&bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_post(&bg, LV_STATE_DEFAULT, true); lv_style_set_border_post(&bg, LV_STATE_DEFAULT, true);
lv_style_set_text_font(&bg, LV_STATE_DEFAULT, theme.font_normal); lv_style_set_text_font(&bg, LV_STATE_DEFAULT, theme.font_normal);
@ -289,6 +290,7 @@ static void basic_init(void)
lv_style_set_outline_opa(&btn, LV_STATE_DEFAULT, LV_OPA_0); lv_style_set_outline_opa(&btn, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_color(&btn, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_outline_color(&btn, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_outline_color(&btn, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_transition_time(&btn, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_time(&btn, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_4(&btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA); lv_style_set_transition_prop_4(&btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA);
lv_style_set_transition_prop_5(&btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); lv_style_set_transition_prop_5(&btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
@ -337,6 +339,7 @@ static void bar_init(void)
lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC); lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
lv_style_set_outline_color(&bar_bg, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_outline_color(&bar_bg, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_outline_color(&bar_bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_outline_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_width(&bar_bg, LV_STATE_DEFAULT, 3); lv_style_set_outline_width(&bar_bg, LV_STATE_DEFAULT, 3);
@ -570,6 +573,7 @@ static void cpicker_init(void)
lv_style_set_border_width(&cpicker_indic, LV_STATE_DEFAULT, 2); lv_style_set_border_width(&cpicker_indic, LV_STATE_DEFAULT, 2);
lv_style_set_border_color(&cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_style_set_border_color(&cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_style_set_border_color(&cpicker_indic, LV_STATE_FOCUSED, theme.color_primary); lv_style_set_border_color(&cpicker_indic, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_border_color(&cpicker_indic, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_pad_left(&cpicker_indic, LV_STATE_DEFAULT,LV_DPX(13)); lv_style_set_pad_left(&cpicker_indic, LV_STATE_DEFAULT,LV_DPX(13));
lv_style_set_pad_right(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13)); lv_style_set_pad_right(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
lv_style_set_pad_top(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13)); lv_style_set_pad_top(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
@ -612,6 +616,7 @@ static void keyboard_init(void)
lv_style_set_border_width(&kb_bg, LV_STATE_DEFAULT, LV_DPX(4)); lv_style_set_border_width(&kb_bg, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_border_side(&kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP); lv_style_set_border_side(&kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP);
lv_style_set_border_color(&kb_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT : LV_COLOR_BLACK); lv_style_set_border_color(&kb_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT : LV_COLOR_BLACK);
lv_style_set_border_color(&kb_bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_pad_left(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_pad_left(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_right(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_pad_right(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_top(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_pad_top(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
@ -774,10 +779,12 @@ static void tabview_init(void)
lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20)); lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20)); lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_text_color(&tabview_btns, LV_STATE_FOCUSED, theme.color_primary); lv_style_set_text_color(&tabview_btns, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_text_color(&tabview_btns, LV_STATE_EDITED, theme.color_secondary);
style_init_reset(&tabview_indic); style_init_reset(&tabview_indic);
lv_style_set_bg_opa(&tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&tabview_indic, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_bg_color(&tabview_indic, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_bg_color(&tabview_indic, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPX(5)); lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPX(5));
lv_style_set_radius(&tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_radius(&tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);

View File

@ -612,7 +612,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
lv_draw_rect_dsc_t draw_rect_tmp_dsc; lv_draw_rect_dsc_t draw_rect_tmp_dsc;
lv_draw_label_dsc_t draw_label_tmp_dsc; lv_draw_label_dsc_t draw_label_tmp_dsc;
/*The state changes without re-caching the styles, disable the use of cache*/ /*The state changes without re-caching the styles, disable the use of cache*/
lv_state_t state_ori = btnm->state; lv_state_t state_ori = btnm->state;
btnm->state = LV_STATE_DEFAULT; btnm->state = LV_STATE_DEFAULT;
@ -689,7 +688,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
btnm->state = LV_STATE_DEFAULT; btnm->state = LV_STATE_DEFAULT;
if(tgl_state) btnm->state = LV_STATE_CHECKED; if(tgl_state) btnm->state = LV_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED; if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED;
if(ext->btn_id_focused == btn_i) btnm->state |= LV_STATE_FOCUSED; if(ext->btn_id_focused == btn_i) {
btnm->state |= LV_STATE_FOCUSED;
if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED;
}
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc); lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
lv_draw_label_dsc_init(&draw_label_tmp_dsc); lv_draw_label_dsc_init(&draw_label_tmp_dsc);

View File

@ -123,6 +123,7 @@ lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new drop down list drop down list*/ /*Init the new drop down list drop down list*/
if(copy == NULL) { if(copy == NULL) {
lv_obj_set_width(ddlist, LV_DPX(150));
lv_dropdown_set_static_options(ddlist, "Option 1\nOption 2\nOption 3"); lv_dropdown_set_static_options(ddlist, "Option 1\nOption 2\nOption 3");
lv_theme_apply(ddlist, LV_THEME_DROPDOWN); lv_theme_apply(ddlist, LV_THEME_DROPDOWN);
} }
@ -902,13 +903,18 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
lv_dropdown_close(ddlist); lv_dropdown_close(ddlist);
} }
else if(sign == LV_SIGNAL_RELEASED) { else if(sign == LV_SIGNAL_RELEASED) {
if(lv_indev_is_dragging(lv_indev_get_act()) == false) { lv_indev_t * indev = lv_indev_get_act();
if(lv_indev_is_dragging(indev) == false) {
if(ext->page) { if(ext->page) {
lv_dropdown_close(ddlist); lv_dropdown_close(ddlist);
if(ext->sel_opt_id_orig != ext->sel_opt_id) { if(ext->sel_opt_id_orig != ext->sel_opt_id) {
ext->sel_opt_id_orig = ext->sel_opt_id; ext->sel_opt_id_orig = ext->sel_opt_id;
lv_obj_invalidate(ddlist); lv_obj_invalidate(ddlist);
} }
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_ENCODER) {
lv_group_set_editing(lv_obj_get_group(ddlist), false);
}
} }
else { else {
lv_dropdown_open(ddlist); lv_dropdown_open(ddlist);

View File

@ -162,6 +162,13 @@ void lv_msgbox_add_btns(lv_obj_t * mbox, const char * btn_map[])
lv_obj_set_event_cb(ext->btnm, lv_msgbox_btnm_event_cb); lv_obj_set_event_cb(ext->btnm, lv_msgbox_btnm_event_cb);
if(lv_obj_is_focused(mbox)) { if(lv_obj_is_focused(mbox)) {
lv_state_t state = lv_obj_get_state(mbox, LV_TABVIEW_PART_BG);
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED | LV_STATE_EDITED);
} else {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED);
}
lv_btnmatrix_set_focused_btn(ext->btnm, 0); lv_btnmatrix_set_focused_btn(ext->btnm, 0);
} }
@ -460,14 +467,27 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
lv_indev_type_t indev_type = lv_indev_get_type(indev); lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_ENCODER) { if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*In navigation mode don't select any button but in edit mode select the fist*/ /*In navigation mode don't select any button but in edit mode select the fist*/
lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm); if(lv_group_get_editing(lv_obj_get_group(mbox))) lv_btnmatrix_set_focused_btn(ext->btnm, 0);
if(lv_group_get_editing(lv_obj_get_group(mbox))) else lv_btnmatrix_set_focused_btn(ext->btnm, LV_BTNMATRIX_BTN_NONE);
btnm_ext->btn_id_pr = 0;
else
btnm_ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
} }
#endif
} }
if(ext->btnm && (sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS)) {
lv_state_t state = lv_obj_get_state(mbox, LV_TABVIEW_PART_BG);
if(state & LV_STATE_FOCUSED) {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED);
} else {
lv_obj_clear_state(ext->btnm, LV_STATE_FOCUSED);
}
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btnm, LV_STATE_EDITED);
} else {
lv_obj_clear_state(ext->btnm, LV_STATE_EDITED);
}
}
#endif
} }
return res; return res;

View File

@ -652,17 +652,34 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
/* The button matrix is not in a group (the tab view is in it) but it should handle the /* 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*/ * group signals. So propagate the related signals to the button matrix manually*/
if(ext->btns) { ext->btns->signal_cb(ext->btns, sign, param);
ext->btns->signal_cb(ext->btns, sign, param);
/*Make the active tab's button focused*/
if(sign == LV_SIGNAL_FOCUS) {
lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur);
}
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
lv_state_t state = lv_obj_get_state(tabview, LV_TABVIEW_PART_BG);
if(state & LV_STATE_FOCUSED) {
lv_obj_set_state(ext->btns, LV_STATE_FOCUSED);
lv_obj_set_state(ext->indic, LV_STATE_FOCUSED);
} else {
lv_obj_clear_state(ext->btns, LV_STATE_FOCUSED);
lv_obj_clear_state(ext->indic, LV_STATE_FOCUSED);
}
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btns, LV_STATE_EDITED);
lv_obj_set_state(ext->indic, LV_STATE_EDITED);
} else {
lv_obj_clear_state(ext->btns, LV_STATE_EDITED);
lv_obj_clear_state(ext->indic, LV_STATE_EDITED);
/*Make the active tab's button focused*/
if(sign == LV_SIGNAL_FOCUS) {
lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur);
} }
} }
} }
return res; return res;
} }
@ -796,6 +813,10 @@ static void tab_btnm_event_cb(lv_obj_t * tab_btnm, lv_event_t event)
lv_res_t res = LV_RES_OK; lv_res_t res = LV_RES_OK;
if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new); if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new);
if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_ENCODER) {
lv_group_set_editing(lv_obj_get_group(tabview), false);
}
if(res != LV_RES_OK) return; if(res != LV_RES_OK) return;
} }