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;
34 #define ELM_SLIDER_INVERTED_FACTOR (-1.0)
36 static const char *widtype = NULL;
37 static void _del_hook(Evas_Object *obj);
38 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
39 static void _theme_hook(Evas_Object *obj);
40 static void _disable_hook(Evas_Object *obj);
41 static void _sizing_eval(Evas_Object *obj);
42 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
43 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
44 static void _units_set(Evas_Object *obj);
45 static void _val_set(Evas_Object *obj);
46 static void _indicator_set(Evas_Object *obj);
47 static void _on_focus_hook(void *data, Evas_Object *obj);
48 static void _drag_up(void *data, Evas_Object *obj,
49 const char *emission, const char *source);
50 static void _drag_down(void *data, Evas_Object *obj,
51 const char *emission, const char *source);
52 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
53 Evas_Callback_Type type, void *event_info);
54 static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
56 static const char SIG_CHANGED[] = "changed";
57 static const char SIG_DELAY_CHANGED[] = "delay,changed";
58 static const char SIG_DRAG_START[] = "slider,drag,start";
59 static const char SIG_DRAG_STOP[] = "slider,drag,stop";
60 static const Evas_Smart_Cb_Description _signals[] = {
62 {SIG_DELAY_CHANGED, ""},
69 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
71 Evas_Event_Mouse_Wheel *mev;
72 Evas_Event_Key_Down *ev;
75 wd = elm_widget_data_get(obj);
76 if (!wd) return EINA_FALSE;
77 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
79 if (type == EVAS_CALLBACK_KEY_DOWN) goto key_down;
80 else if (type != EVAS_CALLBACK_MOUSE_WHEEL) return EINA_FALSE;
83 if (mev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
84 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
86 if (mev->z < 0) _drag_up(obj, NULL, NULL, NULL);
87 else _drag_down(obj, NULL, NULL, NULL);
88 mev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
93 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
94 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
95 if ((!strcmp(ev->keyname, "Left"))
96 || (!strcmp(ev->keyname, "KP_Left")))
98 if (!wd->horizontal) return EINA_FALSE;
99 if (!wd->inverted) _drag_down(obj, NULL, NULL, NULL);
100 else _drag_up(obj, NULL, NULL, NULL);
101 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
104 else if ((!strcmp(ev->keyname, "Right"))
105 || (!strcmp(ev->keyname, "KP_Right")))
107 if (!wd->horizontal) return EINA_FALSE;
108 if (!wd->inverted) _drag_up(obj, NULL, NULL, NULL);
109 else _drag_down(obj, NULL, NULL, NULL);
110 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
113 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
115 if (wd->horizontal) return EINA_FALSE;
116 if (wd->inverted) _drag_up(obj, NULL, NULL, NULL);
117 else _drag_down(obj, NULL, NULL, NULL);
118 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
121 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
123 if (wd->horizontal) return EINA_FALSE;
124 if (wd->inverted) _drag_down(obj, NULL, NULL, NULL);
125 else _drag_up(obj, NULL, NULL, NULL);
126 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
129 else return EINA_FALSE;
133 _del_hook(Evas_Object *obj)
135 Widget_Data *wd = elm_widget_data_get(obj);
137 if (wd->label) eina_stringshare_del(wd->label);
138 if (wd->indicator) eina_stringshare_del(wd->units);
139 if (wd->delay) ecore_timer_del(wd->delay);
144 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
146 Widget_Data *wd = elm_widget_data_get(obj);
148 if (elm_widget_focus_get(obj))
150 edje_object_signal_emit(wd->slider, "elm,action,focus", "elm");
151 evas_object_focus_set(wd->slider, EINA_TRUE);
155 edje_object_signal_emit(wd->slider, "elm,action,unfocus", "elm");
156 evas_object_focus_set(wd->slider, EINA_FALSE);
161 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
163 Widget_Data *wd = elm_widget_data_get(obj);
165 edje_object_mirrored_set(wd->slider, rtl);
169 _theme_hook(Evas_Object *obj)
171 Widget_Data *wd = elm_widget_data_get(obj);
173 _elm_widget_mirrored_reload(obj);
174 _mirrored_set(obj, elm_widget_mirrored_get(obj));
176 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", elm_widget_style_get(obj));
178 _elm_theme_object_set(obj, wd->slider, "slider", "vertical", elm_widget_style_get(obj));
179 if (elm_widget_disabled_get(obj))
180 edje_object_signal_emit(wd->slider, "elm,state,disabled", "elm");
182 edje_object_signal_emit(wd->slider, "elm,state,enabled", "elm");
185 edje_object_part_swallow(wd->slider, "elm.swallow.content", wd->icon);
186 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
189 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
191 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
194 edje_object_part_text_set(wd->slider, "elm.text", wd->label);
195 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
199 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
202 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
204 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
207 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
209 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
212 edje_object_message_signal_process(wd->slider);
213 edje_object_scale_set(wd->slider, elm_widget_scale_get(obj) * _elm_config->scale);
219 _disable_hook(Evas_Object *obj)
221 Widget_Data *wd = elm_widget_data_get(obj);
223 if (elm_widget_disabled_get(obj))
224 edje_object_signal_emit(wd->slider, "elm,state,disabled", "elm");
226 edje_object_signal_emit(wd->slider, "elm,state,enabled", "elm");
230 _sizing_eval(Evas_Object *obj)
232 Widget_Data *wd = elm_widget_data_get(obj);
233 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
235 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
236 edje_object_size_min_restricted_calc(wd->slider, &minw, &minh, minw, minh);
237 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
238 evas_object_size_hint_min_set(obj, minw, minh);
239 evas_object_size_hint_max_set(obj, maxw, maxh);
243 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
245 Widget_Data *wd = elm_widget_data_get(data);
247 if ((obj != wd->icon) && (obj != wd->end)) return;
252 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
254 Widget_Data *wd = elm_widget_data_get(obj);
255 Evas_Object *sub = event_info;
259 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
260 evas_object_event_callback_del_full
261 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
263 edje_object_message_signal_process(wd->slider);
268 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
269 evas_object_event_callback_del_full(sub,
270 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
271 _changed_size_hints, obj);
273 edje_object_message_signal_process(wd->slider);
279 _delay_change(void *data)
281 Widget_Data *wd = elm_widget_data_get(data);
282 if (!wd) return ECORE_CALLBACK_CANCEL;
284 evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, NULL);
285 return ECORE_CALLBACK_CANCEL;
289 _val_fetch(Evas_Object *obj)
292 Widget_Data *wd = elm_widget_data_get(obj);
293 double posx = 0.0, posy = 0.0, pos = 0.0, val;
295 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider",
297 if (wd->horizontal) pos = posx;
300 rtl = elm_widget_mirrored_get(obj);
301 if ((!rtl && wd->inverted) || (rtl &&
302 ((!wd->horizontal && wd->inverted) ||
303 (wd->horizontal && !wd->inverted)))) pos = 1.0 - pos;
304 val = (pos * (wd->val_max - wd->val_min)) + wd->val_min;
308 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
309 if (wd->delay) ecore_timer_del(wd->delay);
310 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
315 _val_set(Evas_Object *obj)
318 Widget_Data *wd = elm_widget_data_get(obj);
321 if (wd->val_max > wd->val_min)
322 pos = (wd->val - wd->val_min) / (wd->val_max - wd->val_min);
325 if (pos < 0.0) pos = 0.0;
326 else if (pos > 1.0) pos = 1.0;
328 rtl = elm_widget_mirrored_get(obj);
329 if ((!rtl && wd->inverted) || (rtl &&
330 ((!wd->horizontal && wd->inverted) ||
331 (wd->horizontal && !wd->inverted)))) pos = 1.0 - pos;
332 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", pos, pos);
336 _units_set(Evas_Object *obj)
338 Widget_Data *wd = elm_widget_data_get(obj);
340 if (wd->units_format_func)
343 buf = wd->units_format_func(wd->val);
344 edje_object_part_text_set(wd->slider, "elm.units", buf);
345 if (wd->units_format_free) wd->units_format_free(buf);
351 snprintf(buf, sizeof(buf), wd->units, wd->val);
352 edje_object_part_text_set(wd->slider, "elm.units", buf);
355 edje_object_part_text_set(wd->slider, "elm.units", NULL);
359 _indicator_set(Evas_Object *obj)
361 Widget_Data *wd = elm_widget_data_get(obj);
363 if (wd->indicator_format_func)
366 buf = wd->indicator_format_func(wd->val);
367 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
368 if (wd->indicator_format_free) wd->indicator_format_free(buf);
370 else if (wd->indicator)
373 snprintf(buf, sizeof(buf), wd->indicator, wd->val);
374 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
377 edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", NULL);
381 _drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
383 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
384 if (elm_widget_disabled_get(data)) return;
387 _indicator_set(data);
388 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
389 edje_object_message_signal_process(wd->slider);
393 _drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
395 Widget_Data *wd = elm_widget_data_get((Evas_Object*)data);
396 if (elm_widget_disabled_get(data)) return;
398 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
400 _indicator_set(data);
401 elm_widget_scroll_freeze_push(data);
402 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
403 edje_object_message_signal_process(wd->slider);
407 _drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
409 if (elm_widget_disabled_get(data)) return;
411 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
413 _indicator_set(data);
414 elm_widget_scroll_freeze_pop(data);
418 _drag_step(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
420 if (elm_widget_disabled_get(data)) return;
423 _indicator_set(data);
427 _drag_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
431 if (elm_widget_disabled_get(data)) return;
433 wd = elm_widget_data_get(data);
436 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
438 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
442 _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
446 if (elm_widget_disabled_get(data)) return;
448 wd = elm_widget_data_get(data);
451 if (wd->inverted) step *= ELM_SLIDER_INVERTED_FACTOR;
453 edje_object_part_drag_step(wd->slider, "elm.dragable.slider", step, step);
457 _spacer_cb(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
459 Widget_Data *wd = elm_widget_data_get(data);
460 Evas_Event_Mouse_Down *ev = event_info;
461 Evas_Coord x, y, w, h;
462 double button_x, button_y;
463 if (elm_widget_disabled_get(data)) return;
465 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
466 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &button_x, &button_y);
469 button_x = ((double)ev->canvas.x - (double)x) / (double)w;
470 if (button_x > 1) button_x = 1;
471 if (button_x < 0) button_x = 0;
475 button_y = ((double)ev->canvas.y - (double)y) / (double)h;
476 if (button_y > 1) button_y = 1;
477 if (button_y < 0) button_y = 0;
479 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
480 evas_event_feed_mouse_cancel(e, 0, NULL);
483 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
488 _elm_slider_label_set(Evas_Object *obj, const char *item, const char *label)
490 ELM_CHECK_WIDTYPE(obj, widtype);
491 Widget_Data *wd = elm_widget_data_get(obj);
492 if (item && strcmp(item, "default")) return;
494 eina_stringshare_replace(&wd->label, label);
497 edje_object_signal_emit(wd->slider, "elm,state,text,visible", "elm");
498 edje_object_message_signal_process(wd->slider);
502 edje_object_signal_emit(wd->slider, "elm,state,text,hidden", "elm");
503 edje_object_message_signal_process(wd->slider);
505 edje_object_part_text_set(wd->slider, "elm.text", label);
510 _elm_slider_label_get(const Evas_Object *obj, const char *item)
512 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
513 Widget_Data *wd = elm_widget_data_get(obj);
514 if (item && strcmp(item, "default")) return NULL;
515 if (!wd) return NULL;
520 elm_slider_add(Evas_Object *parent)
526 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
528 ELM_SET_WIDTYPE(widtype, "slider");
529 elm_widget_type_set(obj, "slider");
530 elm_widget_sub_object_add(parent, obj);
531 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
532 elm_widget_data_set(obj, wd);
533 elm_widget_del_hook_set(obj, _del_hook);
534 elm_widget_theme_hook_set(obj, _theme_hook);
535 elm_widget_disable_hook_set(obj, _disable_hook);
536 elm_widget_can_focus_set(obj, EINA_TRUE);
537 elm_widget_event_hook_set(obj, _event_hook);
538 elm_widget_text_set_hook_set(obj, _elm_slider_label_set);
539 elm_widget_text_get_hook_set(obj, _elm_slider_label_get);
541 wd->horizontal = EINA_TRUE;
542 wd->indicator_show = EINA_TRUE;
548 wd->slider = edje_object_add(e);
549 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
550 elm_widget_resize_object_set(obj, wd->slider);
551 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
552 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
553 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
554 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_step, obj);
555 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
556 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
557 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
559 wd->spacer = evas_object_rectangle_add(e);
560 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
561 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
562 elm_widget_sub_object_add(obj, wd->spacer);
563 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
564 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
565 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
567 _mirrored_set(obj, elm_widget_mirrored_get(obj));
570 // TODO: convert Elementary to subclassing of Evas_Smart_Class
571 // TODO: and save some bytes, making descriptions per-class and not instance!
572 evas_object_smart_callbacks_descriptions_set(obj, _signals);
577 elm_slider_label_set(Evas_Object *obj, const char *label)
579 _elm_slider_label_set(obj, NULL, label);
583 elm_slider_label_get(const Evas_Object *obj)
585 return _elm_slider_label_get(obj, NULL);
589 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
591 ELM_CHECK_WIDTYPE(obj, widtype);
592 Widget_Data *wd = elm_widget_data_get(obj);
594 if (wd->icon == icon) return;
595 if (wd->icon) evas_object_del(wd->icon);
599 elm_widget_sub_object_add(obj, icon);
600 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
601 _changed_size_hints, obj);
602 edje_object_part_swallow(wd->slider, "elm.swallow.icon", icon);
603 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
604 edje_object_message_signal_process(wd->slider);
610 elm_slider_icon_unset(Evas_Object *obj)
612 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
613 Widget_Data *wd = elm_widget_data_get(obj);
614 Evas_Object *ret = NULL;
615 if (!wd) return NULL;
618 elm_widget_sub_object_del(obj, wd->icon);
620 edje_object_part_unswallow(wd->slider, wd->icon);
621 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
629 elm_slider_icon_get(const Evas_Object *obj)
631 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
632 Widget_Data *wd = elm_widget_data_get(obj);
633 if (!wd) return NULL;
638 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
640 ELM_CHECK_WIDTYPE(obj, widtype);
641 Widget_Data *wd = elm_widget_data_get(obj);
643 if (wd->size == size) return;
646 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
648 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
649 if (wd->indicator_show)
650 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
652 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
653 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
658 elm_slider_span_size_get(const Evas_Object *obj)
660 ELM_CHECK_WIDTYPE(obj, widtype) 0;
661 Widget_Data *wd = elm_widget_data_get(obj);
667 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
669 ELM_CHECK_WIDTYPE(obj, widtype);
670 Widget_Data *wd = elm_widget_data_get(obj);
672 eina_stringshare_replace(&wd->units, units);
675 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
676 edje_object_message_signal_process(wd->slider);
680 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
681 edje_object_message_signal_process(wd->slider);
688 elm_slider_unit_format_get(const Evas_Object *obj)
690 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
691 Widget_Data *wd = elm_widget_data_get(obj);
692 if (!wd) return NULL;
697 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
699 ELM_CHECK_WIDTYPE(obj, widtype);
700 Widget_Data *wd = elm_widget_data_get(obj);
702 eina_stringshare_replace(&wd->indicator, indicator);
707 elm_slider_indicator_format_get(const Evas_Object *obj)
709 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
710 Widget_Data *wd = elm_widget_data_get(obj);
711 if (!wd) return NULL;
712 return wd->indicator;
716 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
718 ELM_CHECK_WIDTYPE(obj, widtype);
719 Widget_Data *wd = elm_widget_data_get(obj);
721 horizontal = !!horizontal;
722 if (wd->horizontal == horizontal) return;
723 wd->horizontal = horizontal;
728 elm_slider_horizontal_get(const Evas_Object *obj)
730 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
731 Widget_Data *wd = elm_widget_data_get(obj);
732 if (!wd) return EINA_FALSE;
733 return wd->horizontal;
737 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
739 ELM_CHECK_WIDTYPE(obj, widtype);
740 Widget_Data *wd = elm_widget_data_get(obj);
742 if ((wd->val_min == min) && (wd->val_max == max)) return;
745 if (wd->val < wd->val_min) wd->val = wd->val_min;
746 if (wd->val > wd->val_max) wd->val = wd->val_max;
753 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
757 ELM_CHECK_WIDTYPE(obj, widtype);
758 Widget_Data *wd = elm_widget_data_get(obj);
760 if (min) *min = wd->val_min;
761 if (max) *max = wd->val_max;
765 elm_slider_value_set(Evas_Object *obj, double val)
767 ELM_CHECK_WIDTYPE(obj, widtype);
768 Widget_Data *wd = elm_widget_data_get(obj);
770 if (wd->val == val) return;
772 if (wd->val < wd->val_min) wd->val = wd->val_min;
773 if (wd->val > wd->val_max) wd->val = wd->val_max;
774 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
781 elm_slider_value_get(const Evas_Object *obj)
783 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
784 Widget_Data *wd = elm_widget_data_get(obj);
790 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
792 ELM_CHECK_WIDTYPE(obj, widtype);
793 Widget_Data *wd = elm_widget_data_get(obj);
795 inverted = !!inverted;
796 if (wd->inverted == inverted) return;
797 wd->inverted = inverted;
799 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
801 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
802 edje_object_message_signal_process(wd->slider);
809 elm_slider_inverted_get(const Evas_Object *obj)
811 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
812 Widget_Data *wd = elm_widget_data_get(obj);
813 if (!wd) return EINA_FALSE;
818 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
820 ELM_CHECK_WIDTYPE(obj, widtype);
821 Widget_Data *wd = elm_widget_data_get(obj);
823 wd->indicator_format_func = func;
824 wd->indicator_format_free = free_func;
829 elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
831 ELM_CHECK_WIDTYPE(obj, widtype);
832 Widget_Data *wd = elm_widget_data_get(obj);
834 wd->units_format_func = func;
835 wd->units_format_free = free_func;
840 elm_slider_end_set(Evas_Object *obj, Evas_Object *end)
842 ELM_CHECK_WIDTYPE(obj, widtype);
843 Widget_Data *wd = elm_widget_data_get(obj);
845 if (wd->end == end) return;
846 if (wd->end) evas_object_del(wd->end);
850 elm_widget_sub_object_add(obj, end);
851 evas_object_event_callback_add(end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
852 _changed_size_hints, obj);
853 edje_object_part_swallow(wd->slider, "elm.swallow.end", end);
854 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
855 edje_object_message_signal_process(wd->slider);
861 elm_slider_end_unset(Evas_Object *obj)
863 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
864 Widget_Data *wd = elm_widget_data_get(obj);
865 Evas_Object *ret = NULL;
866 if (!wd) return NULL;
869 elm_widget_sub_object_del(obj, wd->end);
871 edje_object_part_unswallow(wd->slider, wd->end);
872 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
880 elm_slider_end_get(const Evas_Object *obj)
882 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
883 Widget_Data *wd = elm_widget_data_get(obj);
884 if (!wd) return NULL;
889 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
891 ELM_CHECK_WIDTYPE(obj, widtype);
892 Widget_Data *wd = elm_widget_data_get(obj);
894 wd->indicator_show = EINA_TRUE;
895 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
898 wd->indicator_show = EINA_FALSE;
899 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
904 elm_slider_indicator_show_get(const Evas_Object *obj)
906 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
907 Widget_Data *wd = elm_widget_data_get(obj);
908 if (!wd) return EINA_FALSE;
909 return wd->indicator_show;