1 #include <Elementary.h>
5 * @defgroup Scroller Scroller
7 * A scroller holds a single object and "scrolls it around". This means that
8 * it allows the user to use a scrollbar (or a finger) to drag the viewable
9 * region around, allowing to move through a much larger object that is
10 * contained in the scroller. The scroiller will always have a small minimum
11 * size by default as it won't be limited by the contents of the scroller.
13 * Signals that you can add callbacks for are:
15 * "edge,left" - the left edge of the content has been reached
16 * "edge,right" - the right edge of the content has been reached
17 * "edge,top" - the top edge of the content has been reached
18 * "edge,bottom" - the bottom edge of the content has been reached
19 * "scroll" - the content has been scrolled (moved)
20 * "scroll,anim,start" - scrolling animation has started
21 * "scroll,anim,stop" - scrolling animation has stopped
22 * "scroll,drag,start" - dragging the contents around has started
23 * "scroll,drag,stop" - dragging the contents around has stopped
25 typedef struct _Widget_Data Widget_Data;
31 const char *widget_name, *widget_base;
34 double pagerel_h, pagerel_v;
35 Evas_Coord pagesize_h, pagesize_v;
38 static const char *widtype = NULL;
39 static void _del_hook(Evas_Object *obj);
40 static void _theme_hook(Evas_Object *obj);
41 static void _show_region_hook(void *data, Evas_Object *obj);
42 static void _sizing_eval(Evas_Object *obj);
43 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
44 static void _on_focus_hook(void *data, Evas_Object *obj);
45 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
46 Evas_Callback_Type type, void *event_info);
49 static const char SIG_SCROLL[] = "scroll";
50 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
51 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
52 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
53 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
54 static const char SIG_EDGE_LEFT[] = "edge,left";
55 static const char SIG_EDGE_RIGHT[] = "edge,right";
56 static const char SIG_EDGE_TOP[] = "edge,top";
57 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
58 static const Evas_Smart_Cb_Description _signals[] = {
60 {SIG_SCROLL_ANIM_START, ""},
61 {SIG_SCROLL_ANIM_STOP, ""},
62 {SIG_SCROLL_DRAG_START, ""},
63 {SIG_SCROLL_DRAG_STOP, ""},
67 {SIG_EDGE_BOTTOM, ""},
72 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
74 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
75 Evas_Event_Key_Down *ev = event_info;
76 Widget_Data *wd = elm_widget_data_get(obj);
77 if (!wd) return EINA_FALSE;
78 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
79 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
83 Evas_Coord step_x = 0;
84 Evas_Coord step_y = 0;
89 Evas_Coord page_x = 0;
90 Evas_Coord page_y = 0;
92 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
93 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
94 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
95 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
96 elm_scroller_child_size_get(obj, &max_x, &max_y);
98 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
102 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
106 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
110 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
114 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
118 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
122 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
125 y -= -(page_y * v_h) / 100;
129 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
132 y += -(page_y * v_h) / 100;
136 else return EINA_FALSE;
138 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
139 elm_smart_scroller_child_pos_set(wd->scr, x, y);
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->scr, "elm,action,focus", "elm");
151 evas_object_focus_set(wd->scr, EINA_TRUE);
155 edje_object_signal_emit(wd->scr, "elm,action,unfocus", "elm");
156 evas_object_focus_set(wd->scr, EINA_FALSE);
161 _del_hook(Evas_Object *obj)
163 Widget_Data *wd = elm_widget_data_get(obj);
169 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
171 Widget_Data *wd = elm_widget_data_get(obj);
174 elm_smart_scroller_mirrored_set(wd->scr, mirrored);
178 _theme_hook(Evas_Object *obj)
180 Widget_Data *wd = elm_widget_data_get(obj);
182 _elm_widget_mirrored_reload(obj);
188 _mirrored_set(obj, elm_widget_mirrored_get(obj));
189 elm_smart_scroller_object_theme_set(obj, wd->scr,
190 wd->widget_name, wd->widget_base,
191 elm_widget_style_get(obj));
192 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
193 edj = elm_smart_scroller_edje_object_get(wd->scr);
194 str = edje_object_data_get(edj, "focus_highlight");
195 if ((str) && (!strcmp(str, "on")))
196 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
198 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
204 _elm_scroller_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
206 Widget_Data *wd = elm_widget_data_get(obj);
209 if ((!wd) || (!wd->content))
214 /* Try Focus cycle in subitem */
215 if ((elm_widget_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
216 return elm_widget_focus_next_get(cur, dir, next);
219 *next = (Evas_Object *)obj;
220 return !elm_widget_focus_get(obj);
224 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
226 Widget_Data *wd = elm_widget_data_get(obj);
228 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
233 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
235 Widget_Data *wd = elm_widget_data_get(obj);
237 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
238 emission, source, func_cb, data);
242 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
244 Widget_Data *wd = elm_widget_data_get(obj);
245 edje_object_signal_callback_del_full(
246 elm_smart_scroller_edje_object_get(wd->scr), emission, source,
251 _show_region_hook(void *data, Evas_Object *obj)
253 Widget_Data *wd = elm_widget_data_get(data);
254 Evas_Coord x, y, w, h;
256 elm_widget_show_region_get(obj, &x, &y, &w, &h);
258 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
262 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
264 Widget_Data *wd = elm_widget_data_get(obj);
266 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
270 _sizing_eval(Evas_Object *obj)
272 Widget_Data *wd = elm_widget_data_get(obj);
273 Evas_Coord vw, vh, minw = 0, minh = 0, maxw = 0, maxh = 0, w, h, vmw, vmh;
274 double xw = 0.0, yw = 0.0;
279 evas_object_size_hint_min_get(wd->content, &minw, &minh);
280 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
281 evas_object_size_hint_weight_get(wd->content, &xw, &yw);
285 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
288 if ((minw > 0) && (vw < minw)) vw = minw;
289 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
291 else if (minw > 0) vw = minw;
294 if ((minh > 0) && (vh < minh)) vh = minh;
295 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
297 else if (minh > 0) vh = minh;
298 if (wd->content) evas_object_resize(wd->content, vw, vh);
301 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
302 if (wd->min_w) w = vmw + minw;
303 if (wd->min_h) h = vmh + minh;
304 evas_object_size_hint_max_get(obj, &maxw, &maxh);
305 if ((maxw > 0) && (w > maxw)) w = maxw;
306 if ((maxh > 0) && (h > maxh)) h = maxh;
307 evas_object_size_hint_min_set(obj, w, h);
312 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
318 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
320 Widget_Data *wd = elm_widget_data_get(obj);
321 Evas_Object *sub = event_info;
324 if (sub == wd->content)
326 elm_widget_on_show_region_hook_set(wd->content, NULL, NULL);
327 evas_object_event_callback_del_full (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
328 _changed_size_hints, obj);
332 else if (sub == wd->scr)
337 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
339 Widget_Data *wd = elm_widget_data_get(obj);
343 elm_smart_scroller_hold_set(wd->scr, 1);
347 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
349 Widget_Data *wd = elm_widget_data_get(obj);
353 elm_smart_scroller_hold_set(wd->scr, 0);
357 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
359 Widget_Data *wd = elm_widget_data_get(obj);
363 elm_smart_scroller_freeze_set(wd->scr, 1);
367 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
369 Widget_Data *wd = elm_widget_data_get(obj);
373 elm_smart_scroller_freeze_set(wd->scr, 0);
377 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
383 _edge_left(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
385 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
389 _edge_right(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
391 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
395 _edge_top(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
397 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
401 _edge_bottom(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
403 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
407 _scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
409 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
413 _scroll_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
415 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
419 _scroll_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
421 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
425 _scroll_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
427 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
431 _scroll_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
433 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
437 * Add a new scroller to the parent
439 * @param parent The parent object
440 * @return The new object or NULL if it cannot be created
445 elm_scroller_add(Evas_Object *parent)
450 Evas_Coord minw, minh;
452 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
454 ELM_SET_WIDTYPE(widtype, "scroller");
455 elm_widget_type_set(obj, "scroller");
456 elm_widget_sub_object_add(parent, obj);
457 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
458 elm_widget_data_set(obj, wd);
459 elm_widget_del_hook_set(obj, _del_hook);
460 elm_widget_theme_hook_set(obj, _theme_hook);
461 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
462 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
463 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
464 elm_widget_focus_next_hook_set(obj, _elm_scroller_focus_next_hook);
465 elm_widget_can_focus_set(obj, EINA_TRUE);
466 elm_widget_event_hook_set(obj, _event_hook);
467 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
469 wd->widget_name = eina_stringshare_add("scroller");
470 wd->widget_base = eina_stringshare_add("base");
472 wd->scr = elm_smart_scroller_add(e);
473 elm_smart_scroller_widget_set(wd->scr, obj);
475 elm_widget_resize_object_set(obj, wd->scr);
476 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
477 _changed_size_hints, obj);
479 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
480 evas_object_size_hint_min_set(obj, minw, minh);
481 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
483 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
484 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
485 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
486 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
487 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
489 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
490 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
491 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
492 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
493 evas_object_smart_callback_add(wd->scr, "scroll", _scroll, obj);
494 evas_object_smart_callback_add(wd->scr, "animate,start", _scroll_anim_start, obj);
495 evas_object_smart_callback_add(wd->scr, "animate,stop", _scroll_anim_stop, obj);
496 evas_object_smart_callback_add(wd->scr, "drag,start", _scroll_drag_start, obj);
497 evas_object_smart_callback_add(wd->scr, "drag,stop", _scroll_drag_stop, obj);
501 // TODO: convert Elementary to subclassing of Evas_Smart_Class
502 // TODO: and save some bytes, making descriptions per-class and not instance!
503 evas_object_smart_callbacks_descriptions_set(obj, _signals);
504 _mirrored_set(obj, elm_widget_mirrored_get(obj));
509 _elm_scroller_edje_object_get(Evas_Object *obj)
511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
512 Widget_Data *wd = elm_widget_data_get(obj);
513 if (!wd) return NULL;
514 return elm_smart_scroller_edje_object_get(wd->scr);
518 * Set the content of the scroller widget (the object to be scrolled around).
520 * Once the content object is set, a previously set one will be deleted.
521 * If you want to keep that old content object, use the
522 * elm_scroller_content_unset() function.
524 * @param obj The scroller object
525 * @param content The new content object
530 elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
532 ELM_CHECK_WIDTYPE(obj, widtype);
533 Widget_Data *wd = elm_widget_data_get(obj);
535 if (wd->content == content) return;
536 if (wd->content) evas_object_del(wd->content);
537 wd->content = content;
540 elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
541 elm_widget_sub_object_add(obj, content);
543 elm_smart_scroller_child_set(wd->scr, content);
544 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
545 _changed_size_hints, obj);
551 * Get the content of the scroller widget
553 * Return the content object which is set for this widget
555 * @param obj The slider object
556 * @return The content that is being used
561 elm_scroller_content_get(const Evas_Object *obj)
563 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
564 Widget_Data *wd = elm_widget_data_get(obj);
565 if (!wd) return NULL;
570 * Unset the content of the scroller widget
572 * Unparent and return the content object which was set for this widget
574 * @param obj The slider object
575 * @return The content that was being used
580 elm_scroller_content_unset(Evas_Object *obj)
582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
583 Widget_Data *wd = elm_widget_data_get(obj);
584 Evas_Object *content;
585 if (!wd) return NULL;
586 if (!wd->content) return NULL;
587 content = wd->content;
588 elm_widget_sub_object_del(obj, wd->content);
589 edje_object_part_unswallow(wd->scr, wd->content);
595 * Set custom theme elements for the scroller
597 * @param obj The scroller object
598 * @param widget The widget name to use (default is "scroller")
599 * @param base The base name to use (default is "base")
604 elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)
606 ELM_CHECK_WIDTYPE(obj, widtype);
607 Widget_Data *wd = elm_widget_data_get(obj);
609 EINA_SAFETY_ON_NULL_RETURN(widget);
610 EINA_SAFETY_ON_NULL_RETURN(base);
611 if (eina_stringshare_replace(&wd->widget_name, widget) |
612 eina_stringshare_replace(&wd->widget_base, base))
617 * Make the scroller minimum size limited to the minimum size of the content
619 * By default the scroller will be as small as its design allows, irrespective
620 * of its content. This will make the scroller minimum size the right size
621 * horizontally and/or vertically to perfectly fit its content.
623 * @param obj The scroller object
624 * @param w Enable limiting minimum size horizontally
625 * @param h Enable limiting minimum size vertically
630 elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
632 ELM_CHECK_WIDTYPE(obj, widtype);
633 Widget_Data *wd = elm_widget_data_get(obj);
641 * Show a specific virtual region within the scroller content object
643 * This will ensure all (or part if it does not fit) of the designated
644 * region in the virtual content object (0, 0 starting at the top-left of the
645 * virtual content object) is shown within the scroller.
647 * @param obj The scroller object
648 * @param x X coordinate of the region
649 * @param y Y coordinate of the region
650 * @param w Width of the region
651 * @param h Height of the region
656 elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
658 ELM_CHECK_WIDTYPE(obj, widtype);
659 Widget_Data *wd = elm_widget_data_get(obj);
660 if ((!wd) || (!wd->scr)) return;
661 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
665 * Set the scroller scrollbar policy
667 * This sets the scrollbar visibility policy for the given scroller.
668 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
669 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
670 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
671 * This applies respectively for the horizontal and vertical scrollbars.
673 * @param obj The scroller object
674 * @param policy_h Horizontal scrollbar policy
675 * @param policy_v Vertical scrollbar policy
680 elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
682 ELM_CHECK_WIDTYPE(obj, widtype);
683 Widget_Data *wd = elm_widget_data_get(obj);
684 const Elm_Scroller_Policy map[3] =
686 ELM_SMART_SCROLLER_POLICY_AUTO,
687 ELM_SMART_SCROLLER_POLICY_ON,
688 ELM_SMART_SCROLLER_POLICY_OFF
690 if ((!wd) || (!wd->scr)) return;
691 if ((policy_h >= 3) || (policy_v >= 3)) return;
692 elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
696 elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
698 ELM_CHECK_WIDTYPE(obj, widtype);
699 Widget_Data *wd = elm_widget_data_get(obj);
700 if ((!wd) || (!wd->scr)) return;
701 elm_smart_scroller_policy_get(wd->scr,
702 (Elm_Smart_Scroller_Policy *) policy_h,
703 (Elm_Smart_Scroller_Policy *) policy_v);
707 * Get the currently visible content region
709 * This gets the current region in the content object that is visible through
710 * the scroller. Also see elm_scroller_region_show(). The region co-ordinates
711 * are returned in the @p x, @p y, @p w, @p h values pointed to.
713 * @param obj The scroller object
714 * @param x X coordinate of the region
715 * @param y Y coordinate of the region
716 * @param w Width of the region
717 * @param h Height of the region
722 elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
724 ELM_CHECK_WIDTYPE(obj, widtype);
725 Widget_Data *wd = elm_widget_data_get(obj);
726 if ((!wd) || (!wd->scr)) return;
727 if ((x) || (y)) elm_smart_scroller_child_pos_get(wd->scr, x, y);
728 if ((w) || (h)) elm_smart_scroller_child_viewport_size_get(wd->scr, w, h);
732 * Get the size of the content child object
734 * This gets the size of the child object of the scroller. Actually the
735 * content of a scroller doesn't specifically need to be an actual object
736 * as it can be virtual and defined purely by callbacks.
738 * @param obj The scroller object
739 * @param w Width return
740 * @param h Height return
745 elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
747 ELM_CHECK_WIDTYPE(obj, widtype);
748 Widget_Data *wd = elm_widget_data_get(obj);
750 evas_object_geometry_get(wd->content, NULL, NULL, w, h);
754 * Set bouncing behavior
756 * When scrolling, the scroller may "bounce" when reaching an edge of the child
757 * object. This is a visual way to indicate the end has been reached. This is
758 * enabled by default for both axes. This will set if it is enabled for that
759 * axis with the boolean parameters for each axis.
761 * @param obj The scroller object
762 * @param h_bounce Will the scroller bounce horizontally or not
763 * @param v_bounce Will the scroller bounce vertically or not
768 elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
770 ELM_CHECK_WIDTYPE(obj, widtype);
771 Widget_Data *wd = elm_widget_data_get(obj);
772 if ((!wd) || (!wd->scr)) return;
773 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
777 * Get the bounce mode
779 * @param obj The Scroller object
780 * @param h_bounce Allow bounce horizontally
781 * @param v_bounce Allow bounce vertically
786 elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
788 ELM_CHECK_WIDTYPE(obj, widtype);
789 Widget_Data *wd = elm_widget_data_get(obj);
791 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
795 * Set scroll page size relative to viewport size.
797 * The scroller is capable of limiting scrolling by the user to "pages". That
798 * is to jump by and only show a "whole page" at a time as if the continuous
799 * area of the scroller content is split into page sized pieces. This sets
800 * the size of a page relative to the viewport of the scroller. 1.0 is "1
801 * viewport" is size (horizontally or vertically). 0.0 turns it off in that
802 * axis. This is mutually exclusive with page size
803 * (see elm_scroller_page_size_set() for more information). Likewise 0.5
804 * is "half a viewport". Sane usable valus are normally between 0.0 and 1.0
805 * including 1.0. If you only want 1 axis to be page "limited", use 0.0 for
808 * @param obj The scroller object
809 * @param h_pagerel The horizontal page relative size
810 * @param v_pagerel The vertical page relative size
815 elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel)
817 ELM_CHECK_WIDTYPE(obj, widtype);
818 Widget_Data *wd = elm_widget_data_get(obj);
820 wd->pagerel_h = h_pagerel;
821 wd->pagerel_v = v_pagerel;
823 elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
824 wd->pagesize_h, wd->pagesize_v);
828 * Set scroll page size.
830 * See also elm_scroller_page_relative_set(). This, instead of a page size
831 * being relative to the viewport, sets it to an absolute fixed value, with
832 * 0 turning it off for that axis.
834 * @param obj The scroller object
835 * @param h_pagesize The horizontal page size
836 * @param v_pagesize The vertical page size
841 elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize)
843 ELM_CHECK_WIDTYPE(obj, widtype);
844 Widget_Data *wd = elm_widget_data_get(obj);
846 wd->pagesize_h = h_pagesize;
847 wd->pagesize_v = v_pagesize;
849 elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
850 wd->pagesize_h, wd->pagesize_v);
854 * Show a specific virtual region within the scroller content object.
856 * This will ensure all (or part if it does not fit) of the designated
857 * region in the virtual content object (0, 0 starting at the top-left of the
858 * virtual content object) is shown within the scroller. Unlike
859 * elm_scroller_region_show(), this allow the scroller to "smoothly slide"
860 * to this location (if configuration in general calls for transitions). It
861 * may not jump immediately to the new location and make take a while and
862 * show other content along the way.
864 * @param obj The scroller object
865 * @param x X coordinate of the region
866 * @param y Y coordinate of the region
867 * @param w Width of the region
868 * @param h Height of the region
873 elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
875 ELM_CHECK_WIDTYPE(obj, widtype);
876 Widget_Data *wd = elm_widget_data_get(obj);
877 if ((!wd) || (!wd->scr)) return;
878 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
883 * Set event propagation on a scroller
885 * This enables or disabled event propagation from the scroller content to
886 * the scroller and its parent. By default event propagation is disabled.
888 * @param obj The scroller object
889 * @param propagation If propagation is enabled or not
894 elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation)
896 ELM_CHECK_WIDTYPE(obj, widtype);
897 Widget_Data *wd = elm_widget_data_get(obj);
900 evas_object_propagate_events_set(wd->scr, propagation);
904 * Get event propagation for a scroller
906 * This gets the event propagation for a scroller. See
907 * elm_scroller_propagate_events_set() for more information
909 * @param obj The scroller object
910 * @return The propagation state
915 elm_scroller_propagate_events_get(const Evas_Object *obj)
917 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
918 Widget_Data *wd = elm_widget_data_get(obj);
919 if (!wd) return EINA_FALSE;
921 return evas_object_propagate_events_get(wd->scr);