1 #include <Elementary.h>
5 * @defgroup Slider Slider
8 * The slider adds a dragable “slider” widget for selecting the value of
9 * something within a range.
11 * Signals that you can add callbacks for are:
13 * changed - Whenever the slider value is changed by the user.
15 * delay,changed - A short time after the value is changed by the user.
16 * This will be called only when the user stops dragging for a very short
17 * period or when they release their finger/mouse, so it avoids possibly
18 * expensive reactions to the value change.
20 * slider,drag,start - dragging the slider indicator around has started
22 * slider,drag,stop - dragging the slider indicator around has stopped
24 * A slider can be horizontal or vertical. It can contain an Icon and has a
25 * primary label as well as a units label (that is formatted with floating
26 * point values and thus accepts a printf-style format string, like
27 * “%1.2f units”. There is also an indicator string that may be somewhere
28 * else (like on the slider itself) that also accepts a format string like
29 * units. Label, Icon Unit and Indicator strings/objects are optional.
31 * A slider may be inverted which means values invert, with high vales being
32 * on the left or top and low values on the right or bottom (as opposed to
33 * normally being low on the left or top and high on the bottom and right).
35 * The slider should have its minimum and maximum values set by the
36 * application with elm_slider_min_max_set() and value should also be set by
37 * the application before use with elm_slider_value_set(). The span of the
38 * slider is its length (horizontally or vertically). This will be scaled by
39 * the object or applications scaling factor. At any point code can query the
40 * slider for its value with elm_slider_value_get().
43 typedef struct _Widget_Data Widget_Data;
52 const char *indicator;
53 const char *(*indicator_format_func)(double val);
54 Eina_Bool horizontal : 1;
55 Eina_Bool inverted : 1;
56 double val, val_min, val_max;
59 /* for supporting aqua feature */
60 Ecore_Timer *mv_timer;
67 #define SLIDER_THUMB_MOVE_STEP 100
69 static void _del_hook(Evas_Object *obj);
70 static void _theme_hook(Evas_Object *obj);
71 static void _sizing_eval(Evas_Object *obj);
72 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
73 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
74 static void _units_set(Evas_Object *obj);
75 static void _indicator_set(Evas_Object *obj);
77 /* supporting aqua feature */
78 static _mv_timer_cb(void *data);
80 static const char SIG_CHANGED[] = "changed";
81 static const char SIG_DELAY_CHANGED[] = "delay,changed";
82 static const char SIG_DRAG_START[] = "slider,drag,start";
83 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
84 static const Evas_Smart_Cb_Description _signals[] = {
86 {SIG_DELAY_CHANGED, ""},
93 _del_hook(Evas_Object *obj)
95 Widget_Data *wd = elm_widget_data_get(obj);
97 if (wd->label) eina_stringshare_del(wd->label);
98 if (wd->indicator) eina_stringshare_del(wd->units);
99 if (wd->delay) ecore_timer_del(wd->delay);
104 _theme_hook(Evas_Object *obj)
106 Widget_Data *wd = elm_widget_data_get(obj);
109 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
111 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
113 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
115 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
117 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
119 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
121 edje_object_signal_emit(wd->slider, "elm,state,ricon,visible", "elm");
123 edje_object_signal_emit(wd->slider, "elm,state,ricon,hidden", "elm");
125 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
127 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
128 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
130 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
132 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
134 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
136 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
137 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
139 edje_object_message_signal_process(wd->slider);
140 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
145 _sizing_eval(Evas_Object *obj)
147 Widget_Data *wd = elm_widget_data_get(obj);
148 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
150 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
151 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
152 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
153 evas_object_size_hint_min_set(obj, minw, minh);
154 evas_object_size_hint_max_set(obj, maxw, maxh);
158 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
160 Widget_Data *wd = elm_widget_data_get(data);
163 // if (obj != wd->icon) return;
164 /*supporting aqua feature*/
165 if (obj != wd->icon && obj != wd->r_icon) return;
171 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
173 Widget_Data *wd = elm_widget_data_get(obj);
174 Evas_Object *sub = event_info;
178 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
179 evas_object_event_callback_del_full
180 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
184 /*supporting aqua feature*/
185 if (sub == wd->r_icon)
187 edje_object_signal_emit(wd->slider, "elm,state,ricon,hidden", "elm");
188 evas_object_event_callback_del_full
189 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
196 _delay_change(void *data)
198 Widget_Data *wd = elm_widget_data_get(data);
201 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
206 _val_fetch(Evas_Object *obj)
208 Widget_Data *wd = elm_widget_data_get(obj);
209 double posx = 0.0, posy = 0.0, pos = 0.0, val;
211 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
213 if (wd->horizontal) pos = posx;
215 if (wd->inverted) pos = 1.0 - pos;
216 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
220 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
221 if (wd->delay) ecore_timer_del(wd->delay);
222 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
227 _val_set(Evas_Object *obj)
229 Widget_Data *wd = elm_widget_data_get(obj);
232 if (wd->val_max > wd->val_min)
233 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
236 if (pos < 0.0) pos = 0.0;
237 else if (pos > 1.0) pos = 1.0;
238 if (wd->inverted) pos = 1.0 - pos;
239 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
243 _units_set(Evas_Object *obj)
245 Widget_Data *wd = elm_widget_data_get(obj);
251 snprintf(buf, sizeof(buf), wd->units, wd->val);
252 edje_object_part_text_set(wd->slider, "elm.units", buf);
255 edje_object_part_text_set(wd->slider, "elm.units", NULL);
259 _indicator_set(Evas_Object *obj)
261 Widget_Data *wd = elm_widget_data_get(obj);
263 if (wd->indicator_format_func)
266 buf = wd->indicator_format_func(wd->val);
267 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
269 else if (wd->indicator)
272 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
273 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
276 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
280 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
282 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
283 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
285 ecore_timer_del(wd->mv_timer);
290 _indicator_set(data);
294 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
296 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
297 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
299 ecore_timer_del(wd->mv_timer);
303 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
305 _indicator_set(data);
309 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
312 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
314 _indicator_set(data);
318 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
320 Widget_Data *wd = elm_widget_data_get(data);
321 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
325 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
327 Widget_Data *wd = elm_widget_data_get(data);
328 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
331 static const char*widtype = NULL;
334 * Add a new slider to the parent
336 * @param parent The parent object
337 * @return The new object or NULL if it cannot be created
342 elm_slider_add(Evas_Object *parent)
348 wd = ELM_NEW(Widget_Data);
349 e = evas_object_evas_get(parent);
350 obj = elm_widget_add(e);
351 ELM_SET_WIDTYPE(widtype, "slider");
352 elm_widget_type_set(obj, "slider");
353 elm_widget_sub_object_add(parent, obj);
354 elm_widget_data_set(obj, wd);
355 elm_widget_del_hook_set(obj, _del_hook);
356 elm_widget_theme_hook_set(obj, _theme_hook);
358 wd->horizontal = EINA_TRUE;
363 /* supporting aqua feature */
364 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
366 wd->slider = edje_object_add(e);
367 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
368 elm_widget_resize_object_set(obj, wd->slider);
369 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
370 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
371 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
372 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
373 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
374 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
375 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
376 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
377 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
379 wd->spacer = evas_object_rectangle_add(e);
380 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
381 evas_object_pass_events_set(wd->spacer, 1);
382 elm_widget_sub_object_add(obj, wd->spacer);
383 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
385 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
389 // TODO: convert Elementary to subclassing of Evas_Smart_Class
390 // TODO: and save some bytes, making descriptions per-class and not instance!
391 evas_object_smart_callbacks_descriptions_set(obj, _signals);
396 * Set the label of the slider
398 * @param obj The slider object
399 * @param label The text label string in UTF-8
404 elm_slider_label_set(Evas_Object *obj, const char *label)
406 ELM_CHECK_WIDTYPE(obj, widtype);
407 Widget_Data *wd = elm_widget_data_get(obj);
409 eina_stringshare_replace(&wd->label, label);
412 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
413 edje_object_message_signal_process(wd->slider);
417 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
418 edje_object_message_signal_process(wd->slider);
420 edje_object_part_text_set(wd->slider, "elm.text", label);
425 * Get the label of the slider
427 * @param obj The slider object
428 * @return The text label string in UTF-8
433 elm_slider_label_get(const Evas_Object *obj)
435 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
436 Widget_Data *wd = elm_widget_data_get(obj);
437 if (!wd) return NULL;
442 * Set the icon object of the slider object
444 * Once the icon object is set, it will become a child of the slider object and
445 * be deleted when the slider object is deleted. If another icon object is set
446 * then the previous one becomes orophaned and will no longer be deleted along
449 * @param obj The slider object
450 * @param icon The icon object
455 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
457 ELM_CHECK_WIDTYPE(obj, widtype);
458 Widget_Data *wd = elm_widget_data_get(obj);
460 if ((wd->icon != icon) && (wd->icon))
461 elm_widget_sub_object_del(obj, wd->icon);
465 elm_widget_sub_object_add(obj, icon);
466 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
467 _changed_size_hints, obj);
468 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
469 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
475 * Get the icon object of the slider object
477 * @param obj The slider object
478 * @return The icon object
483 elm_slider_icon_get(const Evas_Object *obj)
485 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
486 Widget_Data *wd = elm_widget_data_get(obj);
487 if (!wd) return NULL;
492 * Set the length of the dragable region of the slider
494 * This sets the minimum width or height (depending on orientation) of the
495 * area of the slider that allows the slider to be dragged around. This in
496 * turn affects the objects minimum size (along with icon label and unit
497 * text). Note that this will also get multiplied by the scale factor.
499 * @param obj The slider object
500 * @param size The length of the slider area
505 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
507 ELM_CHECK_WIDTYPE(obj, widtype);
508 Widget_Data *wd = elm_widget_data_get(obj);
510 if (wd->size == size) return;
513 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
515 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
516 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
521 * Get the length of the dragable region of the slider
523 * This gets the minimum width or height (depending on orientation) of
524 * the area of the slider that allows the slider to be dragged
525 * around. Note that this will also get multiplied by the scale
528 * @param obj The slider object
529 * @return The length of the slider area
534 elm_slider_span_size_get(const Evas_Object *obj)
536 ELM_CHECK_WIDTYPE(obj, widtype) 0;
537 Widget_Data *wd = elm_widget_data_get(obj);
543 * Set the format string of the unit area
545 * If NULL, this disabls the unit area display. If not it sets the format
546 * string for the unit text. The unit text is provided a floating point
547 * value, so the unit text can display up to 1 floating point value. Note that
548 * this is optional. Use a format string such as "%1.2f meters" for example.
550 * @param obj The slider object
551 * @param units The format string for the units display
556 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
558 ELM_CHECK_WIDTYPE(obj, widtype);
559 Widget_Data *wd = elm_widget_data_get(obj);
561 eina_stringshare_replace(&wd->units, units);
564 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
565 edje_object_message_signal_process(wd->slider);
569 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
570 edje_object_message_signal_process(wd->slider);
577 * Get the format string for the unit area
579 * The slider may also display a value (the value of the slider) somewhere
580 * (for example above the slider knob that is dragged around). This sets the
581 * format string for this. See elm_slider_unit_format_set() for more
582 * information on how this works.
584 * @param obj The slider object
585 * @return The format string for the unit display.
590 elm_slider_unit_format_get(const Evas_Object *obj)
592 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
593 Widget_Data *wd = elm_widget_data_get(obj);
594 if (!wd) return NULL;
599 * Set the format string for the indicator area
601 * The slider may also display a value (the value of the slider) somewhere
602 * (for example above the slider knob that is dragged around). This sets the
603 * format string for this. See elm_slider_unit_format_set() for more
604 * information on how this works.
606 * @param obj The slider object
607 * @param indicator The format string for the indicator display
612 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
614 ELM_CHECK_WIDTYPE(obj, widtype);
615 Widget_Data *wd = elm_widget_data_get(obj);
617 eina_stringshare_replace(&wd->indicator, indicator);
622 * Get the format string for the indicator area
624 * The slider may also display a value (the value of the slider) somewhere
625 * (for example above the slider knob that is dragged around). This sets the
626 * format string for this. See elm_slider_indicator_format_set() for more
627 * information on how this works.
629 * @param obj The slider object
630 * @return The format string for the indicator display.
635 elm_slider_indicator_format_get(const Evas_Object *obj)
637 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
638 Widget_Data *wd = elm_widget_data_get(obj);
639 if (!wd) return NULL;
640 return wd->indicator;
644 * Set orientation of the slider
646 * @param obj The slider object
647 * @param horizontal If set, the slider will be horizontal
652 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
654 ELM_CHECK_WIDTYPE(obj, widtype);
655 Widget_Data *wd = elm_widget_data_get(obj);
657 horizontal = !!horizontal;
658 if (wd->horizontal == horizontal) return;
659 wd->horizontal = horizontal;
664 * Get orientation of the slider
666 * @param obj The slider object
667 * @return If @c EINA_TRUE the slider will be horizontal, else it is
672 elm_slider_horizontal_get(const Evas_Object *obj)
674 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
675 Widget_Data *wd = elm_widget_data_get(obj);
676 if (!wd) return EINA_FALSE;
677 return wd->horizontal;
681 * Set the minimum and maximum values for the slider
683 * Maximum mut be greater than minimum.
685 * @param obj The slider object
686 * @param min The minimum value
687 * @param max The maximum value
692 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
694 ELM_CHECK_WIDTYPE(obj, widtype);
695 Widget_Data *wd = elm_widget_data_get(obj);
697 if ((wd->val_min == min) && (wd->val_max == max)) return;
701 /* supporting aqua feature */
702 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
704 if (wd->val < wd->val_min) wd->val = wd->val_min;
705 if (wd->val > wd->val_max) wd->val = wd->val_max;
712 * Get the minimum and maximum values for the slider
714 * @param obj The slider object
715 * @param min The pointer to store minimum value, may be @c NULL.
716 * @param max The pointer to store maximum value, may be @c NULL.
721 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
725 ELM_CHECK_WIDTYPE(obj, widtype);
726 Widget_Data *wd = elm_widget_data_get(obj);
728 if (min) *min = wd->val_min;
729 if (max) *max = wd->val_max;
733 * Set the value the slider indicates
735 * @param obj The slider object
736 * @param val The value (must be beween min and max for the slider)
741 elm_slider_value_set(Evas_Object *obj, double val)
743 ELM_CHECK_WIDTYPE(obj, widtype);
744 Widget_Data *wd = elm_widget_data_get(obj);
746 if (wd->val == val) return;
748 if (wd->val < wd->val_min) wd->val = wd->val_min;
749 if (wd->val > wd->val_max) wd->val = wd->val_max;
756 * Get the value the slider has
758 * @param obj The slider object
759 * @return The value of the slider
764 elm_slider_value_get(const Evas_Object *obj)
766 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
767 Widget_Data *wd = elm_widget_data_get(obj);
773 * Invert the slider display
775 * Normally the slider will display and interpret values from low to high
776 * and when horizontal that is left to right. When vertical that is top
777 * to bottom. This inverts this (so from right to left or bottom to top) if
778 * inverted is set to 1.
780 * @param obj The slider object
781 * @param inverted The inverted flag. 1 == inverted, 0 == normal
786 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
788 ELM_CHECK_WIDTYPE(obj, widtype);
789 Widget_Data *wd = elm_widget_data_get(obj);
791 inverted = !!inverted;
792 if (wd->inverted == inverted) return;
793 wd->inverted = inverted;
795 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
797 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
798 edje_object_message_signal_process(wd->slider);
805 * Get if the slider display is inverted (backwards)
807 * @param obj The slider object
808 * @return If @c EINA_TRUE the slider will be inverted.
812 elm_slider_inverted_get(const Evas_Object *obj)
814 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
815 Widget_Data *wd = elm_widget_data_get(obj);
816 if (!wd) return EINA_FALSE;
821 * Set the format function pointer for the inducator area
823 * Set the callback function to format the indicator string.
824 * See elm_slider_indicator_format_set() for more info on how this works.
826 * @param obj The slider object
827 * @param indicator The format string for the indicator display
828 * @param func The indicator format function
833 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
835 ELM_CHECK_WIDTYPE(obj, widtype);
836 Widget_Data *wd = elm_widget_data_get(obj);
838 wd->indicator_format_func = func;
843 //////////////////////////////////////////////////////////////////////////////////////////////////////
844 //////////////////////// supporting aqua feature ///////////////////////////////////////////////////
845 //////////////////////////////////////////////////////////////////////////////////////////////////////
850 * Set the right icon object of the slider object
852 * Once the right icon object is set, it will become a child of the slider object and
853 * be deleted when the slider object is deleted. If another icon object is set
854 * then the previous one becomes orophaned and will no longer be deleted along
857 * @param obj The slider object
858 * @param icon The icon object
860 * @return 1 if icon set succeed, 0 if there is no part for right icon
865 elm_slider_right_icon_set(Evas_Object *obj, Evas_Object *icon)
867 Widget_Data *wd = elm_widget_data_get(obj);
869 if ((wd->r_icon != icon) && (wd->r_icon))
870 elm_widget_sub_object_del(obj, wd->r_icon);
874 if ( !(edje_object_part_swallow(wd->slider, "right_icon", icon)) )
877 elm_widget_sub_object_add(obj, icon);
878 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
879 _changed_size_hints, obj);
880 edje_object_signal_emit(wd->slider, "elm,state,ricon,visible", "elm");
889 * Get the right icon object of the slider object
891 * @param obj The slider object
892 * @return The right icon object
897 elm_slider_right_icon_get(Evas_Object *obj)
899 Widget_Data *wd = elm_widget_data_get(obj);
900 if (!wd) return NULL;
906 * Set whether showing the number(indicator) or not.
908 * @param obj The slider object
909 * @param show 1 will show the number, 0 will not.
914 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
916 Widget_Data *wd = elm_widget_data_get(obj);
918 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
920 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
925 static _mv_timer_cb(void *data)
927 Evas_Object* obj = (Evas_Object*)data;
928 Widget_Data *wd = elm_widget_data_get(obj);
930 if (!wd) return EINA_TRUE;
932 if(wd->src_val < wd->des_val) {
933 wd->src_val += wd->mv_step;
934 if(wd-> src_val > wd->des_val)
935 wd->src_val = wd->des_val;
938 else if (wd->src_val > wd->des_val) {
939 wd->src_val -= wd->mv_step;
940 if(wd->src_val < wd->des_val)
941 wd->src_val = wd->des_val;
944 elm_slider_value_set(obj, wd->src_val);
945 evas_object_smart_callback_call(obj, "changed", NULL);
947 if (wd->val == wd->des_val ) {
949 ecore_timer_del(wd->mv_timer);
960 * Move the thumb to the specified value.
962 * This is different with elm_slider_value_set() in animated moving.
964 * @param obj The slider object
965 * @param val thumb's destination value.
970 elm_slider_value_animated_set(Evas_Object *obj, double val)
972 Widget_Data *wd = elm_widget_data_get(obj);
974 if (wd->val == val) return;
976 wd->src_val = wd->val;
978 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
979 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
982 ecore_timer_del(wd->mv_timer);
986 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);