1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix(slider): consider transformation when draging

fixes #4053
This commit is contained in:
Gabor Kiss-Vamosi 2023-03-13 15:09:42 +01:00
parent d400689b15
commit a19ad9bd1d

View File

@ -132,6 +132,7 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
else if(code == LV_EVENT_PRESSED) { else if(code == LV_EVENT_PRESSED) {
/*Save the pressed coordinates*/ /*Save the pressed coordinates*/
lv_indev_get_point(lv_indev_get_act(), &slider->pressed_point); lv_indev_get_point(lv_indev_get_act(), &slider->pressed_point);
lv_obj_transform_point(obj, &slider->pressed_point, true, true);
} }
else if(code == LV_EVENT_PRESSING) { else if(code == LV_EVENT_PRESSING) {
update_knob_pos(obj, true); update_knob_pos(obj, true);
@ -353,6 +354,7 @@ static void drag_start(lv_obj_t * obj)
} }
else if(mode == LV_SLIDER_MODE_RANGE) { else if(mode == LV_SLIDER_MODE_RANGE) {
lv_indev_get_point(lv_indev_get_act(), &p); lv_indev_get_point(lv_indev_get_act(), &p);
lv_obj_transform_point(obj, &p, true, true);
bool hor = is_slider_horizontal(obj); bool hor = is_slider_horizontal(obj);
lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN);
@ -419,6 +421,8 @@ static void update_knob_pos(lv_obj_t * obj, bool check_drag)
lv_point_t p; lv_point_t p;
lv_indev_get_point(indev, &p); lv_indev_get_point(indev, &p);
lv_obj_transform_point(obj, &p, true, true);
bool is_hor = is_slider_horizontal(obj); bool is_hor = is_slider_horizontal(obj);
if(check_drag && !slider->dragging) { if(check_drag && !slider->dragging) {