From ca9b365d6ec7841a341ba8d24a91bb3376bf2968 Mon Sep 17 00:00:00 2001 From: WooHyun Jung Date: Fri, 17 Dec 2010 10:52:59 +0000 Subject: [PATCH] From: WooHyun Jung Subject: [E-devel] [PATCH] Patch for elm_slider.c (if you click the bar of the slider, the button will be at there.) I made one patch for elm_slider.c file. If you click the bar of the slider, the button will be located at there. (If you keep your "mouse_down" after moving of the button, you can continuously move the button.) SVN revision: 55610 --- src/lib/elm_slider.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c index df0ad93..99ec220 100644 --- a/src/lib/elm_slider.c +++ b/src/lib/elm_slider.c @@ -78,6 +78,7 @@ static void _drag_down(void *data, Evas_Object *obj, const char *emission, const char *source); static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); +static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info); static const char SIG_CHANGED[] = "changed"; static const char SIG_DELAY_CHANGED[] = "delay,changed"; @@ -434,6 +435,33 @@ _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSE edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step); } +static void +_spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info) +{ + Widget_Data *wd = elm_widget_data_get(data); + Evas_Event_Mouse_Down *ev = event_info; + Evas_Coord x, y, w, h; + double button_x, button_y; + + evas_object_geometry_get(wd->spacer, &x, &y, &w, &h); + edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y); + if(wd->horizontal) + { + button_x = ((double)ev->output.x - (double)x) / (double)w; + if (button_x > 1) button_x = 1; + if (button_x < 0) button_x = 0; + } + else + { + button_y = ((double)ev->output.y - (double)y) / (double)h; + if (button_y > 1) button_y = 1; + if (button_y < 0) button_y = 0; + } + edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y); + evas_event_feed_mouse_cancel(e, 0, NULL); + evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL); +} + /** * Add a new slider to the parent * @@ -488,7 +516,7 @@ elm_slider_add(Evas_Object *parent) evas_object_pass_events_set(wd->spacer, EINA_TRUE); elm_widget_sub_object_add(obj, wd->spacer); edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer); - + evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj); evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj); _sizing_eval(obj); -- 2.7.4