1 #include <Elementary.h>
5 * @defgroup Scroller Scroller
8 * A scroller holds a single object and "scrolls it around". This means that
9 * it allows the user to use a scrollbar (or a finger) to drag the viewable
10 * region around, allowing to move through a much larger object that is
11 * contained in the scroller. The scroiller will always have a small minimum
12 * size by default as it won't be limited by the contents of the scroller.
14 * Signals that you can add callbacks for are:
16 * edge,left - the left edge of the content has been reached
18 * edge,right - the right edge of the content has been reached
20 * edge,top - the top edge of the content has been reached
22 * edge,bottom - the bottom edge of the content has been reached
24 * scroll - the content has been scrolled (moved)
26 * scroll,anim,start - scrolling animation has started
28 * scroll,anim,stop - scrolling animation has stopped
30 * scroll,drag,start - dragging the contents around has started
32 * scroll,drag,stop - dragging the contents around has stopped
34 typedef struct _Widget_Data Widget_Data;
40 const char *widget_name, *widget_base;
43 double pagerel_h, pagerel_v;
44 Evas_Coord pagesize_h, pagesize_v;
47 static const char *widtype = NULL;
48 static void _del_hook(Evas_Object *obj);
49 static void _theme_hook(Evas_Object *obj);
50 static void _show_region_hook(void *data, Evas_Object *obj);
51 static void _sizing_eval(Evas_Object *obj);
52 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
53 static void _on_focus_hook(void *data, Evas_Object *obj);
54 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
55 Evas_Callback_Type type, void *event_info);
58 static const char SIG_SCROLL[] = "scroll";
59 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
60 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
61 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
62 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
63 static const char SIG_EDGE_LEFT[] = "edge,left";
64 static const char SIG_EDGE_RIGHT[] = "edge,right";
65 static const char SIG_EDGE_TOP[] = "edge,top";
66 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
67 static const Evas_Smart_Cb_Description _signals[] = {
69 {SIG_SCROLL_ANIM_START, ""},
70 {SIG_SCROLL_ANIM_STOP, ""},
71 {SIG_SCROLL_DRAG_START, ""},
72 {SIG_SCROLL_DRAG_STOP, ""},
76 {SIG_EDGE_BOTTOM, ""},
81 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
83 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
84 Evas_Event_Key_Down *ev = event_info;
85 Widget_Data *wd = elm_widget_data_get(obj);
86 if (!wd) return EINA_FALSE;
87 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
88 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
92 Evas_Coord step_x = 0;
93 Evas_Coord step_y = 0;
98 Evas_Coord page_x = 0;
99 Evas_Coord page_y = 0;
101 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
102 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
103 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
104 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
105 elm_scroller_child_size_get(obj, &max_x, &max_y);
107 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
111 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
115 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
119 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
123 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
127 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
131 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
134 y -= -(page_y * v_h) / 100;
138 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
141 y += -(page_y * v_h) / 100;
145 else return EINA_FALSE;
147 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
148 elm_smart_scroller_child_pos_set(wd->scr, x, y);
153 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
155 Widget_Data *wd = elm_widget_data_get(obj);
157 if (elm_widget_focus_get(obj))
159 edje_object_signal_emit(wd->scr, "elm,action,focus", "elm");
160 evas_object_focus_set(wd->scr, EINA_TRUE);
164 edje_object_signal_emit(wd->scr, "elm,action,unfocus", "elm");
165 evas_object_focus_set(wd->scr, EINA_FALSE);
170 _del_hook(Evas_Object *obj)
172 Widget_Data *wd = elm_widget_data_get(obj);
178 _theme_hook(Evas_Object *obj)
180 Widget_Data *wd = elm_widget_data_get(obj);
187 elm_smart_scroller_object_theme_set(obj, wd->scr,
188 wd->widget_name, wd->widget_base,
189 elm_widget_style_get(obj));
190 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
191 edj = elm_smart_scroller_edje_object_get(wd->scr);
192 str = edje_object_data_get(edj, "focus_highlight");
193 if ((str) && (!strcmp(str, "on")))
194 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
196 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
202 _elm_scroller_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
204 Widget_Data *wd = elm_widget_data_get(obj);
207 if ((!wd) || (!wd->content))
212 /* Try Focus cycle in subitem */
213 if ((elm_widget_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
214 return elm_widget_focus_next_get(cur, dir, next);
217 *next = (Evas_Object *)obj;
218 return !elm_widget_focus_get(obj);
222 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
224 Widget_Data *wd = elm_widget_data_get(obj);
226 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
231 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
233 Widget_Data *wd = elm_widget_data_get(obj);
235 edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
236 emission, source, func_cb, data);
240 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
242 Widget_Data *wd = elm_widget_data_get(obj);
243 edje_object_signal_callback_del_full(
244 elm_smart_scroller_edje_object_get(wd->scr), emission, source,
249 _show_region_hook(void *data, Evas_Object *obj)
251 Widget_Data *wd = elm_widget_data_get(data);
252 Evas_Coord x, y, w, h;
254 elm_widget_show_region_get(obj, &x, &y, &w, &h);
256 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
260 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
262 Widget_Data *wd = elm_widget_data_get(obj);
264 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
268 _sizing_eval(Evas_Object *obj)
270 Widget_Data *wd = elm_widget_data_get(obj);
271 Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
275 evas_object_size_hint_min_get(wd->content, &minw, &minh);
276 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
277 evas_object_size_hint_weight_get(wd->content, &xw, &yw);
280 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
283 if ((minw > 0) && (vw < minw)) vw = minw;
284 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
286 else if (minw > 0) vw = minw;
289 if ((minh > 0) && (vh < minh)) vh = minh;
290 else if ((maxh > 0) && (vh > maxh)) vh = maxh;
292 else if (minh > 0) vh = minh;
293 evas_object_resize(wd->content, vw, vh);
296 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
297 if (wd->min_w) w = vmw + minw;
298 if (wd->min_h) h = vmh + minh;
299 evas_object_size_hint_max_get(obj, &maxw, &maxh);
300 if ((maxw > 0) && (w > maxw)) w = maxw;
301 if ((maxh > 0) && (h > maxh)) h = maxh;
302 evas_object_size_hint_min_set(obj, w, h);
307 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
313 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
315 Widget_Data *wd = elm_widget_data_get(obj);
316 Evas_Object *sub = event_info;
319 if (sub == wd->content)
321 elm_widget_on_show_region_hook_set(wd->content, NULL, NULL);
322 evas_object_event_callback_del_full (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
323 _changed_size_hints, obj);
327 else if (sub == wd->scr)
332 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
334 Widget_Data *wd = elm_widget_data_get(obj);
338 elm_smart_scroller_hold_set(wd->scr, 1);
342 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
344 Widget_Data *wd = elm_widget_data_get(obj);
348 elm_smart_scroller_hold_set(wd->scr, 0);
352 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
354 Widget_Data *wd = elm_widget_data_get(obj);
358 elm_smart_scroller_freeze_set(wd->scr, 1);
362 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
364 Widget_Data *wd = elm_widget_data_get(obj);
368 elm_smart_scroller_freeze_set(wd->scr, 0);
372 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
378 _edge_left(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
380 evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
384 _edge_right(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
386 evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
390 _edge_top(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
392 evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
396 _edge_bottom(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
398 evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
402 _scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
404 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
408 _scroll_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
410 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
414 _scroll_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
416 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
420 _scroll_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
422 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
426 _scroll_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
428 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
432 * Add a new scroller to the parent
434 * @param parent The parent object
435 * @return The new object or NULL if it cannot be created
440 elm_scroller_add(Evas_Object *parent)
445 Evas_Coord minw, minh;
447 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
449 wd = ELM_NEW(Widget_Data);
450 e = evas_object_evas_get(parent);
452 obj = elm_widget_add(e);
453 ELM_SET_WIDTYPE(widtype, "scroller");
454 elm_widget_type_set(obj, "scroller");
455 elm_widget_sub_object_add(parent, obj);
456 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
457 elm_widget_data_set(obj, wd);
458 elm_widget_del_hook_set(obj, _del_hook);
459 elm_widget_theme_hook_set(obj, _theme_hook);
460 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
461 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
462 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
463 elm_widget_focus_next_hook_set(obj, _elm_scroller_focus_next_hook);
464 elm_widget_can_focus_set(obj, EINA_TRUE);
465 elm_widget_event_hook_set(obj, _event_hook);
466 elm_widget_focus_region_hook_set(obj, _focus_region_hook);
468 wd->widget_name = eina_stringshare_add("scroller");
469 wd->widget_base = eina_stringshare_add("base");
471 wd->scr = elm_smart_scroller_add(e);
472 elm_smart_scroller_widget_set(wd->scr, obj);
474 elm_widget_resize_object_set(obj, wd->scr);
475 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
476 _changed_size_hints, obj);
478 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
479 evas_object_size_hint_min_set(obj, minw, minh);
480 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
482 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
483 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
484 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
485 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
486 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
488 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
489 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
490 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
491 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
492 evas_object_smart_callback_add(wd->scr, "scroll", _scroll, obj);
493 evas_object_smart_callback_add(wd->scr, "animate,start", _scroll_anim_start, obj);
494 evas_object_smart_callback_add(wd->scr, "animate,stop", _scroll_anim_stop, obj);
495 evas_object_smart_callback_add(wd->scr, "drag,start", _scroll_drag_start, obj);
496 evas_object_smart_callback_add(wd->scr, "drag,stop", _scroll_drag_stop, obj);
500 // TODO: convert Elementary to subclassing of Evas_Smart_Class
501 // TODO: and save some bytes, making descriptions per-class and not instance!
502 evas_object_smart_callbacks_descriptions_set(obj, _signals);
507 _elm_scroller_edje_object_get(Evas_Object *obj)
509 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
510 Widget_Data *wd = elm_widget_data_get(obj);
511 if (!wd) return NULL;
512 return elm_smart_scroller_edje_object_get(wd->scr);
516 * Set the content of the scroller widget (the object to be scrolled around).
518 * Once the content object is set, a previously set one will be deleted.
519 * If you want to keep that old content object, use the
520 * elm_scroller_content_unset() function.
522 * @param obj The scroller object
523 * @param content The new content object
528 elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
530 ELM_CHECK_WIDTYPE(obj, widtype);
531 Widget_Data *wd = elm_widget_data_get(obj);
533 if (wd->content == content) return;
534 if (wd->content) evas_object_del(wd->content);
535 wd->content = content;
538 elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
539 elm_widget_sub_object_add(obj, content);
541 elm_smart_scroller_child_set(wd->scr, content);
542 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
543 _changed_size_hints, obj);
549 * Get the content of the scroller widget
551 * Return the content object which is set for this widget
553 * @param obj The slider object
554 * @return The content that is being used
559 elm_scroller_content_get(const Evas_Object *obj)
561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
562 Widget_Data *wd = elm_widget_data_get(obj);
563 if (!wd) return NULL;
568 * Unset the content of the scroller widget
570 * Unparent and return the content object which was set for this widget
572 * @param obj The slider object
573 * @return The content that was being used
578 elm_scroller_content_unset(Evas_Object *obj)
580 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
581 Widget_Data *wd = elm_widget_data_get(obj);
582 Evas_Object *content;
583 if (!wd) return NULL;
584 if (!wd->content) return NULL;
585 content = wd->content;
586 elm_widget_sub_object_del(obj, wd->content);
587 edje_object_part_unswallow(wd->scr, wd->content);
593 * Set custom theme elements for the scroller
595 * @param obj The scroller object
596 * @param widget The widget name to use (default is "scroller")
597 * @param base The base name to use (default is "base")
602 elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)
604 ELM_CHECK_WIDTYPE(obj, widtype);
605 Widget_Data *wd = elm_widget_data_get(obj);
607 EINA_SAFETY_ON_NULL_RETURN(widget);
608 EINA_SAFETY_ON_NULL_RETURN(base);
609 if (eina_stringshare_replace(&wd->widget_name, widget) |
610 eina_stringshare_replace(&wd->widget_base, base))
615 * Make the scroller minimum size limited to the minimum size of the content
617 * By default the scroller will be as small as its design allows, irrespective
618 * of its content. This will make the scroller minimum size the right size
619 * horizontally and/or vertically to perfectly fit its content.
621 * @param obj The scroller object
622 * @param w Enable limiting minimum size horizontally
623 * @param h Enable limiting minimum size vertically
628 elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
630 ELM_CHECK_WIDTYPE(obj, widtype);
631 Widget_Data *wd = elm_widget_data_get(obj);
639 * Show a specific virtual region within the scroller content object
641 * This will ensure all (or part if it does not fit) of the designated
642 * region in the virtual content object (0, 0 starting at the top-left of the
643 * virtual content object) is shown within the scroller.
645 * @param obj The scroller object
646 * @param x X coordinate of the region
647 * @param y Y coordinate of the region
648 * @param w Width of the region
649 * @param h Height of the region
654 elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
656 ELM_CHECK_WIDTYPE(obj, widtype);
657 Widget_Data *wd = elm_widget_data_get(obj);
658 if ((!wd) || (!wd->scr)) return;
659 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
663 * Set the scroller scrollbar policy
665 * This sets the scrollbar visibility policy for the given scroller.
666 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
667 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
668 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
669 * This applies respectively for the horizontal and vertical scrollbars.
671 * @param obj The scroller object
672 * @param policy_h Horizontal scrollbar policy
673 * @param policy_v Vertical scrollbar policy
678 elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
680 ELM_CHECK_WIDTYPE(obj, widtype);
681 Widget_Data *wd = elm_widget_data_get(obj);
682 const Elm_Scroller_Policy map[3] =
684 ELM_SMART_SCROLLER_POLICY_AUTO,
685 ELM_SMART_SCROLLER_POLICY_ON,
686 ELM_SMART_SCROLLER_POLICY_OFF
688 if ((!wd) || (!wd->scr)) return;
689 if ((policy_h >= 3) || (policy_v >= 3)) return;
690 elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
694 elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
696 ELM_CHECK_WIDTYPE(obj, widtype);
697 Widget_Data *wd = elm_widget_data_get(obj);
698 if ((!wd) || (!wd->scr)) return;
699 elm_smart_scroller_policy_get(wd->scr,
700 (Elm_Smart_Scroller_Policy *) policy_h,
701 (Elm_Smart_Scroller_Policy *) policy_v);
705 * Get the currently visible content region
707 * This gets the current region in the content object that is visible through
708 * the scroller. Also see elm_scroller_region_show(). The region co-ordinates
709 * are returned in the @p x, @p y, @p w, @p h values pointed to.
711 * @param obj The scroller object
712 * @param x X coordinate of the region
713 * @param y Y coordinate of the region
714 * @param w Width of the region
715 * @param h Height of the region
720 elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
722 ELM_CHECK_WIDTYPE(obj, widtype);
723 Widget_Data *wd = elm_widget_data_get(obj);
724 if ((!wd) || (!wd->scr)) return;
725 if ((x) || (y)) elm_smart_scroller_child_pos_get(wd->scr, x, y);
726 if ((w) || (h)) elm_smart_scroller_child_viewport_size_get(wd->scr, w, h);
730 * Get the size of the content child object
732 * This gets the size of the child object of the scroller. Actually the
733 * content of a scroller doesn't specifically need to be an actual object
734 * as it can be virtual and defined purely by callbacks.
736 * @param obj The scroller object
737 * @param w Width return
738 * @param h Height return
743 elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
745 ELM_CHECK_WIDTYPE(obj, widtype);
746 Widget_Data *wd = elm_widget_data_get(obj);
748 evas_object_geometry_get(wd->content, NULL, NULL, w, h);
752 * Set bouncing behavior
754 * When scrolling, the scroller may "bounce" when reaching an edge of the child
755 * object. This is a visual way to indicate the end has been reached. This is
756 * enabled by default for both axes. This will set if it is enabled for that
757 * axis with the boolean parameters for each axis.
759 * @param obj The scroller object
760 * @param h_bounce Will the scroller bounce horizontally or not
761 * @param v_bounce Will the scroller bounce vertically or not
766 elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
768 ELM_CHECK_WIDTYPE(obj, widtype);
769 Widget_Data *wd = elm_widget_data_get(obj);
770 if ((!wd) || (!wd->scr)) return;
771 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
775 * Get the bounce mode
777 * @param obj The Scroller object
778 * @param h_bounce Allow bounce horizontally
779 * @param v_bounce Allow bounce vertically
784 elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
786 ELM_CHECK_WIDTYPE(obj, widtype);
787 Widget_Data *wd = elm_widget_data_get(obj);
789 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
793 * Set scroll page size relative to viewport size.
795 * The scroller is capable of limiting scrolling by the user to "pages". That
796 * is to jump by and only show a "whole page" at a time as if the continuous
797 * area of the scroller content is split into page sized pieces. This sets
798 * the size of a page relative to the viewport of the scroller. 1.0 is "1
799 * viewport" is size (horizontally or vertically). 0.0 turns it off in that
800 * axis. This is mutually exclusive with page size
801 * (see elm_scroller_page_size_set() for more information). Likewise 0.5
802 * is "half a viewport". Sane usable valus are normally between 0.0 and 1.0
803 * including 1.0. If you only want 1 axis to be page "limited", use 0.0 for
806 * @param obj The scroller object
807 * @param h_pagerel The horizontal page relative size
808 * @param v_pagerel The vertical page relative size
813 elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel)
815 ELM_CHECK_WIDTYPE(obj, widtype);
816 Widget_Data *wd = elm_widget_data_get(obj);
818 wd->pagerel_h = h_pagerel;
819 wd->pagerel_v = v_pagerel;
821 elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
822 wd->pagesize_h, wd->pagesize_v);
826 * Set scroll page size.
828 * See also elm_scroller_page_relative_set(). This, instead of a page size
829 * being relative to the viewport, sets it to an absolute fixed value, with
830 * 0 turning it off for that axis.
832 * @param obj The scroller object
833 * @param h_pagesize The horizontal page size
834 * @param v_pagesize The vertical page size
839 elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize)
841 ELM_CHECK_WIDTYPE(obj, widtype);
842 Widget_Data *wd = elm_widget_data_get(obj);
844 wd->pagesize_h = h_pagesize;
845 wd->pagesize_v = v_pagesize;
847 elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
848 wd->pagesize_h, wd->pagesize_v);
852 * Show a specific virtual region within the scroller content object.
854 * This will ensure all (or part if it does not fit) of the designated
855 * region in the virtual content object (0, 0 starting at the top-left of the
856 * virtual content object) is shown within the scroller. Unlike
857 * elm_scroller_region_show(), this allow the scroller to "smoothly slide"
858 * to this location (if configuration in general calls for transitions). It
859 * may not jump immediately to the new location and make take a while and
860 * show other content along the way.
862 * @param obj The scroller object
863 * @param x X coordinate of the region
864 * @param y Y coordinate of the region
865 * @param w Width of the region
866 * @param h Height of the region
871 elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
873 ELM_CHECK_WIDTYPE(obj, widtype);
874 Widget_Data *wd = elm_widget_data_get(obj);
875 if ((!wd) || (!wd->scr)) return;
876 elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
881 * Set event propagation on a scroller
883 * This enables or disabled event propagation from the scroller content to
884 * the scroller and its parent. By default event propagation is disabled.
886 * @param obj The scroller object
887 * @param propagation If propagation is enabled or not
892 elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation)
894 ELM_CHECK_WIDTYPE(obj, widtype);
895 Widget_Data *wd = elm_widget_data_get(obj);
898 evas_object_propagate_events_set(wd->scr, propagation);
902 * Get event propagation for a scroller
904 * This gets the event propagation for a scroller. See
905 * elm_scroller_propagate_events_set() for more information
907 * @param obj The scroller object
908 * @return The propagation state
913 elm_scroller_propagate_events_get(const Evas_Object *obj)
915 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
916 Widget_Data *wd = elm_widget_data_get(obj);
917 if (!wd) return EINA_FALSE;
919 return evas_object_propagate_events_get(wd->scr);
925 elm_scroller_page_move_set(Evas_Object *obj, Eina_Bool set)