summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-10-30 18:56:29 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-10-30 18:56:29 +0900
commitc7c245da67038ae70d66b8091346a0b8503659ce (patch)
treea2df4df2cc4ffa479cf4e10e6ce908fb2ef253c2
parentcbd7446f0bf413ad821ac40703d2a2ca728758ef (diff)
elm_slider: Step set/get API additions.
Issue: As step size was hard coded in the widget, when slider indicator is dragged using a key event or during accessibility the value was not exactly incremented/decremented instead same value was shown more than1 time/values were skipped. Solution: Two APIs added which will set/get step size. Reviewer: SeoZ Reviewer Comment: This is a manual merge of D293 due to arc issue on Shilpa. I modified some codes from her original code. She'll use arc next time. fixed documentation fixed typos. fixed indentation used macro added some guide codes. removed unnecessary empty line. updated NEWS and ChangeLog.
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/bin/test_slider.c25
-rwxr-xr-xsrc/lib/elm_slider.c47
-rw-r--r--src/lib/elm_slider_eo.h37
-rw-r--r--src/lib/elm_slider_legacy.h29
-rw-r--r--src/lib/elm_widget_slider.h2
7 files changed, 142 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e99d3fd09..0060f0ae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1731,3 +1731,7 @@
17312013-10-30 Daniel Juyung Seo (SeoZ) 17312013-10-30 Daniel Juyung Seo (SeoZ)
1732 1732
1733 * conform: Added "virtualkeypad,size,changed" callback on virtualkeypad min size change. 1733 * conform: Added "virtualkeypad,size,changed" callback on virtualkeypad min size change.
1734
17352013-10-30 Shilpa Onkar Singh
1736
1737 * slider: Added elm_slider_step_get(), elm_slider_step_set().
diff --git a/NEWS b/NEWS
index 6876073e5..3d59bc787 100644
--- a/NEWS
+++ b/NEWS
@@ -102,6 +102,7 @@ Additions:
102 * Add signals "spinner,drag,start" and "spinner,drag,stop" to the spinner widget. 102 * Add signals "spinner,drag,start" and "spinner,drag,stop" to the spinner widget.
103 * Add support for "clicked" callback on Return/space/KP_Enter key press for image. 103 * Add support for "clicked" callback on Return/space/KP_Enter key press for image.
104 * Add "virtualkeypad,size,changed" callback on virtualkeypad min size change for conformant. 104 * Add "virtualkeypad,size,changed" callback on virtualkeypad min size change for conformant.
105 * Add elm_slider_step_get(), elm_slider_step_set() for slider.
105 106
106Improvements: 107Improvements:
107 108
diff --git a/src/bin/test_slider.c b/src/bin/test_slider.c
index 8d85ce713..a4b13986d 100644
--- a/src/bin/test_slider.c
+++ b/src/bin/test_slider.c
@@ -48,10 +48,22 @@ _bt_m1(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
48 elm_slider_value_set(data, elm_slider_value_get(data) - 0.1); 48 elm_slider_value_set(data, elm_slider_value_get(data) - 0.1);
49} 49}
50 50
51static double
52_step_size_calculate(double min, double max)
53{
54 double step = 0.0;
55 int steps = 0;
56
57 steps = max - min;
58 if (steps) step = (1.0 / steps);
59 return step;
60}
61
51void 62void
52test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 63test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{ 64{
54 Evas_Object *win, *fr, *bx, *sl, *ic, *sl1, *bx2, *bt; 65 Evas_Object *win, *fr, *bx, *sl, *ic, *sl1, *bx2, *bt;
66 double step;
55 char buf[PATH_MAX]; 67 char buf[PATH_MAX];
56 68
57 win = elm_win_util_standard_add("slider", "Slider"); 69 win = elm_win_util_standard_add("slider", "Slider");
@@ -88,6 +100,19 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
88 elm_box_pack_end(bx, sl); 100 elm_box_pack_end(bx, sl);
89 evas_object_show(sl); 101 evas_object_show(sl);
90 102
103 sl = elm_slider_add(bx);
104 elm_slider_unit_format_set(sl, "%1.0f units");
105 elm_slider_indicator_format_set(sl, "%1.0f");
106 elm_slider_span_size_set(sl, 120);
107 elm_slider_min_max_set(sl, 0, 9);
108 elm_object_text_set(sl, "Manual step");
109 step = _step_size_calculate(0, 9);
110 elm_slider_step_set(sl, step);
111 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
112 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
113 elm_box_pack_end(bx, sl);
114 evas_object_show(sl);
115
91 // normal horizontal slider 116 // normal horizontal slider
92 ic = elm_icon_add(bx); 117 ic = elm_icon_add(bx);
93 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 118 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c
index 22a81af0d..0e3fb531a 100755
--- a/src/lib/elm_slider.c
+++ b/src/lib/elm_slider.c
@@ -14,6 +14,7 @@ EAPI Eo_Op ELM_OBJ_SLIDER_BASE_ID = EO_NOOP;
14 14
15#define MY_CLASS_NAME "elm_slider" 15#define MY_CLASS_NAME "elm_slider"
16#define SLIDER_DELAY_CHANGED_INTERVAL 0.2 16#define SLIDER_DELAY_CHANGED_INTERVAL 0.2
17#define SLIDER_STEP 0.05
17 18
18static const Elm_Layout_Part_Alias_Description _content_aliases[] = 19static const Elm_Layout_Part_Alias_Description _content_aliases[] =
19{ 20{
@@ -260,7 +261,7 @@ _drag_up(void *data,
260 double step; 261 double step;
261 262
262 ELM_SLIDER_DATA_GET(data, sd); 263 ELM_SLIDER_DATA_GET(data, sd);
263 step = 0.05; 264 step = sd->step;
264 265
265 if (sd->inverted) step *= -1.0; 266 if (sd->inverted) step *= -1.0;
266 267
@@ -278,7 +279,7 @@ _drag_down(void *data,
278 double step; 279 double step;
279 280
280 ELM_SLIDER_DATA_GET(data, sd); 281 ELM_SLIDER_DATA_GET(data, sd);
281 step = -0.05; 282 step = -sd->step;
282 283
283 if (sd->inverted) step *= -1.0; 284 if (sd->inverted) step *= -1.0;
284 285
@@ -821,6 +822,7 @@ _elm_slider_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
821 priv->horizontal = EINA_TRUE; 822 priv->horizontal = EINA_TRUE;
822 priv->indicator_show = EINA_TRUE; 823 priv->indicator_show = EINA_TRUE;
823 priv->val_max = 1.0; 824 priv->val_max = 1.0;
825 priv->step = SLIDER_STEP;
824 826
825 if (!elm_layout_theme_set 827 if (!elm_layout_theme_set
826 (obj, "slider", "horizontal", elm_widget_style_get(obj))) 828 (obj, "slider", "horizontal", elm_widget_style_get(obj)))
@@ -1343,6 +1345,43 @@ _elm_slider_indicator_show_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
1343 *ret = sd->indicator_show; 1345 *ret = sd->indicator_show;
1344} 1346}
1345 1347
1348EAPI void
1349elm_slider_step_set(Evas_Object *obj, double step)
1350{
1351 ELM_SLIDER_CHECK(obj);
1352 eo_do(obj, elm_obj_slider_step_set(step));
1353}
1354
1355static void
1356_elm_slider_step_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
1357{
1358 double step = va_arg(*list, double);
1359 Elm_Slider_Smart_Data *sd = _pd;
1360 if (sd->step == step) return;
1361
1362 if (step < 0.0) step = 0.0;
1363 else if (step > 1.0) step = 1.0;
1364
1365 sd->step = step;
1366}
1367
1368EAPI double
1369elm_slider_step_get(const Evas_Object *obj)
1370{
1371 ELM_SLIDER_CHECK(obj) 0.0;
1372 double ret;
1373 eo_do((Eo *) obj, elm_obj_slider_step_get(&ret));
1374 return ret;
1375}
1376
1377static void
1378_elm_slider_step_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
1379{
1380 double *ret = va_arg(*list, double *);
1381 Elm_Slider_Smart_Data *sd = _pd;
1382 *ret = sd->step;
1383}
1384
1346static void 1385static void
1347_elm_slider_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) 1386_elm_slider_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
1348{ 1387{
@@ -1395,6 +1434,8 @@ _class_constructor(Eo_Class *klass)
1395 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET), _elm_slider_units_format_function_set), 1434 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET), _elm_slider_units_format_function_set),
1396 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET), _elm_slider_indicator_show_set), 1435 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET), _elm_slider_indicator_show_set),
1397 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), _elm_slider_indicator_show_get), 1436 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), _elm_slider_indicator_show_get),
1437 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_SET), _elm_slider_step_set),
1438 EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), _elm_slider_step_get),
1398 EO_OP_FUNC_SENTINEL 1439 EO_OP_FUNC_SENTINEL
1399 }; 1440 };
1400 eo_class_funcs_set(klass, func_desc); 1441 eo_class_funcs_set(klass, func_desc);
@@ -1421,6 +1462,8 @@ static const Eo_Op_Description op_desc[] = {
1421 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET, "Set the format function pointer for the units label."), 1462 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET, "Set the format function pointer for the units label."),
1422 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET, "Set whether to enlarge slider indicator (augmented knob) or not."), 1463 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET, "Set whether to enlarge slider indicator (augmented knob) or not."),
1423 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET, "Get whether a given slider widget's enlarging indicator or not."), 1464 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET, "Get whether a given slider widget's enlarging indicator or not."),
1465 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_SET, "Set the draggable's step size."),
1466 EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_GET, "Get the draggable's step size."),
1424 EO_OP_DESCRIPTION_SENTINEL 1467 EO_OP_DESCRIPTION_SENTINEL
1425}; 1468};
1426static const Eo_Class_Description class_desc = { 1469static const Eo_Class_Description class_desc = {
diff --git a/src/lib/elm_slider_eo.h b/src/lib/elm_slider_eo.h
index 35872d65a..f3373d7c5 100644
--- a/src/lib/elm_slider_eo.h
+++ b/src/lib/elm_slider_eo.h
@@ -27,6 +27,8 @@ enum
27 ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET, 27 ELM_OBJ_SLIDER_SUB_ID_UNITS_FORMAT_FUNCTION_SET,
28 ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET, 28 ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_SET,
29 ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET, 29 ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET,
30 ELM_OBJ_SLIDER_SUB_ID_STEP_SET,
31 ELM_OBJ_SLIDER_SUB_ID_STEP_GET,
30 ELM_OBJ_SLIDER_SUB_ID_LAST 32 ELM_OBJ_SLIDER_SUB_ID_LAST
31}; 33};
32 34
@@ -289,3 +291,38 @@ enum
289 * @ingroup Slider 291 * @ingroup Slider
290 */ 292 */
291#define elm_obj_slider_indicator_show_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), EO_TYPECHECK(Eina_Bool *, ret) 293#define elm_obj_slider_indicator_show_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), EO_TYPECHECK(Eina_Bool *, ret)
294
295/**
296 * @def elm_obj_slider_step_set
297 * @since 1.8
298 *
299 * Set the step by which slider indicator will move.
300 *
301 * This value is used when draggable object is moved automatically i.e., in case
302 * of key event when up/down/left/right key is pressed or in case when
303 * accessibility is set and flick event is used to inc/dec slider values.
304 * By default step value is equal to 0.05.
305 *
306 * @param[in] step
307 *
308 * @see elm_slider_step_set
309 *
310 * @ingroup Slider
311 */
312
313#define elm_obj_slider_step_set(step) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_SET), EO_TYPECHECK(double, step)
314
315
316/**
317 * @def elm_obj_slider_step_get
318 * @since 1.8
319 *
320 * Get the step by which slider indicator moves.
321 *
322 * @param[out] ret
323 *
324 * @see elm_slider_step_get
325 *
326 * @ingroup Slider
327 */
328#define elm_obj_slider_step_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), EO_TYPECHECK(double *, ret)
diff --git a/src/lib/elm_slider_legacy.h b/src/lib/elm_slider_legacy.h
index a547b5550..81e55a81f 100644
--- a/src/lib/elm_slider_legacy.h
+++ b/src/lib/elm_slider_legacy.h
@@ -328,3 +328,32 @@ EAPI void elm_slider_indicator_show_set(Evas_Object *obj
328 * @ingroup Slider 328 * @ingroup Slider
329 */ 329 */
330EAPI Eina_Bool elm_slider_indicator_show_get(const Evas_Object *obj); 330EAPI Eina_Bool elm_slider_indicator_show_get(const Evas_Object *obj);
331
332/**
333 * Set the step by which slider indicator will move.
334 *
335 * @param obj The slider object.
336 * @param step The step value.
337 *
338 * This value is used when draggable object is moved automatically i.e., in case
339 * of key event when up/down/left/right key is pressed or in case when
340 * accessibility is set and flick event is used to inc/dec slider values.
341 * By default step value is equal to 0.05.
342 *
343 * @see elm_slider_step_get() for more details.
344 *
345 * @ingroup Slider
346 */
347EAPI void elm_slider_step_set(Evas_Object *obj, double step);
348
349/**
350 * Get the step by which slider indicator moves.
351 *
352 * @param obj The slider object.
353 * @return The step value.
354 *
355 * @see elm_slider_step_set() for more details.
356 *
357 * @ingroup Slider
358 */
359EAPI double elm_slider_step_get(const Evas_Object *obj);
diff --git a/src/lib/elm_widget_slider.h b/src/lib/elm_widget_slider.h
index c8ff66cad..27c3bfc48 100644
--- a/src/lib/elm_widget_slider.h
+++ b/src/lib/elm_widget_slider.h
@@ -32,7 +32,7 @@ struct _Elm_Slider_Smart_Data
32 char *(*units_format_func)(double val); 32 char *(*units_format_func)(double val);
33 void (*units_format_free)(char *str); 33 void (*units_format_free)(char *str);
34 34
35 double val, val_min, val_max, val2; 35 double val, val_min, val_max, val2, step;
36 Evas_Coord size; 36 Evas_Coord size;
37 Evas_Coord downx, downy; 37 Evas_Coord downx, downy;
38 38