1 #include <Elementary.h>
5 * @defgroup Slider Slider
8 * The slider adds a dragable “slider” widget for selecting the value of
9 * something within a range.
11 * Signals that you can add callbacks for are:
13 * changed - Whenever the slider value is changed by the user.
15 * delay,changed - A short time after the value is changed by the user.
16 * This will be called only when the user stops dragging for a very short
17 * period or when they release their finger/mouse, so it avoids possibly
18 * expensive reactions to the value change.
20 * slider,drag,start - dragging the slider indicator around has started
22 * slider,drag,stop - dragging the slider indicator around has stopped
24 * A slider can be horizontal or vertical. It can contain an Icon and has a
25 * primary label as well as a units label (that is formatted with floating
26 * point values and thus accepts a printf-style format string, like
27 * “%1.2f units”. There is also an indicator string that may be somewhere
28 * else (like on the slider itself) that also accepts a format string like
29 * units. Label, Icon Unit and Indicator strings/objects are optional.
31 * A slider may be inverted which means values invert, with high vales being
32 * on the left or top and low values on the right or bottom (as opposed to
33 * normally being low on the left or top and high on the bottom and right).
35 * The slider should have its minimum and maximum values set by the
36 * application with elm_slider_min_max_set() and value should also be set by
37 * the application before use with elm_slider_value_set(). The span of the
38 * slider is its length (horizontally or vertically). This will be scaled by
39 * the object or applications scaling factor. At any point code can query the
40 * slider for its value with elm_slider_value_get().
43 typedef struct _Widget_Data Widget_Data;
53 const char *indicator;
54 const char *(*indicator_format_func)(double val);
55 Eina_Bool horizontal : 1;
56 Eina_Bool inverted : 1;
57 Eina_Bool indicator_show : 1;
59 double val, val_min, val_max;
64 #define ELM_SLIDER_INVERTED_FACTOR (-1.0)
66 static const char *widtype = NULL;
67 static void _del_hook(Evas_Object *obj);
68 static void _theme_hook(Evas_Object *obj);
69 static void _disable_hook(Evas_Object *obj);
70 static void _sizing_eval(Evas_Object *obj);
71 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
72 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
73 static void _units_set(Evas_Object *obj);
74 static void _val_set(Evas_Object *obj);
75 static void _indicator_set(Evas_Object *obj);
76 static void _on_focus_hook(void *data, Evas_Object *obj);
77 static void _drag_up(void *data, Evas_Object *obj,
78 const char *emission, const char *source);
79 static void _drag_down(void *data, Evas_Object *obj,
80 const char *emission, const char *source);
81 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
82 Evas_Callback_Type type, void *event_info);
83 static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
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 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
100 Evas_Event_Mouse_Wheel *mev;
101 Evas_Event_Key_Down *ev;
104 wd = elm_widget_data_get(obj);
105 if (!wd) return EINA_FALSE;
107 if (type == EVAS_CALLBACK_KEY_DOWN) goto key_down;
108 else if (type != EVAS_CALLBACK_MOUSE_WHEEL) return EINA_FALSE;
111 if (mev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
112 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
114 if (mev->z < 0) _drag_up(obj, NULL, NULL, NULL);
115 else _drag_down(obj, NULL, NULL, NULL);
116 mev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
121 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
122 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
123 if ((!strcmp(ev->keyname, "Left"))
124 || (!strcmp(ev->keyname, "KP_Left")))
126 if (!wd->horizontal) return EINA_FALSE;
127 if (!wd->inverted) _drag_down(obj, NULL, NULL, NULL);
128 else _drag_up(obj, NULL, NULL, NULL);
129 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
132 else if ((!strcmp(ev->keyname, "Right"))
133 || (!strcmp(ev->keyname, "KP_Right")))
135 if (!wd->horizontal) return EINA_FALSE;
136 if (!wd->inverted) _drag_up(obj, NULL, NULL, NULL);
137 else _drag_down(obj, NULL, NULL, NULL);
138 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
141 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
143 if (wd->horizontal) return EINA_FALSE;
144 if (wd->inverted) _drag_up(obj, NULL, NULL, NULL);
145 else _drag_down(obj, NULL, NULL, NULL);
146 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
149 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
151 if (wd->horizontal) return EINA_FALSE;
152 if (wd->inverted) _drag_down(obj, NULL, NULL, NULL);
153 else _drag_up(obj, NULL, NULL, NULL);
154 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
157 else return EINA_FALSE;
161 _del_hook(Evas_Object *obj)
163 Widget_Data *wd = elm_widget_data_get(obj);
165 if (wd->label) eina_stringshare_del(wd->label);
166 if (wd->indicator) eina_stringshare_del(wd->units);
167 if (wd->delay) ecore_timer_del(wd->delay);
172 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
174 Widget_Data *wd = elm_widget_data_get(obj);
176 if (elm_widget_focus_get(obj))
178 edje_object_signal_emit(wd->slider, "elm,action,focus", "elm");
179 evas_object_focus_set(wd->slider, EINA_TRUE);
183 edje_object_signal_emit(wd->slider, "elm,action,unfocus", "elm");
184 evas_object_focus_set(wd->slider, EINA_FALSE);
189 _theme_hook(Evas_Object *obj)
191 Widget_Data *wd = elm_widget_data_get(obj);
194 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
196 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
199 edje_object_part_swallow(wd->slider, "elm.swallow.content", wd->icon);
200 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
203 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
205 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
208 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
209 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
213 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
216 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
218 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
221 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
223 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
226 edje_object_message_signal_process(wd->slider);
227 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
233 _disable_hook(Evas_Object *obj)
235 Widget_Data *wd = elm_widget_data_get(obj);
237 if (elm_widget_disabled_get(obj))
238 edje_object_signal_emit(wd->slider, "elm,state,disabled", "elm");
240 edje_object_signal_emit(wd->slider, "elm,state,enabled", "elm");
244 _sizing_eval(Evas_Object *obj)
246 Widget_Data *wd = elm_widget_data_get(obj);
247 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
249 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
250 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
251 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
252 evas_object_size_hint_min_set(obj, minw, minh);
253 evas_object_size_hint_max_set(obj, maxw, maxh);
257 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
259 Widget_Data *wd = elm_widget_data_get(data);
261 if ((obj != wd->icon) && (obj != wd->end)) return;
266 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
268 Widget_Data *wd = elm_widget_data_get(obj);
269 Evas_Object *sub = event_info;
273 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
274 evas_object_event_callback_del_full
275 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
277 edje_object_message_signal_process(wd->slider);
282 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
283 evas_object_event_callback_del_full(sub,
284 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
285 _changed_size_hints, obj);
287 edje_object_message_signal_process(wd->slider);
293 _delay_change(void *data)
295 Widget_Data *wd = elm_widget_data_get(data);
296 if (!wd) return ECORE_CALLBACK_CANCEL;
298 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
299 return ECORE_CALLBACK_CANCEL;
303 _val_fetch(Evas_Object *obj)
305 Widget_Data *wd = elm_widget_data_get(obj);
306 double posx = 0.0, posy = 0.0, pos = 0.0, val;
308 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
310 if (wd->horizontal) pos = posx;
312 if (wd->inverted) pos = 1.0 - pos;
313 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
317 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
318 if (wd->delay) ecore_timer_del(wd->delay);
319 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
324 _val_set(Evas_Object *obj)
326 Widget_Data *wd = elm_widget_data_get(obj);
329 if (wd->val_max > wd->val_min)
330 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
333 if (pos < 0.0) pos = 0.0;
334 else if (pos > 1.0) pos = 1.0;
335 if (wd->inverted) pos = 1.0 - pos;
336 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
340 _units_set(Evas_Object *obj)
342 Widget_Data *wd = elm_widget_data_get(obj);
348 snprintf(buf, sizeof(buf), wd->units, wd->val);
349 edje_object_part_text_set(wd->slider, "elm.units", buf);
352 edje_object_part_text_set(wd->slider, "elm.units", NULL);
356 _indicator_set(Evas_Object *obj)
358 Widget_Data *wd = elm_widget_data_get(obj);
360 if (wd->indicator_format_func)
363 buf = wd->indicator_format_func(wd->val);
364 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
366 else if (wd->indicator)
369 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
370 edje_object_part_text_set(wd->slider, "elm.indicator", buf);
373 edje_object_part_text_set(wd->slider, "elm.indicator", NULL);
377 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
379 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
380 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
381 edje_object_message_signal_process(wd->slider);
384 _indicator_set(data);
388 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
390 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
392 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
393 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
394 edje_object_message_signal_process(wd->slider);
396 _indicator_set(data);
397 elm_widget_scroll_hold_push(data);
401 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
404 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
406 _indicator_set(data);
407 elm_widget_scroll_hold_pop(data);
411 _drag_step(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
415 _indicator_set(data);
419 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
424 wd = elm_widget_data_get(data);
427 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
429 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
433 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
438 wd = elm_widget_data_get(data);
441 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
443 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
447 _spacer_cb(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
449 Widget_Data *wd = elm_widget_data_get(data);
450 Evas_Event_Mouse_Down *ev = event_info;
451 Evas_Coord x, y, w, h;
452 double button_x, button_y;
454 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
455 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
458 button_x = ((double)ev->output.x - (double)x) / (double)w;
459 if (button_x > 1) button_x = 1;
460 if (button_x < 0) button_x = 0;
464 button_y = ((double)ev->output.y - (double)y) / (double)h;
465 if (button_y > 1) button_y = 1;
466 if (button_y < 0) button_y = 0;
468 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
469 evas_event_feed_mouse_cancel(e, 0, NULL);
472 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
477 * Add a new slider to the parent
479 * @param parent The parent object
480 * @return The new object or NULL if it cannot be created
485 elm_slider_add(Evas_Object *parent)
491 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
493 wd = ELM_NEW(Widget_Data);
494 e = evas_object_evas_get(parent);
496 obj = elm_widget_add(e);
497 ELM_SET_WIDTYPE(widtype, "slider");
498 elm_widget_type_set(obj, "slider");
499 elm_widget_sub_object_add(parent, obj);
500 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
501 elm_widget_data_set(obj, wd);
502 elm_widget_del_hook_set(obj, _del_hook);
503 elm_widget_theme_hook_set(obj, _theme_hook);
504 elm_widget_disable_hook_set(obj, _disable_hook);
505 elm_widget_can_focus_set(obj, EINA_TRUE);
506 elm_widget_event_hook_set(obj, _event_hook);
508 wd->horizontal = EINA_TRUE;
509 wd->indicator_show = EINA_TRUE;
515 wd->slider = edje_object_add(e);
516 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
517 elm_widget_resize_object_set(obj, wd->slider);
518 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
519 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
520 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
521 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_step, obj);
522 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
523 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
524 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
526 wd->spacer = evas_object_rectangle_add(e);
527 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
528 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
529 elm_widget_sub_object_add(obj, wd->spacer);
530 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
531 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
532 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
536 // TODO: convert Elementary to subclassing of Evas_Smart_Class
537 // TODO: and save some bytes, making descriptions per-class and not instance!
538 evas_object_smart_callbacks_descriptions_set(obj, _signals);
543 * Set the label of the slider
545 * @param obj The slider object
546 * @param label The text label string in UTF-8
551 elm_slider_label_set(Evas_Object *obj, const char *label)
553 ELM_CHECK_WIDTYPE(obj, widtype);
554 Widget_Data *wd = elm_widget_data_get(obj);
556 eina_stringshare_replace(&wd->label, label);
559 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
560 edje_object_message_signal_process(wd->slider);
564 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
565 edje_object_message_signal_process(wd->slider);
567 edje_object_part_text_set(wd->slider, "elm.text", label);
572 * Get the label of the slider
574 * @param obj The slider object
575 * @return The text label string in UTF-8
580 elm_slider_label_get(const Evas_Object *obj)
582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
583 Widget_Data *wd = elm_widget_data_get(obj);
584 if (!wd) return NULL;
589 * Set the icon object (leftmost widget) of the slider object.
591 * Once the icon object is set, a previously set one will be deleted.
592 * If you want to keep that old content object, use the
593 * elm_slider_icon_unset() function.
595 * @param obj The slider object
596 * @param icon The icon object
598 * @note If the object being set does not have minimum size hints set,
599 * it won't get properly displayed.
604 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
606 ELM_CHECK_WIDTYPE(obj, widtype);
607 Widget_Data *wd = elm_widget_data_get(obj);
609 if (wd->icon == icon) return;
610 if (wd->icon) evas_object_del(wd->icon);
614 elm_widget_sub_object_add(obj, icon);
615 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
616 _changed_size_hints, obj);
617 edje_object_part_swallow(wd->slider, "elm.swallow.icon", icon);
618 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
619 edje_object_message_signal_process(wd->slider);
625 * Unset the leftmost widget of the slider, unparenting and
628 * @param obj The slider object
629 * @return the previously set icon sub-object of this slider, on
632 * @see elm_slider_icon_set()
637 elm_slider_icon_unset(Evas_Object *obj)
639 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
640 Widget_Data *wd = elm_widget_data_get(obj);
641 Evas_Object *ret = NULL;
642 if (!wd) return NULL;
645 elm_widget_sub_object_del(obj, wd->icon);
647 edje_object_part_unswallow(wd->slider, wd->icon);
648 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
656 * Get the icon object of the slider object. This object is owned by
657 * the scrolled entry and should not be modified.
659 * @param obj The slider object
660 * @return The icon object
665 elm_slider_icon_get(const Evas_Object *obj)
667 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
668 Widget_Data *wd = elm_widget_data_get(obj);
669 if (!wd) return NULL;
674 * Set the length of the dragable region of the slider
676 * This sets the minimum width or height (depending on orientation) of the
677 * area of the slider that allows the slider to be dragged around. This in
678 * turn affects the objects minimum size (along with icon label and unit
679 * text). Note that this will also get multiplied by the scale factor.
681 * @param obj The slider object
682 * @param size The length of the slider area
687 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
689 ELM_CHECK_WIDTYPE(obj, widtype);
690 Widget_Data *wd = elm_widget_data_get(obj);
692 if (wd->size == size) return;
695 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
697 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
698 if (wd->indicator_show)
699 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
701 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
702 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
707 * Get the length of the dragable region of the slider
709 * This gets the minimum width or height (depending on orientation) of
710 * the area of the slider that allows the slider to be dragged
711 * around. Note that this will also get multiplied by the scale
714 * @param obj The slider object
715 * @return The length of the slider area
720 elm_slider_span_size_get(const Evas_Object *obj)
722 ELM_CHECK_WIDTYPE(obj, widtype) 0;
723 Widget_Data *wd = elm_widget_data_get(obj);
729 * Set the format string of the unit area
731 * If NULL, this disabls the unit area display. If not it sets the format
732 * string for the unit text. The unit text is provided a floating point
733 * value, so the unit text can display up to 1 floating point value. Note that
734 * this is optional. Use a format string such as "%1.2f meters" for example.
736 * @param obj The slider object
737 * @param units The format string for the units display
742 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
744 ELM_CHECK_WIDTYPE(obj, widtype);
745 Widget_Data *wd = elm_widget_data_get(obj);
747 eina_stringshare_replace(&wd->units, units);
750 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
751 edje_object_message_signal_process(wd->slider);
755 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
756 edje_object_message_signal_process(wd->slider);
763 * Get the format string for the unit area
765 * The slider may also display a value (the value of the slider) somewhere
766 * (for example above the slider knob that is dragged around). This sets the
767 * format string for this. See elm_slider_unit_format_set() for more
768 * information on how this works.
770 * @param obj The slider object
771 * @return The format string for the unit display.
776 elm_slider_unit_format_get(const Evas_Object *obj)
778 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
779 Widget_Data *wd = elm_widget_data_get(obj);
780 if (!wd) return NULL;
785 * Set the format string for the indicator area
787 * The slider may also display a value (the value of the slider) somewhere
788 * (for example above the slider knob that is dragged around). This sets the
789 * format string for this. See elm_slider_unit_format_set() for more
790 * information on how this works.
792 * @param obj The slider object
793 * @param indicator The format string for the indicator display
798 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
800 ELM_CHECK_WIDTYPE(obj, widtype);
801 Widget_Data *wd = elm_widget_data_get(obj);
803 eina_stringshare_replace(&wd->indicator, indicator);
808 * Get the format string for the indicator area
810 * The slider may also display a value (the value of the slider) somewhere
811 * (for example above the slider knob that is dragged around). This sets the
812 * format string for this. See elm_slider_indicator_format_set() for more
813 * information on how this works.
815 * @param obj The slider object
816 * @return The format string for the indicator display.
821 elm_slider_indicator_format_get(const Evas_Object *obj)
823 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
824 Widget_Data *wd = elm_widget_data_get(obj);
825 if (!wd) return NULL;
826 return wd->indicator;
830 * Set orientation of the slider
832 * @param obj The slider object
833 * @param horizontal If set, the slider will be horizontal
838 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
840 ELM_CHECK_WIDTYPE(obj, widtype);
841 Widget_Data *wd = elm_widget_data_get(obj);
843 horizontal = !!horizontal;
844 if (wd->horizontal == horizontal) return;
845 wd->horizontal = horizontal;
850 * Get orientation of the slider
852 * @param obj The slider object
853 * @return If @c EINA_TRUE the slider will be horizontal, else it is
858 elm_slider_horizontal_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;
863 return wd->horizontal;
867 * Set the minimum and maximum values for the slider
869 * Maximum mut be greater than minimum.
871 * @param obj The slider object
872 * @param min The minimum value
873 * @param max The maximum value
878 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
880 ELM_CHECK_WIDTYPE(obj, widtype);
881 Widget_Data *wd = elm_widget_data_get(obj);
883 if ((wd->val_min == min) && (wd->val_max == max)) return;
886 if (wd->val < wd->val_min) wd->val = wd->val_min;
887 if (wd->val > wd->val_max) wd->val = wd->val_max;
894 * Get the minimum and maximum values for the slider
896 * @param obj The slider object
897 * @param min The pointer to store minimum value, may be @c NULL.
898 * @param max The pointer to store maximum value, may be @c NULL.
903 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
907 ELM_CHECK_WIDTYPE(obj, widtype);
908 Widget_Data *wd = elm_widget_data_get(obj);
910 if (min) *min = wd->val_min;
911 if (max) *max = wd->val_max;
915 * Set the value the slider indicates
917 * @param obj The slider object
918 * @param val The value (must be between min and max for the slider)
923 elm_slider_value_set(Evas_Object *obj, double val)
925 ELM_CHECK_WIDTYPE(obj, widtype);
926 Widget_Data *wd = elm_widget_data_get(obj);
928 if (wd->val == val) return;
930 if (wd->val < wd->val_min) wd->val = wd->val_min;
931 if (wd->val > wd->val_max) wd->val = wd->val_max;
932 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
939 * Get the value the slider has
941 * @param obj The slider object
942 * @return The value of the slider
947 elm_slider_value_get(const Evas_Object *obj)
949 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
950 Widget_Data *wd = elm_widget_data_get(obj);
956 * Invert the slider display
958 * Normally the slider will display and interpret values from low to high
959 * and when horizontal that is left to right. When vertical that is top
960 * to bottom. This inverts this (so from right to left or bottom to top) if
961 * inverted is set to 1.
963 * @param obj The slider object
964 * @param inverted The inverted flag. 1 == inverted, 0 == normal
969 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
971 ELM_CHECK_WIDTYPE(obj, widtype);
972 Widget_Data *wd = elm_widget_data_get(obj);
974 inverted = !!inverted;
975 if (wd->inverted == inverted) return;
976 wd->inverted = inverted;
978 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
980 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
981 edje_object_message_signal_process(wd->slider);
988 * Get if the slider display is inverted (backwards)
990 * @param obj The slider object
991 * @return If @c EINA_TRUE the slider will be inverted.
995 elm_slider_inverted_get(const Evas_Object *obj)
997 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
998 Widget_Data *wd = elm_widget_data_get(obj);
999 if (!wd) return EINA_FALSE;
1000 return wd->inverted;
1004 * Set the format function pointer for the inducator area
1006 * Set the callback function to format the indicator string.
1007 * See elm_slider_indicator_format_set() for more info on how this works.
1009 * @param obj The slider object
1010 * @param indicator The format string for the indicator display
1011 * @param func The indicator format function
1016 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
1018 ELM_CHECK_WIDTYPE(obj, widtype);
1019 Widget_Data *wd = elm_widget_data_get(obj);
1021 wd->indicator_format_func = func;
1022 _indicator_set(obj);
1026 * Set the end object (rightmost widget) of the slider object.
1028 * Once the end object is set, a previously set one will be deleted.
1029 * If you want to keep that old content object, use the
1030 * elm_button_end_unset() function.
1032 * @param obj The slider object
1033 * @param end The end object
1035 * @note If the object being set does not have minimum size hints set,
1036 * it won't get properly displayed.
1041 elm_slider_end_set(Evas_Object *obj, Evas_Object *end)
1043 ELM_CHECK_WIDTYPE(obj, widtype);
1044 Widget_Data *wd = elm_widget_data_get(obj);
1046 if (wd->end == end) return;
1047 if (wd->end) evas_object_del(wd->end);
1051 elm_widget_sub_object_add(obj, end);
1052 evas_object_event_callback_add(end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1053 _changed_size_hints, obj);
1054 edje_object_part_swallow(wd->slider, "elm.swallow.end", end);
1055 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
1056 edje_object_message_signal_process(wd->slider);
1062 * Unset the rightmost widget of the slider, unparenting and
1065 * @param obj The slider object
1066 * @return the previously set end sub-object of this slider, on
1069 * @see elm_slider_end_set()
1074 elm_slider_end_unset(Evas_Object *obj)
1076 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1077 Widget_Data *wd = elm_widget_data_get(obj);
1078 Evas_Object *ret = NULL;
1079 if (!wd) return NULL;
1082 elm_widget_sub_object_del(obj, wd->end);
1084 edje_object_part_unswallow(wd->slider, wd->end);
1085 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
1093 * Get the end icon object of the slider object. This object is owned
1094 * by the scrolled entry and should not be modified.
1096 * @param obj The slider object
1097 * @return The end icon object
1102 elm_slider_end_get(const Evas_Object *obj)
1104 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1105 Widget_Data *wd = elm_widget_data_get(obj);
1106 if (!wd) return NULL;
1111 * Set whether to the slider indicator (augmented knob) at all.
1113 * @param obj The slider object
1114 * @param show @c EINA_TRUE will make it show it, @c EINA_FALSE will
1115 * let the knob alwayes at default size.
1117 * @note It will conflict with elm_slider_indicator_format_set(), if
1118 * you wanted those effects.
1123 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
1125 ELM_CHECK_WIDTYPE(obj, widtype);
1126 Widget_Data *wd = elm_widget_data_get(obj);
1128 wd->indicator_show = EINA_TRUE;
1129 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
1132 wd->indicator_show = EINA_FALSE;
1133 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
1138 * Get the state of indicator in the slider (if it's being shown or
1141 * @param obj The slider object
1142 * @return @c EINA_TRUE if the indicator is being shown, @c EINA_FALSE
1148 elm_slider_indicator_show_get(const Evas_Object *obj)
1150 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1151 Widget_Data *wd = elm_widget_data_get(obj);
1152 if (!wd) return EINA_FALSE;
1153 return wd->indicator_show;
1157 //////////////////////////////////////////////////////////////////////////////////////////////////////
1158 //////////////////////// DEPRECTAED ///////////////////////////////////////////////////
1159 //////////////////////////////////////////////////////////////////////////////////////////////////////
1162 elm_slider_end_icon_set(Evas_Object *obj, Evas_Object *icon)
1164 elm_slider_end_set(obj, icon);
1169 elm_slider_end_icon_get(Evas_Object *obj)
1171 return elm_slider_end_get(obj);
1175 elm_slider_value_animated_set(Evas_Object *obj, double val)
1181 elm_slider_end_label_set(Evas_Object *obj, const char *label)
1187 elm_slider_end_label_get(const Evas_Object *obj)