summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBowon Ryu <bowon.ryu@samsung.com>2019-11-18 21:25:26 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-11-18 21:25:26 +0900
commitc30176e7ffac0ab70b8ef92cb0fce62b75499181 (patch)
tree41ba8ca7090ddda5baed1b881e13e00d947da5f9
parent070cde61b5a55bae055a084aa4dffbca02dfdcba (diff)
slider: fix value error from step
Summary: When the slider moves using step, _drag_value_fetch(), _val_fetch() calculates a value from position of edje_part. Then the calculated value is updated. However, this causes a slight error. This patch updates value ​​first when moving with steps. * Test Example ``` Evas_Object *sl = elm_slider_add(bx); elm_slider_min_max_set(sl, -5, 5); elm_slider_value_set(sl, 0.0); elm_slider_step_set(sl, 0.1); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_smart_callback_add(sl, "changed", _change_cb, NULL); ``` ``` void _change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) { double val = elm_slider_value_get(obj); if (val == -5.0) printf("val[%f] == -5.0 \n", val); if (val == -4.0) printf("val[%f] == -4.0 \n", val); if (val == -3.0) printf("val[%f] == -3.0 \n", val); if (val == -2.0) printf("val[%f] == -2.0 \n", val); if (val == -1.0) printf("val[%f] == -1.0 \n", val); if (val == 0.0) printf("val[%f] == 0.0 \n", val); if (val == 1.0) printf("val[%f] == 1.0 \n", val); if (val == 2.0) printf("val[%f] == 2.0 \n", val); if (val == 3.0) printf("val[%f] == 3.0 \n", val); if (val == 4.0) printf("val[%f] == 4.0 \n", val); if (val == 5.0) printf("val[%f] == 5.0 \n", val); } ``` If you move the slider using step in this test, You can see that some logs are not visible. (Some values ​​are incorrect) Test Plan: elementary_test -to slider elementary_test -to efl.ui.slider Reviewers: woohyun, cedric, bu5hm4n Reviewed By: woohyun, bu5hm4n Subscribers: bu5hm4n, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10662
-rw-r--r--src/lib/elementary/efl_ui_slider.c21
-rw-r--r--src/lib/elementary/elm_priv.h3
-rw-r--r--src/lib/elementary/elm_slider.c39
3 files changed, 60 insertions, 3 deletions
diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c
index 2aca5f96f5..219a15bc94 100644
--- a/src/lib/elementary/efl_ui_slider.c
+++ b/src/lib/elementary/efl_ui_slider.c
@@ -78,6 +78,21 @@ _user_value_update(Evas_Object *obj, double value)
78} 78}
79 79
80static void 80static void
81_step_value_update(Evas_Object *obj, double step)
82{
83 double value;
84
85 EFL_UI_SLIDER_DATA_GET(obj, sd);
86
87 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
88 step *= -1.0;
89
90 value = CLAMP(sd->val + step, sd->val_min, sd->val_max);
91 _user_value_update(obj, value);
92
93}
94
95static void
81_drag_value_fetch(Evas_Object *obj) 96_drag_value_fetch(Evas_Object *obj)
82{ 97{
83 EFL_UI_SLIDER_DATA_GET(obj, sd); 98 EFL_UI_SLIDER_DATA_GET(obj, sd);
@@ -194,7 +209,8 @@ _drag_up(Evas_Object *obj)
194 209
195 efl_ui_drag_step_move(efl_part(wd->resize_obj, "efl.draggable.slider"), 210 efl_ui_drag_step_move(efl_part(wd->resize_obj, "efl.draggable.slider"),
196 relative_step, relative_step); 211 relative_step, relative_step);
197 _drag_value_fetch(obj); 212
213 _step_value_update(obj, step);
198} 214}
199 215
200static void 216static void
@@ -214,7 +230,8 @@ _drag_down(Evas_Object *obj)
214 230
215 efl_ui_drag_step_move(efl_part(wd->resize_obj, "efl.draggable.slider"), 231 efl_ui_drag_step_move(efl_part(wd->resize_obj, "efl.draggable.slider"),
216 relative_step, relative_step); 232 relative_step, relative_step);
217 _drag_value_fetch(obj); 233
234 _step_value_update(obj, step);
218} 235}
219 236
220static Eina_Bool 237static Eina_Bool
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 0d71bd0b08..0be9080eab 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -329,6 +329,9 @@ extern const char *_elm_engines[];
329# define ELM_PRIV_SMART_CALLBACKS_DESC(name, signal, type) \ 329# define ELM_PRIV_SMART_CALLBACKS_DESC(name, signal, type) \
330 {name, type}, 330 {name, type},
331 331
332# define CLAMP(x, min, max) \
333 (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
334
332struct _Elm_Config_Flags 335struct _Elm_Config_Flags
333{ 336{
334 Eina_Bool engine : 1; 337 Eina_Bool engine : 1;
diff --git a/src/lib/elementary/elm_slider.c b/src/lib/elementary/elm_slider.c
index 85426386e2..c426a45aeb 100644
--- a/src/lib/elementary/elm_slider.c
+++ b/src/lib/elementary/elm_slider.c
@@ -144,7 +144,6 @@ _indicator_set(Evas_Object *obj)
144 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", str); 144 elm_layout_text_set(obj, "elm.dragable.slider:elm.indicator", str);
145 if (sd->popup) 145 if (sd->popup)
146 edje_object_part_text_set(sd->popup, "elm.indicator", str); 146 edje_object_part_text_set(sd->popup, "elm.indicator", str);
147
148 if (sd->popup2) 147 if (sd->popup2)
149 { 148 {
150 eina_strbuf_reset(sd->indi_format_strbuf); 149 eina_strbuf_reset(sd->indi_format_strbuf);
@@ -336,6 +335,40 @@ _val_set(Evas_Object *obj)
336} 335}
337 336
338static void 337static void
338_user_value_update(Evas_Object *obj, double value)
339{
340 double val = value;
341
342 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
343
344 if (fabs(val - sd->val) > DBL_EPSILON)
345 {
346 sd->val = val;
347 sd->intvl_from = val;
348 _val_set(obj);
349
350 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
351 ecore_timer_del(sd->delay);
352 sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj);
353 }
354}
355
356static void
357_step_value_update(Evas_Object *obj, double step)
358{
359 double value, absolute_step;
360
361 ELM_SLIDER_DATA_GET(obj, sd);
362
363 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
364 step *= -1.0;
365
366 absolute_step = step * (sd->val_max - sd->val_min);
367 value = CLAMP(sd->val + absolute_step, sd->val_min, sd->val_max);
368 _user_value_update(obj, value);
369}
370
371static void
339_val_fetch(Evas_Object *obj, Eina_Bool user_event) 372_val_fetch(Evas_Object *obj, Eina_Bool user_event)
340{ 373{
341 double posx = 0.0, posy = 0.0, pos = 0.0, val; 374 double posx = 0.0, posy = 0.0, pos = 0.0, val;
@@ -489,6 +522,8 @@ _drag_up(void *data,
489 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); 522 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
490 efl_ui_drag_step_move(efl_part(wd->resize_obj, "elm.dragable.slider"), 523 efl_ui_drag_step_move(efl_part(wd->resize_obj, "elm.dragable.slider"),
491 step, step); 524 step, step);
525
526 _step_value_update(data, step);
492} 527}
493 528
494static void 529static void
@@ -507,6 +542,8 @@ _drag_down(void *data,
507 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); 542 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
508 efl_ui_drag_step_move(efl_part(wd->resize_obj, "elm.dragable.slider"), 543 efl_ui_drag_step_move(efl_part(wd->resize_obj, "elm.dragable.slider"),
509 step, step); 544 step, step);
545
546 _step_value_update(data, step);
510} 547}
511 548
512static Eina_Bool 549static Eina_Bool