1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
17 const char *indicator;
19 const char *(*indicator_format_func)(double val);
20 void (*indicator_format_free)(const char *str);
22 const char *(*units_format_func)(double val);
23 void (*units_format_free)(const char *str);
25 double val, val_min, val_max;
28 Eina_Bool horizontal : 1;
29 Eina_Bool inverted : 1;
30 Eina_Bool indicator_show : 1;
33 #define ELM_SLIDER_INVERTED_FACTOR (-1.0)
35 static const char *widtype = NULL;
36 static void _del_hook(Evas_Object *obj);
37 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
38 static void _theme_hook(Evas_Object *obj);
39 static void _disable_hook(Evas_Object *obj);
40 static void _sizing_eval(Evas_Object *obj);
41 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
42 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
43 static void _units_set(Evas_Object *obj);
44 static void _val_set(Evas_Object *obj);
45 static void _indicator_set(Evas_Object *obj);
46 static void _on_focus_hook(void *data, Evas_Object *obj);
47 static void _drag_up(void *data, Evas_Object *obj,
48 const char *emission, const char *source);
49 static void _drag_down(void *data, Evas_Object *obj,
50 const char *emission, const char *source);
51 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
52 Evas_Callback_Type type, void *event_info);
53 static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
55 static const char SIG_CHANGED[] = "changed";
56 static const char SIG_DELAY_CHANGED[] = "delay,changed";
57 static const char SIG_DRAG_START[] = "slider,drag,start";
58 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
59 static const Evas_Smart_Cb_Description _signals[] = {
61 {SIG_DELAY_CHANGED, ""},
68 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
70 Evas_Event_Mouse_Wheel *mev;
71 Evas_Event_Key_Down *ev;
74 wd = elm_widget_data_get(obj);
75 if (!wd) return EINA_FALSE;
77 if (type == EVAS_CALLBACK_KEY_DOWN) goto key_down;
78 else if (type != EVAS_CALLBACK_MOUSE_WHEEL) return EINA_FALSE;
81 if (mev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
82 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
84 if (mev->z < 0) _drag_up(obj, NULL, NULL, NULL);
85 else _drag_down(obj, NULL, NULL, NULL);
86 mev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
91 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
92 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
93 if ((!strcmp(ev->keyname, "Left"))
94 || (!strcmp(ev->keyname, "KP_Left")))
96 if (!wd->horizontal) return EINA_FALSE;
97 if (!wd->inverted) _drag_down(obj, NULL, NULL, NULL);
98 else _drag_up(obj, NULL, NULL, NULL);
99 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
102 else if ((!strcmp(ev->keyname, "Right"))
103 || (!strcmp(ev->keyname, "KP_Right")))
105 if (!wd->horizontal) return EINA_FALSE;
106 if (!wd->inverted) _drag_up(obj, NULL, NULL, NULL);
107 else _drag_down(obj, NULL, NULL, NULL);
108 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
111 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
113 if (wd->horizontal) return EINA_FALSE;
114 if (wd->inverted) _drag_up(obj, NULL, NULL, NULL);
115 else _drag_down(obj, NULL, NULL, NULL);
116 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
119 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
121 if (wd->horizontal) return EINA_FALSE;
122 if (wd->inverted) _drag_down(obj, NULL, NULL, NULL);
123 else _drag_up(obj, NULL, NULL, NULL);
124 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
127 else return EINA_FALSE;
131 _del_hook(Evas_Object *obj)
133 Widget_Data *wd = elm_widget_data_get(obj);
135 if (wd->label) eina_stringshare_del(wd->label);
136 if (wd->indicator) eina_stringshare_del(wd->units);
137 if (wd->delay) ecore_timer_del(wd->delay);
142 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
144 Widget_Data *wd = elm_widget_data_get(obj);
146 if (elm_widget_focus_get(obj))
148 edje_object_signal_emit(wd->slider, "elm,action,focus", "elm");
149 evas_object_focus_set(wd->slider, EINA_TRUE);
153 edje_object_signal_emit(wd->slider, "elm,action,unfocus", "elm");
154 evas_object_focus_set(wd->slider, EINA_FALSE);
159 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
161 Widget_Data *wd = elm_widget_data_get(obj);
163 edje_object_mirrored_set(wd->slider, rtl);
167 _theme_hook(Evas_Object *obj)
169 Widget_Data *wd = elm_widget_data_get(obj);
171 _elm_widget_mirrored_reload(obj);
172 _mirrored_set(obj, elm_widget_mirrored_get(obj));
174 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
176 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
179 edje_object_part_swallow(wd->slider, "elm.swallow.content", wd->icon);
180 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
183 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
185 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
188 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
189 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
193 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
196 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
198 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
201 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
203 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
206 edje_object_message_signal_process(wd->slider);
207 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
213 _disable_hook(Evas_Object *obj)
215 Widget_Data *wd = elm_widget_data_get(obj);
217 if (elm_widget_disabled_get(obj))
218 edje_object_signal_emit(wd->slider, "elm,state,disabled", "elm");
220 edje_object_signal_emit(wd->slider, "elm,state,enabled", "elm");
224 _sizing_eval(Evas_Object *obj)
226 Widget_Data *wd = elm_widget_data_get(obj);
227 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
229 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
230 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
231 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
232 evas_object_size_hint_min_set(obj, minw, minh);
233 evas_object_size_hint_max_set(obj, maxw, maxh);
237 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
239 Widget_Data *wd = elm_widget_data_get(data);
241 if ((obj != wd->icon) && (obj != wd->end)) return;
246 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
248 Widget_Data *wd = elm_widget_data_get(obj);
249 Evas_Object *sub = event_info;
253 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
254 evas_object_event_callback_del_full
255 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
257 edje_object_message_signal_process(wd->slider);
262 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
263 evas_object_event_callback_del_full(sub,
264 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
265 _changed_size_hints, obj);
267 edje_object_message_signal_process(wd->slider);
273 _delay_change(void *data)
275 Widget_Data *wd = elm_widget_data_get(data);
276 if (!wd) return ECORE_CALLBACK_CANCEL;
278 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
279 return ECORE_CALLBACK_CANCEL;
283 _val_fetch(Evas_Object *obj)
286 Widget_Data *wd = elm_widget_data_get(obj);
287 double posx = 0.0, posy = 0.0, pos = 0.0, val;
289 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
291 if (wd->horizontal) pos = posx;
294 rtl = elm_widget_mirrored_get(obj);
295 if ((!rtl && wd->inverted) || (rtl &&
296 ((!wd->horizontal && wd->inverted) ||
297 (wd->horizontal && !wd->inverted)))) pos = 1.0 - pos;
298 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
302 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
303 if (wd->delay) ecore_timer_del(wd->delay);
304 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
309 _val_set(Evas_Object *obj)
312 Widget_Data *wd = elm_widget_data_get(obj);
315 if (wd->val_max > wd->val_min)
316 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
319 if (pos < 0.0) pos = 0.0;
320 else if (pos > 1.0) pos = 1.0;
322 rtl = elm_widget_mirrored_get(obj);
323 if ((!rtl && wd->inverted) || (rtl &&
324 ((!wd->horizontal && wd->inverted) ||
325 (wd->horizontal && !wd->inverted)))) pos = 1.0 - pos;
326 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
330 _units_set(Evas_Object *obj)
332 Widget_Data *wd = elm_widget_data_get(obj);
334 if (wd->units_format_func)
337 buf = wd->units_format_func(wd->val);
338 edje_object_part_text_set(wd->slider, "elm.units", buf);
339 if (wd->units_format_free) wd->units_format_free(buf);
345 snprintf(buf, sizeof(buf), wd->units, wd->val);
346 edje_object_part_text_set(wd->slider, "elm.units", buf);
349 edje_object_part_text_set(wd->slider, "elm.units", NULL);
353 _indicator_set(Evas_Object *obj)
355 Widget_Data *wd = elm_widget_data_get(obj);
357 if (wd->indicator_format_func)
360 buf = wd->indicator_format_func(wd->val);
361 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
362 if (wd->indicator_format_free) wd->indicator_format_free(buf);
364 else if (wd->indicator)
367 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
368 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
371 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", NULL);
375 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
379 _indicator_set(data);
383 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
386 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
388 _indicator_set(data);
389 elm_widget_scroll_freeze_push(data);
393 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
396 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
398 _indicator_set(data);
399 elm_widget_scroll_freeze_pop(data);
403 _drag_step(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
407 _indicator_set(data);
411 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
416 wd = elm_widget_data_get(data);
419 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
421 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
425 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
430 wd = elm_widget_data_get(data);
433 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
435 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
439 _spacer_cb(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
441 Widget_Data *wd = elm_widget_data_get(data);
442 Evas_Event_Mouse_Down *ev = event_info;
443 Evas_Coord x, y, w, h;
444 double button_x, button_y;
446 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
447 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
450 button_x = ((double)ev->canvas.x - (double)x) / (double)w;
451 if (button_x > 1) button_x = 1;
452 if (button_x < 0) button_x = 0;
456 button_y = ((double)ev->canvas.y - (double)y) / (double)h;
457 if (button_y > 1) button_y = 1;
458 if (button_y < 0) button_y = 0;
460 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
461 evas_event_feed_mouse_cancel(e, 0, NULL);
462 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
466 _elm_slider_label_set(Evas_Object *obj, const char *item, const char *label)
468 ELM_CHECK_WIDTYPE(obj, widtype);
469 Widget_Data *wd = elm_widget_data_get(obj);
470 if (item && strcmp(item, "default")) return;
472 eina_stringshare_replace(&wd->label, label);
475 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
476 edje_object_message_signal_process(wd->slider);
480 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
481 edje_object_message_signal_process(wd->slider);
483 edje_object_part_text_set(wd->slider, "elm.text", label);
488 _elm_slider_label_get(const Evas_Object *obj, const char *item)
490 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
491 Widget_Data *wd = elm_widget_data_get(obj);
492 if (item && strcmp(item, "default")) return NULL;
493 if (!wd) return NULL;
498 _icon_set(Evas_Object *obj, Evas_Object *icon)
500 Widget_Data *wd = elm_widget_data_get(obj);
502 if (wd->icon == icon) return;
503 if (wd->icon) evas_object_del(wd->icon);
507 elm_widget_sub_object_add(obj, icon);
508 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
509 _changed_size_hints, obj);
510 edje_object_part_swallow(wd->slider, "elm.swallow.icon", icon);
511 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
512 edje_object_message_signal_process(wd->slider);
518 _icon_unset(Evas_Object *obj)
520 Widget_Data *wd = elm_widget_data_get(obj);
521 Evas_Object *ret = NULL;
522 if (!wd) return NULL;
525 elm_widget_sub_object_del(obj, wd->icon);
526 evas_object_event_callback_del_full(wd->icon,
527 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
528 _changed_size_hints, obj);
530 edje_object_part_unswallow(wd->slider, wd->icon);
531 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
539 _end_set(Evas_Object *obj, Evas_Object *end)
541 Widget_Data *wd = elm_widget_data_get(obj);
543 if (wd->end == end) return;
544 if (wd->end) evas_object_del(wd->end);
548 elm_widget_sub_object_add(obj, end);
549 evas_object_event_callback_add(end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
550 _changed_size_hints, obj);
551 edje_object_part_swallow(wd->slider, "elm.swallow.end", end);
552 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
553 edje_object_message_signal_process(wd->slider);
559 _end_unset(Evas_Object *obj)
561 Widget_Data *wd = elm_widget_data_get(obj);
562 Evas_Object *ret = NULL;
563 if (!wd) return NULL;
566 elm_widget_sub_object_del(obj, wd->end);
567 evas_object_event_callback_del_full(wd->end,
568 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
569 _changed_size_hints, obj);
571 edje_object_part_unswallow(wd->slider, wd->end);
572 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
580 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
582 ELM_CHECK_WIDTYPE(obj, widtype);
584 if (!strcmp(part, "icon"))
585 _icon_set(obj, content);
586 else if (!strcmp(part, "end"))
587 _end_set(obj, content);
591 _content_get_hook(const Evas_Object *obj, const char *part)
593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
595 if (!part) return NULL;
596 wd = elm_widget_data_get(obj);
597 if (!wd) return NULL;
598 if (!strcmp(part, "icon"))
600 else if (!strcmp(part, "end"))
606 _content_unset_hook(Evas_Object *obj, const char *part)
608 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
609 if (!part) return NULL;
610 if (!strcmp(part, "icon"))
611 return _icon_unset(obj);
612 else if (!strcmp(part, "end"))
613 return _end_unset(obj);
618 elm_slider_add(Evas_Object *parent)
624 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
626 ELM_SET_WIDTYPE(widtype, "slider");
627 elm_widget_type_set(obj, "slider");
628 elm_widget_sub_object_add(parent, obj);
629 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
630 elm_widget_data_set(obj, wd);
631 elm_widget_del_hook_set(obj, _del_hook);
632 elm_widget_theme_hook_set(obj, _theme_hook);
633 elm_widget_disable_hook_set(obj, _disable_hook);
634 elm_widget_can_focus_set(obj, EINA_TRUE);
635 elm_widget_event_hook_set(obj, _event_hook);
636 elm_widget_text_set_hook_set(obj, _elm_slider_label_set);
637 elm_widget_text_get_hook_set(obj, _elm_slider_label_get);
638 elm_widget_content_set_hook_set(obj, _content_set_hook);
639 elm_widget_content_get_hook_set(obj, _content_get_hook);
640 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
642 wd->horizontal = EINA_TRUE;
643 wd->indicator_show = EINA_TRUE;
648 wd->slider = edje_object_add(e);
649 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
650 elm_widget_resize_object_set(obj, wd->slider);
651 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
652 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
653 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
654 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_step, obj);
655 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
656 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
657 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
659 wd->spacer = evas_object_rectangle_add(e);
660 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
661 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
662 elm_widget_sub_object_add(obj, wd->spacer);
663 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
664 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
665 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
667 _mirrored_set(obj, elm_widget_mirrored_get(obj));
670 // TODO: convert Elementary to subclassing of Evas_Smart_Class
671 // TODO: and save some bytes, making descriptions per-class and not instance!
672 evas_object_smart_callbacks_descriptions_set(obj, _signals);
677 elm_slider_label_set(Evas_Object *obj, const char *label)
679 _elm_slider_label_set(obj, NULL, label);
683 elm_slider_label_get(const Evas_Object *obj)
685 return _elm_slider_label_get(obj, NULL);
689 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
691 _content_set_hook(obj, "icon", icon);
695 elm_slider_icon_unset(Evas_Object *obj)
697 return _content_unset_hook(obj, "icon");
701 elm_slider_icon_get(const Evas_Object *obj)
703 return _content_get_hook(obj, "icon");
707 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
709 ELM_CHECK_WIDTYPE(obj, widtype);
710 Widget_Data *wd = elm_widget_data_get(obj);
712 if (wd->size == size) return;
715 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
717 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
718 if (wd->indicator_show)
719 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
721 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
722 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
727 elm_slider_span_size_get(const Evas_Object *obj)
729 ELM_CHECK_WIDTYPE(obj, widtype) 0;
730 Widget_Data *wd = elm_widget_data_get(obj);
736 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
738 ELM_CHECK_WIDTYPE(obj, widtype);
739 Widget_Data *wd = elm_widget_data_get(obj);
741 eina_stringshare_replace(&wd->units, units);
744 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
745 edje_object_message_signal_process(wd->slider);
749 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
750 edje_object_message_signal_process(wd->slider);
757 elm_slider_unit_format_get(const Evas_Object *obj)
759 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
760 Widget_Data *wd = elm_widget_data_get(obj);
761 if (!wd) return NULL;
766 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
768 ELM_CHECK_WIDTYPE(obj, widtype);
769 Widget_Data *wd = elm_widget_data_get(obj);
771 eina_stringshare_replace(&wd->indicator, indicator);
776 elm_slider_indicator_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;
781 return wd->indicator;
785 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
787 ELM_CHECK_WIDTYPE(obj, widtype);
788 Widget_Data *wd = elm_widget_data_get(obj);
790 horizontal = !!horizontal;
791 if (wd->horizontal == horizontal) return;
792 wd->horizontal = horizontal;
797 elm_slider_horizontal_get(const Evas_Object *obj)
799 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
800 Widget_Data *wd = elm_widget_data_get(obj);
801 if (!wd) return EINA_FALSE;
802 return wd->horizontal;
806 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
808 ELM_CHECK_WIDTYPE(obj, widtype);
809 Widget_Data *wd = elm_widget_data_get(obj);
811 if ((wd->val_min == min) && (wd->val_max == max)) return;
814 if (wd->val < wd->val_min) wd->val = wd->val_min;
815 if (wd->val > wd->val_max) wd->val = wd->val_max;
822 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
826 ELM_CHECK_WIDTYPE(obj, widtype);
827 Widget_Data *wd = elm_widget_data_get(obj);
829 if (min) *min = wd->val_min;
830 if (max) *max = wd->val_max;
834 elm_slider_value_set(Evas_Object *obj, double val)
836 ELM_CHECK_WIDTYPE(obj, widtype);
837 Widget_Data *wd = elm_widget_data_get(obj);
839 if (wd->val == val) return;
841 if (wd->val < wd->val_min) wd->val = wd->val_min;
842 if (wd->val > wd->val_max) wd->val = wd->val_max;
849 elm_slider_value_get(const Evas_Object *obj)
851 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
852 Widget_Data *wd = elm_widget_data_get(obj);
858 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
860 ELM_CHECK_WIDTYPE(obj, widtype);
861 Widget_Data *wd = elm_widget_data_get(obj);
863 inverted = !!inverted;
864 if (wd->inverted == inverted) return;
865 wd->inverted = inverted;
867 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
869 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
870 edje_object_message_signal_process(wd->slider);
877 elm_slider_inverted_get(const Evas_Object *obj)
879 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
880 Widget_Data *wd = elm_widget_data_get(obj);
881 if (!wd) return EINA_FALSE;
886 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
888 ELM_CHECK_WIDTYPE(obj, widtype);
889 Widget_Data *wd = elm_widget_data_get(obj);
891 wd->indicator_format_func = func;
892 wd->indicator_format_free = free_func;
897 elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
899 ELM_CHECK_WIDTYPE(obj, widtype);
900 Widget_Data *wd = elm_widget_data_get(obj);
902 wd->units_format_func = func;
903 wd->units_format_free = free_func;
908 elm_slider_end_set(Evas_Object *obj, Evas_Object *end)
910 _content_set_hook(obj, "end", end);
914 elm_slider_end_unset(Evas_Object *obj)
916 return _content_unset_hook(obj, "end");
920 elm_slider_end_get(const Evas_Object *obj)
922 return _content_get_hook(obj, "end");
926 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
928 ELM_CHECK_WIDTYPE(obj, widtype);
929 Widget_Data *wd = elm_widget_data_get(obj);
931 wd->indicator_show = EINA_TRUE;
932 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
935 wd->indicator_show = EINA_FALSE;
936 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
941 elm_slider_indicator_show_get(const Evas_Object *obj)
943 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
944 Widget_Data *wd = elm_widget_data_get(obj);
945 if (!wd) return EINA_FALSE;
946 return wd->indicator_show;