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);
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);
317 _indicator_set(data);
321 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
323 elm_widget_scroll_hold_pop(data);
325 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
327 _indicator_set(data);
331 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
333 Widget_Data *wd = elm_widget_data_get(data);
334 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", -0.05, -0.05);
338 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
340 Widget_Data *wd = elm_widget_data_get(data);
341 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", 0.05, 0.05);
345 _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
347 Widget_Data *wd = elm_widget_data_get(data);
348 Evas_Event_Mouse_Down *ev = event_info;
349 Evas_Coord x, y, w, h;
350 double button_x, button_y;
352 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
353 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
355 button_x = ((double)ev->output.x - (double)x) / (double)w;
362 button_y = ((double)ev->output.y - (double)y) / (double)h;
368 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
369 // evas_object_smart_callback_call(cp->parent, "clicked", NULL);
370 evas_event_feed_mouse_cancel(e, 0, NULL);
371 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
374 static const char*widtype = NULL;
377 * Add a new slider to the parent
379 * @param parent The parent object
380 * @return The new object or NULL if it cannot be created
385 elm_slider_add(Evas_Object *parent)
391 wd = ELM_NEW(Widget_Data);
392 e = evas_object_evas_get(parent);
393 obj = elm_widget_add(e);
394 ELM_SET_WIDTYPE(widtype, "slider");
395 elm_widget_type_set(obj, "slider");
396 elm_widget_sub_object_add(parent, obj);
397 elm_widget_data_set(obj, wd);
398 elm_widget_del_hook_set(obj, _del_hook);
399 elm_widget_theme_hook_set(obj, _theme_hook);
401 wd->horizontal = EINA_TRUE;
406 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
408 wd->slider = edje_object_add(e);
409 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
410 elm_widget_resize_object_set(obj, wd->slider);
411 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
412 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
413 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
414 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_stop, obj);
415 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
416 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
417 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,-1", "*", _drag_up, obj);
418 edje_object_signal_callback_add(wd->slider, "mouse,wheel,0,1", "*", _drag_down, obj);
419 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
421 wd->spacer = evas_object_rectangle_add(e);
422 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
423 evas_object_pass_events_set(wd->spacer, 1);
424 elm_widget_sub_object_add(obj, wd->spacer);
425 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
426 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
428 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
432 // TODO: convert Elementary to subclassing of Evas_Smart_Class
433 // TODO: and save some bytes, making descriptions per-class and not instance!
434 evas_object_smart_callbacks_descriptions_set(obj, _signals);
439 * Set the label of the slider
441 * @param obj The slider object
442 * @param label The text label string in UTF-8
447 elm_slider_label_set(Evas_Object *obj, const char *label)
449 ELM_CHECK_WIDTYPE(obj, widtype);
450 Widget_Data *wd = elm_widget_data_get(obj);
452 eina_stringshare_replace(&wd->label, label);
455 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
456 edje_object_message_signal_process(wd->slider);
460 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
461 edje_object_message_signal_process(wd->slider);
463 edje_object_part_text_set(wd->slider, "elm.text", label);
468 * Get the label of the slider
470 * @param obj The slider object
471 * @return The text label string in UTF-8
476 elm_slider_label_get(const Evas_Object *obj)
478 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
479 Widget_Data *wd = elm_widget_data_get(obj);
480 if (!wd) return NULL;
485 * Set the icon object of the slider object
487 * Once the icon object is set, it will become a child of the slider object and
488 * be deleted when the slider object is deleted. If another icon object is set
489 * then the previous one becomes orophaned and will no longer be deleted along
492 * @param obj The slider object
493 * @param icon The icon object
498 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
500 ELM_CHECK_WIDTYPE(obj, widtype);
501 Widget_Data *wd = elm_widget_data_get(obj);
503 if ((wd->icon != icon) && (wd->icon))
504 elm_widget_sub_object_del(obj, wd->icon);
508 elm_widget_sub_object_add(obj, icon);
509 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
510 _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");
518 * Get the icon object of the slider object
520 * @param obj The slider object
521 * @return The icon object
526 elm_slider_icon_get(const Evas_Object *obj)
528 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
529 Widget_Data *wd = elm_widget_data_get(obj);
530 if (!wd) return NULL;
535 * Set the length of the dragable region of the slider
537 * This sets the minimum width or height (depending on orientation) of the
538 * area of the slider that allows the slider to be dragged around. This in
539 * turn affects the objects minimum size (along with icon label and unit
540 * text). Note that this will also get multiplied by the scale factor.
542 * @param obj The slider object
543 * @param size The length of the slider area
548 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
550 ELM_CHECK_WIDTYPE(obj, widtype);
551 Widget_Data *wd = elm_widget_data_get(obj);
553 if (wd->size == size) return;
556 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
558 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
559 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
564 * Get the length of the dragable region of the slider
566 * This gets the minimum width or height (depending on orientation) of
567 * the area of the slider that allows the slider to be dragged
568 * around. Note that this will also get multiplied by the scale
571 * @param obj The slider object
572 * @return The length of the slider area
577 elm_slider_span_size_get(const Evas_Object *obj)
579 ELM_CHECK_WIDTYPE(obj, widtype) 0;
580 Widget_Data *wd = elm_widget_data_get(obj);
586 * Set the format string of the unit area
588 * If NULL, this disabls the unit area display. If not it sets the format
589 * string for the unit text. The unit text is provided a floating point
590 * value, so the unit text can display up to 1 floating point value. Note that
591 * this is optional. Use a format string such as "%1.2f meters" for example.
593 * @param obj The slider object
594 * @param units The format string for the units display
599 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
601 ELM_CHECK_WIDTYPE(obj, widtype);
602 Widget_Data *wd = elm_widget_data_get(obj);
604 eina_stringshare_replace(&wd->units, units);
607 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
608 edje_object_message_signal_process(wd->slider);
612 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
613 edje_object_message_signal_process(wd->slider);
620 * Get the format string for the unit area
622 * The slider may also display a value (the value of the slider) somewhere
623 * (for example above the slider knob that is dragged around). This sets the
624 * format string for this. See elm_slider_unit_format_set() for more
625 * information on how this works.
627 * @param obj The slider object
628 * @return The format string for the unit display.
633 elm_slider_unit_format_get(const Evas_Object *obj)
635 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
636 Widget_Data *wd = elm_widget_data_get(obj);
637 if (!wd) return NULL;
642 * Set the format string for the indicator area
644 * The slider may also display a value (the value of the slider) somewhere
645 * (for example above the slider knob that is dragged around). This sets the
646 * format string for this. See elm_slider_unit_format_set() for more
647 * information on how this works.
649 * @param obj The slider object
650 * @param indicator The format string for the indicator display
655 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
657 ELM_CHECK_WIDTYPE(obj, widtype);
658 Widget_Data *wd = elm_widget_data_get(obj);
660 eina_stringshare_replace(&wd->indicator, indicator);
665 * Get the format string for the indicator area
667 * The slider may also display a value (the value of the slider) somewhere
668 * (for example above the slider knob that is dragged around). This sets the
669 * format string for this. See elm_slider_indicator_format_set() for more
670 * information on how this works.
672 * @param obj The slider object
673 * @return The format string for the indicator display.
678 elm_slider_indicator_format_get(const Evas_Object *obj)
680 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
681 Widget_Data *wd = elm_widget_data_get(obj);
682 if (!wd) return NULL;
683 return wd->indicator;
687 * Set orientation of the slider
689 * @param obj The slider object
690 * @param horizontal If set, the slider will be horizontal
695 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
697 ELM_CHECK_WIDTYPE(obj, widtype);
698 Widget_Data *wd = elm_widget_data_get(obj);
700 horizontal = !!horizontal;
701 if (wd->horizontal == horizontal) return;
702 wd->horizontal = horizontal;
707 * Get orientation of the slider
709 * @param obj The slider object
710 * @return If @c EINA_TRUE the slider will be horizontal, else it is
715 elm_slider_horizontal_get(const Evas_Object *obj)
717 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
718 Widget_Data *wd = elm_widget_data_get(obj);
719 if (!wd) return EINA_FALSE;
720 return wd->horizontal;
724 * Set the minimum and maximum values for the slider
726 * Maximum mut be greater than minimum.
728 * @param obj The slider object
729 * @param min The minimum value
730 * @param max The maximum value
735 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
737 ELM_CHECK_WIDTYPE(obj, widtype);
738 Widget_Data *wd = elm_widget_data_get(obj);
740 if ((wd->val_min == min) && (wd->val_max == max)) return;
744 wd->mv_step = (double)((wd->val_max - wd->val_min) / (double)SLIDER_THUMB_MOVE_STEP);
746 if (wd->val < wd->val_min) wd->val = wd->val_min;
747 if (wd->val > wd->val_max) wd->val = wd->val_max;
754 * Get the minimum and maximum values for the slider
756 * @param obj The slider object
757 * @param min The pointer to store minimum value, may be @c NULL.
758 * @param max The pointer to store maximum value, may be @c NULL.
763 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
767 ELM_CHECK_WIDTYPE(obj, widtype);
768 Widget_Data *wd = elm_widget_data_get(obj);
770 if (min) *min = wd->val_min;
771 if (max) *max = wd->val_max;
775 * Set the value the slider indicates
777 * @param obj The slider object
778 * @param val The value (must be beween min and max for the slider)
783 elm_slider_value_set(Evas_Object *obj, double val)
785 ELM_CHECK_WIDTYPE(obj, widtype);
786 Widget_Data *wd = elm_widget_data_get(obj);
788 if (wd->val == val) return;
790 if (wd->val < wd->val_min) wd->val = wd->val_min;
791 if (wd->val > wd->val_max) wd->val = wd->val_max;
798 * Get the value the slider has
800 * @param obj The slider object
801 * @return The value of the slider
806 elm_slider_value_get(const Evas_Object *obj)
808 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
809 Widget_Data *wd = elm_widget_data_get(obj);
815 * Invert the slider display
817 * Normally the slider will display and interpret values from low to high
818 * and when horizontal that is left to right. When vertical that is top
819 * to bottom. This inverts this (so from right to left or bottom to top) if
820 * inverted is set to 1.
822 * @param obj The slider object
823 * @param inverted The inverted flag. 1 == inverted, 0 == normal
828 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
830 ELM_CHECK_WIDTYPE(obj, widtype);
831 Widget_Data *wd = elm_widget_data_get(obj);
833 inverted = !!inverted;
834 if (wd->inverted == inverted) return;
835 wd->inverted = inverted;
837 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
839 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
840 edje_object_message_signal_process(wd->slider);
847 * Get if the slider display is inverted (backwards)
849 * @param obj The slider object
850 * @return If @c EINA_TRUE the slider will be inverted.
854 elm_slider_inverted_get(const Evas_Object *obj)
856 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
857 Widget_Data *wd = elm_widget_data_get(obj);
858 if (!wd) return EINA_FALSE;
863 * Set the format function pointer for the inducator area
865 * Set the callback function to format the indicator string.
866 * See elm_slider_indicator_format_set() for more info on how this works.
868 * @param obj The slider object
869 * @param indicator The format string for the indicator display
870 * @param func The indicator format function
875 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
877 ELM_CHECK_WIDTYPE(obj, widtype);
878 Widget_Data *wd = elm_widget_data_get(obj);
880 wd->indicator_format_func = func;
885 //////////////////////////////////////////////////////////////////////////////////////////////////////
886 //////////////////////// supporting beat feature ///////////////////////////////////////////////////
887 //////////////////////////////////////////////////////////////////////////////////////////////////////
892 * Set the right icon object of the slider object
894 * Once the right icon object is set, it will become a child of the slider object and
895 * be deleted when the slider object is deleted. If another icon object is set
896 * then the previous one becomes orophaned and will no longer be deleted along
899 * @param obj The slider object
900 * @param icon The icon object
902 * @return 1 if icon set succeed, 0 if there is no part for right icon
907 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
909 Widget_Data *wd = elm_widget_data_get(obj);
911 if ((wd->e_icon != icon) && (wd->e_icon))
912 elm_widget_sub_object_del(obj, wd->e_icon);
916 if ( !(edje_object_part_swallow(wd->slider, "end_icon", icon)) )
919 elm_widget_sub_object_add(obj, icon);
920 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
921 _changed_size_hints, obj);
922 edje_object_signal_emit(wd->slider, "elm,state,eicon,visible", "elm");
931 * Get the right icon object of the slider object
933 * @param obj The slider object
934 * @return The right 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);
960 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
962 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
965 static Eina_Bool _mv_timer_cb(void *data)
967 Evas_Object* obj = (Evas_Object*)data;
968 Widget_Data *wd = elm_widget_data_get(obj);
970 if (!wd) return EINA_TRUE;
972 if(wd->src_val < wd->des_val)
974 wd->src_val += wd->mv_step;
975 if(wd-> src_val > wd->des_val)
976 wd->src_val = wd->des_val;
978 else if (wd->src_val > wd->des_val)
980 wd->src_val -= wd->mv_step;
981 if(wd->src_val < wd->des_val)
982 wd->src_val = wd->des_val;
985 elm_slider_value_set(obj, wd->src_val);
986 evas_object_smart_callback_call(obj, "changed", NULL);
988 if (wd->val == wd->des_val)
992 ecore_timer_del(wd->mv_timer);
1003 * Move the thumb to the specified value.
1005 * This is different with elm_slider_value_set() in animated moving.
1007 * @param obj The slider object
1008 * @param val thumb's destination value.
1013 elm_slider_value_animated_set(Evas_Object *obj, double val)
1015 Widget_Data *wd = elm_widget_data_get(obj);
1017 if (wd->val == val) return;
1019 wd->src_val = wd->val;
1021 if (wd->des_val < wd->val_min) wd->des_val = wd->val_min;
1022 if (wd->des_val > wd->val_max) wd->des_val = wd->val_max;
1026 ecore_timer_del(wd->mv_timer);
1027 wd->mv_timer = NULL;
1030 wd->mv_timer = ecore_timer_add(0.005, _mv_timer_cb, obj);
1035 * Set the label of the slider
1037 * @param obj The slider object
1038 * @param label The text label string in UTF-8
1043 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1045 ELM_CHECK_WIDTYPE(obj, widtype);
1046 Widget_Data *wd = elm_widget_data_get(obj);
1048 eina_stringshare_replace(&wd->e_label, label);
1051 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
1052 edje_object_message_signal_process(wd->slider);
1056 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
1057 edje_object_message_signal_process(wd->slider);
1059 edje_object_part_text_set(wd->slider, "elm.units", label);
1066 * Get the label of the slider
1068 * @param obj The slider object
1069 * @return The text label string in UTF-8
1074 elm_slider_end_label_get(const Evas_Object *obj)
1076 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1077 Widget_Data *wd = elm_widget_data_get(obj);
1078 if (!wd) return NULL;