mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
minor fixes for better encoder support
This commit is contained in:
parent
0835e0584a
commit
36369325e7
@ -394,7 +394,7 @@ lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t * group)
|
||||
* @param group pointer to group
|
||||
* @return true editing is enabled
|
||||
*/
|
||||
bool lv_group_get_edit_enable(const lv_group_t * group, bool en)
|
||||
bool lv_group_get_edit_enable(const lv_group_t * group)
|
||||
{
|
||||
return group->edit_mode_en ? true : false;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t * group);
|
||||
* @param group pointer to group
|
||||
* @return true editing is enabled
|
||||
*/
|
||||
bool lv_group_get_edit_enable(const lv_group_t * group, bool en);
|
||||
bool lv_group_get_edit_enable(const lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the current mode (edit or navigate).
|
||||
|
@ -366,13 +366,14 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME )
|
||||
{
|
||||
/*If edit mode is enabled and the focused obejct is editable then change between edit and navigate on long press*/
|
||||
/*If edit mode is enabled and the focused obeject is editable then change between edit and navigate on long press*/
|
||||
lv_obj_t * focused = lv_group_get_focused(i->group);
|
||||
bool editable = false;
|
||||
focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
|
||||
if (i->group->edit_mode_en && editable) {
|
||||
i->group->editing = i->group->editing ? 0 : 1;
|
||||
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);
|
||||
}
|
||||
|
@ -283,10 +283,25 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(bar, mask, mode);;
|
||||
return ancestor_design_f(bar, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(bar);
|
||||
|
||||
#if USE_LV_GROUP == 0
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
#else
|
||||
/* Draw the borders later if the bar is focused.
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't be visible*/
|
||||
if(lv_obj_is_focused(bar)) {
|
||||
lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
|
||||
lv_style_t style_tmp;
|
||||
lv_style_copy(&style_tmp, style_bg);
|
||||
style_tmp.body.border.width = 0;
|
||||
lv_draw_rect(&bar->coords, mask, &style_tmp, opa_scale);
|
||||
} else {
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
}
|
||||
#endif
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
if(ext->cur_value != ext->min_value) {
|
||||
@ -310,8 +325,22 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&indic_area, mask, style_indic, lv_obj_get_opa_scale(bar));
|
||||
lv_draw_rect(&indic_area, mask, style_indic, opa_scale);
|
||||
}
|
||||
}else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
#if USE_LV_GROUP
|
||||
/*Draw the border*/
|
||||
if(lv_obj_is_focused(bar)) {
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(bar);
|
||||
lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
|
||||
lv_style_t style_tmp;
|
||||
lv_style_copy(&style_tmp, style_bg);
|
||||
style_tmp.body.empty = 1;
|
||||
style_tmp.body.shadow.width = 0;
|
||||
lv_draw_rect(&bar->coords, mask, &style_tmp, opa_scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -526,7 +526,13 @@ 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) {
|
||||
if(ext->opened == false) {
|
||||
|
||||
/*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);
|
||||
|
||||
if(ext->opened == false && editing) {
|
||||
ext->opened = true;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
|
@ -557,9 +557,9 @@ static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mo
|
||||
return ancestor_design(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
#if USE_LV_GROUP
|
||||
/* If the page is the active in a group and
|
||||
/* If the page is focused in a group and
|
||||
* the background (page) is not visible (transparent or empty)
|
||||
* then activate the style of the scrollable*/
|
||||
* then "activate" the style of the scrollable*/
|
||||
lv_style_t * style_ori = lv_obj_get_style(scrl);
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
lv_style_t * style_page = lv_obj_get_style(page);
|
||||
|
@ -269,6 +269,8 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
lv_style_t * style_knob = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
|
||||
lv_style_t * style_indic = lv_slider_get_style(slider, LV_SLIDER_STYLE_INDIC);
|
||||
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(slider);
|
||||
|
||||
lv_coord_t slider_w = lv_area_get_width(&slider->coords);
|
||||
lv_coord_t slider_h = lv_area_get_height(&slider->coords);
|
||||
|
||||
@ -301,7 +303,23 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
area_bg.y1 += slider_w > slider_h ? pad_ver_bg : 0; /*Pad only for horizontal slider*/
|
||||
area_bg.y2 -= slider_w > slider_h ? pad_ver_bg : 0; /*Pad only for horizontal slider*/
|
||||
}
|
||||
|
||||
|
||||
#if USE_LV_GROUP == 0
|
||||
lv_draw_rect(&area_bg, mask, style_bg, lv_obj_get_opa_scale(slider));
|
||||
#else
|
||||
/* Draw the borders later if the bar is focused.
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't be visible*/
|
||||
if(lv_obj_is_focused(slider)) {
|
||||
lv_style_t style_tmp;
|
||||
lv_style_copy(&style_tmp, style_bg);
|
||||
style_tmp.body.border.width = 0;
|
||||
lv_draw_rect(&area_bg, mask, &style_tmp, opa_scale);
|
||||
} else {
|
||||
lv_draw_rect(&area_bg, mask, style_bg, opa_scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_area_t area_indic;
|
||||
@ -339,7 +357,20 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1;
|
||||
}
|
||||
|
||||
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, lv_obj_get_opa_scale(slider));
|
||||
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, opa_scale);
|
||||
|
||||
/*Before the knob add the border if required*/
|
||||
#if USE_LV_GROUP
|
||||
/* Draw the borders later if the bar is focused.
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't be visible*/
|
||||
if(lv_obj_is_focused(slider)) {
|
||||
lv_style_t style_tmp;
|
||||
lv_style_copy(&style_tmp, style_bg);
|
||||
style_tmp.body.empty = 1;
|
||||
style_tmp.body.shadow.width = 0;
|
||||
lv_draw_rect(&area_bg, mask, &style_tmp, opa_scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*Draw the knob*/
|
||||
lv_area_t knob_area;
|
||||
@ -371,7 +402,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
|
||||
}
|
||||
|
||||
lv_draw_rect(&knob_area, mask, style_knob, lv_obj_get_opa_scale(slider));
|
||||
lv_draw_rect(&knob_area, mask, style_knob, opa_scale);
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
@ -455,7 +486,7 @@ 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) {
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_ENTER) {
|
||||
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) {
|
||||
|
@ -250,7 +250,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(lv_sw_get_state(sw)) lv_sw_off(sw);
|
||||
if(old_val) lv_sw_off(sw);
|
||||
else lv_sw_on(sw);
|
||||
|
||||
if(slider_action) slider_action(sw);
|
||||
|
Loading…
x
Reference in New Issue
Block a user