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;
53 const char *indicator;
54 const char *(*indicator_format_func)(double val);
55 Eina_Bool horizontal : 1;
56 Eina_Bool inverted : 1;
57 double val, val_min, val_max;
60 /* for supporting aqua feature */
61 Ecore_Timer *mv_timer;
68 #define SLIDER_THUMB_MOVE_STEP 100
70 static void _del_hook(Evas_Object *obj);
71 static void _theme_hook(Evas_Object *obj);
72 static void _sizing_eval(Evas_Object *obj);
73 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
75 static void _units_set(Evas_Object *obj);
76 static void _indicator_set(Evas_Object *obj);
78 /* supporting aqua feature */
79 static _mv_timer_cb(void *data);
81 static const char SIG_CHANGED[] = "changed";
82 static const char SIG_DELAY_CHANGED[] = "delay,changed";
83 static const char SIG_DRAG_START[] = "slider,drag,start";
84 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
85 static const Evas_Smart_Cb_Description _signals[] = {
87 {SIG_DELAY_CHANGED, ""},
94 _del_hook(Evas_Object *obj)
96 Widget_Data *wd = elm_widget_data_get(obj);
98 if (wd->label) eina_stringshare_del(wd->label);
99 if (wd->e_label) eina_stringshare_del(wd->label);
100 if (wd->indicator) eina_stringshare_del(wd->units);
101 if (wd->delay) ecore_timer_del(wd->delay);
106 _theme_hook(Evas_Object *obj)
108 Widget_Data *wd = elm_widget_data_get(obj);
111 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
113 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
115 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
117 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
119 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
121 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
123 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
125 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
127 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
129 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
130 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
132 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
134 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
135 edje_object_part_text_set(wd->slider, "elm.text", wd->e_label);
137 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
139 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
141 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
143 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
144 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
146 edje_object_message_signal_process(wd->slider);
147 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
152 _sizing_eval(Evas_Object *obj)
154 Widget_Data *wd = elm_widget_data_get(obj);
155 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
157 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
158 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
159 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
160 evas_object_size_hint_min_set(obj, minw, minh);
161 evas_object_size_hint_max_set(obj, maxw, maxh);
165 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
167 Widget_Data *wd = elm_widget_data_get(data);
170 // if (obj != wd->icon) return;
171 /*supporting aqua feature*/
172 if (obj != wd->icon && obj != wd->e_icon) return;
178 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
180 Widget_Data *wd = elm_widget_data_get(obj);
181 Evas_Object *sub = event_info;
185 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
186 evas_object_event_callback_del_full
187 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
191 /*supporting aqua feature*/
192 if (sub == wd->e_icon)
194 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
195 evas_object_event_callback_del_full
196 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
203 _delay_change(void *data)
205 Widget_Data *wd = elm_widget_data_get(data);
208 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
213 _val_fetch(Evas_Object *obj)
215 Widget_Data *wd = elm_widget_data_get(obj);
216 double posx = 0.0, posy = 0.0, pos = 0.0, val;
218 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
220 if (wd->horizontal) pos = posx;
222 if (wd->inverted) pos = 1.0 - pos;
223 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
227 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
228 if (wd->delay) ecore_timer_del(wd->delay);
229 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
234 _val_set(Evas_Object *obj)
236 Widget_Data *wd = elm_widget_data_get(obj);
239 if (wd->val_max > wd->val_min)
240 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
243 if (pos < 0.0) pos = 0.0;
244 else if (pos > 1.0) pos = 1.0;
245 if (wd->inverted) pos = 1.0 - pos;
246 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
250 _units_set(Evas_Object *obj)
252 Widget_Data *wd = elm_widget_data_get(obj);
258 snprintf(buf, sizeof(buf), wd->units, wd->val);
259 edje_object_part_text_set(wd->slider, "elm.units", buf);
261 else if (wd->e_label)
262 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
264 edje_object_part_text_set(wd->slider, "elm.units", NULL);
268 _indicator_set(Evas_Object *obj)
270 Widget_Data *wd = elm_widget_data_get(obj);
272 if (wd->indicator_format_func)
275 buf = wd->indicator_format_func(wd->val);
276 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
278 else if (wd->indicator)
281 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
282 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
285 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
289 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
291 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
292 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
294 ecore_timer_del(wd->mv_timer);
299 _indicator_set(data);
303 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
305 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
306 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
308 ecore_timer_del(wd->mv_timer);
312 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
314 _indicator_set(data);
318 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
321 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
323 _indicator_set(data);
327 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
329 Widget_Data *wd = elm_widget_data_get(data);
330 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
334 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
336 Widget_Data *wd = elm_widget_data_get(data);
337 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
340 static const char*widtype = NULL;
343 * Add a new slider to the parent
345 * @param parent The parent object
346 * @return The new object or NULL if it cannot be created
351 elm_slider_add(Evas_Object *parent)
357 wd = ELM_NEW(Widget_Data);
358 e = evas_object_evas_get(parent);
359 obj = elm_widget_add(e);
360 ELM_SET_WIDTYPE(widtype, "slider");
361 elm_widget_type_set(obj, "slider");
362 elm_widget_sub_object_add(parent, obj);
363 elm_widget_data_set(obj, wd);
364 elm_widget_del_hook_set(obj, _del_hook);
365 elm_widget_theme_hook_set(obj, _theme_hook);
367 wd->horizontal = EINA_TRUE;
372 /* supporting aqua feature */
373 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
375 wd->slider = edje_object_add(e);
376 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
377 elm_widget_resize_object_set(obj, wd->slider);
378 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
379 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
380 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
381 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
382 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
383 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
384 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
385 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
386 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
388 wd->spacer = evas_object_rectangle_add(e);
389 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
390 evas_object_pass_events_set(wd->spacer, 1);
391 elm_widget_sub_object_add(obj, wd->spacer);
392 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
394 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
398 // TODO: convert Elementary to subclassing of Evas_Smart_Class
399 // TODO: and save some bytes, making descriptions per-class and not instance!
400 evas_object_smart_callbacks_descriptions_set(obj, _signals);
405 * Set the label of the slider
407 * @param obj The slider object
408 * @param label The text label string in UTF-8
413 elm_slider_label_set(Evas_Object *obj, const char *label)
415 ELM_CHECK_WIDTYPE(obj, widtype);
416 Widget_Data *wd = elm_widget_data_get(obj);
418 eina_stringshare_replace(&wd->label, label);
421 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
422 edje_object_message_signal_process(wd->slider);
426 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
427 edje_object_message_signal_process(wd->slider);
429 edje_object_part_text_set(wd->slider, "elm.text", label);
434 * Get the label of the slider
436 * @param obj The slider object
437 * @return The text label string in UTF-8
442 elm_slider_label_get(const Evas_Object *obj)
444 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
445 Widget_Data *wd = elm_widget_data_get(obj);
446 if (!wd) return NULL;
451 * Set the icon object of the slider object
453 * Once the icon object is set, it will become a child of the slider object and
454 * be deleted when the slider object is deleted. If another icon object is set
455 * then the previous one becomes orophaned and will no longer be deleted along
458 * @param obj The slider object
459 * @param icon The icon object
464 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
466 ELM_CHECK_WIDTYPE(obj, widtype);
467 Widget_Data *wd = elm_widget_data_get(obj);
469 if ((wd->icon != icon) && (wd->icon))
470 elm_widget_sub_object_del(obj, wd->icon);
474 elm_widget_sub_object_add(obj, icon);
475 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
476 _changed_size_hints, obj);
477 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
478 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
484 * Get the icon object of the slider object
486 * @param obj The slider object
487 * @return The icon object
492 elm_slider_icon_get(const Evas_Object *obj)
494 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
495 Widget_Data *wd = elm_widget_data_get(obj);
496 if (!wd) return NULL;
501 * Set the length of the dragable region of the slider
503 * This sets the minimum width or height (depending on orientation) of the
504 * area of the slider that allows the slider to be dragged around. This in
505 * turn affects the objects minimum size (along with icon label and unit
506 * text). Note that this will also get multiplied by the scale factor.
508 * @param obj The slider object
509 * @param size The length of the slider area
514 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
516 ELM_CHECK_WIDTYPE(obj, widtype);
517 Widget_Data *wd = elm_widget_data_get(obj);
519 if (wd->size == size) return;
522 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
524 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
525 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
530 * Get the length of the dragable region of the slider
532 * This gets the minimum width or height (depending on orientation) of
533 * the area of the slider that allows the slider to be dragged
534 * around. Note that this will also get multiplied by the scale
537 * @param obj The slider object
538 * @return The length of the slider area
543 elm_slider_span_size_get(const Evas_Object *obj)
545 ELM_CHECK_WIDTYPE(obj, widtype) 0;
546 Widget_Data *wd = elm_widget_data_get(obj);
552 * Set the format string of the unit area
554 * If NULL, this disabls the unit area display. If not it sets the format
555 * string for the unit text. The unit text is provided a floating point
556 * value, so the unit text can display up to 1 floating point value. Note that
557 * this is optional. Use a format string such as "%1.2f meters" for example.
559 * @param obj The slider object
560 * @param units The format string for the units display
565 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
567 ELM_CHECK_WIDTYPE(obj, widtype);
568 Widget_Data *wd = elm_widget_data_get(obj);
570 eina_stringshare_replace(&wd->units, units);
573 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
574 edje_object_message_signal_process(wd->slider);
578 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
579 edje_object_message_signal_process(wd->slider);
586 * Get the format string for the unit area
588 * The slider may also display a value (the value of the slider) somewhere
589 * (for example above the slider knob that is dragged around). This sets the
590 * format string for this. See elm_slider_unit_format_set() for more
591 * information on how this works.
593 * @param obj The slider object
594 * @return The format string for the unit display.
599 elm_slider_unit_format_get(const Evas_Object *obj)
601 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
602 Widget_Data *wd = elm_widget_data_get(obj);
603 if (!wd) return NULL;
608 * Set the format string for the indicator area
610 * The slider may also display a value (the value of the slider) somewhere
611 * (for example above the slider knob that is dragged around). This sets the
612 * format string for this. See elm_slider_unit_format_set() for more
613 * information on how this works.
615 * @param obj The slider object
616 * @param indicator The format string for the indicator display
621 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
623 ELM_CHECK_WIDTYPE(obj, widtype);
624 Widget_Data *wd = elm_widget_data_get(obj);
626 eina_stringshare_replace(&wd->indicator, indicator);
631 * Get the format string for the indicator area
633 * The slider may also display a value (the value of the slider) somewhere
634 * (for example above the slider knob that is dragged around). This sets the
635 * format string for this. See elm_slider_indicator_format_set() for more
636 * information on how this works.
638 * @param obj The slider object
639 * @return The format string for the indicator display.
644 elm_slider_indicator_format_get(const Evas_Object *obj)
646 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
647 Widget_Data *wd = elm_widget_data_get(obj);
648 if (!wd) return NULL;
649 return wd->indicator;
653 * Set orientation of the slider
655 * @param obj The slider object
656 * @param horizontal If set, the slider will be horizontal
661 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
663 ELM_CHECK_WIDTYPE(obj, widtype);
664 Widget_Data *wd = elm_widget_data_get(obj);
666 horizontal = !!horizontal;
667 if (wd->horizontal == horizontal) return;
668 wd->horizontal = horizontal;
673 * Get orientation of the slider
675 * @param obj The slider object
676 * @return If @c EINA_TRUE the slider will be horizontal, else it is
681 elm_slider_horizontal_get(const Evas_Object *obj)
683 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
684 Widget_Data *wd = elm_widget_data_get(obj);
685 if (!wd) return EINA_FALSE;
686 return wd->horizontal;
690 * Set the minimum and maximum values for the slider
692 * Maximum mut be greater than minimum.
694 * @param obj The slider object
695 * @param min The minimum value
696 * @param max The maximum value
701 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
703 ELM_CHECK_WIDTYPE(obj, widtype);
704 Widget_Data *wd = elm_widget_data_get(obj);
706 if ((wd->val_min == min) && (wd->val_max == max)) return;
710 /* supporting aqua feature */
711 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
713 if (wd->val < wd->val_min) wd->val = wd->val_min;
714 if (wd->val > wd->val_max) wd->val = wd->val_max;
721 * Get the minimum and maximum values for the slider
723 * @param obj The slider object
724 * @param min The pointer to store minimum value, may be @c NULL.
725 * @param max The pointer to store maximum value, may be @c NULL.
730 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
734 ELM_CHECK_WIDTYPE(obj, widtype);
735 Widget_Data *wd = elm_widget_data_get(obj);
737 if (min) *min = wd->val_min;
738 if (max) *max = wd->val_max;
742 * Set the value the slider indicates
744 * @param obj The slider object
745 * @param val The value (must be beween min and max for the slider)
750 elm_slider_value_set(Evas_Object *obj, double val)
752 ELM_CHECK_WIDTYPE(obj, widtype);
753 Widget_Data *wd = elm_widget_data_get(obj);
755 if (wd->val == val) return;
757 if (wd->val < wd->val_min) wd->val = wd->val_min;
758 if (wd->val > wd->val_max) wd->val = wd->val_max;
765 * Get the value the slider has
767 * @param obj The slider object
768 * @return The value of the slider
773 elm_slider_value_get(const Evas_Object *obj)
775 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
776 Widget_Data *wd = elm_widget_data_get(obj);
782 * Invert the slider display
784 * Normally the slider will display and interpret values from low to high
785 * and when horizontal that is left to right. When vertical that is top
786 * to bottom. This inverts this (so from right to left or bottom to top) if
787 * inverted is set to 1.
789 * @param obj The slider object
790 * @param inverted The inverted flag. 1 == inverted, 0 == normal
795 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
797 ELM_CHECK_WIDTYPE(obj, widtype);
798 Widget_Data *wd = elm_widget_data_get(obj);
800 inverted = !!inverted;
801 if (wd->inverted == inverted) return;
802 wd->inverted = inverted;
804 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
806 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
807 edje_object_message_signal_process(wd->slider);
814 * Get if the slider display is inverted (backwards)
816 * @param obj The slider object
817 * @return If @c EINA_TRUE the slider will be inverted.
821 elm_slider_inverted_get(const Evas_Object *obj)
823 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
824 Widget_Data *wd = elm_widget_data_get(obj);
825 if (!wd) return EINA_FALSE;
830 * Set the format function pointer for the inducator area
832 * Set the callback function to format the indicator string.
833 * See elm_slider_indicator_format_set() for more info on how this works.
835 * @param obj The slider object
836 * @param indicator The format string for the indicator display
837 * @param func The indicator format function
842 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
844 ELM_CHECK_WIDTYPE(obj, widtype);
845 Widget_Data *wd = elm_widget_data_get(obj);
847 wd->indicator_format_func = func;
852 //////////////////////////////////////////////////////////////////////////////////////////////////////
853 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
854 //////////////////////////////////////////////////////////////////////////////////////////////////////
859 * Set the right icon object of the slider object
861 * Once the right icon object is set, it will become a child of the slider object and
862 * be deleted when the slider object is deleted. If another icon object is set
863 * then the previous one becomes orophaned and will no longer be deleted along
866 * @param obj The slider object
867 * @param icon The icon object
869 * @return 1 if icon set succeed, 0 if there is no part for right icon
874 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
876 Widget_Data *wd = elm_widget_data_get(obj);
878 if ((wd->e_icon != icon) && (wd->e_icon))
879 elm_widget_sub_object_del(obj, wd->e_icon);
883 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
886 elm_widget_sub_object_add(obj, icon);
887 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
888 _changed_size_hints, obj);
889 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
898 * Get the right icon object of the slider object
900 * @param obj The slider object
901 * @return The right icon object
906 elm_slider_end_icon_get(Evas_Object *obj)
908 Widget_Data *wd = elm_widget_data_get(obj);
909 if (!wd) return NULL;
915 * Set whether showing the number(indicator) or not.
917 * @param obj The slider object
918 * @param show 1 will show the number, 0 will not.
923 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
925 Widget_Data *wd = elm_widget_data_get(obj);
927 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
929 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
934 static _mv_timer_cb(void *data)
936 Evas_Object* obj = (Evas_Object*)data;
937 Widget_Data *wd = elm_widget_data_get(obj);
939 if (!wd) return EINA_TRUE;
941 if(wd->src_val < wd->des_val) {
942 wd->src_val += wd->mv_step;
943 if(wd-> src_val > wd->des_val)
944 wd->src_val = wd->des_val;
947 else if (wd->src_val > wd->des_val) {
948 wd->src_val -= wd->mv_step;
949 if(wd->src_val < wd->des_val)
950 wd->src_val = wd->des_val;
953 elm_slider_value_set(obj, wd->src_val);
954 evas_object_smart_callback_call(obj, "changed", NULL);
956 if (wd->val == wd->des_val ) {
958 ecore_timer_del(wd->mv_timer);
969 * Move the thumb to the specified value.
971 * This is different with elm_slider_value_set() in animated moving.
973 * @param obj The slider object
974 * @param val thumb's destination value.
979 elm_slider_value_animated_set(Evas_Object *obj, double val)
981 Widget_Data *wd = elm_widget_data_get(obj);
983 if (wd->val == val) return;
985 wd->src_val = wd->val;
987 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
988 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
991 ecore_timer_del(wd->mv_timer);
995 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1000 * Set the label of the slider
1002 * @param obj The slider object
1003 * @param label The text label string in UTF-8
1008 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1010 ELM_CHECK_WIDTYPE(obj, widtype);
1011 Widget_Data *wd = elm_widget_data_get(obj);
1013 eina_stringshare_replace(&wd->e_label, label);
1016 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1017 edje_object_message_signal_process(wd->slider);
1021 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1022 edje_object_message_signal_process(wd->slider);
1024 edje_object_part_text_set(wd->slider, "elm.units", label);
1031 * Get the label of the slider
1033 * @param obj The slider object
1034 * @return The text label string in UTF-8
1039 elm_slider_end_label_get(const Evas_Object *obj)
1041 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1042 Widget_Data *wd = elm_widget_data_get(obj);
1043 if (!wd) return NULL;