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
189 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
191 edje_object_message_signal_process(wd->slider);
194 if (sub == wd->e_icon)
196 edje_object_signal_emit(wd->slider, "elm,state,eicon,hidden", "elm");
197 evas_object_event_callback_del_full
198 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
205 _delay_change(void *data)
207 Widget_Data *wd = elm_widget_data_get(data);
208 if (!wd) return ECORE_CALLBACK_CANCEL;
210 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
211 return ECORE_CALLBACK_CANCEL;
215 _val_fetch(Evas_Object *obj)
217 Widget_Data *wd = elm_widget_data_get(obj);
218 double posx = 0.0, posy = 0.0, pos = 0.0, val;
220 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
222 if (wd->horizontal) pos = posx;
224 if (wd->inverted) pos = 1.0 - pos;
225 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
229 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
230 if (wd->delay) ecore_timer_del(wd->delay);
231 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
236 _val_set(Evas_Object *obj)
238 Widget_Data *wd = elm_widget_data_get(obj);
241 if (wd->val_max > wd->val_min)
242 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
245 if (pos < 0.0) pos = 0.0;
246 else if (pos > 1.0) pos = 1.0;
247 if (wd->inverted) pos = 1.0 - pos;
248 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
252 _units_set(Evas_Object *obj)
254 Widget_Data *wd = elm_widget_data_get(obj);
260 snprintf(buf, sizeof(buf), wd->units, wd->val);
261 edje_object_part_text_set(wd->slider, "elm.units", buf);
263 else if (wd->e_label)
264 edje_object_part_text_set(wd->slider, "elm.units", wd->e_label);
266 edje_object_part_text_set(wd->slider, "elm.units", NULL);
270 _indicator_set(Evas_Object *obj)
272 Widget_Data *wd = elm_widget_data_get(obj);
274 if (wd->indicator_format_func)
277 buf = wd->indicator_format_func(wd->val);
278 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
280 else if (wd->indicator)
283 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
284 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
287 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
291 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
293 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
294 /* delete thumb move timer when drag event occured to the moving thumb */
297 ecore_timer_del(wd->mv_timer);
300 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
301 edje_object_message_signal_process(wd->slider);
304 _indicator_set(data);
308 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
310 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
311 /* delete thumb move timer when drag event occured to the moving thumb */
314 ecore_timer_del(wd->mv_timer);
317 elm_widget_scroll_hold_push(data);
319 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
320 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
321 edje_object_message_signal_process(wd->slider);
323 _indicator_set(data);
327 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
329 elm_widget_scroll_hold_pop(data);
331 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
333 _indicator_set(data);
337 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
339 Widget_Data *wd = elm_widget_data_get(data);
340 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
344 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
346 Widget_Data *wd = elm_widget_data_get(data);
347 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
351 _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
353 Widget_Data *wd = elm_widget_data_get(data);
354 Evas_Event_Mouse_Down *ev = event_info;
355 Evas_Coord x, y, w, h;
356 double button_x, button_y;
358 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
359 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
361 button_x = ((double)ev->output.x - (double)x) / (double)w;
368 button_y = ((double)ev->output.y - (double)y) / (double)h;
374 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
375 evas_event_feed_mouse_cancel(e, 0, NULL);
378 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
382 static const char*widtype = NULL;
385 * Add a new slider to the parent
387 * @param parent The parent object
388 * @return The new object or NULL if it cannot be created
393 elm_slider_add(Evas_Object *parent)
399 e = evas_object_evas_get(parent);
400 if (e == NULL) return NULL;
401 wd = ELM_NEW(Widget_Data);
402 obj = elm_widget_add(e);
403 ELM_SET_WIDTYPE(widtype, "slider");
404 elm_widget_type_set(obj, "slider");
405 elm_widget_sub_object_add(parent, obj);
406 elm_widget_data_set(obj, wd);
407 elm_widget_del_hook_set(obj, _del_hook);
408 elm_widget_theme_hook_set(obj, _theme_hook);
410 wd->horizontal = EINA_TRUE;
416 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
418 wd->slider = edje_object_add(e);
419 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
420 elm_widget_resize_object_set(obj, wd->slider);
421 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
422 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
423 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
424 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
425 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
426 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
427 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
428 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
429 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
431 wd->spacer = evas_object_rectangle_add(e);
432 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
433 evas_object_pass_events_set(wd->spacer, 1);
434 elm_widget_sub_object_add(obj, wd->spacer);
435 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
436 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
438 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
442 // TODO: convert Elementary to subclassing of Evas_Smart_Class
443 // TODO: and save some bytes, making descriptions per-class and not instance!
444 evas_object_smart_callbacks_descriptions_set(obj, _signals);
449 * Set the label of the slider
451 * @param obj The slider object
452 * @param label The text label string in UTF-8
457 elm_slider_label_set(Evas_Object *obj, const char *label)
459 ELM_CHECK_WIDTYPE(obj, widtype);
460 Widget_Data *wd = elm_widget_data_get(obj);
462 eina_stringshare_replace(&wd->label, label);
465 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
466 edje_object_message_signal_process(wd->slider);
470 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
471 edje_object_message_signal_process(wd->slider);
473 edje_object_part_text_set(wd->slider, "elm.text", label);
478 * Get the label of the slider
480 * @param obj The slider object
481 * @return The text label string in UTF-8
486 elm_slider_label_get(const Evas_Object *obj)
488 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
489 Widget_Data *wd = elm_widget_data_get(obj);
490 if (!wd) return NULL;
495 * Set the icon object of the slider object
497 * Once the icon object is set, a previously set one will be deleted.
499 * @param obj The slider object
500 * @param icon The icon object
505 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
507 ELM_CHECK_WIDTYPE(obj, widtype);
508 Widget_Data *wd = elm_widget_data_get(obj);
510 if (wd->icon == icon) return;
511 if (wd->icon) evas_object_del(wd->icon);
515 elm_widget_sub_object_add(obj, icon);
516 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
517 _changed_size_hints, obj);
518 edje_object_part_swallow(wd->slider, "elm.swallow.content", icon);
519 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
520 edje_object_message_signal_process(wd->slider);
526 * Get the icon object of the slider object
528 * @param obj The slider object
529 * @return The icon object
534 elm_slider_icon_get(const Evas_Object *obj)
536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
537 Widget_Data *wd = elm_widget_data_get(obj);
538 if (!wd) return NULL;
543 * Set the length of the dragable region of the slider
545 * This sets the minimum width or height (depending on orientation) of the
546 * area of the slider that allows the slider to be dragged around. This in
547 * turn affects the objects minimum size (along with icon label and unit
548 * text). Note that this will also get multiplied by the scale factor.
550 * @param obj The slider object
551 * @param size The length of the slider area
556 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
558 ELM_CHECK_WIDTYPE(obj, widtype);
559 Widget_Data *wd = elm_widget_data_get(obj);
561 if (wd->size == size) return;
564 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
566 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
567 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
572 * Get the length of the dragable region of the slider
574 * This gets the minimum width or height (depending on orientation) of
575 * the area of the slider that allows the slider to be dragged
576 * around. Note that this will also get multiplied by the scale
579 * @param obj The slider object
580 * @return The length of the slider area
585 elm_slider_span_size_get(const Evas_Object *obj)
587 ELM_CHECK_WIDTYPE(obj, widtype) 0;
588 Widget_Data *wd = elm_widget_data_get(obj);
594 * Set the format string of the unit area
596 * If NULL, this disabls the unit area display. If not it sets the format
597 * string for the unit text. The unit text is provided a floating point
598 * value, so the unit text can display up to 1 floating point value. Note that
599 * this is optional. Use a format string such as "%1.2f meters" for example.
601 * @param obj The slider object
602 * @param units The format string for the units display
607 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
609 ELM_CHECK_WIDTYPE(obj, widtype);
610 Widget_Data *wd = elm_widget_data_get(obj);
612 eina_stringshare_replace(&wd->units, units);
615 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
616 edje_object_message_signal_process(wd->slider);
620 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
621 edje_object_message_signal_process(wd->slider);
628 * Get the format string for the unit area
630 * The slider may also display a value (the value of the slider) somewhere
631 * (for example above the slider knob that is dragged around). This sets the
632 * format string for this. See elm_slider_unit_format_set() for more
633 * information on how this works.
635 * @param obj The slider object
636 * @return The format string for the unit display.
641 elm_slider_unit_format_get(const Evas_Object *obj)
643 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
644 Widget_Data *wd = elm_widget_data_get(obj);
645 if (!wd) return NULL;
650 * Set the format string for the indicator area
652 * The slider may also display a value (the value of the slider) somewhere
653 * (for example above the slider knob that is dragged around). This sets the
654 * format string for this. See elm_slider_unit_format_set() for more
655 * information on how this works.
657 * @param obj The slider object
658 * @param indicator The format string for the indicator display
663 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
665 ELM_CHECK_WIDTYPE(obj, widtype);
666 Widget_Data *wd = elm_widget_data_get(obj);
668 eina_stringshare_replace(&wd->indicator, indicator);
673 * Get the format string for the indicator area
675 * The slider may also display a value (the value of the slider) somewhere
676 * (for example above the slider knob that is dragged around). This sets the
677 * format string for this. See elm_slider_indicator_format_set() for more
678 * information on how this works.
680 * @param obj The slider object
681 * @return The format string for the indicator display.
686 elm_slider_indicator_format_get(const Evas_Object *obj)
688 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
689 Widget_Data *wd = elm_widget_data_get(obj);
690 if (!wd) return NULL;
691 return wd->indicator;
695 * Set orientation of the slider
697 * @param obj The slider object
698 * @param horizontal If set, the slider will be horizontal
703 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
705 ELM_CHECK_WIDTYPE(obj, widtype);
706 Widget_Data *wd = elm_widget_data_get(obj);
708 horizontal = !!horizontal;
709 if (wd->horizontal == horizontal) return;
710 wd->horizontal = horizontal;
715 * Get orientation of the slider
717 * @param obj The slider object
718 * @return If @c EINA_TRUE the slider will be horizontal, else it is
723 elm_slider_horizontal_get(const Evas_Object *obj)
725 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
726 Widget_Data *wd = elm_widget_data_get(obj);
727 if (!wd) return EINA_FALSE;
728 return wd->horizontal;
732 * Set the minimum and maximum values for the slider
734 * Maximum mut be greater than minimum.
736 * @param obj The slider object
737 * @param min The minimum value
738 * @param max The maximum value
743 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
745 ELM_CHECK_WIDTYPE(obj, widtype);
746 Widget_Data *wd = elm_widget_data_get(obj);
748 if ((wd->val_min == min) && (wd->val_max == max)) return;
752 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
754 if (wd->val < wd->val_min) wd->val = wd->val_min;
755 if (wd->val > wd->val_max) wd->val = wd->val_max;
762 * Get the minimum and maximum values for the slider
764 * @param obj The slider object
765 * @param min The pointer to store minimum value, may be @c NULL.
766 * @param max The pointer to store maximum value, may be @c NULL.
771 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
775 ELM_CHECK_WIDTYPE(obj, widtype);
776 Widget_Data *wd = elm_widget_data_get(obj);
778 if (min) *min = wd->val_min;
779 if (max) *max = wd->val_max;
783 * Set the value the slider indicates
785 * @param obj The slider object
786 * @param val The value (must be beween min and max for the slider)
791 elm_slider_value_set(Evas_Object *obj, double val)
793 ELM_CHECK_WIDTYPE(obj, widtype);
794 Widget_Data *wd = elm_widget_data_get(obj);
796 if (wd->val == val) return;
798 if (wd->val < wd->val_min) wd->val = wd->val_min;
799 if (wd->val > wd->val_max) wd->val = wd->val_max;
800 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
807 * Get the value the slider has
809 * @param obj The slider object
810 * @return The value of the slider
815 elm_slider_value_get(const Evas_Object *obj)
817 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
818 Widget_Data *wd = elm_widget_data_get(obj);
824 * Invert the slider display
826 * Normally the slider will display and interpret values from low to high
827 * and when horizontal that is left to right. When vertical that is top
828 * to bottom. This inverts this (so from right to left or bottom to top) if
829 * inverted is set to 1.
831 * @param obj The slider object
832 * @param inverted The inverted flag. 1 == inverted, 0 == normal
837 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
839 ELM_CHECK_WIDTYPE(obj, widtype);
840 Widget_Data *wd = elm_widget_data_get(obj);
842 inverted = !!inverted;
843 if (wd->inverted == inverted) return;
844 wd->inverted = inverted;
846 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
848 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
849 edje_object_message_signal_process(wd->slider);
856 * Get if the slider display is inverted (backwards)
858 * @param obj The slider object
859 * @return If @c EINA_TRUE the slider will be inverted.
863 elm_slider_inverted_get(const Evas_Object *obj)
865 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
866 Widget_Data *wd = elm_widget_data_get(obj);
867 if (!wd) return EINA_FALSE;
872 * Set the format function pointer for the inducator area
874 * Set the callback function to format the indicator string.
875 * See elm_slider_indicator_format_set() for more info on how this works.
877 * @param obj The slider object
878 * @param indicator The format string for the indicator display
879 * @param func The indicator format function
884 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
886 ELM_CHECK_WIDTYPE(obj, widtype);
887 Widget_Data *wd = elm_widget_data_get(obj);
889 wd->indicator_format_func = func;
894 //////////////////////////////////////////////////////////////////////////////////////////////////////
895 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
896 //////////////////////////////////////////////////////////////////////////////////////////////////////
901 * Set the end side icon object of the slider object
903 * Once the end side icon object is set, it will become a child of the slider object and
904 * be deleted when the slider object is deleted. If another icon object is set
905 * then the previous one becomes orophaned and will no longer be deleted along
908 * @param obj The slider object
909 * @param icon The icon object
911 * @return 1 if icon set succeed, 0 if there is no part for the end side icon
916 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
918 Widget_Data *wd = elm_widget_data_get(obj);
920 if ((wd->e_icon != icon) && (wd->e_icon))
921 elm_widget_sub_object_del(obj, wd->e_icon);
925 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
928 elm_widget_sub_object_add(obj, icon);
929 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
930 _changed_size_hints, obj);
931 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
940 * Get the end side icon object of the slider object
942 * @param obj The slider object
943 * @return The end side icon object
948 elm_slider_end_icon_get(Evas_Object *obj)
950 Widget_Data *wd = elm_widget_data_get(obj);
951 if (!wd) return NULL;
957 * Set whether showing the number(indicator) or not.
959 * @param obj The slider object
960 * @param show 1 will show the number, 0 will not.
965 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
967 Widget_Data *wd = elm_widget_data_get(obj);
970 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
972 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
975 static Eina_Bool _mv_timer_cb(void *data)
977 Evas_Object* obj = (Evas_Object*)data;
978 Widget_Data *wd = elm_widget_data_get(obj);
982 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;
988 else if (wd->src_val > wd->des_val)
990 wd->src_val -= wd->mv_step;
991 if(wd->src_val < wd->des_val)
992 wd->src_val = wd->des_val;
995 elm_slider_value_set(obj, wd->src_val);
996 evas_object_smart_callback_call(obj, SIG_CHANGED , NULL);
998 if (wd->val == wd->des_val)
1002 ecore_timer_del(wd->mv_timer);
1003 wd->mv_timer = NULL;
1013 * Move the thumb to the specified value.
1015 * This is different with elm_slider_value_set() in animated moving.
1017 * @param obj The slider object
1018 * @param val thumb's destination value.
1023 elm_slider_value_animated_set(Evas_Object *obj, double val)
1025 Widget_Data *wd = elm_widget_data_get(obj);
1027 if (wd->val == val) return;
1029 wd->src_val = wd->val;
1031 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
1032 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
1036 ecore_timer_del(wd->mv_timer);
1037 wd->mv_timer = NULL;
1040 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1045 * Set the end side label of the slider
1047 * @param obj The slider object
1048 * @param label The text label string in UTF-8
1053 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1055 ELM_CHECK_WIDTYPE(obj, widtype);
1056 Widget_Data *wd = elm_widget_data_get(obj);
1058 eina_stringshare_replace(&wd->e_label, label);
1061 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1062 edje_object_message_signal_process(wd->slider);
1066 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1067 edje_object_message_signal_process(wd->slider);
1069 edje_object_part_text_set(wd->slider, "elm.units", label);
1076 * Get the end side label of the slider
1078 * @param obj The slider object
1079 * @return The text label string in UTF-8
1084 elm_slider_end_label_get(const Evas_Object *obj)
1086 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1087 Widget_Data *wd = elm_widget_data_get(obj);
1088 if (!wd) return NULL;