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 _icon_set(Evas_Object *obj, Evas_Object *icon)
522 Widget_Data *wd = elm_widget_data_get(obj);
524 if (wd->icon == icon) return;
525 if (wd->icon) evas_object_del(wd->icon);
529 elm_widget_sub_object_add(obj, icon);
530 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
531 _changed_size_hints, obj);
532 edje_object_part_swallow(wd->slider, "elm.swallow.icon", icon);
533 edje_object_signal_emit(wd->slider, "elm,state,icon,visible", "elm");
534 edje_object_message_signal_process(wd->slider);
540 _icon_unset(Evas_Object *obj)
542 Widget_Data *wd = elm_widget_data_get(obj);
543 Evas_Object *ret = NULL;
544 if (!wd) return NULL;
547 elm_widget_sub_object_del(obj, wd->icon);
548 evas_object_event_callback_del_full(wd->icon,
549 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
550 _changed_size_hints, obj);
552 edje_object_part_unswallow(wd->slider, wd->icon);
553 edje_object_signal_emit(wd->slider, "elm,state,icon,hidden", "elm");
561 _end_set(Evas_Object *obj, Evas_Object *end)
563 Widget_Data *wd = elm_widget_data_get(obj);
565 if (wd->end == end) return;
566 if (wd->end) evas_object_del(wd->end);
570 elm_widget_sub_object_add(obj, end);
571 evas_object_event_callback_add(end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
572 _changed_size_hints, obj);
573 edje_object_part_swallow(wd->slider, "elm.swallow.end", end);
574 edje_object_signal_emit(wd->slider, "elm,state,end,visible", "elm");
575 edje_object_message_signal_process(wd->slider);
581 _end_unset(Evas_Object *obj)
583 Widget_Data *wd = elm_widget_data_get(obj);
584 Evas_Object *ret = NULL;
585 if (!wd) return NULL;
588 elm_widget_sub_object_del(obj, wd->end);
589 evas_object_event_callback_del_full(wd->end,
590 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
591 _changed_size_hints, obj);
593 edje_object_part_unswallow(wd->slider, wd->end);
594 edje_object_signal_emit(wd->slider, "elm,state,end,hidden", "elm");
602 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
604 ELM_CHECK_WIDTYPE(obj, widtype);
605 if ((!part) || (!strcmp(part, "elm.swallow.icon")))
606 _icon_set(obj, content);
607 else if (!strcmp(part, "elm.swallow.end"))
608 _end_set(obj, content);
612 _content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
614 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
615 Widget_Data *wd = elm_widget_data_get(obj);
616 if (!wd) return NULL;
617 if ((!part) || (!strcmp(part, "elm.swallow.icon")))
619 else if (!strcmp(part, "elm.swallow.end"))
625 _content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
627 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
628 if ((!part) || (!strcmp(part, "elm.swallow.icon")))
629 return _icon_unset(obj);
630 else if (!strcmp(part, "elm.swallow.end"))
631 return _end_unset(obj);
636 elm_slider_add(Evas_Object *parent)
642 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
644 ELM_SET_WIDTYPE(widtype, "slider");
645 elm_widget_type_set(obj, "slider");
646 elm_widget_sub_object_add(parent, obj);
647 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
648 elm_widget_data_set(obj, wd);
649 elm_widget_del_hook_set(obj, _del_hook);
650 elm_widget_theme_hook_set(obj, _theme_hook);
651 elm_widget_disable_hook_set(obj, _disable_hook);
652 elm_widget_can_focus_set(obj, EINA_TRUE);
653 elm_widget_event_hook_set(obj, _event_hook);
654 elm_widget_text_set_hook_set(obj, _elm_slider_label_set);
655 elm_widget_text_get_hook_set(obj, _elm_slider_label_get);
656 elm_widget_content_set_hook_set(obj, _content_set_hook);
657 elm_widget_content_get_hook_set(obj, _content_get_hook);
658 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
660 wd->horizontal = EINA_TRUE;
661 wd->indicator_show = EINA_TRUE;
667 wd->slider = edje_object_add(e);
668 _elm_theme_object_set(obj, wd->slider, "slider", "horizontal", "default");
669 elm_widget_resize_object_set(obj, wd->slider);
670 edje_object_signal_callback_add(wd->slider, "drag", "*", _drag, obj);
671 edje_object_signal_callback_add(wd->slider, "drag,start", "*", _drag_start, obj);
672 edje_object_signal_callback_add(wd->slider, "drag,stop", "*", _drag_stop, obj);
673 edje_object_signal_callback_add(wd->slider, "drag,step", "*", _drag_step, obj);
674 edje_object_signal_callback_add(wd->slider, "drag,page", "*", _drag_stop, obj);
675 // edje_object_signal_callback_add(wd->slider, "drag,set", "*", _drag_stop, obj);
676 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", 0.0, 0.0);
678 wd->spacer = evas_object_rectangle_add(e);
679 evas_object_color_set(wd->spacer, 0, 0, 0, 0);
680 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
681 elm_widget_sub_object_add(obj, wd->spacer);
682 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
683 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj);
684 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
686 _mirrored_set(obj, elm_widget_mirrored_get(obj));
689 // TODO: convert Elementary to subclassing of Evas_Smart_Class
690 // TODO: and save some bytes, making descriptions per-class and not instance!
691 evas_object_smart_callbacks_descriptions_set(obj, _signals);
696 elm_slider_label_set(Evas_Object *obj, const char *label)
698 _elm_slider_label_set(obj, NULL, label);
702 elm_slider_label_get(const Evas_Object *obj)
704 return _elm_slider_label_get(obj, NULL);
708 elm_slider_icon_set(Evas_Object *obj, Evas_Object *icon)
710 _content_set_hook(obj, NULL, icon);
714 elm_slider_icon_unset(Evas_Object *obj)
716 return _content_unset_hook(obj, NULL);
720 elm_slider_icon_get(const Evas_Object *obj)
722 return _content_get_hook(obj, NULL);
726 elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
728 ELM_CHECK_WIDTYPE(obj, widtype);
729 Widget_Data *wd = elm_widget_data_get(obj);
731 if (wd->size == size) return;
734 evas_object_size_hint_min_set(wd->spacer, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale, 1);
736 evas_object_size_hint_min_set(wd->spacer, 1, (double)wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
737 if (wd->indicator_show)
738 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
740 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
741 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
746 elm_slider_span_size_get(const Evas_Object *obj)
748 ELM_CHECK_WIDTYPE(obj, widtype) 0;
749 Widget_Data *wd = elm_widget_data_get(obj);
755 elm_slider_unit_format_set(Evas_Object *obj, const char *units)
757 ELM_CHECK_WIDTYPE(obj, widtype);
758 Widget_Data *wd = elm_widget_data_get(obj);
760 eina_stringshare_replace(&wd->units, units);
763 edje_object_signal_emit(wd->slider, "elm,state,units,visible", "elm");
764 edje_object_message_signal_process(wd->slider);
768 edje_object_signal_emit(wd->slider, "elm,state,units,hidden", "elm");
769 edje_object_message_signal_process(wd->slider);
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 elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator)
787 ELM_CHECK_WIDTYPE(obj, widtype);
788 Widget_Data *wd = elm_widget_data_get(obj);
790 eina_stringshare_replace(&wd->indicator, indicator);
795 elm_slider_indicator_format_get(const Evas_Object *obj)
797 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
798 Widget_Data *wd = elm_widget_data_get(obj);
799 if (!wd) return NULL;
800 return wd->indicator;
804 elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
806 ELM_CHECK_WIDTYPE(obj, widtype);
807 Widget_Data *wd = elm_widget_data_get(obj);
809 horizontal = !!horizontal;
810 if (wd->horizontal == horizontal) return;
811 wd->horizontal = horizontal;
816 elm_slider_horizontal_get(const Evas_Object *obj)
818 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
819 Widget_Data *wd = elm_widget_data_get(obj);
820 if (!wd) return EINA_FALSE;
821 return wd->horizontal;
825 elm_slider_min_max_set(Evas_Object *obj, double min, double max)
827 ELM_CHECK_WIDTYPE(obj, widtype);
828 Widget_Data *wd = elm_widget_data_get(obj);
830 if ((wd->val_min == min) && (wd->val_max == max)) return;
833 if (wd->val < wd->val_min) wd->val = wd->val_min;
834 if (wd->val > wd->val_max) wd->val = wd->val_max;
841 elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
845 ELM_CHECK_WIDTYPE(obj, widtype);
846 Widget_Data *wd = elm_widget_data_get(obj);
848 if (min) *min = wd->val_min;
849 if (max) *max = wd->val_max;
853 elm_slider_value_set(Evas_Object *obj, double val)
855 ELM_CHECK_WIDTYPE(obj, widtype);
856 Widget_Data *wd = elm_widget_data_get(obj);
858 if (wd->val == val) return;
860 if (wd->val < wd->val_min) wd->val = wd->val_min;
861 if (wd->val > wd->val_max) wd->val = wd->val_max;
862 edje_object_signal_emit(wd->slider, "elm,state,drag", "elm");
869 elm_slider_value_get(const Evas_Object *obj)
871 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
872 Widget_Data *wd = elm_widget_data_get(obj);
878 elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
880 ELM_CHECK_WIDTYPE(obj, widtype);
881 Widget_Data *wd = elm_widget_data_get(obj);
883 inverted = !!inverted;
884 if (wd->inverted == inverted) return;
885 wd->inverted = inverted;
887 edje_object_signal_emit(wd->slider, "elm,state,inverted,on", "elm");
889 edje_object_signal_emit(wd->slider, "elm,state,inverted,off", "elm");
890 edje_object_message_signal_process(wd->slider);
897 elm_slider_inverted_get(const Evas_Object *obj)
899 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
900 Widget_Data *wd = elm_widget_data_get(obj);
901 if (!wd) return EINA_FALSE;
906 elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
908 ELM_CHECK_WIDTYPE(obj, widtype);
909 Widget_Data *wd = elm_widget_data_get(obj);
911 wd->indicator_format_func = func;
912 wd->indicator_format_free = free_func;
917 elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
919 ELM_CHECK_WIDTYPE(obj, widtype);
920 Widget_Data *wd = elm_widget_data_get(obj);
922 wd->units_format_func = func;
923 wd->units_format_free = free_func;
928 elm_slider_end_set(Evas_Object *obj, Evas_Object *end)
930 _content_set_hook(obj, "elm.swallow.end", end);
934 elm_slider_end_unset(Evas_Object *obj)
936 return _content_unset_hook(obj, "elm.swallow.end");
940 elm_slider_end_get(const Evas_Object *obj)
942 return _content_get_hook(obj, "elm.swallow.end");
946 elm_slider_indicator_show_set(Evas_Object *obj, Eina_Bool show)
948 ELM_CHECK_WIDTYPE(obj, widtype);
949 Widget_Data *wd = elm_widget_data_get(obj);
951 wd->indicator_show = EINA_TRUE;
952 edje_object_signal_emit(wd->slider, "elm,state,val,show", "elm");
955 wd->indicator_show = EINA_FALSE;
956 edje_object_signal_emit(wd->slider, "elm,state,val,hide", "elm");
961 elm_slider_indicator_show_get(const Evas_Object *obj)
963 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
964 Widget_Data *wd = elm_widget_data_get(obj);
965 if (!wd) return EINA_FALSE;
966 return wd->indicator_show;