Initialize Tizen 2.3
[framework/uifw/elementary.git] / wearable / 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 EAPI void                          elm_scroller_origin_reverse_set(Evas_Object *obj, Eina_Bool origin_x, Eina_Bool origin_y);
259 EAPI void                          elm_scroller_origin_reverse_get(Evas_Object *obj, Eina_Bool *origin_x, Eina_Bool *origin_y);
260 /**
261  * @brief Set scroll page size relative to viewport size.
262  *
263  * @param obj The scroller object
264  * @param h_pagerel The horizontal page relative size
265  * @param v_pagerel The vertical page relative size
266  *
267  * The scroller is capable of limiting scrolling by the user to "pages". That
268  * is to jump by and only show a "whole page" at a time as if the continuous
269  * area of the scroller content is split into page sized pieces. This sets
270  * the size of a page relative to the viewport of the scroller. 1.0 is "1
271  * viewport" is size (horizontally or vertically). 0.0 turns it off in that
272  * axis. This is mutually exclusive with page size
273  * (see elm_scroller_page_size_set()  for more information). Likewise 0.5
274  * is "half a viewport". Sane usable values are normally between 0.0 and 1.0
275  * including 1.0. If you only want 1 axis to be page "limited", use 0.0 for
276  * the other axis.
277  *
278  * @ingroup Scroller
279  */
280 EAPI void                          elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel);
281
282 /**
283  * Get a given scroller widget's scrolling page size, relative to
284  * its viewport size.
285  *
286  * @param obj The scroller object
287  * @param h_pagerel Pointer to a variable where to store the
288  * horizontal page (relative) size
289  * @param v_pagerel Pointer to a variable where to store the
290  * vertical page (relative) size
291  *
292  * @see elm_scroller_page_relative_set() for more details
293  *
294  * @since 1.7
295  *
296  * @ingroup Scroller
297  */
298 EAPI void                          elm_scroller_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel);
299
300 /**
301  * @brief Set scroll page size.
302  *
303  * @param obj The scroller object
304  * @param h_pagesize The horizontal page size
305  * @param v_pagesize The vertical page size
306  *
307  * This sets the page size to an absolute fixed value, with 0 turning it off
308  * for that axis.
309  *
310  * @see elm_scroller_page_relative_set()
311  * @see elm_scroller_page_size_get()
312  *
313  * @ingroup Scroller
314  */
315 EAPI void                          elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize);
316
317 /**
318  * @brief Retrieve a scroller widget's current page size.
319  *
320  * @param obj The scroller object
321  * @param h_pagesize Where to store its horizontal page size
322  * @param v_pagesize Where to store its vertical page size
323  *
324  * @see elm_scroller_page_size_set() for more details
325  * @see elm_scroller_page_relative_set()
326  *
327  * @since 1.7
328  *
329  * @ingroup Scroller
330  */
331 EAPI void                          elm_scroller_page_size_get(const Evas_Object *obj, Evas_Coord *h_pagesize, Evas_Coord *v_pagesize);
332
333 /**
334  * @brief Set the maxium of the movable page at a flicking.
335  *
336  * @param obj The scroller object
337  * @param page_limit_h The maxium of the movable horizontal page
338  * @param page_limit_v The maxium of the movable vertical page
339  *
340  * The value of maxium movable page should be more than 1.
341  *
342  * @see elm_scroller_page_scroll_limit_get()
343  *
344  * @since 1.8
345  *
346  * @ingroup Scroller
347  */
348 EAPI void                          elm_scroller_page_scroll_limit_set(Evas_Object *obj, int page_limit_h, int page_limit_v);
349
350 /**
351  * @brief Get the maxium of the movable page at a flicking.
352  *
353  * @param obj The scroller object
354  * @param page_limit_h The maxium of the movable horizontal page
355  * @param page_limit_v The maxium of the movable vertical page
356  *
357  *
358  * @see elm_scroller_page_scroll_limit_set()
359  *
360  * @since 1.8
361  *
362  * @ingroup Scroller
363  */
364 EAPI void                          elm_scroller_page_scroll_limit_get(Evas_Object *obj, int *page_limit_h, int *page_limit_v);
365
366 /**
367  * @brief Get scroll current page number.
368  *
369  * @param obj The scroller object
370  * @param h_pagenumber The horizontal page number
371  * @param v_pagenumber The vertical page number
372  *
373  * The page number starts from 0. 0 is the first page.
374  * Current page means the page which meets the top-left of the viewport.
375  * If there are two or more pages in the viewport, it returns the number of the page
376  * which meets the top-left of the viewport.
377  *
378  * @see elm_scroller_last_page_get()
379  * @see elm_scroller_page_show()
380  * @see elm_scroller_page_bring_in()
381  *
382  * @ingroup Scroller
383  */
384 EAPI void                          elm_scroller_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
385
386 /**
387  * @brief Get scroll last page number.
388  *
389  * @param obj The scroller object
390  * @param h_pagenumber The horizontal page number
391  * @param v_pagenumber The vertical page number
392  *
393  * The page number starts from 0. 0 is the first page.
394  * This returns the last page number among the pages.
395  *
396  * @see elm_scroller_current_page_get()
397  * @see elm_scroller_page_show()
398  * @see elm_scroller_page_bring_in()
399  *
400  * @ingroup Scroller
401  */
402 EAPI void                          elm_scroller_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
403
404 /**
405  * Show a specific virtual region within the scroller content object by page number.
406  *
407  * @param obj The scroller object
408  * @param h_pagenumber The horizontal page number
409  * @param v_pagenumber The vertical page number
410  *
411  * 0, 0 of the indicated page is located at the top-left of the viewport.
412  * This will jump to the page directly without animation.
413  *
414  * Example of usage:
415  *
416  * @code
417  * sc = elm_scroller_add(win);
418  * elm_object_content_set(sc, content);
419  * elm_scroller_page_relative_set(sc, 1, 0);
420  * elm_scroller_current_page_get(sc, &h_page, &v_page);
421  * elm_scroller_page_show(sc, h_page + 1, v_page);
422  * @endcode
423  *
424  * @see elm_scroller_page_bring_in()
425  *
426  * @ingroup Scroller
427  */
428 EAPI void                          elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
429
430 /**
431  * Show a specific virtual region within the scroller content object by page number.
432  *
433  * @param obj The scroller object
434  * @param h_pagenumber The horizontal page number
435  * @param v_pagenumber The vertical page number
436  *
437  * 0, 0 of the indicated page is located at the top-left of the viewport.
438  * This will slide to the page with animation.
439  *
440  * Example of usage:
441  *
442  * @code
443  * sc = elm_scroller_add(win);
444  * elm_object_content_set(sc, content);
445  * elm_scroller_page_relative_set(sc, 1, 0);
446  * elm_scroller_last_page_get(sc, &h_page, &v_page);
447  * elm_scroller_page_bring_in(sc, h_page, v_page);
448  * @endcode
449  *
450  * @see elm_scroller_page_show()
451  *
452  * @ingroup Scroller
453  */
454 EAPI void                          elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
455
456 /**
457  * @brief Show a specific virtual region within the scroller content object.
458  *
459  * @param obj The scroller object
460  * @param x X coordinate of the region
461  * @param y Y coordinate of the region
462  * @param w Width of the region
463  * @param h Height of the region
464  *
465  * This will ensure all (or part if it does not fit) of the designated
466  * region in the virtual content object (0, 0 starting at the top-left of the
467  * virtual content object) is shown within the scroller. Unlike
468  * elm_scroller_region_show(), this allow the scroller to "smoothly slide"
469  * to this location (if configuration in general calls for transitions). It
470  * may not jump immediately to the new location and make take a while and
471  * show other content along the way.
472  *
473  * @see elm_scroller_region_show()
474  *
475  * @ingroup Scroller
476  */
477 EAPI void                          elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
478
479 /**
480  * @brief Set event propagation on a scroller
481  *
482  * @param obj The scroller object
483  * @param propagation If propagation is enabled or not
484  *
485  * This enables or disables event propagation from the scroller
486  * content to the scroller and its parent. By default event
487  * propagation is @b enabled.
488  *
489  * @ingroup Scroller
490  */
491 EAPI void                          elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation);
492
493 /**
494  * @brief Get event propagation for a scroller
495  *
496  * @param obj The scroller object
497  * @return The propagation state
498  *
499  * This gets the event propagation for a scroller.
500  *
501  * @see elm_scroller_propagate_events_set()
502  *
503  * @ingroup Scroller
504  */
505 EAPI Eina_Bool                     elm_scroller_propagate_events_get(const Evas_Object *obj);
506
507 /**
508  * @brief Set scrolling gravity on a scroller
509  *
510  * @param obj The scroller object
511  * @param x The scrolling horizontal gravity
512  * @param y The scrolling vertical gravity
513  *
514  * The gravity, defines how the scroller will adjust its view
515  * when the size of the scroller contents increase.
516  *
517  * The scroller will adjust the view to glue itself as follows.
518  *
519  *  x=0.0, for showing the left most region of the content.
520  *  x=1.0, for showing the right most region of the content.
521  *  y=0.0, for showing the bottom most region of the content.
522  *  y=1.0, for showing the top most region of the content.
523  *
524  * Default values for x and y are 0.0
525  *
526  * @ingroup Scroller
527  */
528 EAPI void                          elm_scroller_gravity_set(Evas_Object *obj, double x, double y);
529
530 /**
531  * @brief Get scrolling gravity values for a scroller
532  *
533  * @param obj The scroller object
534  * @param x The scrolling horizontal gravity
535  * @param y The scrolling vertical gravity
536  *
537  * This gets gravity values for a scroller.
538  *
539  * @see elm_scroller_gravity_set()
540  *
541  * @ingroup Scroller
542  */
543 EAPI void                          elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y);
544
545 /**
546  * @brief Set mouse wheel event on a scroller
547  *
548  * @param obj The scroller object
549  * @param disabled If wheel event is disabled or not
550  *
551  * This enables or disables mouse wheel event for scroller.
552  * By default mouse wheel event is enabled.
553  *
554  * @ingroup Scroller
555  */
556 EAPI void                          elm_scroller_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled);
557
558 /**
559  * @brief Get mouse wheel event for a scroller
560  *
561  * @param obj The scroller object
562  *
563  * This gets if wheel event is disabled or not.
564  *
565  * @see elm_scroller_wheel_disabled_set()
566  *
567  * @ingroup Scroller
568  */
569 EAPI Eina_Bool                      elm_scroller_wheel_disabled_get(const Evas_Object *obj);
570
571 /**
572  * @brief Set the infinite loop for a scroller
573  *
574  * @param obj The scroller object
575  * @param loop_h The scrolling horizontal loop
576  * @param loop_v The scrolling vertical loop
577  *
578  * This sets infinite loop for a scroller.
579  *
580  * @since 1.8
581  *
582  * @ingroup Scroller
583  */
584 EAPI void                          elm_scroller_loop_set(Evas_Object *obj, Eina_Bool loop_h, Eina_Bool loop_v);
585
586 /**
587  * @brief Get the infinite loop for a scroller
588  *
589  * @param obj The scroller object
590  * @param loop_h The scrolling horizontal loop
591  * @param loop_v The scrolling vertical loop
592  *
593  * This gets infinite loop for a scroller.
594  *
595  * @see elm_scroller_loop_set()
596  *
597  * @since 1.8
598  *
599  * @ingroup Scroller
600  */
601
602 EAPI void                          elm_scroller_loop_get(const Evas_Object *obj, Eina_Bool *loop_h, Eina_Bool *loop_v);
603
604 /**
605  * @}
606  */