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;
61 double val, val_min, val_max;
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);
80 static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
83 static Eina_Bool _mv_timer_cb(void *data);
85 static const char SIG_CHANGED[] = "changed";
86 static const char SIG_DELAY_CHANGED[] = "delay,changed";
87 static const char SIG_DRAG_START[] = "slider,drag,start";
88 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
89 static const Evas_Smart_Cb_Description _signals[] = {
91 {SIG_DELAY_CHANGED, ""},
98 _del_hook(Evas_Object *obj)
100 Widget_Data *wd = elm_widget_data_get(obj);
102 if (wd->label) eina_stringshare_del(wd->label);
103 if (wd->e_label) eina_stringshare_del(wd->label);
104 if (wd->indicator) eina_stringshare_del(wd->units);
105 if (wd->delay) ecore_timer_del(wd->delay);
110 _theme_hook(Evas_Object *obj)
112 Widget_Data *wd = elm_widget_data_get(obj);
115 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
117 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
119 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
121 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
123 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
125 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
127 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
129 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
131 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
133 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
134 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
136 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
138 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
139 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
141 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
143 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
145 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
147 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
148 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
150 edje_object_message_signal_process(wd->slider);
151 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
156 _sizing_eval(Evas_Object *obj)
158 Widget_Data *wd = elm_widget_data_get(obj);
159 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
161 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
162 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
163 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
164 evas_object_size_hint_min_set(obj, minw, minh);
165 evas_object_size_hint_max_set(obj, maxw, maxh);
169 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
171 Widget_Data *wd = elm_widget_data_get(data);
174 if (obj != wd->icon && obj != wd->e_icon) return;
180 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
182 Widget_Data *wd = elm_widget_data_get(obj);
183 Evas_Object *sub = event_info;
187 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
188 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
190 edje_object_message_signal_process(wd->slider);
193 if (sub == wd->e_icon)
195 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
196 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
203 _delay_change(void *data)
205 Widget_Data *wd = elm_widget_data_get(data);
206 if (!wd) return ECORE_CALLBACK_CANCEL;
208 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
209 return ECORE_CALLBACK_CANCEL;
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", &posx, &posy);
219 if (wd->horizontal) pos = posx;
221 if (wd->inverted) pos = 1.0 - pos;
222 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
226 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
227 if (wd->delay) ecore_timer_del(wd->delay);
228 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
233 _val_set(Evas_Object *obj)
235 Widget_Data *wd = elm_widget_data_get(obj);
238 if (wd->val_max > wd->val_min)
239 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
242 if (pos < 0.0) pos = 0.0;
243 else if (pos > 1.0) pos = 1.0;
244 if (wd->inverted) pos = 1.0 - pos;
245 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
249 _units_set(Evas_Object *obj)
251 Widget_Data *wd = elm_widget_data_get(obj);
256 snprintf(buf, sizeof(buf), wd->units, wd->val);
257 edje_object_part_text_set(wd->slider, "elm.units", buf);
259 else if (wd->e_label)
260 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
262 edje_object_part_text_set(wd->slider, "elm.units", NULL);
266 _indicator_set(Evas_Object *obj)
268 Widget_Data *wd = elm_widget_data_get(obj);
270 if (wd->indicator_format_func)
273 buf = wd->indicator_format_func(wd->val);
274 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
276 else if (wd->indicator)
279 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
280 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
283 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
287 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
289 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
290 /* delete thumb move timer when drag event occured to the moving thumb */
293 ecore_timer_del(wd->mv_timer);
296 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
297 edje_object_message_signal_process(wd->slider);
300 _indicator_set(data);
304 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
306 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
307 /* delete thumb move timer when drag event occured to the moving thumb */
310 ecore_timer_del(wd->mv_timer);
313 elm_widget_scroll_hold_push(data);
315 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
316 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
317 edje_object_message_signal_process(wd->slider);
319 _indicator_set(data);
323 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
325 elm_widget_scroll_hold_pop(data);
327 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
329 _indicator_set(data);
333 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
335 Widget_Data *wd = elm_widget_data_get(data);
336 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
340 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
342 Widget_Data *wd = elm_widget_data_get(data);
343 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
347 _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
349 Widget_Data *wd = elm_widget_data_get(data);
350 Evas_Event_Mouse_Down *ev = event_info;
351 Evas_Coord x, y, w, h;
352 double button_x, button_y;
354 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
355 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
358 button_x = ((double)ev->output.x - (double)x) / (double)w;
359 if (button_x > 1) button_x = 1;
360 if (button_x < 0) button_x = 0;
364 button_y = ((double)ev->output.y - (double)y) / (double)h;
365 if (button_y > 1) button_y = 1;
366 if (button_y < 0) button_y = 0;
368 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
369 evas_event_feed_mouse_cancel(e, 0, NULL);
372 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
376 static const char*widtype = NULL;
379 * Add a new slider to the parent
381 * @param parent The parent object
382 * @return The new object or NULL if it cannot be created
387 elm_slider_add(Evas_Object *parent)
393 e = evas_object_evas_get(parent);
394 if (e == NULL) return NULL;
395 wd = ELM_NEW(Widget_Data);
396 obj = elm_widget_add(e);
397 ELM_SET_WIDTYPE(widtype, "slider");
398 elm_widget_type_set(obj, "slider");
399 elm_widget_sub_object_add(parent, obj);
400 elm_widget_data_set(obj, wd);
401 elm_widget_del_hook_set(obj, _del_hook);
402 elm_widget_theme_hook_set(obj, _theme_hook);
404 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, a previously set one will be deleted.
493 * @param obj The slider object
494 * @param icon The icon object
499 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
501 ELM_CHECK_WIDTYPE(obj, widtype);
502 Widget_Data *wd = elm_widget_data_get(obj);
504 if (wd->icon == icon) return;
505 if (wd->icon) evas_object_del(wd->icon);
509 elm_widget_sub_object_add(obj, icon);
510 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
511 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
512 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
513 edje_object_message_signal_process(wd->slider);
519 * Get the icon object of the slider object
521 * @param obj The slider object
522 * @return The icon object
527 elm_slider_icon_get(const Evas_Object *obj)
529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
530 Widget_Data *wd = elm_widget_data_get(obj);
531 if (!wd) return NULL;
536 * Set the length of the dragable region of the slider
538 * This sets the minimum width or height (depending on orientation) of the
539 * area of the slider that allows the slider to be dragged around. This in
540 * turn affects the objects minimum size (along with icon label and unit
541 * text). Note that this will also get multiplied by the scale factor.
543 * @param obj The slider object
544 * @param size The length of the slider area
549 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
551 ELM_CHECK_WIDTYPE(obj, widtype);
552 Widget_Data *wd = elm_widget_data_get(obj);
554 if (wd->size == size) return;
557 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
559 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
560 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
565 * Get the length of the dragable region of the slider
567 * This gets the minimum width or height (depending on orientation) of
568 * the area of the slider that allows the slider to be dragged
569 * around. Note that this will also get multiplied by the scale
572 * @param obj The slider object
573 * @return The length of the slider area
578 elm_slider_span_size_get(const Evas_Object *obj)
580 ELM_CHECK_WIDTYPE(obj, widtype) 0;
581 Widget_Data *wd = elm_widget_data_get(obj);
587 * Set the format string of the unit area
589 * If NULL, this disabls the unit area display. If not it sets the format
590 * string for the unit text. The unit text is provided a floating point
591 * value, so the unit text can display up to 1 floating point value. Note that
592 * this is optional. Use a format string such as "%1.2f meters" for example.
594 * @param obj The slider object
595 * @param units The format string for the units display
600 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
602 ELM_CHECK_WIDTYPE(obj, widtype);
603 Widget_Data *wd = elm_widget_data_get(obj);
605 eina_stringshare_replace(&wd->units, units);
608 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
609 edje_object_message_signal_process(wd->slider);
613 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
614 edje_object_message_signal_process(wd->slider);
621 * Get the format string for the unit 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_unit_format_set() for more
626 * information on how this works.
628 * @param obj The slider object
629 * @return The format string for the unit display.
634 elm_slider_unit_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;
643 * Set the format string for the indicator area
645 * The slider may also display a value (the value of the slider) somewhere
646 * (for example above the slider knob that is dragged around). This sets the
647 * format string for this. See elm_slider_unit_format_set() for more
648 * information on how this works.
650 * @param obj The slider object
651 * @param indicator The format string for the indicator display
656 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
658 ELM_CHECK_WIDTYPE(obj, widtype);
659 Widget_Data *wd = elm_widget_data_get(obj);
661 eina_stringshare_replace(&wd->indicator, indicator);
666 * Get the format string for the indicator area
668 * The slider may also display a value (the value of the slider) somewhere
669 * (for example above the slider knob that is dragged around). This sets the
670 * format string for this. See elm_slider_indicator_format_set() for more
671 * information on how this works.
673 * @param obj The slider object
674 * @return The format string for the indicator display.
679 elm_slider_indicator_format_get(const Evas_Object *obj)
681 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
682 Widget_Data *wd = elm_widget_data_get(obj);
683 if (!wd) return NULL;
684 return wd->indicator;
688 * Set orientation of the slider
690 * @param obj The slider object
691 * @param horizontal If set, the slider will be horizontal
696 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
698 ELM_CHECK_WIDTYPE(obj, widtype);
699 Widget_Data *wd = elm_widget_data_get(obj);
701 horizontal = !!horizontal;
702 if (wd->horizontal == horizontal) return;
703 wd->horizontal = horizontal;
708 * Get orientation of the slider
710 * @param obj The slider object
711 * @return If @c EINA_TRUE the slider will be horizontal, else it is
716 elm_slider_horizontal_get(const Evas_Object *obj)
718 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
719 Widget_Data *wd = elm_widget_data_get(obj);
720 if (!wd) return EINA_FALSE;
721 return wd->horizontal;
725 * Set the minimum and maximum values for the slider
727 * Maximum mut be greater than minimum.
729 * @param obj The slider object
730 * @param min The minimum value
731 * @param max The maximum value
736 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
738 ELM_CHECK_WIDTYPE(obj, widtype);
739 Widget_Data *wd = elm_widget_data_get(obj);
741 if ((wd->val_min == min) && (wd->val_max == max)) return;
745 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
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 minimum and maximum values for the slider
757 * @param obj The slider object
758 * @param min The pointer to store minimum value, may be @c NULL.
759 * @param max The pointer to store maximum value, may be @c NULL.
764 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
768 ELM_CHECK_WIDTYPE(obj, widtype);
769 Widget_Data *wd = elm_widget_data_get(obj);
771 if (min) *min = wd->val_min;
772 if (max) *max = wd->val_max;
776 * Set the value the slider indicates
778 * @param obj The slider object
779 * @param val The value (must be beween min and max for the slider)
784 elm_slider_value_set(Evas_Object *obj, double val)
786 ELM_CHECK_WIDTYPE(obj, widtype);
787 Widget_Data *wd = elm_widget_data_get(obj);
789 if (wd->val == val) return;
791 if (wd->val < wd->val_min) wd->val = wd->val_min;
792 if (wd->val > wd->val_max) wd->val = wd->val_max;
793 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
800 * Get the value the slider has
802 * @param obj The slider object
803 * @return The value of the slider
808 elm_slider_value_get(const Evas_Object *obj)
810 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
811 Widget_Data *wd = elm_widget_data_get(obj);
817 * Invert the slider display
819 * Normally the slider will display and interpret values from low to high
820 * and when horizontal that is left to right. When vertical that is top
821 * to bottom. This inverts this (so from right to left or bottom to top) if
822 * inverted is set to 1.
824 * @param obj The slider object
825 * @param inverted The inverted flag. 1 == inverted, 0 == normal
830 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
832 ELM_CHECK_WIDTYPE(obj, widtype);
833 Widget_Data *wd = elm_widget_data_get(obj);
835 inverted = !!inverted;
836 if (wd->inverted == inverted) return;
837 wd->inverted = inverted;
839 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
841 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
842 edje_object_message_signal_process(wd->slider);
849 * Get if the slider display is inverted (backwards)
851 * @param obj The slider object
852 * @return If @c EINA_TRUE the slider will be inverted.
856 elm_slider_inverted_get(const Evas_Object *obj)
858 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
859 Widget_Data *wd = elm_widget_data_get(obj);
860 if (!wd) return EINA_FALSE;
865 * Set the format function pointer for the inducator area
867 * Set the callback function to format the indicator string.
868 * See elm_slider_indicator_format_set() for more info on how this works.
870 * @param obj The slider object
871 * @param indicator The format string for the indicator display
872 * @param func The indicator format function
877 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
879 ELM_CHECK_WIDTYPE(obj, widtype);
880 Widget_Data *wd = elm_widget_data_get(obj);
882 wd->indicator_format_func = func;
887 //////////////////////////////////////////////////////////////////////////////////////////////////////
888 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
889 //////////////////////////////////////////////////////////////////////////////////////////////////////
894 * Set the end side icon object of the slider object
896 * Once the end side icon object is set, it will become a child of the slider object and
897 * be deleted when the slider object is deleted. If another icon object is set
898 * then the previous one becomes orophaned and will no longer be deleted along
901 * @param obj The slider object
902 * @param icon The icon object
904 * @return 1 if icon set succeed, 0 if there is no part for the end side icon
909 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
911 Widget_Data *wd = elm_widget_data_get(obj);
913 if ((wd->e_icon != icon) && (wd->e_icon))
914 elm_widget_sub_object_del(obj, wd->e_icon);
918 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
921 elm_widget_sub_object_add(obj, icon);
922 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,_changed_size_hints, obj);
923 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");_sizing_eval(obj);
931 * Get the end side icon object of the slider object
933 * @param obj The slider object
934 * @return The end side icon object
939 elm_slider_end_icon_get(Evas_Object *obj)
941 Widget_Data *wd = elm_widget_data_get(obj);
942 if (!wd) return NULL;
948 * Set whether showing the number(indicator) or not.
950 * @param obj The slider object
951 * @param show 1 will show the number, 0 will not.
956 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
958 Widget_Data *wd = elm_widget_data_get(obj);
961 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
963 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
967 _mv_timer_cb(void *data)
969 Evas_Object* obj = (Evas_Object*)data;
970 Widget_Data *wd = elm_widget_data_get(obj);
974 if(wd->src_val < wd->des_val)
976 wd->src_val += wd->mv_step;
977 if(wd-> src_val > wd->des_val)
978 wd->src_val = wd->des_val;
980 else if (wd->src_val > wd->des_val)
982 wd->src_val -= wd->mv_step;
983 if(wd->src_val < wd->des_val)
984 wd->src_val = wd->des_val;
987 elm_slider_value_set(obj, wd->src_val);
988 evas_object_smart_callback_call(obj, SIG_CHANGED , NULL);
990 if (wd->val == wd->des_val)
994 ecore_timer_del(wd->mv_timer);
1005 * Move the thumb to the specified value.
1007 * This is different with elm_slider_value_set() in animated moving.
1009 * @param obj The slider object
1010 * @param val thumb's destination value.
1015 elm_slider_value_animated_set(Evas_Object *obj, double val)
1017 Widget_Data *wd = elm_widget_data_get(obj);
1019 if (wd->val == val) return;
1021 wd->src_val = wd->val;
1023 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
1024 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
1028 ecore_timer_del(wd->mv_timer);
1029 wd->mv_timer = NULL;
1032 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1037 * Set the end side label of the slider
1039 * @param obj The slider object
1040 * @param label The text label string in UTF-8
1045 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1047 ELM_CHECK_WIDTYPE(obj, widtype);
1048 Widget_Data *wd = elm_widget_data_get(obj);
1050 eina_stringshare_replace(&wd->e_label, label);
1053 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1054 edje_object_message_signal_process(wd->slider);
1058 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1059 edje_object_message_signal_process(wd->slider);
1061 edje_object_part_text_set(wd->slider, "elm.units", label);
1068 * Get the end side label of the slider
1070 * @param obj The slider object
1071 * @return The text label string in UTF-8
1076 elm_slider_end_label_get(const Evas_Object *obj)
1078 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1079 Widget_Data *wd = elm_widget_data_get(obj);
1080 if (!wd) return NULL;