1 #include <Elementary.h>
5 * @defgroup Slider Slider
7 * The slider adds a dragable “slider” widget for selecting the value of
8 * something within a range.
10 * Signals that you can add callbacks for are:
12 * changed - Whenever the slider value is changed by the user.
14 * delay,changed - A short time after the value is changed by the user.
15 * This will be called only when the user stops dragging for a very short
16 * period or when they release their finger/mouse, so it avoids possibly
17 * expensive reactions to the value change.
19 * slider,drag,start - dragging the slider indicator around has started
21 * slider,drag,stop - dragging the slider indicator around has stopped
23 * A slider can be horizontal or vertical. It can contain an Icon and has a
24 * primary label as well as a units label (that is formatted with floating
25 * point values and thus accepts a printf-style format string, like
26 * “%1.2f units”. There is also an indicator string that may be somewhere
27 * else (like on the slider itself) that also accepts a format string like
28 * units. Label, Icon Unit and Indicator strings/objects are optional.
30 * A slider may be inverted which means values invert, with high vales being
31 * on the left or top and low values on the right or bottom (as opposed to
32 * normally being low on the left or top and high on the bottom and right).
34 * The slider should have its minimum and maximum values set by the
35 * application with elm_slider_min_max_set() and value should also be set by
36 * the application before use with elm_slider_value_set(). The span of the
37 * slider is its length (horizontally or vertically). This will be scaled by
38 * the object or applications scaling factor. At any point code can query the
39 * slider for its value with elm_slider_value_get().
42 typedef struct _Widget_Data Widget_Data;
51 const char *indicator;
52 const char *(*indicator_format_func)(double val);
53 Eina_Bool horizontal : 1;
54 Eina_Bool inverted : 1;
55 double val, val_min, val_max;
58 /* for supporting aqua feature */
59 Ecore_Timer *mv_timer;
66 #define SLIDER_THUMB_MOVE_STEP 100
68 static void _del_hook(Evas_Object *obj);
69 static void _theme_hook(Evas_Object *obj);
70 static void _sizing_eval(Evas_Object *obj);
71 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
72 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
73 static void _units_set(Evas_Object *obj);
74 static void _indicator_set(Evas_Object *obj);
76 /* supporting aqua feature */
77 static _mv_timer_cb(void *data);
79 static const char SIG_CHANGED[] = "changed";
80 static const char SIG_DELAY_CHANGED[] = "delay,changed";
81 static const char SIG_DRAG_START[] = "slider,drag,start";
82 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
83 static const Evas_Smart_Cb_Description _signals[] = {
85 {SIG_DELAY_CHANGED, ""},
92 _del_hook(Evas_Object *obj)
94 Widget_Data *wd = elm_widget_data_get(obj);
96 if (wd->label) eina_stringshare_del(wd->label);
97 if (wd->indicator) eina_stringshare_del(wd->units);
98 if (wd->delay) ecore_timer_del(wd->delay);
103 _theme_hook(Evas_Object *obj)
105 Widget_Data *wd = elm_widget_data_get(obj);
108 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
110 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
112 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
114 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
116 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
118 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
120 edje_object_signal_emit(wd->slider, "elm,state,ricon,visible", "elm");
122 edje_object_signal_emit(wd->slider, "elm,state,ricon,hidden", "elm");
124 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
126 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
127 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
129 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
131 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
133 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
135 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
136 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
138 edje_object_message_signal_process(wd->slider);
139 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
144 _sizing_eval(Evas_Object *obj)
146 Widget_Data *wd = elm_widget_data_get(obj);
147 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
149 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
150 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
151 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
152 evas_object_size_hint_min_set(obj, minw, minh);
153 evas_object_size_hint_max_set(obj, maxw, maxh);
157 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
159 Widget_Data *wd = elm_widget_data_get(data);
162 // if (obj != wd->icon) return;
163 /*supporting aqua feature*/
164 if (obj != wd->icon && obj != wd->r_icon) return;
170 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
172 Widget_Data *wd = elm_widget_data_get(obj);
173 Evas_Object *sub = event_info;
177 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
178 evas_object_event_callback_del_full
179 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
183 /*supporting aqua feature*/
184 if (sub == wd->r_icon)
186 edje_object_signal_emit(wd->slider, "elm,state,ricon,hidden", "elm");
187 evas_object_event_callback_del_full
188 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
195 _delay_change(void *data)
197 Widget_Data *wd = elm_widget_data_get(data);
200 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
205 _val_fetch(Evas_Object *obj)
207 Widget_Data *wd = elm_widget_data_get(obj);
208 double posx = 0.0, posy = 0.0, pos = 0.0, val;
210 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
212 if (wd->horizontal) pos = posx;
214 if (wd->inverted) pos = 1.0 - pos;
215 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
219 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
220 if (wd->delay) ecore_timer_del(wd->delay);
221 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
226 _val_set(Evas_Object *obj)
228 Widget_Data *wd = elm_widget_data_get(obj);
231 if (wd->val_max > wd->val_min)
232 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
235 if (pos < 0.0) pos = 0.0;
236 else if (pos > 1.0) pos = 1.0;
237 if (wd->inverted) pos = 1.0 - pos;
238 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
242 _units_set(Evas_Object *obj)
244 Widget_Data *wd = elm_widget_data_get(obj);
250 snprintf(buf, sizeof(buf), wd->units, wd->val);
251 edje_object_part_text_set(wd->slider, "elm.units", buf);
254 edje_object_part_text_set(wd->slider, "elm.units", NULL);
258 _indicator_set(Evas_Object *obj)
260 Widget_Data *wd = elm_widget_data_get(obj);
262 if (wd->indicator_format_func)
265 buf = wd->indicator_format_func(wd->val);
266 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
268 else if (wd->indicator)
271 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
272 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
275 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
279 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
281 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
282 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
284 ecore_timer_del(wd->mv_timer);
289 _indicator_set(data);
293 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
295 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
296 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
298 ecore_timer_del(wd->mv_timer);
302 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
304 _indicator_set(data);
308 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
311 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
313 _indicator_set(data);
317 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
319 Widget_Data *wd = elm_widget_data_get(data);
320 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
324 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
326 Widget_Data *wd = elm_widget_data_get(data);
327 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
331 * Add a new slider to the parent
333 * @param parent The parent object
334 * @return The new object or NULL if it cannot be created
339 elm_slider_add(Evas_Object *parent)
345 wd = ELM_NEW(Widget_Data);
346 e = evas_object_evas_get(parent);
347 obj = elm_widget_add(e);
348 ELM_SET_WIDTYPE(widtype, "slider");
349 elm_widget_type_set(obj, "slider");
350 elm_widget_sub_object_add(parent, obj);
351 elm_widget_data_set(obj, wd);
352 elm_widget_del_hook_set(obj, _del_hook);
353 elm_widget_theme_hook_set(obj, _theme_hook);
355 wd->horizontal = EINA_TRUE;
360 /* supporting aqua feature */
361 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
363 wd->slider = edje_object_add(e);
364 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
365 elm_widget_resize_object_set(obj, wd->slider);
366 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
367 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
368 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
369 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
370 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
371 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
372 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
373 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
374 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
376 wd->spacer = evas_object_rectangle_add(e);
377 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
378 evas_object_pass_events_set(wd->spacer, 1);
379 elm_widget_sub_object_add(obj, wd->spacer);
380 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
382 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
386 // TODO: convert Elementary to subclassing of Evas_Smart_Class
387 // TODO: and save some bytes, making descriptions per-class and not instance!
388 evas_object_smart_callbacks_descriptions_set(obj, _signals);
393 * Set the label of the slider
395 * @param obj The slider object
396 * @param label The text label string in UTF-8
401 elm_slider_label_set(Evas_Object *obj, const char *label)
403 ELM_CHECK_WIDTYPE(obj, widtype);
404 Widget_Data *wd = elm_widget_data_get(obj);
406 eina_stringshare_replace(&wd->label, label);
409 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
410 edje_object_message_signal_process(wd->slider);
414 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
415 edje_object_message_signal_process(wd->slider);
417 edje_object_part_text_set(wd->slider, "elm.text", label);
422 * Get the label of the slider
424 * @param obj The slider object
425 * @return The text label string in UTF-8
430 elm_slider_label_get(const Evas_Object *obj)
432 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
433 Widget_Data *wd = elm_widget_data_get(obj);
434 if (!wd) return NULL;
439 * Set the icon object of the slider object
441 * Once the icon object is set, it will become a child of the slider object and
442 * be deleted when the slider object is deleted. If another icon object is set
443 * then the previous one becomes orophaned and will no longer be deleted along
446 * @param obj The slider object
447 * @param icon The icon object
452 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
454 ELM_CHECK_WIDTYPE(obj, widtype);
455 Widget_Data *wd = elm_widget_data_get(obj);
457 if ((wd->icon != icon) && (wd->icon))
458 elm_widget_sub_object_del(obj, wd->icon);
462 elm_widget_sub_object_add(obj, icon);
463 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
464 _changed_size_hints, obj);
465 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
466 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
472 * Get the icon object of the slider object
474 * @param obj The slider object
475 * @return The icon object
480 elm_slider_icon_get(const Evas_Object *obj)
482 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
483 Widget_Data *wd = elm_widget_data_get(obj);
484 if (!wd) return NULL;
489 * Set the length of the dragable region of the slider
491 * This sets the minimum width or height (depending on orientation) of the
492 * area of the slider that allows the slider to be dragged around. This in
493 * turn affects the objects minimum size (along with icon label and unit
494 * text). Note that this will also get multiplied by the scale factor.
496 * @param obj The slider object
497 * @param size The length of the slider area
502 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
504 ELM_CHECK_WIDTYPE(obj, widtype);
505 Widget_Data *wd = elm_widget_data_get(obj);
507 if (wd->size == size) return;
510 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
512 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
513 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
518 * Get the length of the dragable region of the slider
520 * This gets the minimum width or height (depending on orientation) of
521 * the area of the slider that allows the slider to be dragged
522 * around. Note that this will also get multiplied by the scale
525 * @param obj The slider object
526 * @return The length of the slider area
531 elm_slider_span_size_get(const Evas_Object *obj)
533 ELM_CHECK_WIDTYPE(obj, widtype) 0;
534 Widget_Data *wd = elm_widget_data_get(obj);
540 * Set the format string of the unit area
542 * If NULL, this disabls the unit area display. If not it sets the format
543 * string for the unit text. The unit text is provided a floating point
544 * value, so the unit text can display up to 1 floating point value. Note that
545 * this is optional. Use a format string such as "%1.2f meters" for example.
547 * @param obj The slider object
548 * @param units The format string for the units display
553 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
555 ELM_CHECK_WIDTYPE(obj, widtype);
556 Widget_Data *wd = elm_widget_data_get(obj);
558 eina_stringshare_replace(&wd->units, units);
561 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
562 edje_object_message_signal_process(wd->slider);
566 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
567 edje_object_message_signal_process(wd->slider);
574 * Get the format string for the unit area
576 * The slider may also display a value (the value of the slider) somewhere
577 * (for example above the slider knob that is dragged around). This sets the
578 * format string for this. See elm_slider_unit_format_set() for more
579 * information on how this works.
581 * @param obj The slider object
582 * @return The format string for the unit display.
587 elm_slider_unit_format_get(const Evas_Object *obj)
589 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
590 Widget_Data *wd = elm_widget_data_get(obj);
591 if (!wd) return NULL;
596 * Set the format string for the indicator area
598 * The slider may also display a value (the value of the slider) somewhere
599 * (for example above the slider knob that is dragged around). This sets the
600 * format string for this. See elm_slider_unit_format_set() for more
601 * information on how this works.
603 * @param obj The slider object
604 * @param indicator The format string for the indicator display
609 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
611 ELM_CHECK_WIDTYPE(obj, widtype);
612 Widget_Data *wd = elm_widget_data_get(obj);
614 eina_stringshare_replace(&wd->indicator, indicator);
619 * Get the format string for the indicator area
621 * The slider may also display a value (the value of the slider) somewhere
622 * (for example above the slider knob that is dragged around). This sets the
623 * format string for this. See elm_slider_indicator_format_set() for more
624 * information on how this works.
626 * @param obj The slider object
627 * @return The format string for the indicator display.
632 elm_slider_indicator_format_get(const Evas_Object *obj)
634 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
635 Widget_Data *wd = elm_widget_data_get(obj);
636 if (!wd) return NULL;
637 return wd->indicator;
641 * Set orientation of the slider
643 * @param obj The slider object
644 * @param horizontal If set, the slider will be horizontal
649 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
651 ELM_CHECK_WIDTYPE(obj, widtype);
652 Widget_Data *wd = elm_widget_data_get(obj);
654 horizontal = !!horizontal;
655 if (wd->horizontal == horizontal) return;
656 wd->horizontal = horizontal;
661 * Get orientation of the slider
663 * @param obj The slider object
664 * @return If @c EINA_TRUE the slider will be horizontal, else it is
669 elm_slider_horizontal_get(const Evas_Object *obj)
671 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
672 Widget_Data *wd = elm_widget_data_get(obj);
673 if (!wd) return EINA_FALSE;
674 return wd->horizontal;
678 * Set the minimum and maximum values for the slider
680 * Maximum mut be greater than minimum.
682 * @param obj The slider object
683 * @param min The minimum value
684 * @param max The maximum value
689 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
691 ELM_CHECK_WIDTYPE(obj, widtype);
692 Widget_Data *wd = elm_widget_data_get(obj);
694 if ((wd->val_min == min) && (wd->val_max == max)) return;
698 /* supporting aqua feature */
699 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
701 if (wd->val < wd->val_min) wd->val = wd->val_min;
702 if (wd->val > wd->val_max) wd->val = wd->val_max;
709 * Get the minimum and maximum values for the slider
711 * @param obj The slider object
712 * @param min The pointer to store minimum value, may be @c NULL.
713 * @param max The pointer to store maximum value, may be @c NULL.
718 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
722 ELM_CHECK_WIDTYPE(obj, widtype);
723 Widget_Data *wd = elm_widget_data_get(obj);
725 if (min) *min = wd->val_min;
726 if (max) *max = wd->val_max;
730 * Set the value the slider indicates
732 * @param obj The slider object
733 * @param val The value (must be beween min and max for the slider)
738 elm_slider_value_set(Evas_Object *obj, double val)
740 ELM_CHECK_WIDTYPE(obj, widtype);
741 Widget_Data *wd = elm_widget_data_get(obj);
743 if (wd->val == val) return;
745 if (wd->val < wd->val_min) wd->val = wd->val_min;
746 if (wd->val > wd->val_max) wd->val = wd->val_max;
753 * Get the value the slider has
755 * @param obj The slider object
756 * @return The value of the slider
761 elm_slider_value_get(const Evas_Object *obj)
763 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
764 Widget_Data *wd = elm_widget_data_get(obj);
770 * Invert the slider display
772 * Normally the slider will display and interpret values from low to high
773 * and when horizontal that is left to right. When vertical that is top
774 * to bottom. This inverts this (so from right to left or bottom to top) if
775 * inverted is set to 1.
777 * @param obj The slider object
778 * @param inverted The inverted flag. 1 == inverted, 0 == normal
783 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
785 ELM_CHECK_WIDTYPE(obj, widtype);
786 Widget_Data *wd = elm_widget_data_get(obj);
788 inverted = !!inverted;
789 if (wd->inverted == inverted) return;
790 wd->inverted = inverted;
792 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
794 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
795 edje_object_message_signal_process(wd->slider);
802 * Get if the slider display is inverted (backwards)
804 * @param obj The slider object
805 * @return If @c EINA_TRUE the slider will be inverted.
809 elm_slider_inverted_get(const Evas_Object *obj)
811 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
812 Widget_Data *wd = elm_widget_data_get(obj);
813 if (!wd) return EINA_FALSE;
818 * Set the format function pointer for the inducator area
820 * Set the callback function to format the indicator string.
821 * See elm_slider_indicator_format_set() for more info on how this works.
823 * @param obj The slider object
824 * @param indicator The format string for the indicator display
825 * @param func The indicator format function
830 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
832 ELM_CHECK_WIDTYPE(obj, widtype);
833 Widget_Data *wd = elm_widget_data_get(obj);
835 wd->indicator_format_func = func;
840 //////////////////////////////////////////////////////////////////////////////////////////////////////
841 //////////////////////// supporting aqua feature ///////////////////////////////////////////////////
842 //////////////////////////////////////////////////////////////////////////////////////////////////////
847 * Set the right icon object of the slider object
849 * Once the right icon object is set, it will become a child of the slider object and
850 * be deleted when the slider object is deleted. If another icon object is set
851 * then the previous one becomes orophaned and will no longer be deleted along
854 * @param obj The slider object
855 * @param icon The icon object
857 * @return 1 if icon set succeed, 0 if there is no part for right icon
862 elm_slider_right_icon_set(Evas_Object *obj, Evas_Object *icon)
864 Widget_Data *wd = elm_widget_data_get(obj);
866 if ((wd->r_icon != icon) && (wd->r_icon))
867 elm_widget_sub_object_del(obj, wd->r_icon);
871 if ( !(edje_object_part_swallow(wd->slider, "right_icon", icon)) )
874 elm_widget_sub_object_add(obj, icon);
875 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
876 _changed_size_hints, obj);
877 edje_object_signal_emit(wd->slider, "elm,state,ricon,visible", "elm");
886 * Get the right icon object of the slider object
888 * @param obj The slider object
889 * @return The right icon object
894 elm_slider_right_icon_get(Evas_Object *obj)
896 Widget_Data *wd = elm_widget_data_get(obj);
897 if (!wd) return NULL;
903 * Set whether showing the number(indicator) or not.
905 * @param obj The slider object
906 * @param show 1 will show the number, 0 will not.
911 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
913 Widget_Data *wd = elm_widget_data_get(obj);
915 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
917 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
922 static _mv_timer_cb(void *data)
924 Evas_Object* obj = (Evas_Object*)data;
925 Widget_Data *wd = elm_widget_data_get(obj);
927 if (!wd) return EINA_TRUE;
929 if(wd->src_val < wd->des_val) {
930 wd->src_val += wd->mv_step;
931 if(wd-> src_val > wd->des_val)
932 wd->src_val = wd->des_val;
935 else if (wd->src_val > wd->des_val) {
936 wd->src_val -= wd->mv_step;
937 if(wd->src_val < wd->des_val)
938 wd->src_val = wd->des_val;
941 elm_slider_value_set(obj, wd->src_val);
942 evas_object_smart_callback_call(obj, "changed", NULL);
944 if (wd->val == wd->des_val ) {
946 ecore_timer_del(wd->mv_timer);
957 * Move the thumb to the specified value.
959 * This is different with elm_slider_value_set() in animated moving.
961 * @param obj The slider object
962 * @param val thumb's destination value.
967 elm_slider_value_animated_set(Evas_Object *obj, double val)
969 Widget_Data *wd = elm_widget_data_get(obj);
971 if (wd->val == val) return;
973 wd->src_val = wd->val;
975 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
976 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
979 ecore_timer_del(wd->mv_timer);
983 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);