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 Ecore_Timer *mv_timer;
70 #define SLIDER_THUMB_MOVE_STEP 100
72 static void _del_hook(Evas_Object *obj);
73 static void _theme_hook(Evas_Object *obj);
74 static void _sizing_eval(Evas_Object *obj);
75 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
76 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
77 static void _units_set(Evas_Object *obj);
78 static void _indicator_set(Evas_Object *obj);
79 static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
82 static Eina_Bool _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 && obj != wd->e_icon) return;
179 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
181 Widget_Data *wd = elm_widget_data_get(obj);
182 Evas_Object *sub = event_info;
186 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
187 evas_object_event_callback_del_full
188 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
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 /* delete thumb move timer when drag event occured to the moving thumb */
295 ecore_timer_del(wd->mv_timer);
298 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
299 edje_object_message_signal_process(wd->slider);
302 _indicator_set(data);
306 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
308 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
309 /* delete thumb move timer when drag event occured to the moving thumb */
312 ecore_timer_del(wd->mv_timer);
315 elm_widget_scroll_hold_push(data);
317 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
318 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
319 edje_object_message_signal_process(wd->slider);
321 _indicator_set(data);
325 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
327 elm_widget_scroll_hold_pop(data);
329 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
331 _indicator_set(data);
335 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
337 Widget_Data *wd = elm_widget_data_get(data);
338 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
342 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
344 Widget_Data *wd = elm_widget_data_get(data);
345 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
349 _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
351 Widget_Data *wd = elm_widget_data_get(data);
352 Evas_Event_Mouse_Down *ev = event_info;
353 Evas_Coord x, y, w, h;
354 double button_x, button_y;
356 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
357 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
359 button_x = ((double)ev->output.x - (double)x) / (double)w;
366 button_y = ((double)ev->output.y - (double)y) / (double)h;
372 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
373 // evas_object_smart_callback_call(cp->parent, "clicked", NULL);
374 evas_event_feed_mouse_cancel(e, 0, NULL);
375 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
378 static const char*widtype = NULL;
381 * Add a new slider to the parent
383 * @param parent The parent object
384 * @return The new object or NULL if it cannot be created
389 elm_slider_add(Evas_Object *parent)
395 wd = ELM_NEW(Widget_Data);
396 e = evas_object_evas_get(parent);
397 obj = elm_widget_add(e);
398 ELM_SET_WIDTYPE(widtype, "slider");
399 elm_widget_type_set(obj, "slider");
400 elm_widget_sub_object_add(parent, obj);
401 elm_widget_data_set(obj, wd);
402 elm_widget_del_hook_set(obj, _del_hook);
403 elm_widget_theme_hook_set(obj, _theme_hook);
405 wd->horizontal = EINA_TRUE;
410 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
412 wd->slider = edje_object_add(e);
413 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
414 elm_widget_resize_object_set(obj, wd->slider);
415 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
416 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
417 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
418 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
419 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
420 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
421 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
422 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
423 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
425 wd->spacer = evas_object_rectangle_add(e);
426 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
427 evas_object_pass_events_set(wd->spacer, 1);
428 elm_widget_sub_object_add(obj, wd->spacer);
429 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
430 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
432 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
436 // TODO: convert Elementary to subclassing of Evas_Smart_Class
437 // TODO: and save some bytes, making descriptions per-class and not instance!
438 evas_object_smart_callbacks_descriptions_set(obj, _signals);
443 * Set the label of the slider
445 * @param obj The slider object
446 * @param label The text label string in UTF-8
451 elm_slider_label_set(Evas_Object *obj, const char *label)
453 ELM_CHECK_WIDTYPE(obj, widtype);
454 Widget_Data *wd = elm_widget_data_get(obj);
456 eina_stringshare_replace(&wd->label, label);
459 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
460 edje_object_message_signal_process(wd->slider);
464 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
465 edje_object_message_signal_process(wd->slider);
467 edje_object_part_text_set(wd->slider, "elm.text", label);
472 * Get the label of the slider
474 * @param obj The slider object
475 * @return The text label string in UTF-8
480 elm_slider_label_get(const Evas_Object *obj)
482 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
483 Widget_Data *wd = elm_widget_data_get(obj);
484 if (!wd) return NULL;
489 * Set the icon object of the slider object
491 * Once the icon object is set, it will become a child of the slider object and
492 * be deleted when the slider object is deleted. If another icon object is set
493 * then the previous one becomes orophaned and will no longer be deleted along
496 * @param obj The slider object
497 * @param icon The icon object
502 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
504 ELM_CHECK_WIDTYPE(obj, widtype);
505 Widget_Data *wd = elm_widget_data_get(obj);
507 if ((wd->icon != icon) && (wd->icon))
508 elm_widget_sub_object_del(obj, wd->icon);
512 elm_widget_sub_object_add(obj, icon);
513 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
514 _changed_size_hints, obj);
515 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
516 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
522 * Get the icon object of the slider object
524 * @param obj The slider object
525 * @return The icon object
530 elm_slider_icon_get(const Evas_Object *obj)
532 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
533 Widget_Data *wd = elm_widget_data_get(obj);
534 if (!wd) return NULL;
539 * Set the length of the dragable region of the slider
541 * This sets the minimum width or height (depending on orientation) of the
542 * area of the slider that allows the slider to be dragged around. This in
543 * turn affects the objects minimum size (along with icon label and unit
544 * text). Note that this will also get multiplied by the scale factor.
546 * @param obj The slider object
547 * @param size The length of the slider area
552 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
554 ELM_CHECK_WIDTYPE(obj, widtype);
555 Widget_Data *wd = elm_widget_data_get(obj);
557 if (wd->size == size) return;
560 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
562 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
563 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
568 * Get the length of the dragable region of the slider
570 * This gets the minimum width or height (depending on orientation) of
571 * the area of the slider that allows the slider to be dragged
572 * around. Note that this will also get multiplied by the scale
575 * @param obj The slider object
576 * @return The length of the slider area
581 elm_slider_span_size_get(const Evas_Object *obj)
583 ELM_CHECK_WIDTYPE(obj, widtype) 0;
584 Widget_Data *wd = elm_widget_data_get(obj);
590 * Set the format string of the unit area
592 * If NULL, this disabls the unit area display. If not it sets the format
593 * string for the unit text. The unit text is provided a floating point
594 * value, so the unit text can display up to 1 floating point value. Note that
595 * this is optional. Use a format string such as "%1.2f meters" for example.
597 * @param obj The slider object
598 * @param units The format string for the units display
603 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
605 ELM_CHECK_WIDTYPE(obj, widtype);
606 Widget_Data *wd = elm_widget_data_get(obj);
608 eina_stringshare_replace(&wd->units, units);
611 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
612 edje_object_message_signal_process(wd->slider);
616 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
617 edje_object_message_signal_process(wd->slider);
624 * Get the format string for the unit area
626 * The slider may also display a value (the value of the slider) somewhere
627 * (for example above the slider knob that is dragged around). This sets the
628 * format string for this. See elm_slider_unit_format_set() for more
629 * information on how this works.
631 * @param obj The slider object
632 * @return The format string for the unit display.
637 elm_slider_unit_format_get(const Evas_Object *obj)
639 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
640 Widget_Data *wd = elm_widget_data_get(obj);
641 if (!wd) return NULL;
646 * Set the format string for the indicator area
648 * The slider may also display a value (the value of the slider) somewhere
649 * (for example above the slider knob that is dragged around). This sets the
650 * format string for this. See elm_slider_unit_format_set() for more
651 * information on how this works.
653 * @param obj The slider object
654 * @param indicator The format string for the indicator display
659 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
661 ELM_CHECK_WIDTYPE(obj, widtype);
662 Widget_Data *wd = elm_widget_data_get(obj);
664 eina_stringshare_replace(&wd->indicator, indicator);
669 * Get the format string for the indicator area
671 * The slider may also display a value (the value of the slider) somewhere
672 * (for example above the slider knob that is dragged around). This sets the
673 * format string for this. See elm_slider_indicator_format_set() for more
674 * information on how this works.
676 * @param obj The slider object
677 * @return The format string for the indicator display.
682 elm_slider_indicator_format_get(const Evas_Object *obj)
684 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
685 Widget_Data *wd = elm_widget_data_get(obj);
686 if (!wd) return NULL;
687 return wd->indicator;
691 * Set orientation of the slider
693 * @param obj The slider object
694 * @param horizontal If set, the slider will be horizontal
699 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
701 ELM_CHECK_WIDTYPE(obj, widtype);
702 Widget_Data *wd = elm_widget_data_get(obj);
704 horizontal = !!horizontal;
705 if (wd->horizontal == horizontal) return;
706 wd->horizontal = horizontal;
711 * Get orientation of the slider
713 * @param obj The slider object
714 * @return If @c EINA_TRUE the slider will be horizontal, else it is
719 elm_slider_horizontal_get(const Evas_Object *obj)
721 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
722 Widget_Data *wd = elm_widget_data_get(obj);
723 if (!wd) return EINA_FALSE;
724 return wd->horizontal;
728 * Set the minimum and maximum values for the slider
730 * Maximum mut be greater than minimum.
732 * @param obj The slider object
733 * @param min The minimum value
734 * @param max The maximum value
739 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
741 ELM_CHECK_WIDTYPE(obj, widtype);
742 Widget_Data *wd = elm_widget_data_get(obj);
744 if ((wd->val_min == min) && (wd->val_max == max)) return;
748 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
750 if (wd->val < wd->val_min) wd->val = wd->val_min;
751 if (wd->val > wd->val_max) wd->val = wd->val_max;
758 * Get the minimum and maximum values for the slider
760 * @param obj The slider object
761 * @param min The pointer to store minimum value, may be @c NULL.
762 * @param max The pointer to store maximum value, may be @c NULL.
767 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
771 ELM_CHECK_WIDTYPE(obj, widtype);
772 Widget_Data *wd = elm_widget_data_get(obj);
774 if (min) *min = wd->val_min;
775 if (max) *max = wd->val_max;
779 * Set the value the slider indicates
781 * @param obj The slider object
782 * @param val The value (must be beween min and max for the slider)
787 elm_slider_value_set(Evas_Object *obj, double val)
789 ELM_CHECK_WIDTYPE(obj, widtype);
790 Widget_Data *wd = elm_widget_data_get(obj);
792 if (wd->val == val) return;
794 if (wd->val < wd->val_min) wd->val = wd->val_min;
795 if (wd->val > wd->val_max) wd->val = wd->val_max;
802 * Get the value the slider has
804 * @param obj The slider object
805 * @return The value of the slider
810 elm_slider_value_get(const Evas_Object *obj)
812 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
813 Widget_Data *wd = elm_widget_data_get(obj);
819 * Invert the slider display
821 * Normally the slider will display and interpret values from low to high
822 * and when horizontal that is left to right. When vertical that is top
823 * to bottom. This inverts this (so from right to left or bottom to top) if
824 * inverted is set to 1.
826 * @param obj The slider object
827 * @param inverted The inverted flag. 1 == inverted, 0 == normal
832 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
834 ELM_CHECK_WIDTYPE(obj, widtype);
835 Widget_Data *wd = elm_widget_data_get(obj);
837 inverted = !!inverted;
838 if (wd->inverted == inverted) return;
839 wd->inverted = inverted;
841 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
843 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
844 edje_object_message_signal_process(wd->slider);
851 * Get if the slider display is inverted (backwards)
853 * @param obj The slider object
854 * @return If @c EINA_TRUE the slider will be inverted.
858 elm_slider_inverted_get(const Evas_Object *obj)
860 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
861 Widget_Data *wd = elm_widget_data_get(obj);
862 if (!wd) return EINA_FALSE;
867 * Set the format function pointer for the inducator area
869 * Set the callback function to format the indicator string.
870 * See elm_slider_indicator_format_set() for more info on how this works.
872 * @param obj The slider object
873 * @param indicator The format string for the indicator display
874 * @param func The indicator format function
879 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
881 ELM_CHECK_WIDTYPE(obj, widtype);
882 Widget_Data *wd = elm_widget_data_get(obj);
884 wd->indicator_format_func = func;
889 //////////////////////////////////////////////////////////////////////////////////////////////////////
890 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
891 //////////////////////////////////////////////////////////////////////////////////////////////////////
896 * Set the right icon object of the slider object
898 * Once the right icon object is set, it will become a child of the slider object and
899 * be deleted when the slider object is deleted. If another icon object is set
900 * then the previous one becomes orophaned and will no longer be deleted along
903 * @param obj The slider object
904 * @param icon The icon object
906 * @return 1 if icon set succeed, 0 if there is no part for right icon
911 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
913 Widget_Data *wd = elm_widget_data_get(obj);
915 if ((wd->e_icon != icon) && (wd->e_icon))
916 elm_widget_sub_object_del(obj, wd->e_icon);
920 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
923 elm_widget_sub_object_add(obj, icon);
924 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
925 _changed_size_hints, obj);
926 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
935 * Get the right icon object of the slider object
937 * @param obj The slider object
938 * @return The right icon object
943 elm_slider_end_icon_get(Evas_Object *obj)
945 Widget_Data *wd = elm_widget_data_get(obj);
946 if (!wd) return NULL;
952 * Set whether showing the number(indicator) or not.
954 * @param obj The slider object
955 * @param show 1 will show the number, 0 will not.
960 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
962 Widget_Data *wd = elm_widget_data_get(obj);
964 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
966 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
969 static Eina_Bool _mv_timer_cb(void *data)
971 Evas_Object* obj = (Evas_Object*)data;
972 Widget_Data *wd = elm_widget_data_get(obj);
974 if (!wd) return EINA_TRUE;
976 if(wd->src_val < wd->des_val)
978 wd->src_val += wd->mv_step;
979 if(wd-> src_val > wd->des_val)
980 wd->src_val = wd->des_val;
982 else if (wd->src_val > wd->des_val)
984 wd->src_val -= wd->mv_step;
985 if(wd->src_val < wd->des_val)
986 wd->src_val = wd->des_val;
989 elm_slider_value_set(obj, wd->src_val);
990 evas_object_smart_callback_call(obj, "changed", NULL);
992 if (wd->val == wd->des_val)
996 ecore_timer_del(wd->mv_timer);
1007 * Move the thumb to the specified value.
1009 * This is different with elm_slider_value_set() in animated moving.
1011 * @param obj The slider object
1012 * @param val thumb's destination value.
1017 elm_slider_value_animated_set(Evas_Object *obj, double val)
1019 Widget_Data *wd = elm_widget_data_get(obj);
1021 if (wd->val == val) return;
1023 wd->src_val = wd->val;
1025 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
1026 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
1030 ecore_timer_del(wd->mv_timer);
1031 wd->mv_timer = NULL;
1034 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1039 * Set the label of the slider
1041 * @param obj The slider object
1042 * @param label The text label string in UTF-8
1047 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1049 ELM_CHECK_WIDTYPE(obj, widtype);
1050 Widget_Data *wd = elm_widget_data_get(obj);
1052 eina_stringshare_replace(&wd->e_label, label);
1055 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1056 edje_object_message_signal_process(wd->slider);
1060 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1061 edje_object_message_signal_process(wd->slider);
1063 edje_object_part_text_set(wd->slider, "elm.units", label);
1070 * Get the label of the slider
1072 * @param obj The slider object
1073 * @return The text label string in UTF-8
1078 elm_slider_end_label_get(const Evas_Object *obj)
1080 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1081 Widget_Data *wd = elm_widget_data_get(obj);
1082 if (!wd) return NULL;