Initialize Tizen 2.3
[framework/uifw/elementary.git] / mobile / src / lib / elm_scroller.h
1 /**
2  * @defgroup Scroller Scroller
3  * @ingroup Elementary
4  *
5  * @image html scroller_inheritance_tree.png
6  * @image latex scroller_inheritance_tree.eps
7  *
8  * A scroller holds (and clips) a single object and "scrolls it
9  * around". This means that it allows the user to use a scroll bar (or
10  * a finger) to drag the viewable region around, moving through a much
11  * larger object that is contained in the scroller. The scroller will
12  * always have a small minimum size by default as it won't be limited
13  * by the contents of the scroller.
14  *
15  * This widget inherits from the @ref Layout one, so that all the
16  * functions acting on it also work for scroller objects.
17  *
18  * This widget emits the following signals, besides the ones sent from
19  * @li @c "edge,left" - the left edge of the content has been reached
20  * @li @c "edge,right" - the right edge of the content has been reached
21  * @li @c "edge,top" - the top edge of the content has been reached
22  * @li @c "edge,bottom" - the bottom edge of the content has been reached
23  * @li @c "scroll" - the content has been scrolled (moved)
24  * @li @c "scroll,anim,start" - scrolling animation has started
25  * @li @c "scroll,anim,stop" - scrolling animation has stopped
26  * @li @c "scroll,drag,start" - dragging the contents around has started
27  * @li @c "scroll,drag,stop" - dragging the contents around has stopped
28  *
29  * This widget implements the @ref elm-scrollable-interface interface.
30  * Its (non-deprecated) API functions, except for elm_scroller_add(),
31  * which gives basic scroller objects, are meant to be a basis for all
32  * other scrollable widgets (i.e. widgets implementing @ref
33  * elm-scrollable-interface). So, they will work both on pristine
34  * scroller widgets and on other "specialized" scrollable widgets.
35  *
36  * @note The @c "scroll,anim,*" and @c "scroll,drag,*" signals are
37  * only emitted by user intervention.
38  *
39  * @note When Elementary is under its default profile and theme (meant
40  * for touch interfaces), scroll bars will @b not be draggable --
41  * their function is merely to indicate how much has been scrolled.
42  *
43  * @note When Elementary is under its desktop/standard profile and
44  * theme, the thumb scroll (a.k.a. finger scroll) won't work.
45  *
46  * Default content parts of the scroller widget that you can use are:
47  * @li @c "default" - Content of the scroller
48  *
49  * In @ref tutorial_scroller you'll find an example on how to use most
50  * of this API.
51  * @{
52  */
53
54 /**
55  * @brief Type that controls when scrollbars should appear.
56  *
57  * @see elm_scroller_policy_set()
58  */
59 typedef enum
60 {
61    ELM_SCROLLER_POLICY_AUTO = 0, /**< Show scrollbars as needed */
62    ELM_SCROLLER_POLICY_ON, /**< Always show scrollbars */
63    ELM_SCROLLER_POLICY_OFF, /**< Never show scrollbars */
64    ELM_SCROLLER_POLICY_LAST
65 } Elm_Scroller_Policy;
66
67 /**
68  * @brief Type that controls how the content is scrolled.
69  *
70  * @see elm_scroller_single_direction_set()
71  */
72 typedef enum
73 {
74    ELM_SCROLLER_SINGLE_DIRECTION_NONE = 0, /**< Scroll every direction */
75    ELM_SCROLLER_SINGLE_DIRECTION_SOFT, /**< Scroll single direction if the direction is certain*/
76    ELM_SCROLLER_SINGLE_DIRECTION_HARD, /**< Scroll only single direction */
77    ELM_SCROLLER_SINGLE_DIRECTION_LAST
78 } Elm_Scroller_Single_Direction;
79
80 /**
81  * @brief Add a new scroller to the parent
82  *
83  * @param parent The parent object
84  * @return The new object or NULL if it cannot be created
85  *
86  * @ingroup Scroller
87  */
88 EAPI Evas_Object                  *elm_scroller_add(Evas_Object *parent);
89
90 /**
91  * @brief Set custom theme elements for the scroller
92  *
93  * @param obj The scroller object
94  * @param widget The widget name to use (default is "scroller")
95  * @param base The base name to use (default is "base")
96  *
97  * @deprecated Use elm_layout_theme_set() instead.
98  *
99  * @ingroup Scroller
100  */
101 EINA_DEPRECATED EAPI void          elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base);
102
103 /**
104  * @brief Make the scroller minimum size limited to the minimum size of the content
105  *
106  * @param obj The scroller object
107  * @param w Enable limiting minimum size horizontally
108  * @param h Enable limiting minimum size vertically
109  *
110  * By default the scroller will be as small as its design allows,
111  * irrespective of its content. This will make the scroller minimum size the
112  * right size horizontally and/or vertically to perfectly fit its content in
113  * that direction.
114  *
115  * @ingroup Scroller
116  */
117 EAPI void                          elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h);
118
119 /**
120  * @brief Show a specific virtual region within the scroller content object
121  *
122  * @param obj The scroller object
123  * @param x X coordinate of the region
124  * @param y Y coordinate of the region
125  * @param w Width of the region
126  * @param h Height of the region
127  *
128  * This will ensure all (or part if it does not fit) of the designated
129  * region in the virtual content object (0, 0 starting at the top-left of the
130  * virtual content object) is shown within the scroller.
131  *
132  * @ingroup Scroller
133  */
134 EAPI void                          elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
135
136 /**
137  * @brief Set the scrollbar visibility policy
138  *
139  * @param obj The scroller object
140  * @param policy_h Horizontal scrollbar policy
141  * @param policy_v Vertical scrollbar policy
142  *
143  * This sets the scrollbar visibility policy for the given scroller.
144  * ELM_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it is
145  * needed, and otherwise kept hidden. ELM_SCROLLER_POLICY_ON turns it on all
146  * the time, and ELM_SCROLLER_POLICY_OFF always keeps it off. This applies
147  * respectively for the horizontal and vertical scrollbars.
148  *
149  * @ingroup Scroller
150  */
151 EAPI void                          elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v);
152
153 /**
154  * @brief Gets scrollbar visibility policy
155  *
156  * @param obj The scroller object
157  * @param policy_h Horizontal scrollbar policy
158  * @param policy_v Vertical scrollbar policy
159  *
160  * @see elm_scroller_policy_set()
161  *
162  * @ingroup Scroller
163  */
164 EAPI void                          elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v);
165
166 /**
167  * @brief Set the type of single direction scroll
168  *
169  * @param obj The scroller object
170  * @param single_dir The type of single direction
171  *
172  * @see elm_scroller_single_direction_get()
173  *
174  * @since 1.8
175  *
176  * @ingroup Scroller
177  */
178 EAPI void                          elm_scroller_single_direction_set(Evas_Object *obj, Elm_Scroller_Single_Direction single_dir);
179
180 /**
181  * @brief Get the type of single direction scroll
182  *
183  * @param obj The scroller object
184  * @return the type of single direction
185  *
186  * @see elm_scroller_single_direction_get()
187  *
188  * @since 1.8
189  *
190  * @ingroup Scroller
191  */
192 EAPI Elm_Scroller_Single_Direction elm_scroller_single_direction_get(const Evas_Object *obj);
193
194 /**
195  * @brief Get the currently visible content region
196  *
197  * @param obj The scroller object
198  * @param x X coordinate of the region
199  * @param y Y coordinate of the region
200  * @param w Width of the region
201  * @param h Height of the region
202  *
203  * This gets the current region in the content object that is visible through
204  * the scroller. The region co-ordinates are returned in the @p x, @p y, @p
205  * w, @p h values pointed to.
206  *
207  * @note All coordinates are relative to the content.
208  *
209  * @see elm_scroller_region_show()
210  *
211  * @ingroup Scroller
212  */
213 EAPI void                          elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
214
215 /**
216  * @brief Get the size of the content object
217  *
218  * @param obj The scroller object
219  * @param w Width of the content object.
220  * @param h Height of the content object.
221  *
222  * This gets the size of the content object of the scroller.
223  *
224  * @ingroup Scroller
225  */
226 EAPI void                          elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
227
228 /**
229  * @brief Set bouncing behavior
230  *
231  * @param obj The scroller object
232  * @param h_bounce Allow bounce horizontally
233  * @param v_bounce Allow bounce vertically
234  *
235  * When scrolling, the scroller may "bounce" when reaching an edge of the
236  * content object. This is a visual way to indicate the end has been reached.
237  * This is enabled by default for both axis. This API will set if it is enabled
238  * for the given axis with the boolean parameters for each axis.
239  *
240  * @ingroup Scroller
241  */
242 EAPI void                          elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
243
244 /**
245  * @brief Get the bounce behaviour
246  *
247  * @param obj The Scroller object
248  * @param h_bounce Will the scroller bounce horizontally or not
249  * @param v_bounce Will the scroller bounce vertically or not
250  *
251  * @see elm_scroller_bounce_set()
252  *
253  * @ingroup Scroller
254  */
255 EAPI void                          elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
256
257 /**
258  * @brief Set scroll page size relative to viewport size.
259  *
260  * @param obj The scroller object
261  * @param h_pagerel The horizontal page relative size
262  * @param v_pagerel The vertical page relative size
263  *
264  * The scroller is capable of limiting scrolling by the user to "pages". That
265  * is to jump by and only show a "whole page" at a time as if the continuous
266  * area of the scroller content is split into page sized pieces. This sets
267  * the size of a page relative to the viewport of the scroller. 1.0 is "1
268  * viewport" is size (horizontally or vertically). 0.0 turns it off in that
269  * axis. This is mutually exclusive with page size
270  * (see elm_scroller_page_size_set()  for more information). Likewise 0.5
271  * is "half a viewport". Sane usable values are normally between 0.0 and 1.0
272  * including 1.0. If you only want 1 axis to be page "limited", use 0.0 for
273  * the other axis.
274  *
275  * @ingroup Scroller
276  */
277 EAPI void                          elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel);
278
279 /**
280  * Get a given scroller widget's scrolling page size, relative to
281  * its viewport size.
282  *
283  * @param obj The scroller object
284  * @param h_pagerel Pointer to a variable where to store the
285  * horizontal page (relative) size
286  * @param v_pagerel Pointer to a variable where to store the
287  * vertical page (relative) size
288  *
289  * @see elm_scroller_page_relative_set() for more details
290  *
291  * @since 1.7
292  *
293  * @ingroup Scroller
294  */
295 EAPI void                          elm_scroller_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel);
296
297 /**
298  * @brief Set scroll page size.
299  *
300  * @param obj The scroller object
301  * @param h_pagesize The horizontal page size
302  * @param v_pagesize The vertical page size
303  *
304  * This sets the page size to an absolute fixed value, with 0 turning it off
305  * for that axis.
306  *
307  * @see elm_scroller_page_relative_set()
308  * @see elm_scroller_page_size_get()
309  *
310  * @ingroup Scroller
311  */
312 EAPI void                          elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize);
313
314 /**
315  * @brief Retrieve a scroller widget's current page size.
316  *
317  * @param obj The scroller object
318  * @param h_pagesize Where to store its horizontal page size
319  * @param v_pagesize Where to store its vertical page size
320  *
321  * @see elm_scroller_page_size_set() for more details
322  * @see elm_scroller_page_relative_set()
323  *
324  * @since 1.7
325  *
326  * @ingroup Scroller
327  */
328 EAPI void                          elm_scroller_page_size_get(const Evas_Object *obj, Evas_Coord *h_pagesize, Evas_Coord *v_pagesize);
329
330 /**
331  * @brief Set the maxium of the movable page at a flicking.
332  *
333  * @param obj The scroller object
334  * @param page_limit_h The maxium of the movable horizontal page
335  * @param page_limit_v The maxium of the movable vertical page
336  *
337  * The value of maxium movable page should be more than 1.
338  *
339  * @see elm_scroller_page_scroll_limit_get()
340  *
341  * @since 1.8
342  *
343  * @ingroup Scroller
344  */
345 EAPI void                          elm_scroller_page_scroll_limit_set(Evas_Object *obj, int page_limit_h, int page_limit_v);
346
347 /**
348  * @brief Get the maxium of the movable page at a flicking.
349  *
350  * @param obj The scroller object
351  * @param page_limit_h The maxium of the movable horizontal page
352  * @param page_limit_v The maxium of the movable vertical page
353  *
354  *
355  * @see elm_scroller_page_scroll_limit_set()
356  *
357  * @since 1.8
358  *
359  * @ingroup Scroller
360  */
361 EAPI void                          elm_scroller_page_scroll_limit_get(Evas_Object *obj, int *page_limit_h, int *page_limit_v);
362
363 /**
364  * @brief Get scroll current page number.
365  *
366  * @param obj The scroller object
367  * @param h_pagenumber The horizontal page number
368  * @param v_pagenumber The vertical page number
369  *
370  * The page number starts from 0. 0 is the first page.
371  * Current page means the page which meets the top-left of the viewport.
372  * If there are two or more pages in the viewport, it returns the number of the page
373  * which meets the top-left of the viewport.
374  *
375  * @see elm_scroller_last_page_get()
376  * @see elm_scroller_page_show()
377  * @see elm_scroller_page_bring_in()
378  *
379  * @ingroup Scroller
380  */
381 EAPI void                          elm_scroller_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
382
383 /**
384  * @brief Get scroll last page number.
385  *
386  * @param obj The scroller object
387  * @param h_pagenumber The horizontal page number
388  * @param v_pagenumber The vertical page number
389  *
390  * The page number starts from 0. 0 is the first page.
391  * This returns the last page number among the pages.
392  *
393  * @see elm_scroller_current_page_get()
394  * @see elm_scroller_page_show()
395  * @see elm_scroller_page_bring_in()
396  *
397  * @ingroup Scroller
398  */
399 EAPI void                          elm_scroller_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
400
401 /**
402  * Show a specific virtual region within the scroller content object by page number.
403  *
404  * @param obj The scroller object
405  * @param h_pagenumber The horizontal page number
406  * @param v_pagenumber The vertical page number
407  *
408  * 0, 0 of the indicated page is located at the top-left of the viewport.
409  * This will jump to the page directly without animation.
410  *
411  * Example of usage:
412  *
413  * @code
414  * sc = elm_scroller_add(win);
415  * elm_object_content_set(sc, content);
416  * elm_scroller_page_relative_set(sc, 1, 0);
417  * elm_scroller_current_page_get(sc, &h_page, &v_page);
418  * elm_scroller_page_show(sc, h_page + 1, v_page);
419  * @endcode
420  *
421  * @see elm_scroller_page_bring_in()
422  *
423  * @ingroup Scroller
424  */
425 EAPI void                          elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
426
427 /**
428  * Show a specific virtual region within the scroller content object by page number.
429  *
430  * @param obj The scroller object
431  * @param h_pagenumber The horizontal page number
432  * @param v_pagenumber The vertical page number
433  *
434  * 0, 0 of the indicated page is located at the top-left of the viewport.
435  * This will slide to the page with animation.
436  *
437  * Example of usage:
438  *
439  * @code
440  * sc = elm_scroller_add(win);
441  * elm_object_content_set(sc, content);
442  * elm_scroller_page_relative_set(sc, 1, 0);
443  * elm_scroller_last_page_get(sc, &h_page, &v_page);
444  * elm_scroller_page_bring_in(sc, h_page, v_page);
445  * @endcode
446  *
447  * @see elm_scroller_page_show()
448  *
449  * @ingroup Scroller
450  */
451 EAPI void                          elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
452
453 /**
454  * @brief Show a specific virtual region within the scroller content object.
455  *
456  * @param obj The scroller object
457  * @param x X coordinate of the region
458  * @param y Y coordinate of the region
459  * @param w Width of the region
460  * @param h Height of the region
461  *
462  * This will ensure all (or part if it does not fit) of the designated
463  * region in the virtual content object (0, 0 starting at the top-left of the
464  * virtual content object) is shown within the scroller. Unlike
465  * elm_scroller_region_show(), this allow the scroller to "smoothly slide"
466  * to this location (if configuration in general calls for transitions). It
467  * may not jump immediately to the new location and make take a while and
468  * show other content along the way.
469  *
470  * @see elm_scroller_region_show()
471  *
472  * @ingroup Scroller
473  */
474 EAPI void                          elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
475
476 /**
477  * @brief Set event propagation on a scroller
478  *
479  * @param obj The scroller object
480  * @param propagation If propagation is enabled or not
481  *
482  * This enables or disables event propagation from the scroller
483  * content to the scroller and its parent. By default event
484  * propagation is @b enabled.
485  *
486  * @ingroup Scroller
487  */
488 EAPI void                          elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation);
489
490 /**
491  * @brief Get event propagation for a scroller
492  *
493  * @param obj The scroller object
494  * @return The propagation state
495  *
496  * This gets the event propagation for a scroller.
497  *
498  * @see elm_scroller_propagate_events_set()
499  *
500  * @ingroup Scroller
501  */
502 EAPI Eina_Bool                     elm_scroller_propagate_events_get(const Evas_Object *obj);
503
504 /**
505  * @brief Set scrolling gravity on a scroller
506  *
507  * @param obj The scroller object
508  * @param x The scrolling horizontal gravity
509  * @param y The scrolling vertical gravity
510  *
511  * The gravity, defines how the scroller will adjust its view
512  * when the size of the scroller contents increase.
513  *
514  * The scroller will adjust the view to glue itself as follows.
515  *
516  *  x=0.0, for showing the left most region of the content.
517  *  x=1.0, for showing the right most region of the content.
518  *  y=0.0, for showing the bottom most region of the content.
519  *  y=1.0, for showing the top most region of the content.
520  *
521  * Default values for x and y are 0.0
522  *
523  * @ingroup Scroller
524  */
525 EAPI void                          elm_scroller_gravity_set(Evas_Object *obj, double x, double y);
526
527 /**
528  * @brief Get scrolling gravity values for a scroller
529  *
530  * @param obj The scroller object
531  * @param x The scrolling horizontal gravity
532  * @param y The scrolling vertical gravity
533  *
534  * This gets gravity values for a scroller.
535  *
536  * @see elm_scroller_gravity_set()
537  *
538  * @ingroup Scroller
539  */
540 EAPI void                          elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y);
541
542 /**
543  * @brief Set the infinite loop for a scroller
544  *
545  * @param obj The scroller object
546  * @param loop_h The scrolling horizontal loop
547  * @param loop_v The scrolling vertical loop
548  *
549  * This sets infinite loop for a scroller.
550  *
551  * @since 1.8
552  *
553  * @ingroup Scroller
554  */
555 EAPI void                          elm_scroller_loop_set(Evas_Object *obj, Eina_Bool loop_h, Eina_Bool loop_v);
556
557 /**
558  * @brief Get the infinite loop for a scroller
559  *
560  * @param obj The scroller object
561  * @param loop_h The scrolling horizontal loop
562  * @param loop_v The scrolling vertical loop
563  *
564  * This gets infinite loop for a scroller.
565  *
566  * @see elm_scroller_loop_set()
567  *
568  * @since 1.8
569  *
570  * @ingroup Scroller
571  */
572
573 EAPI void                          elm_scroller_loop_get(const Evas_Object *obj, Eina_Bool *loop_h, Eina_Bool *loop_v);
574
575 /**
576  * @}
577  */