2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
4 #include <Elementary.h>
8 * @defgroup Slider Slider
11 * The slider adds a dragable “slider” widget for selecting the value of
12 * something within a range.
14 * Signals that you can add callbacks for are:
16 * changed - Whenever the slider value is changed by the user.
18 * delay,changed - A short time after the value is changed by the user.
19 * This will be called only when the user stops dragging for a very short
20 * period or when they release their finger/mouse, so it avoids possibly
21 * expensive reactions to the value change.
23 * slider,drag,start - dragging the slider indicator around has started
25 * slider,drag,stop - dragging the slider indicator around has stopped
27 * A slider can be horizontal or vertical. It can contain an Icon and has a
28 * primary label as well as a units label (that is formatted with floating
29 * point values and thus accepts a printf-style format string, like
30 * “%1.2f units”. There is also an indicator string that may be somewhere
31 * else (like on the slider itself) that also accepts a format string like
32 * units. Label, Icon Unit and Indicator strings/objects are optional.
34 * A slider may be inverted which means values invert, with high vales being
35 * on the left or top and low values on the right or bottom (as opposed to
36 * normally being low on the left or top and high on the bottom and right).
38 * The slider should have its minimum and maximum values set by the
39 * application with elm_slider_min_max_set() and value should also be set by
40 * the application before use with elm_slider_value_set(). The span of the
41 * slider is its length (horizontally or vertically). This will be scaled by
42 * the object or applications scaling factor. At any point code can query the
43 * slider for its value with elm_slider_value_get().
46 typedef struct _Widget_Data Widget_Data;
56 const char *indicator;
57 const char *(*indicator_format_func)(double val);
58 Eina_Bool horizontal : 1;
59 Eina_Bool inverted : 1;
60 double val, val_min, val_max;
63 /* for supporting aqua feature */
64 Ecore_Timer *mv_timer;
71 #define SLIDER_THUMB_MOVE_STEP 100
73 static void _del_hook(Evas_Object *obj);
74 static void _theme_hook(Evas_Object *obj);
75 static void _sizing_eval(Evas_Object *obj);
76 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
77 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
78 static void _units_set(Evas_Object *obj);
79 static void _indicator_set(Evas_Object *obj);
81 /* supporting aqua feature */
82 static _mv_timer_cb(void *data);
84 static const char SIG_CHANGED[] = "changed";
85 static const char SIG_DELAY_CHANGED[] = "delay,changed";
86 static const char SIG_DRAG_START[] = "slider,drag,start";
87 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
88 static const Evas_Smart_Cb_Description _signals[] = {
90 {SIG_DELAY_CHANGED, ""},
97 _del_hook(Evas_Object *obj)
99 Widget_Data *wd = elm_widget_data_get(obj);
101 if (wd->label) eina_stringshare_del(wd->label);
102 if (wd->e_label) eina_stringshare_del(wd->label);
103 if (wd->indicator) eina_stringshare_del(wd->units);
104 if (wd->delay) ecore_timer_del(wd->delay);
109 _theme_hook(Evas_Object *obj)
111 Widget_Data *wd = elm_widget_data_get(obj);
114 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
116 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
118 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
120 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
122 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
124 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
126 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
128 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
130 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
132 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
133 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
135 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
137 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
138 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
140 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
142 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
144 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
146 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
147 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
149 edje_object_message_signal_process(wd->slider);
150 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
155 _sizing_eval(Evas_Object *obj)
157 Widget_Data *wd = elm_widget_data_get(obj);
158 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
160 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
161 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
162 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
163 evas_object_size_hint_min_set(obj, minw, minh);
164 evas_object_size_hint_max_set(obj, maxw, maxh);
168 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
170 Widget_Data *wd = elm_widget_data_get(data);
173 // if (obj != wd->icon) return;
174 /*supporting aqua feature*/
175 if (obj != wd->icon && obj != wd->e_icon) return;
181 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
183 Widget_Data *wd = elm_widget_data_get(obj);
184 Evas_Object *sub = event_info;
188 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
189 evas_object_event_callback_del_full
190 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
194 /*supporting aqua feature*/
195 if (sub == wd->e_icon)
197 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
198 evas_object_event_callback_del_full
199 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
206 _delay_change(void *data)
208 Widget_Data *wd = elm_widget_data_get(data);
211 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
216 _val_fetch(Evas_Object *obj)
218 Widget_Data *wd = elm_widget_data_get(obj);
219 double posx = 0.0, posy = 0.0, pos = 0.0, val;
221 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
223 if (wd->horizontal) pos = posx;
225 if (wd->inverted) pos = 1.0 - pos;
226 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
230 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
231 if (wd->delay) ecore_timer_del(wd->delay);
232 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
237 _val_set(Evas_Object *obj)
239 Widget_Data *wd = elm_widget_data_get(obj);
242 if (wd->val_max > wd->val_min)
243 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
246 if (pos < 0.0) pos = 0.0;
247 else if (pos > 1.0) pos = 1.0;
248 if (wd->inverted) pos = 1.0 - pos;
249 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
253 _units_set(Evas_Object *obj)
255 Widget_Data *wd = elm_widget_data_get(obj);
261 snprintf(buf, sizeof(buf), wd->units, wd->val);
262 edje_object_part_text_set(wd->slider, "elm.units", buf);
264 else if (wd->e_label)
265 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
267 edje_object_part_text_set(wd->slider, "elm.units", NULL);
271 _indicator_set(Evas_Object *obj)
273 Widget_Data *wd = elm_widget_data_get(obj);
275 if (wd->indicator_format_func)
278 buf = wd->indicator_format_func(wd->val);
279 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
281 else if (wd->indicator)
284 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
285 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
288 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
292 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
294 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
295 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
298 ecore_timer_del(wd->mv_timer);
303 _indicator_set(data);
307 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
309 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
310 /* supporting aqua feature : delete thumb move timer when drag event occured to the moving thumb */
313 ecore_timer_del(wd->mv_timer);
317 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
319 _indicator_set(data);
323 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
326 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
328 _indicator_set(data);
332 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
334 Widget_Data *wd = elm_widget_data_get(data);
335 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
339 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
341 Widget_Data *wd = elm_widget_data_get(data);
342 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
345 static const char*widtype = NULL;
348 * Add a new slider to the parent
350 * @param parent The parent object
351 * @return The new object or NULL if it cannot be created
356 elm_slider_add(Evas_Object *parent)
362 wd = ELM_NEW(Widget_Data);
363 e = evas_object_evas_get(parent);
364 obj = elm_widget_add(e);
365 ELM_SET_WIDTYPE(widtype, "slider");
366 elm_widget_type_set(obj, "slider");
367 elm_widget_sub_object_add(parent, obj);
368 elm_widget_data_set(obj, wd);
369 elm_widget_del_hook_set(obj, _del_hook);
370 elm_widget_theme_hook_set(obj, _theme_hook);
372 wd->horizontal = EINA_TRUE;
377 /* supporting aqua feature */
378 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
380 wd->slider = edje_object_add(e);
381 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
382 elm_widget_resize_object_set(obj, wd->slider);
383 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
384 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
385 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
386 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
387 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
388 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
389 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
390 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
391 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
393 wd->spacer = evas_object_rectangle_add(e);
394 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
395 evas_object_pass_events_set(wd->spacer, 1);
396 elm_widget_sub_object_add(obj, wd->spacer);
397 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
399 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
403 // TODO: convert Elementary to subclassing of Evas_Smart_Class
404 // TODO: and save some bytes, making descriptions per-class and not instance!
405 evas_object_smart_callbacks_descriptions_set(obj, _signals);
410 * Set the label of the slider
412 * @param obj The slider object
413 * @param label The text label string in UTF-8
418 elm_slider_label_set(Evas_Object *obj, const char *label)
420 ELM_CHECK_WIDTYPE(obj, widtype);
421 Widget_Data *wd = elm_widget_data_get(obj);
423 eina_stringshare_replace(&wd->label, label);
426 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
427 edje_object_message_signal_process(wd->slider);
431 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
432 edje_object_message_signal_process(wd->slider);
434 edje_object_part_text_set(wd->slider, "elm.text", label);
439 * Get the label of the slider
441 * @param obj The slider object
442 * @return The text label string in UTF-8
447 elm_slider_label_get(const Evas_Object *obj)
449 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
450 Widget_Data *wd = elm_widget_data_get(obj);
451 if (!wd) return NULL;
456 * Set the icon object of the slider object
458 * Once the icon object is set, it will become a child of the slider object and
459 * be deleted when the slider object is deleted. If another icon object is set
460 * then the previous one becomes orophaned and will no longer be deleted along
463 * @param obj The slider object
464 * @param icon The icon object
469 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
471 ELM_CHECK_WIDTYPE(obj, widtype);
472 Widget_Data *wd = elm_widget_data_get(obj);
474 if ((wd->icon != icon) && (wd->icon))
475 elm_widget_sub_object_del(obj, wd->icon);
479 elm_widget_sub_object_add(obj, icon);
480 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
481 _changed_size_hints, obj);
482 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
483 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
489 * Get the icon object of the slider object
491 * @param obj The slider object
492 * @return The icon object
497 elm_slider_icon_get(const Evas_Object *obj)
499 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
500 Widget_Data *wd = elm_widget_data_get(obj);
501 if (!wd) return NULL;
506 * Set the length of the dragable region of the slider
508 * This sets the minimum width or height (depending on orientation) of the
509 * area of the slider that allows the slider to be dragged around. This in
510 * turn affects the objects minimum size (along with icon label and unit
511 * text). Note that this will also get multiplied by the scale factor.
513 * @param obj The slider object
514 * @param size The length of the slider area
519 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
521 ELM_CHECK_WIDTYPE(obj, widtype);
522 Widget_Data *wd = elm_widget_data_get(obj);
524 if (wd->size == size) return;
527 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
529 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
530 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
535 * Get the length of the dragable region of the slider
537 * This gets the minimum width or height (depending on orientation) of
538 * the area of the slider that allows the slider to be dragged
539 * around. Note that this will also get multiplied by the scale
542 * @param obj The slider object
543 * @return The length of the slider area
548 elm_slider_span_size_get(const Evas_Object *obj)
550 ELM_CHECK_WIDTYPE(obj, widtype) 0;
551 Widget_Data *wd = elm_widget_data_get(obj);
557 * Set the format string of the unit area
559 * If NULL, this disabls the unit area display. If not it sets the format
560 * string for the unit text. The unit text is provided a floating point
561 * value, so the unit text can display up to 1 floating point value. Note that
562 * this is optional. Use a format string such as "%1.2f meters" for example.
564 * @param obj The slider object
565 * @param units The format string for the units display
570 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
572 ELM_CHECK_WIDTYPE(obj, widtype);
573 Widget_Data *wd = elm_widget_data_get(obj);
575 eina_stringshare_replace(&wd->units, units);
578 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
579 edje_object_message_signal_process(wd->slider);
583 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
584 edje_object_message_signal_process(wd->slider);
591 * Get the format string for the unit area
593 * The slider may also display a value (the value of the slider) somewhere
594 * (for example above the slider knob that is dragged around). This sets the
595 * format string for this. See elm_slider_unit_format_set() for more
596 * information on how this works.
598 * @param obj The slider object
599 * @return The format string for the unit display.
604 elm_slider_unit_format_get(const Evas_Object *obj)
606 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
607 Widget_Data *wd = elm_widget_data_get(obj);
608 if (!wd) return NULL;
613 * Set the format string for the indicator area
615 * The slider may also display a value (the value of the slider) somewhere
616 * (for example above the slider knob that is dragged around). This sets the
617 * format string for this. See elm_slider_unit_format_set() for more
618 * information on how this works.
620 * @param obj The slider object
621 * @param indicator The format string for the indicator display
626 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
628 ELM_CHECK_WIDTYPE(obj, widtype);
629 Widget_Data *wd = elm_widget_data_get(obj);
631 eina_stringshare_replace(&wd->indicator, indicator);
636 * Get the format string for the indicator area
638 * The slider may also display a value (the value of the slider) somewhere
639 * (for example above the slider knob that is dragged around). This sets the
640 * format string for this. See elm_slider_indicator_format_set() for more
641 * information on how this works.
643 * @param obj The slider object
644 * @return The format string for the indicator display.
649 elm_slider_indicator_format_get(const Evas_Object *obj)
651 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
652 Widget_Data *wd = elm_widget_data_get(obj);
653 if (!wd) return NULL;
654 return wd->indicator;
658 * Set orientation of the slider
660 * @param obj The slider object
661 * @param horizontal If set, the slider will be horizontal
666 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
668 ELM_CHECK_WIDTYPE(obj, widtype);
669 Widget_Data *wd = elm_widget_data_get(obj);
671 horizontal = !!horizontal;
672 if (wd->horizontal == horizontal) return;
673 wd->horizontal = horizontal;
678 * Get orientation of the slider
680 * @param obj The slider object
681 * @return If @c EINA_TRUE the slider will be horizontal, else it is
686 elm_slider_horizontal_get(const Evas_Object *obj)
688 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
689 Widget_Data *wd = elm_widget_data_get(obj);
690 if (!wd) return EINA_FALSE;
691 return wd->horizontal;
695 * Set the minimum and maximum values for the slider
697 * Maximum mut be greater than minimum.
699 * @param obj The slider object
700 * @param min The minimum value
701 * @param max The maximum value
706 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
708 ELM_CHECK_WIDTYPE(obj, widtype);
709 Widget_Data *wd = elm_widget_data_get(obj);
711 if ((wd->val_min == min) && (wd->val_max == max)) return;
715 /* supporting aqua feature */
716 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
718 if (wd->val < wd->val_min) wd->val = wd->val_min;
719 if (wd->val > wd->val_max) wd->val = wd->val_max;
726 * Get the minimum and maximum values for the slider
728 * @param obj The slider object
729 * @param min The pointer to store minimum value, may be @c NULL.
730 * @param max The pointer to store maximum value, may be @c NULL.
735 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
739 ELM_CHECK_WIDTYPE(obj, widtype);
740 Widget_Data *wd = elm_widget_data_get(obj);
742 if (min) *min = wd->val_min;
743 if (max) *max = wd->val_max;
747 * Set the value the slider indicates
749 * @param obj The slider object
750 * @param val The value (must be beween min and max for the slider)
755 elm_slider_value_set(Evas_Object *obj, double val)
757 ELM_CHECK_WIDTYPE(obj, widtype);
758 Widget_Data *wd = elm_widget_data_get(obj);
760 if (wd->val == val) return;
762 if (wd->val < wd->val_min) wd->val = wd->val_min;
763 if (wd->val > wd->val_max) wd->val = wd->val_max;
770 * Get the value the slider has
772 * @param obj The slider object
773 * @return The value of the slider
778 elm_slider_value_get(const Evas_Object *obj)
780 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
781 Widget_Data *wd = elm_widget_data_get(obj);
787 * Invert the slider display
789 * Normally the slider will display and interpret values from low to high
790 * and when horizontal that is left to right. When vertical that is top
791 * to bottom. This inverts this (so from right to left or bottom to top) if
792 * inverted is set to 1.
794 * @param obj The slider object
795 * @param inverted The inverted flag. 1 == inverted, 0 == normal
800 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
802 ELM_CHECK_WIDTYPE(obj, widtype);
803 Widget_Data *wd = elm_widget_data_get(obj);
805 inverted = !!inverted;
806 if (wd->inverted == inverted) return;
807 wd->inverted = inverted;
809 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
811 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
812 edje_object_message_signal_process(wd->slider);
819 * Get if the slider display is inverted (backwards)
821 * @param obj The slider object
822 * @return If @c EINA_TRUE the slider will be inverted.
826 elm_slider_inverted_get(const Evas_Object *obj)
828 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
829 Widget_Data *wd = elm_widget_data_get(obj);
830 if (!wd) return EINA_FALSE;
835 * Set the format function pointer for the inducator area
837 * Set the callback function to format the indicator string.
838 * See elm_slider_indicator_format_set() for more info on how this works.
840 * @param obj The slider object
841 * @param indicator The format string for the indicator display
842 * @param func The indicator format function
847 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
849 ELM_CHECK_WIDTYPE(obj, widtype);
850 Widget_Data *wd = elm_widget_data_get(obj);
852 wd->indicator_format_func = func;
857 //////////////////////////////////////////////////////////////////////////////////////////////////////
858 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
859 //////////////////////////////////////////////////////////////////////////////////////////////////////
864 * Set the right icon object of the slider object
866 * Once the right icon object is set, it will become a child of the slider object and
867 * be deleted when the slider object is deleted. If another icon object is set
868 * then the previous one becomes orophaned and will no longer be deleted along
871 * @param obj The slider object
872 * @param icon The icon object
874 * @return 1 if icon set succeed, 0 if there is no part for right icon
879 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
881 Widget_Data *wd = elm_widget_data_get(obj);
883 if ((wd->e_icon != icon) && (wd->e_icon))
884 elm_widget_sub_object_del(obj, wd->e_icon);
888 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
891 elm_widget_sub_object_add(obj, icon);
892 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
893 _changed_size_hints, obj);
894 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
903 * Get the right icon object of the slider object
905 * @param obj The slider object
906 * @return The right icon object
911 elm_slider_end_icon_get(Evas_Object *obj)
913 Widget_Data *wd = elm_widget_data_get(obj);
914 if (!wd) return NULL;
920 * Set whether showing the number(indicator) or not.
922 * @param obj The slider object
923 * @param show 1 will show the number, 0 will not.
928 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
930 Widget_Data *wd = elm_widget_data_get(obj);
932 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
934 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
937 static _mv_timer_cb(void *data)
939 Evas_Object* obj = (Evas_Object*)data;
940 Widget_Data *wd = elm_widget_data_get(obj);
942 if (!wd) return EINA_TRUE;
944 if(wd->src_val < wd->des_val)
946 wd->src_val += wd->mv_step;
947 if(wd-> src_val > wd->des_val)
948 wd->src_val = wd->des_val;
950 else if (wd->src_val > wd->des_val)
952 wd->src_val -= wd->mv_step;
953 if(wd->src_val < wd->des_val)
954 wd->src_val = wd->des_val;
957 elm_slider_value_set(obj, wd->src_val);
958 evas_object_smart_callback_call(obj, "changed", NULL);
960 if (wd->val == wd->des_val)
964 ecore_timer_del(wd->mv_timer);
975 * Move the thumb to the specified value.
977 * This is different with elm_slider_value_set() in animated moving.
979 * @param obj The slider object
980 * @param val thumb's destination value.
985 elm_slider_value_animated_set(Evas_Object *obj, double val)
987 Widget_Data *wd = elm_widget_data_get(obj);
989 if (wd->val == val) return;
991 wd->src_val = wd->val;
993 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
994 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
998 ecore_timer_del(wd->mv_timer);
1002 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1007 * Set the label of the slider
1009 * @param obj The slider object
1010 * @param label The text label string in UTF-8
1015 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1017 ELM_CHECK_WIDTYPE(obj, widtype);
1018 Widget_Data *wd = elm_widget_data_get(obj);
1020 eina_stringshare_replace(&wd->e_label, label);
1023 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1024 edje_object_message_signal_process(wd->slider);
1028 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1029 edje_object_message_signal_process(wd->slider);
1031 edje_object_part_text_set(wd->slider, "elm.units", label);
1038 * Get the label of the slider
1040 * @param obj The slider object
1041 * @return The text label string in UTF-8
1046 elm_slider_end_label_get(const Evas_Object *obj)
1048 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1049 Widget_Data *wd = elm_widget_data_get(obj);
1050 if (!wd) return NULL;