From: Marcel Hollerbach Date: Sun, 24 Mar 2019 12:24:47 +0000 (+0100) Subject: efl_ui_slider: block scrolling when on slider X-Git-Tag: submit/tizen/20190402.051338~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b3a17bda1b68b87d502b14cecfbe24f36c3422d;p=platform%2Fupstream%2Fefl.git efl_ui_slider: block scrolling when on slider when a mouse cursor is over a slider, the mouse wheel should be used to affect the state of the slider, not also the one of the slider. ref T2529 Reviewed-by: Bowon Ryu Reviewed-by: Jaehyun Cho Differential Revision: https://phab.enlightenment.org/D8455 --- diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c index aa43eac..da2f89d 100644 --- a/src/lib/elementary/efl_ui_slider.c +++ b/src/lib/elementary/efl_ui_slider.c @@ -601,6 +601,24 @@ _spacer_up_cb(void *data, } } +static void +_mouse_in_cb(void *data EINA_UNUSED, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + efl_ui_widget_scroll_hold_push(obj); +} + +static void +_mouse_out_cb(void *data EINA_UNUSED, + Evas *e EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + efl_ui_widget_scroll_hold_pop(obj); +} + static char * _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj) { @@ -679,6 +697,11 @@ _efl_ui_slider_efl_object_constructor(Eo *obj, Efl_Ui_Slider_Data *priv) (priv->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj); evas_object_event_callback_add (priv->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj); + evas_object_event_callback_add + (obj, EVAS_CALLBACK_MOUSE_IN, _mouse_in_cb, obj); + evas_object_event_callback_add + (obj, EVAS_CALLBACK_MOUSE_OUT, _mouse_out_cb, obj); + efl_ui_widget_focus_allow_set(obj, EINA_TRUE); diff --git a/src/tests/elementary/elm_test_slider.c b/src/tests/elementary/elm_test_slider.c index ae9b83e..c503820 100644 --- a/src/tests/elementary/elm_test_slider.c +++ b/src/tests/elementary/elm_test_slider.c @@ -41,8 +41,72 @@ EFL_START_TEST(elm_atspi_role_get) } EFL_END_TEST +static Evas_Object *fslider, *scroller; + +static void +mag_job(void *e) +{ + int x, y, w, h; + ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0); + evas_event_feed_mouse_in(e, 0, NULL); + evas_object_geometry_get(fslider, &x, &y, &w, &h); + evas_event_feed_mouse_move(e, x+w/2, y+h/2, 0, NULL); + //ensure that the scroller is on hold + ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 1); + evas_event_feed_mouse_move(e, x+w+w/2, y+h+h/2, 0, NULL); + ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0); + ecore_main_loop_quit(); +} + +static void +norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED) +{ + ecore_job_add(mag_job, e); + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, norendered); +} + +EFL_START_TEST(elm_slider_in_scroller) +{ + Evas_Object *win, *slider, *box; + + win = win_add(NULL, "slider", ELM_WIN_BASIC); + evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + scroller = elm_scroller_add(win); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(scroller); + elm_win_resize_object_add(win, scroller); + + box = elm_box_add(scroller); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(scroller, box); + evas_object_show(box); + + for (int i = 0; i < 20; ++i) + { + slider = elm_slider_add(win); + evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_slider_min_max_set(slider, 0, 100); + evas_object_show(slider); + elm_box_pack_end(box, slider); + if (i == 0) + fslider = slider; + } + elm_scroller_page_bring_in(scroller, 0, 0); + evas_object_resize(win, 100, 100); + evas_object_show(win); + + evas_smart_objects_calculate(evas_object_evas_get(win)); + evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, norendered, NULL); + + elm_run(); + +} +EFL_END_TEST + void elm_test_slider(TCase *tc) { tcase_add_test(tc, elm_slider_legacy_type_check); + tcase_add_test(tc, elm_slider_in_scroller); tcase_add_test(tc, elm_atspi_role_get); }