From 7b9c6a4fb87b6439049e032ac7b8beab9ef8fcac Mon Sep 17 00:00:00 2001 From: sumanth Date: Mon, 20 Feb 2012 19:26:08 +0530 Subject: [PATCH] [elm_slider.c] fix for Nabi/ S1 - 1271, regarding indicator drag sensitivity. Change-Id: If5bb0b1480c94b11f34b52153177a63d61bf6f70 --- src/lib/elm_slider.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c index 5398a48..9912cc9 100644 --- a/src/lib/elm_slider.c +++ b/src/lib/elm_slider.c @@ -22,13 +22,15 @@ struct _Widget_Data const char *(*units_format_func)(double val); void (*units_format_free)(const char *str); - double val, val_min, val_max; + double val, val_min, val_max, val2; Evas_Coord size; + Evas_Coord downx, downy; Eina_Bool horizontal : 1; Eina_Bool inverted : 1; Eina_Bool indicator_show : 1; Eina_Bool spacer_down : 1; + Eina_Bool frozen : 1; }; #define ELM_SLIDER_INVERTED_FACTOR (-1.0) @@ -76,7 +78,6 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty wd = elm_widget_data_get(obj); if (!wd) return EINA_FALSE; - if (elm_widget_disabled_get(obj)) return EINA_FALSE; if (type == EVAS_CALLBACK_KEY_DOWN) goto key_down; else if (type != EVAS_CALLBACK_MOUSE_WHEEL) return EINA_FALSE; @@ -475,7 +476,10 @@ _spacer_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi if (elm_widget_disabled_get(data)) return; wd->spacer_down = EINA_TRUE; + wd->val2 = wd->val; evas_object_geometry_get(wd->spacer, &x, &y, &w, &h); + wd->downx = ev->canvas.x - x; + wd->downy = ev->canvas.y - y; edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y); if (wd->horizontal) { @@ -494,7 +498,6 @@ _spacer_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi evas_object_smart_callback_call(data, SIG_DRAG_START, NULL); _units_set(data); _indicator_set(data); - elm_widget_scroll_freeze_push(data); edje_object_signal_emit(wd->slider, "elm,state,indicator,show", "elm"); edje_object_signal_emit(wd->slider, "elm,state,drag", "elm"); edje_object_message_signal_process(wd->slider); @@ -505,13 +508,41 @@ _spacer_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi { Widget_Data *wd = elm_widget_data_get(data); Evas_Event_Mouse_Move *ev = event_info; - Evas_Coord x, y, w, h; + Evas_Coord x, y, w, h, d = 0; double button_x = 0.0, button_y = 0.0; if (elm_widget_disabled_get(data)) return; if (wd->spacer_down) { evas_object_geometry_get(wd->spacer, &x, &y, &w, &h); + if (wd->horizontal) d = abs(ev->cur.canvas.x - x - wd->downx); + else d = abs(ev->cur.canvas.y - y - wd->downy); + if (d > (_elm_config->thumbscroll_threshold - 1)) + { + if (!wd->frozen) + { + elm_widget_scroll_freeze_push(data); + wd->frozen = EINA_TRUE; + } + ev->event_flags &= ~EVAS_EVENT_FLAG_ON_HOLD; + } + + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) + { + if (wd->spacer_down) wd->spacer_down = EINA_FALSE; + _val_fetch(data); + evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL); + _units_set(data); + _indicator_set(data); + if (wd->frozen) + { + elm_widget_scroll_freeze_pop(data); + wd->frozen = EINA_FALSE; + } + edje_object_signal_emit(wd->slider, "elm,state,indicator,hide", "elm"); + elm_slider_value_set(data, wd->val2); + return; + } if (wd->horizontal) { button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w; @@ -538,13 +569,18 @@ _spacer_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void { Widget_Data *wd = elm_widget_data_get(data); if (elm_widget_disabled_get(data)) return; + if (!wd->spacer_down) return; - if (wd->spacer_down) wd->spacer_down = EINA_FALSE; + wd->spacer_down = EINA_FALSE; _val_fetch(data); evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL); _units_set(data); _indicator_set(data); - elm_widget_scroll_freeze_pop(data); + if (wd->frozen) + { + elm_widget_scroll_freeze_pop(data); + wd->frozen = EINA_FALSE; + } edje_object_signal_emit(wd->slider, "elm,state,indicator,hide", "elm"); } -- 2.7.4