forked from enlightenment/efl
elm_spinner: add feature in spinner to change values while dragging relative to the speed of dragging
Summary: Currently the values in spinner change while dragging only based on the amount of pixels dragged, this patch will enable Spinner to change value based on the speed of dragging so that it will be more user friendly. This will help users to alter drag values by big amounts if dragged in a good speed. Test Plan: test_spinner.c in elementary_test Reviewers: raster, prince.dubey, shilpasingh, cedric Reviewed By: cedric Subscribers: poornima.srinivasan, rajeshps, govi Differential Revision: https://phab.enlightenment.org/D2659 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
f10b4eb8d0
commit
7ee4a5b8b1
|
@ -164,3 +164,4 @@ Jee-Yong Um <conr2d@gmail.com>
|
||||||
Ji-In Moon <jiin.moon@samsung.com>
|
Ji-In Moon <jiin.moon@samsung.com>
|
||||||
Subodh Kumar <s7158.kumar@samsung.com>
|
Subodh Kumar <s7158.kumar@samsung.com>
|
||||||
Kumar Navneet <k.navneet@samsung.com>
|
Kumar Navneet <k.navneet@samsung.com>
|
||||||
|
Godly T Alias <godly.talias@samsung.com>
|
||||||
|
|
|
@ -35,7 +35,7 @@ test_spinner(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
|
||||||
elm_spinner_label_format_set(sp, "%1.1f units");
|
elm_spinner_label_format_set(sp, "%1.1f units");
|
||||||
elm_spinner_step_set(sp, 1.3);
|
elm_spinner_step_set(sp, 1.3);
|
||||||
elm_spinner_wrap_set(sp, EINA_TRUE);
|
elm_spinner_wrap_set(sp, EINA_TRUE);
|
||||||
elm_spinner_min_max_set(sp, -50.0, 250.0);
|
elm_spinner_min_max_set(sp, -5000.0, 5000.0);
|
||||||
evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
|
evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
|
||||||
evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_smart_callback_add(sp, "spinner,drag,start",
|
evas_object_smart_callback_add(sp, "spinner,drag,start",
|
||||||
|
|
|
@ -162,6 +162,7 @@
|
||||||
* @author yinsc <shouchen.yin@@samsung.com>
|
* @author yinsc <shouchen.yin@@samsung.com>
|
||||||
* @author Subodh Kumar <s7158.kumar@@samsung.com>
|
* @author Subodh Kumar <s7158.kumar@@samsung.com>
|
||||||
* @author Kumar Navneet <k.navneet@@samsung.com>
|
* @author Kumar Navneet <k.navneet@@samsung.com>
|
||||||
|
* @author Godly T Alias <godly.talias@@samsung.com>
|
||||||
*
|
*
|
||||||
* Please contact <enlightenment-devel@lists.sourceforge.net> to get in
|
* Please contact <enlightenment-devel@lists.sourceforge.net> to get in
|
||||||
* contact with the developers and maintainers.
|
* contact with the developers and maintainers.
|
||||||
|
|
|
@ -217,11 +217,18 @@ _drag_cb(void *data,
|
||||||
else
|
else
|
||||||
eo_do((Eo *)wd->resize_obj,
|
eo_do((Eo *)wd->resize_obj,
|
||||||
edje_obj_part_drag_value_get("elm.dragable.slider", &pos, NULL));
|
edje_obj_part_drag_value_get("elm.dragable.slider", &pos, NULL));
|
||||||
|
if (sd->drag_prev_pos != 0)
|
||||||
|
sd->drag_val_step = pow((pos - sd->drag_prev_pos), 2);
|
||||||
|
else
|
||||||
|
sd->drag_val_step = 1;
|
||||||
|
|
||||||
delta = pos * sd->step * _elm_config->scale;
|
|
||||||
|
delta = sd->drag_val_step * sd->step * _elm_config->scale;
|
||||||
|
if (pos < sd->drag_prev_pos) delta *= -1;
|
||||||
|
sd->drag_prev_pos = pos;
|
||||||
/* If we are on rtl mode, change the delta to be negative on such changes */
|
/* If we are on rtl mode, change the delta to be negative on such changes */
|
||||||
if (elm_widget_mirrored_get(obj)) delta *= -1;
|
if (elm_widget_mirrored_get(obj)) delta *= -1;
|
||||||
if (_value_set(data, sd->drag_start_val + delta)) _label_write(data);
|
if (_value_set(data, sd->val + delta)) _label_write(data);
|
||||||
sd->dragging = 1;
|
sd->dragging = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +240,8 @@ _drag_start_cb(void *data,
|
||||||
{
|
{
|
||||||
ELM_SPINNER_DATA_GET(data, sd);
|
ELM_SPINNER_DATA_GET(data, sd);
|
||||||
|
|
||||||
sd->drag_start_val = sd->val;
|
sd->drag_prev_pos = 0;
|
||||||
|
sd->drag_val_step = 1;
|
||||||
|
|
||||||
evas_object_smart_callback_call(obj, SIG_DRAG_START, NULL);
|
evas_object_smart_callback_call(obj, SIG_DRAG_START, NULL);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +255,8 @@ _drag_stop_cb(void *data,
|
||||||
ELM_SPINNER_DATA_GET(data, sd);
|
ELM_SPINNER_DATA_GET(data, sd);
|
||||||
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
|
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
|
||||||
|
|
||||||
sd->drag_start_val = 0;
|
sd->drag_prev_pos = 0;
|
||||||
|
sd->drag_val_step = 1;
|
||||||
edje_object_part_drag_value_set
|
edje_object_part_drag_value_set
|
||||||
(wd->resize_obj, "elm.dragable.slider", 0.0, 0.0);
|
(wd->resize_obj, "elm.dragable.slider", 0.0, 0.0);
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ struct _Elm_Spinner_Data
|
||||||
const char *label;
|
const char *label;
|
||||||
double val, val_min, val_max, val_base;
|
double val, val_min, val_max, val_base;
|
||||||
double step; /**< step for the value change. 1 by default. */
|
double step; /**< step for the value change. 1 by default. */
|
||||||
double drag_start_val; /**< spinner value on drag start.
|
double drag_prev_pos, drag_val_step;
|
||||||
this is reset to 0 when drag stops. */
|
|
||||||
double spin_speed, interval, first_interval;
|
double spin_speed, interval, first_interval;
|
||||||
int round;
|
int round;
|
||||||
Ecore_Timer *delay_change_timer; /**< a timer for a delay,changed smart callback */
|
Ecore_Timer *delay_change_timer; /**< a timer for a delay,changed smart callback */
|
||||||
|
|
Loading…
Reference in New Issue