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);
330 static const char*widtype = NULL;
333 * Add a new slider to the parent
335 * @param parent The parent object
336 * @return The new object or NULL if it cannot be created
341 elm_slider_add(Evas_Object *parent)
347 wd = ELM_NEW(Widget_Data);
348 e = evas_object_evas_get(parent);
349 obj = elm_widget_add(e);
350 ELM_SET_WIDTYPE(widtype, "slider");
351 elm_widget_type_set(obj, "slider");
352 elm_widget_sub_object_add(parent, obj);
353 elm_widget_data_set(obj, wd);
354 elm_widget_del_hook_set(obj, _del_hook);
355 elm_widget_theme_hook_set(obj, _theme_hook);
357 wd->horizontal = EINA_TRUE;
362 /* supporting aqua feature */
363 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
365 wd->slider = edje_object_add(e);
366 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
367 elm_widget_resize_object_set(obj, wd->slider);
368 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
369 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
370 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
371 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
372 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
373 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
374 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
375 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
376 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
378 wd->spacer = evas_object_rectangle_add(e);
379 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
380 evas_object_pass_events_set(wd->spacer, 1);
381 elm_widget_sub_object_add(obj, wd->spacer);
382 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
384 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
388 // TODO: convert Elementary to subclassing of Evas_Smart_Class
389 // TODO: and save some bytes, making descriptions per-class and not instance!
390 evas_object_smart_callbacks_descriptions_set(obj, _signals);
395 * Set the label of the slider
397 * @param obj The slider object
398 * @param label The text label string in UTF-8
403 elm_slider_label_set(Evas_Object *obj, const char *label)
405 ELM_CHECK_WIDTYPE(obj, widtype);
406 Widget_Data *wd = elm_widget_data_get(obj);
408 eina_stringshare_replace(&wd->label, label);
411 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
412 edje_object_message_signal_process(wd->slider);
416 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
417 edje_object_message_signal_process(wd->slider);
419 edje_object_part_text_set(wd->slider, "elm.text", label);
424 * Get the label of the slider
426 * @param obj The slider object
427 * @return The text label string in UTF-8
432 elm_slider_label_get(const Evas_Object *obj)
434 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
435 Widget_Data *wd = elm_widget_data_get(obj);
436 if (!wd) return NULL;
441 * Set the icon object of the slider object
443 * Once the icon object is set, it will become a child of the slider object and
444 * be deleted when the slider object is deleted. If another icon object is set
445 * then the previous one becomes orophaned and will no longer be deleted along
448 * @param obj The slider object
449 * @param icon The icon object
454 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
456 ELM_CHECK_WIDTYPE(obj, widtype);
457 Widget_Data *wd = elm_widget_data_get(obj);
459 if ((wd->icon != icon) && (wd->icon))
460 elm_widget_sub_object_del(obj, wd->icon);
464 elm_widget_sub_object_add(obj, icon);
465 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
466 _changed_size_hints, obj);
467 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
468 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
474 * Get the icon object of the slider object
476 * @param obj The slider object
477 * @return The icon object
482 elm_slider_icon_get(const Evas_Object *obj)
484 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
485 Widget_Data *wd = elm_widget_data_get(obj);
486 if (!wd) return NULL;
491 * Set the length of the dragable region of the slider
493 * This sets the minimum width or height (depending on orientation) of the
494 * area of the slider that allows the slider to be dragged around. This in
495 * turn affects the objects minimum size (along with icon label and unit
496 * text). Note that this will also get multiplied by the scale factor.
498 * @param obj The slider object
499 * @param size The length of the slider area
504 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
506 ELM_CHECK_WIDTYPE(obj, widtype);
507 Widget_Data *wd = elm_widget_data_get(obj);
509 if (wd->size == size) return;
512 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
514 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
515 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
520 * Get the length of the dragable region of the slider
522 * This gets the minimum width or height (depending on orientation) of
523 * the area of the slider that allows the slider to be dragged
524 * around. Note that this will also get multiplied by the scale
527 * @param obj The slider object
528 * @return The length of the slider area
533 elm_slider_span_size_get(const Evas_Object *obj)
535 ELM_CHECK_WIDTYPE(obj, widtype) 0;
536 Widget_Data *wd = elm_widget_data_get(obj);
542 * Set the format string of the unit area
544 * If NULL, this disabls the unit area display. If not it sets the format
545 * string for the unit text. The unit text is provided a floating point
546 * value, so the unit text can display up to 1 floating point value. Note that
547 * this is optional. Use a format string such as "%1.2f meters" for example.
549 * @param obj The slider object
550 * @param units The format string for the units display
555 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
557 ELM_CHECK_WIDTYPE(obj, widtype);
558 Widget_Data *wd = elm_widget_data_get(obj);
560 eina_stringshare_replace(&wd->units, units);
563 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
564 edje_object_message_signal_process(wd->slider);
568 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
569 edje_object_message_signal_process(wd->slider);
576 * Get the format string for the unit area
578 * The slider may also display a value (the value of the slider) somewhere
579 * (for example above the slider knob that is dragged around). This sets the
580 * format string for this. See elm_slider_unit_format_set() for more
581 * information on how this works.
583 * @param obj The slider object
584 * @return The format string for the unit display.
589 elm_slider_unit_format_get(const Evas_Object *obj)
591 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
592 Widget_Data *wd = elm_widget_data_get(obj);
593 if (!wd) return NULL;
598 * Set the format string for the indicator area
600 * The slider may also display a value (the value of the slider) somewhere
601 * (for example above the slider knob that is dragged around). This sets the
602 * format string for this. See elm_slider_unit_format_set() for more
603 * information on how this works.
605 * @param obj The slider object
606 * @param indicator The format string for the indicator display
611 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
613 ELM_CHECK_WIDTYPE(obj, widtype);
614 Widget_Data *wd = elm_widget_data_get(obj);
616 eina_stringshare_replace(&wd->indicator, indicator);
621 * Get the format string for the indicator area
623 * The slider may also display a value (the value of the slider) somewhere
624 * (for example above the slider knob that is dragged around). This sets the
625 * format string for this. See elm_slider_indicator_format_set() for more
626 * information on how this works.
628 * @param obj The slider object
629 * @return The format string for the indicator display.
634 elm_slider_indicator_format_get(const Evas_Object *obj)
636 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
637 Widget_Data *wd = elm_widget_data_get(obj);
638 if (!wd) return NULL;
639 return wd->indicator;
643 * Set orientation of the slider
645 * @param obj The slider object
646 * @param horizontal If set, the slider will be horizontal
651 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
653 ELM_CHECK_WIDTYPE(obj, widtype);
654 Widget_Data *wd = elm_widget_data_get(obj);
656 horizontal = !!horizontal;
657 if (wd->horizontal == horizontal) return;
658 wd->horizontal = horizontal;
663 * Get orientation of the slider
665 * @param obj The slider object
666 * @return If @c EINA_TRUE the slider will be horizontal, else it is
671 elm_slider_horizontal_get(const Evas_Object *obj)
673 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
674 Widget_Data *wd = elm_widget_data_get(obj);
675 if (!wd) return EINA_FALSE;
676 return wd->horizontal;
680 * Set the minimum and maximum values for the slider
682 * Maximum mut be greater than minimum.
684 * @param obj The slider object
685 * @param min The minimum value
686 * @param max The maximum value
691 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
693 ELM_CHECK_WIDTYPE(obj, widtype);
694 Widget_Data *wd = elm_widget_data_get(obj);
696 if ((wd->val_min == min) && (wd->val_max == max)) return;
700 /* supporting aqua feature */
701 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
703 if (wd->val < wd->val_min) wd->val = wd->val_min;
704 if (wd->val > wd->val_max) wd->val = wd->val_max;
711 * Get the minimum and maximum values for the slider
713 * @param obj The slider object
714 * @param min The pointer to store minimum value, may be @c NULL.
715 * @param max The pointer to store maximum value, may be @c NULL.
720 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
724 ELM_CHECK_WIDTYPE(obj, widtype);
725 Widget_Data *wd = elm_widget_data_get(obj);
727 if (min) *min = wd->val_min;
728 if (max) *max = wd->val_max;
732 * Set the value the slider indicates
734 * @param obj The slider object
735 * @param val The value (must be beween min and max for the slider)
740 elm_slider_value_set(Evas_Object *obj, double val)
742 ELM_CHECK_WIDTYPE(obj, widtype);
743 Widget_Data *wd = elm_widget_data_get(obj);
745 if (wd->val == val) return;
747 if (wd->val < wd->val_min) wd->val = wd->val_min;
748 if (wd->val > wd->val_max) wd->val = wd->val_max;
755 * Get the value the slider has
757 * @param obj The slider object
758 * @return The value of the slider
763 elm_slider_value_get(const Evas_Object *obj)
765 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
766 Widget_Data *wd = elm_widget_data_get(obj);
772 * Invert the slider display
774 * Normally the slider will display and interpret values from low to high
775 * and when horizontal that is left to right. When vertical that is top
776 * to bottom. This inverts this (so from right to left or bottom to top) if
777 * inverted is set to 1.
779 * @param obj The slider object
780 * @param inverted The inverted flag. 1 == inverted, 0 == normal
785 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
787 ELM_CHECK_WIDTYPE(obj, widtype);
788 Widget_Data *wd = elm_widget_data_get(obj);
790 inverted = !!inverted;
791 if (wd->inverted == inverted) return;
792 wd->inverted = inverted;
794 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
796 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
797 edje_object_message_signal_process(wd->slider);
804 * Get if the slider display is inverted (backwards)
806 * @param obj The slider object
807 * @return If @c EINA_TRUE the slider will be inverted.
811 elm_slider_inverted_get(const Evas_Object *obj)
813 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
814 Widget_Data *wd = elm_widget_data_get(obj);
815 if (!wd) return EINA_FALSE;
820 * Set the format function pointer for the inducator area
822 * Set the callback function to format the indicator string.
823 * See elm_slider_indicator_format_set() for more info on how this works.
825 * @param obj The slider object
826 * @param indicator The format string for the indicator display
827 * @param func The indicator format function
832 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
834 ELM_CHECK_WIDTYPE(obj, widtype);
835 Widget_Data *wd = elm_widget_data_get(obj);
837 wd->indicator_format_func = func;
842 //////////////////////////////////////////////////////////////////////////////////////////////////////
843 //////////////////////// supporting aqua feature ///////////////////////////////////////////////////
844 //////////////////////////////////////////////////////////////////////////////////////////////////////
849 * Set the right icon object of the slider object
851 * Once the right icon object is set, it will become a child of the slider object and
852 * be deleted when the slider object is deleted. If another icon object is set
853 * then the previous one becomes orophaned and will no longer be deleted along
856 * @param obj The slider object
857 * @param icon The icon object
859 * @return 1 if icon set succeed, 0 if there is no part for right icon
864 elm_slider_right_icon_set(Evas_Object *obj, Evas_Object *icon)
866 Widget_Data *wd = elm_widget_data_get(obj);
868 if ((wd->r_icon != icon) && (wd->r_icon))
869 elm_widget_sub_object_del(obj, wd->r_icon);
873 if ( !(edje_object_part_swallow(wd->slider, "right_icon", icon)) )
876 elm_widget_sub_object_add(obj, icon);
877 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
878 _changed_size_hints, obj);
879 edje_object_signal_emit(wd->slider, "elm,state,ricon,visible", "elm");
888 * Get the right icon object of the slider object
890 * @param obj The slider object
891 * @return The right icon object
896 elm_slider_right_icon_get(Evas_Object *obj)
898 Widget_Data *wd = elm_widget_data_get(obj);
899 if (!wd) return NULL;
905 * Set whether showing the number(indicator) or not.
907 * @param obj The slider object
908 * @param show 1 will show the number, 0 will not.
913 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
915 Widget_Data *wd = elm_widget_data_get(obj);
917 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
919 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
924 static _mv_timer_cb(void *data)
926 Evas_Object* obj = (Evas_Object*)data;
927 Widget_Data *wd = elm_widget_data_get(obj);
929 if (!wd) return EINA_TRUE;
931 if(wd->src_val < wd->des_val) {
932 wd->src_val += wd->mv_step;
933 if(wd-> src_val > wd->des_val)
934 wd->src_val = wd->des_val;
937 else if (wd->src_val > wd->des_val) {
938 wd->src_val -= wd->mv_step;
939 if(wd->src_val < wd->des_val)
940 wd->src_val = wd->des_val;
943 elm_slider_value_set(obj, wd->src_val);
944 evas_object_smart_callback_call(obj, "changed", NULL);
946 if (wd->val == wd->des_val ) {
948 ecore_timer_del(wd->mv_timer);
959 * Move the thumb to the specified value.
961 * This is different with elm_slider_value_set() in animated moving.
963 * @param obj The slider object
964 * @param val thumb's destination value.
969 elm_slider_value_animated_set(Evas_Object *obj, double val)
971 Widget_Data *wd = elm_widget_data_get(obj);
973 if (wd->val == val) return;
975 wd->src_val = wd->val;
977 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
978 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
981 ecore_timer_del(wd->mv_timer);
985 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);