feat(slider): consider ext_click_area on the knob with LV_OBJ_FLAG_ADV_HITTEST

This commit is contained in:
Gabor Kiss-Vamosi
2022-01-08 13:48:35 +01:00
parent 3d1ea607f2
commit 9d3fb41896
2 changed files with 12 additions and 3 deletions

View File

@@ -109,13 +109,20 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
/*Advanced hit testing: react only on dragging the knob(s)*/
if(code == LV_EVENT_HIT_TEST) {
lv_hit_test_info_t * info = lv_event_get_param(e);
lv_coord_t ext_click_area = obj->spec_attr ? obj->spec_attr->ext_click_pad : 0;
/*Ordinary slider: was the knob area hit?*/
info->res = _lv_area_is_point_on(&slider->right_knob_area, info->point, 0);
lv_area_t a;
lv_area_copy(&a, &slider->right_knob_area);
lv_area_increase(&a, ext_click_area, ext_click_area);
info->res = _lv_area_is_point_on(&a, info->point, 0);
/*There's still a change we have a hit, if we have another knob*/
/*There's still a chance that there is a hit if there is another knob*/
if((info->res == false) && (type == LV_SLIDER_MODE_RANGE)) {
info->res = _lv_area_is_point_on(&slider->left_knob_area, info->point, 0);
lv_area_t a;
lv_area_copy(&a, &slider->left_knob_area);
lv_area_increase(&a, ext_click_area, ext_click_area);
info->res = _lv_area_is_point_on(&a, info->point, 0);
}
}
else if(code == LV_EVENT_PRESSED) {