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->labels) eina_hash_free(wd->labels);
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 _labels_foreach_text_set(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
169 Widget_Data *wd = fdata;
171 edje_object_part_text_set(wd->slider, key, data);
177 _theme_hook(Evas_Object *obj)
179 Widget_Data *wd = elm_widget_data_get(obj);
181 _elm_widget_mirrored_reload(obj);
182 _mirrored_set(obj, elm_widget_mirrored_get(obj));
184 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
186 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
189 edje_object_part_swallow(wd->slider, "elm.swallow.content", wd->icon);
190 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
193 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
195 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
198 eina_hash_foreach(wd->labels, _labels_foreach_text_set, wd);
199 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
203 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
206 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
208 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
211 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
213 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
216 edje_object_message_signal_process(wd->slider);
217 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
223 _disable_hook(Evas_Object *obj)
225 Widget_Data *wd = elm_widget_data_get(obj);
227 if (elm_widget_disabled_get(obj))
228 edje_object_signal_emit(wd->slider, "elm,state,disabled", "elm");
230 edje_object_signal_emit(wd->slider, "elm,state,enabled", "elm");
234 _sizing_eval(Evas_Object *obj)
236 Widget_Data *wd = elm_widget_data_get(obj);
237 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
239 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
240 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
241 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
242 evas_object_size_hint_min_set(obj, minw, minh);
243 evas_object_size_hint_max_set(obj, maxw, maxh);
247 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
249 Widget_Data *wd = elm_widget_data_get(data);
251 if ((obj != wd->icon) && (obj != wd->end)) return;
256 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
258 Widget_Data *wd = elm_widget_data_get(obj);
259 Evas_Object *sub = event_info;
263 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
264 evas_object_event_callback_del_full
265 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
267 edje_object_message_signal_process(wd->slider);
272 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
273 evas_object_event_callback_del_full(sub,
274 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
275 _changed_size_hints, obj);
277 edje_object_message_signal_process(wd->slider);
283 _delay_change(void *data)
285 Widget_Data *wd = elm_widget_data_get(data);
286 if (!wd) return ECORE_CALLBACK_CANCEL;
288 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
289 return ECORE_CALLBACK_CANCEL;
293 _val_fetch(Evas_Object *obj)
296 Widget_Data *wd = elm_widget_data_get(obj);
297 double posx = 0.0, posy = 0.0, pos = 0.0, val;
299 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
301 if (wd->horizontal) pos = posx;
304 rtl = elm_widget_mirrored_get(obj);
305 if ((!rtl && wd->inverted) || (rtl &&
306 ((!wd->horizontal && wd->inverted) ||
307 (wd->horizontal && !wd->inverted)))) pos = 1.0 - pos;
308 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
312 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
313 if (wd->delay) ecore_timer_del(wd->delay);
314 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
319 _val_set(Evas_Object *obj)
322 Widget_Data *wd = elm_widget_data_get(obj);
325 if (wd->val_max > wd->val_min)
326 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
329 if (pos < 0.0) pos = 0.0;
330 else if (pos > 1.0) pos = 1.0;
332 rtl = elm_widget_mirrored_get(obj);
333 if ((!rtl && wd->inverted) || (rtl &&
334 ((!wd->horizontal && wd->inverted) ||
335 (wd->horizontal && !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);
344 if (wd->units_format_func)
347 buf = wd->units_format_func(wd->val);
348 edje_object_part_text_set(wd->slider, "elm.units", buf);
349 if (wd->units_format_free) wd->units_format_free(buf);
355 snprintf(buf, sizeof(buf), wd->units, wd->val);
356 edje_object_part_text_set(wd->slider, "elm.units", buf);
359 edje_object_part_text_set(wd->slider, "elm.units", NULL);
363 _indicator_set(Evas_Object *obj)
365 Widget_Data *wd = elm_widget_data_get(obj);
367 if (wd->indicator_format_func)
370 buf = wd->indicator_format_func(wd->val);
371 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
372 if (wd->indicator_format_free) wd->indicator_format_free(buf);
374 else if (wd->indicator)
377 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
378 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
381 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", NULL);
385 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
389 _indicator_set(data);
393 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
396 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
398 _indicator_set(data);
399 elm_widget_scroll_freeze_push(data);
403 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
406 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
408 _indicator_set(data);
409 elm_widget_scroll_freeze_pop(data);
413 _drag_step(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
417 _indicator_set(data);
421 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
426 wd = elm_widget_data_get(data);
429 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
431 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
435 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
440 wd = elm_widget_data_get(data);
443 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
445 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
449 _spacer_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
451 Widget_Data *wd = elm_widget_data_get(data);
452 Evas_Event_Mouse_Down *ev = event_info;
453 Evas_Coord x, y, w, h;
454 double button_x, button_y;
455 double prev_button_x, prev_button_y;
457 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
458 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &prev_button_x, &prev_button_y);
459 button_x = prev_button_x;
460 button_y = prev_button_y;
463 button_x = ((double)ev->canvas.x - (double)x) / (double)w;
464 if (button_x > 1) button_x = 1;
465 if (button_x < 0) button_x = 0;
469 button_y = ((double)ev->canvas.y - (double)y) / (double)h;
470 if (button_y > 1) button_y = 1;
471 if (button_y < 0) button_y = 0;
473 if (button_x != prev_button_x || button_y != prev_button_y)
475 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
478 //What is a purpose of these two mouse events?
479 //I don't know the reason but these calls cause infinite loop.
481 //evas_event_feed_mouse_cancel(e, 0, NULL);
482 //evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
486 _elm_slider_label_set(Evas_Object *obj, const char *part, const char *label)
488 ELM_CHECK_WIDTYPE(obj, widtype);
489 Widget_Data *wd = elm_widget_data_get(obj);
490 const char* default_part = "elm.text";
491 const char* real_part;
496 real_part = default_part;
502 const char* old_label;
504 old_label = eina_hash_find(wd->labels, real_part);
506 eina_hash_add(wd->labels, real_part, eina_stringshare_add(label));
509 eina_stringshare_ref(old_label);
510 eina_hash_modify(wd->labels, real_part, eina_stringshare_add(label));
511 eina_stringshare_del(old_label);
517 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
518 edje_object_message_signal_process(wd->slider);
522 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
523 edje_object_message_signal_process(wd->slider);
526 edje_object_part_text_set(wd->slider, real_part, label);
531 _elm_slider_label_get(const Evas_Object *obj, const char *part)
533 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
534 Widget_Data *wd = elm_widget_data_get(obj);
535 if (!wd) return NULL;
536 if (!wd->labels) return NULL;
539 return eina_hash_find(wd->labels, "elm.text");
540 return eina_hash_find(wd->labels, part);
544 _icon_set(Evas_Object *obj, Evas_Object *icon)
546 Widget_Data *wd = elm_widget_data_get(obj);
548 if (wd->icon == icon) return;
549 if (wd->icon) evas_object_del(wd->icon);
553 elm_widget_sub_object_add(obj, icon);
554 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
555 _changed_size_hints, obj);
556 edje_object_part_swallow(wd->slider, "elm.swallow.icon", icon);
557 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
558 edje_object_message_signal_process(wd->slider);
564 _icon_unset(Evas_Object *obj)
566 Widget_Data *wd = elm_widget_data_get(obj);
567 Evas_Object *ret = NULL;
568 if (!wd) return NULL;
571 elm_widget_sub_object_del(obj, wd->icon);
572 evas_object_event_callback_del_full(wd->icon,
573 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
574 _changed_size_hints, obj);
576 edje_object_part_unswallow(wd->slider, wd->icon);
577 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
585 _end_set(Evas_Object *obj, Evas_Object *end)
587 Widget_Data *wd = elm_widget_data_get(obj);
589 if (wd->end == end) return;
590 if (wd->end) evas_object_del(wd->end);
594 elm_widget_sub_object_add(obj, end);
595 evas_object_event_callback_add(end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
596 _changed_size_hints, obj);
597 edje_object_part_swallow(wd->slider, "elm.swallow.end", end);
598 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
599 edje_object_message_signal_process(wd->slider);
605 _end_unset(Evas_Object *obj)
607 Widget_Data *wd = elm_widget_data_get(obj);
608 Evas_Object *ret = NULL;
609 if (!wd) return NULL;
612 elm_widget_sub_object_del(obj, wd->end);
613 evas_object_event_callback_del_full(wd->end,
614 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
615 _changed_size_hints, obj);
617 edje_object_part_unswallow(wd->slider, wd->end);
618 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
626 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
628 ELM_CHECK_WIDTYPE(obj, widtype);
629 if (!part || !strcmp(part, "icon"))
630 _icon_set(obj, content);
631 else if (!strcmp(part, "end"))
632 _end_set(obj, content);
636 _content_get_hook(const Evas_Object *obj, const char *part)
638 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
640 wd = elm_widget_data_get(obj);
641 if (!wd) return NULL;
642 if (!part || !strcmp(part, "icon"))
644 else if (!strcmp(part, "end"))
650 _content_unset_hook(Evas_Object *obj, const char *part)
652 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
653 if (!part || !strcmp(part, "icon"))
654 return _icon_unset(obj);
655 else if (!strcmp(part, "end"))
656 return _end_unset(obj);
661 _hash_labels_free_cb(void* label)
664 eina_stringshare_del(label);
668 elm_slider_add(Evas_Object *parent)
674 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
676 ELM_SET_WIDTYPE(widtype, "slider");
677 elm_widget_type_set(obj, "slider");
678 elm_widget_sub_object_add(parent, obj);
679 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
680 elm_widget_data_set(obj, wd);
681 elm_widget_del_hook_set(obj, _del_hook);
682 elm_widget_theme_hook_set(obj, _theme_hook);
683 elm_widget_disable_hook_set(obj, _disable_hook);
684 elm_widget_can_focus_set(obj, EINA_TRUE);
685 elm_widget_event_hook_set(obj, _event_hook);
686 elm_widget_text_set_hook_set(obj, _elm_slider_label_set);
687 elm_widget_text_get_hook_set(obj, _elm_slider_label_get);
688 elm_widget_content_set_hook_set(obj, _content_set_hook);
689 elm_widget_content_get_hook_set(obj, _content_get_hook);
690 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
692 wd->horizontal = EINA_TRUE;
693 wd->indicator_show = EINA_TRUE;
697 wd->labels = eina_hash_string_superfast_new(_hash_labels_free_cb);
699 wd->slider = edje_object_add(e);
700 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
701 elm_widget_resize_object_set(obj, wd->slider);
702 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
703 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
704 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
705 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_step, obj);
706 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
707 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
708 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
710 wd->spacer = evas_object_rectangle_add(e);
711 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
712 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
713 elm_widget_sub_object_add(obj, wd->spacer);
714 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
715 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
716 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
718 _mirrored_set(obj, elm_widget_mirrored_get(obj));
721 // TODO: convert Elementary to subclassing of Evas_Smart_Class
722 // TODO: and save some bytes, making descriptions per-class and not instance!
723 evas_object_smart_callbacks_descriptions_set(obj, _signals);
728 elm_slider_label_set(Evas_Object *obj, const char *label)
730 _elm_slider_label_set(obj, NULL, label);
734 elm_slider_label_get(const Evas_Object *obj)
736 return _elm_slider_label_get(obj, NULL);
740 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
742 _content_set_hook(obj, "icon", icon);
746 elm_slider_icon_unset(Evas_Object *obj)
748 return _content_unset_hook(obj, "icon");
752 elm_slider_icon_get(const Evas_Object *obj)
754 return _content_get_hook(obj, "icon");
758 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
760 ELM_CHECK_WIDTYPE(obj, widtype);
761 Widget_Data *wd = elm_widget_data_get(obj);
763 if (wd->size == size) return;
766 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
768 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
769 if (wd->indicator_show)
770 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
772 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
773 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
778 elm_slider_span_size_get(const Evas_Object *obj)
780 ELM_CHECK_WIDTYPE(obj, widtype) 0;
781 Widget_Data *wd = elm_widget_data_get(obj);
787 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
789 ELM_CHECK_WIDTYPE(obj, widtype);
790 Widget_Data *wd = elm_widget_data_get(obj);
792 eina_stringshare_replace(&wd->units, units);
795 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
796 edje_object_message_signal_process(wd->slider);
800 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
801 edje_object_message_signal_process(wd->slider);
808 elm_slider_unit_format_get(const Evas_Object *obj)
810 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
811 Widget_Data *wd = elm_widget_data_get(obj);
812 if (!wd) return NULL;
817 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
819 ELM_CHECK_WIDTYPE(obj, widtype);
820 Widget_Data *wd = elm_widget_data_get(obj);
822 eina_stringshare_replace(&wd->indicator, indicator);
827 elm_slider_indicator_format_get(const Evas_Object *obj)
829 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
830 Widget_Data *wd = elm_widget_data_get(obj);
831 if (!wd) return NULL;
832 return wd->indicator;
836 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
838 ELM_CHECK_WIDTYPE(obj, widtype);
839 Widget_Data *wd = elm_widget_data_get(obj);
841 horizontal = !!horizontal;
842 if (wd->horizontal == horizontal) return;
843 wd->horizontal = horizontal;
848 elm_slider_horizontal_get(const Evas_Object *obj)
850 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
851 Widget_Data *wd = elm_widget_data_get(obj);
852 if (!wd) return EINA_FALSE;
853 return wd->horizontal;
857 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
859 ELM_CHECK_WIDTYPE(obj, widtype);
860 Widget_Data *wd = elm_widget_data_get(obj);
862 if ((wd->val_min == min) && (wd->val_max == max)) return;
865 if (wd->val < wd->val_min) wd->val = wd->val_min;
866 if (wd->val > wd->val_max) wd->val = wd->val_max;
873 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
877 ELM_CHECK_WIDTYPE(obj, widtype);
878 Widget_Data *wd = elm_widget_data_get(obj);
880 if (min) *min = wd->val_min;
881 if (max) *max = wd->val_max;
885 elm_slider_value_set(Evas_Object *obj, double val)
887 ELM_CHECK_WIDTYPE(obj, widtype);
888 Widget_Data *wd = elm_widget_data_get(obj);
890 if (wd->val == val) return;
892 if (wd->val < wd->val_min) wd->val = wd->val_min;
893 if (wd->val > wd->val_max) wd->val = wd->val_max;
900 elm_slider_value_get(const Evas_Object *obj)
902 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
903 Widget_Data *wd = elm_widget_data_get(obj);
909 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
911 ELM_CHECK_WIDTYPE(obj, widtype);
912 Widget_Data *wd = elm_widget_data_get(obj);
914 inverted = !!inverted;
915 if (wd->inverted == inverted) return;
916 wd->inverted = inverted;
918 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
920 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
921 edje_object_message_signal_process(wd->slider);
928 elm_slider_inverted_get(const Evas_Object *obj)
930 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
931 Widget_Data *wd = elm_widget_data_get(obj);
932 if (!wd) return EINA_FALSE;
937 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
939 ELM_CHECK_WIDTYPE(obj, widtype);
940 Widget_Data *wd = elm_widget_data_get(obj);
942 wd->indicator_format_func = func;
943 wd->indicator_format_free = free_func;
948 elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
950 ELM_CHECK_WIDTYPE(obj, widtype);
951 Widget_Data *wd = elm_widget_data_get(obj);
953 wd->units_format_func = func;
954 wd->units_format_free = free_func;
959 elm_slider_end_set(Evas_Object *obj, Evas_Object *end)
961 _content_set_hook(obj, "end", end);
965 elm_slider_end_unset(Evas_Object *obj)
967 return _content_unset_hook(obj, "end");
971 elm_slider_end_get(const Evas_Object *obj)
973 return _content_get_hook(obj, "end");
977 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
979 ELM_CHECK_WIDTYPE(obj, widtype);
980 Widget_Data *wd = elm_widget_data_get(obj);
982 wd->indicator_show = EINA_TRUE;
983 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
986 wd->indicator_show = EINA_FALSE;
987 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
992 elm_slider_indicator_show_get(const Evas_Object *obj)
994 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
995 Widget_Data *wd = elm_widget_data_get(obj);
996 if (!wd) return EINA_FALSE;
997 return wd->indicator_show;