remove eina_pure and eina_nonnull because really.. they screw up
[framework/uifw/elementary.git] / src / lib / elm_scroller.h
1 /**
2  * @defgroup Scroller Scroller
3  *
4  * A scroller holds a single object and "scrolls it around". This means that
5  * it allows the user to use a scrollbar (or a finger) to drag the viewable
6  * region around, allowing to move through a much larger object that is
7  * contained in the scroller. The scroller will always have a small minimum
8  * size by default as it won't be limited by the contents of the scroller.
9  *
10  * Signals that you can add callbacks for are:
11  * @li "edge,left" - the left edge of the content has been reached
12  * @li "edge,right" - the right edge of the content has been reached
13  * @li "edge,top" - the top edge of the content has been reached
14  * @li "edge,bottom" - the bottom edge of the content has been reached
15  * @li "scroll" - the content has been scrolled (moved)
16  * @li "scroll,anim,start" - scrolling animation has started
17  * @li "scroll,anim,stop" - scrolling animation has stopped
18  * @li "scroll,drag,start" - dragging the contents around has started
19  * @li "scroll,drag,stop" - dragging the contents around has stopped
20  * @note The "scroll,anim,*" and "scroll,drag,*" signals are only emitted by
21  * user intervetion.
22  *
23  * @note When Elemementary is in embedded mode the scrollbars will not be
24  * dragable, they appear merely as indicators of how much has been scrolled.
25  * @note When Elementary is in desktop mode the thumbscroll(a.k.a.
26  * fingerscroll) won't work.
27  *
28  * Default contents parts of the scroller widget that you can use for are:
29  * @li "default" - A content of the scroller
30  *
31  * In @ref tutorial_scroller you'll find an example of how to use most of
32  * this API.
33  * @{
34  */
35
36 /**
37  * @brief Type that controls when scrollbars should appear.
38  *
39  * @see elm_scroller_policy_set()
40  */
41 typedef enum
42 {
43    ELM_SCROLLER_POLICY_AUTO = 0, /**< Show scrollbars as needed */
44    ELM_SCROLLER_POLICY_ON, /**< Always show scrollbars */
45    ELM_SCROLLER_POLICY_OFF, /**< Never show scrollbars */
46    ELM_SCROLLER_POLICY_LAST
47 } Elm_Scroller_Policy;
48
49 /**
50  * @brief Add a new scroller to the parent
51  *
52  * @param parent The parent object
53  * @return The new object or NULL if it cannot be created
54  */
55 EAPI Evas_Object                 *elm_scroller_add(Evas_Object *parent);
56
57 /**
58  * @brief Set custom theme elements for the scroller
59  *
60  * @param obj The scroller object
61  * @param widget The widget name to use (default is "scroller")
62  * @param base The base name to use (default is "base")
63  */
64 EAPI void                         elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base);
65
66 /**
67  * @brief Make the scroller minimum size limited to the minimum size of the content
68  *
69  * @param obj The scroller object
70  * @param w Enable limiting minimum size horizontally
71  * @param h Enable limiting minimum size vertically
72  *
73  * By default the scroller will be as small as its design allows,
74  * irrespective of its content. This will make the scroller minimum size the
75  * right size horizontally and/or vertically to perfectly fit its content in
76  * that direction.
77  */
78 EAPI void                         elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h);
79
80 /**
81  * @brief Show a specific virtual region within the scroller content object
82  *
83  * @param obj The scroller object
84  * @param x X coordinate of the region
85  * @param y Y coordinate of the region
86  * @param w Width of the region
87  * @param h Height of the region
88  *
89  * This will ensure all (or part if it does not fit) of the designated
90  * region in the virtual content object (0, 0 starting at the top-left of the
91  * virtual content object) is shown within the scroller.
92  */
93 EAPI void                         elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
94
95 /**
96  * @brief Set the scrollbar visibility policy
97  *
98  * @param obj The scroller object
99  * @param policy_h Horizontal scrollbar policy
100  * @param policy_v Vertical scrollbar policy
101  *
102  * This sets the scrollbar visibility policy for the given scroller.
103  * ELM_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it is
104  * needed, and otherwise kept hidden. ELM_SCROLLER_POLICY_ON turns it on all
105  * the time, and ELM_SCROLLER_POLICY_OFF always keeps it off. This applies
106  * respectively for the horizontal and vertical scrollbars.
107  */
108 EAPI void                         elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v);
109
110 /**
111  * @brief Gets scrollbar visibility policy
112  *
113  * @param obj The scroller object
114  * @param policy_h Horizontal scrollbar policy
115  * @param policy_v Vertical scrollbar policy
116  *
117  * @see elm_scroller_policy_set()
118  */
119 EAPI void                         elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v);
120
121 /**
122  * @brief Get the currently visible content region
123  *
124  * @param obj The scroller object
125  * @param x X coordinate of the region
126  * @param y Y coordinate of the region
127  * @param w Width of the region
128  * @param h Height of the region
129  *
130  * This gets the current region in the content object that is visible through
131  * the scroller. The region co-ordinates are returned in the @p x, @p y, @p
132  * w, @p h values pointed to.
133  *
134  * @note All coordinates are relative to the content.
135  *
136  * @see elm_scroller_region_show()
137  */
138 EAPI void                         elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
139
140 /**
141  * @brief Get the size of the content object
142  *
143  * @param obj The scroller object
144  * @param w Width of the content object.
145  * @param h Height of the content object.
146  *
147  * This gets the size of the content object of the scroller.
148  */
149 EAPI void                         elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
150
151 /**
152  * @brief Set bouncing behavior
153  *
154  * @param obj The scroller object
155  * @param h_bounce Allow bounce horizontally
156  * @param v_bounce Allow bounce vertically
157  *
158  * When scrolling, the scroller may "bounce" when reaching an edge of the
159  * content object. This is a visual way to indicate the end has been reached.
160  * This is enabled by default for both axis. This API will set if it is enabled
161  * for the given axis with the boolean parameters for each axis.
162  */
163 EAPI void                         elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
164
165 /**
166  * @brief Get the bounce behaviour
167  *
168  * @param obj The Scroller object
169  * @param h_bounce Will the scroller bounce horizontally or not
170  * @param v_bounce Will the scroller bounce vertically or not
171  *
172  * @see elm_scroller_bounce_set()
173  */
174 EAPI void                         elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
175
176 /**
177  * @brief Set scroll page size relative to viewport size.
178  *
179  * @param obj The scroller object
180  * @param h_pagerel The horizontal page relative size
181  * @param v_pagerel The vertical page relative size
182  *
183  * The scroller is capable of limiting scrolling by the user to "pages". That
184  * is to jump by and only show a "whole page" at a time as if the continuous
185  * area of the scroller content is split into page sized pieces. This sets
186  * the size of a page relative to the viewport of the scroller. 1.0 is "1
187  * viewport" is size (horizontally or vertically). 0.0 turns it off in that
188  * axis. This is mutually exclusive with page size
189  * (see elm_scroller_page_size_set()  for more information). Likewise 0.5
190  * is "half a viewport". Sane usable values are normally between 0.0 and 1.0
191  * including 1.0. If you only want 1 axis to be page "limited", use 0.0 for
192  * the other axis.
193  */
194 EAPI void                         elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel);
195
196 /**
197  * @brief Set scroll page size.
198  *
199  * @param obj The scroller object
200  * @param h_pagesize The horizontal page size
201  * @param v_pagesize The vertical page size
202  *
203  * This sets the page size to an absolute fixed value, with 0 turning it off
204  * for that axis.
205  *
206  * @see elm_scroller_page_relative_set()
207  */
208 EAPI void                         elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize);
209
210 /**
211  * @brief Get scroll current page number.
212  *
213  * @param obj The scroller object
214  * @param h_pagenumber The horizontal page number
215  * @param v_pagenumber The vertical page number
216  *
217  * The page number starts from 0. 0 is the first page.
218  * Current page means the page which meets the top-left of the viewport.
219  * If there are two or more pages in the viewport, it returns the number of the page
220  * which meets the top-left of the viewport.
221  *
222  * @see elm_scroller_last_page_get()
223  * @see elm_scroller_page_show()
224  * @see elm_scroller_page_brint_in()
225  */
226 EAPI void                         elm_scroller_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
227
228 /**
229  * @brief Get scroll last page number.
230  *
231  * @param obj The scroller object
232  * @param h_pagenumber The horizontal page number
233  * @param v_pagenumber The vertical page number
234  *
235  * The page number starts from 0. 0 is the first page.
236  * This returns the last page number among the pages.
237  *
238  * @see elm_scroller_current_page_get()
239  * @see elm_scroller_page_show()
240  * @see elm_scroller_page_brint_in()
241  */
242 EAPI void                         elm_scroller_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber);
243
244 /**
245  * Show a specific virtual region within the scroller content object by page number.
246  *
247  * @param obj The scroller object
248  * @param h_pagenumber The horizontal page number
249  * @param v_pagenumber The vertical page number
250  *
251  * 0, 0 of the indicated page is located at the top-left of the viewport.
252  * This will jump to the page directly without animation.
253  *
254  * Example of usage:
255  *
256  * @code
257  * sc = elm_scroller_add(win);
258  * elm_scroller_content_set(sc, content);
259  * elm_scroller_page_relative_set(sc, 1, 0);
260  * elm_scroller_current_page_get(sc, &h_page, &v_page);
261  * elm_scroller_page_show(sc, h_page + 1, v_page);
262  * @endcode
263  *
264  * @see elm_scroller_page_bring_in()
265  */
266 EAPI void                         elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
267
268 /**
269  * Show a specific virtual region within the scroller content object by page number.
270  *
271  * @param obj The scroller object
272  * @param h_pagenumber The horizontal page number
273  * @param v_pagenumber The vertical page number
274  *
275  * 0, 0 of the indicated page is located at the top-left of the viewport.
276  * This will slide to the page with animation.
277  *
278  * Example of usage:
279  *
280  * @code
281  * sc = elm_scroller_add(win);
282  * elm_scroller_content_set(sc, content);
283  * elm_scroller_page_relative_set(sc, 1, 0);
284  * elm_scroller_last_page_get(sc, &h_page, &v_page);
285  * elm_scroller_page_bring_in(sc, h_page, v_page);
286  * @endcode
287  *
288  * @see elm_scroller_page_show()
289  */
290 EAPI void                         elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber);
291
292 /**
293  * @brief Show a specific virtual region within the scroller content object.
294  *
295  * @param obj The scroller object
296  * @param x X coordinate of the region
297  * @param y Y coordinate of the region
298  * @param w Width of the region
299  * @param h Height of the region
300  *
301  * This will ensure all (or part if it does not fit) of the designated
302  * region in the virtual content object (0, 0 starting at the top-left of the
303  * virtual content object) is shown within the scroller. Unlike
304  * elm_scroller_region_show(), this allow the scroller to "smoothly slide"
305  * to this location (if configuration in general calls for transitions). It
306  * may not jump immediately to the new location and make take a while and
307  * show other content along the way.
308  *
309  * @see elm_scroller_region_show()
310  */
311 EAPI void                         elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
312
313 /**
314  * @brief Set event propagation on a scroller
315  *
316  * @param obj The scroller object
317  * @param propagation If propagation is enabled or not
318  *
319  * This enables or disabled event propagation from the scroller content to
320  * the scroller and its parent. By default event propagation is disabled.
321  */
322 EAPI void                         elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation);
323
324 /**
325  * @brief Get event propagation for a scroller
326  *
327  * @param obj The scroller object
328  * @return The propagation state
329  *
330  * This gets the event propagation for a scroller.
331  *
332  * @see elm_scroller_propagate_events_set()
333  */
334 EAPI Eina_Bool                    elm_scroller_propagate_events_get(const Evas_Object *obj);
335
336 /**
337  * @brief Set scrolling gravity on a scroller
338  *
339  * @param obj The scroller object
340  * @param x The scrolling horizontal gravity
341  * @param y The scrolling vertical gravity
342  *
343  * The gravity, defines how the scroller will adjust its view
344  * when the size of the scroller contents increase.
345  *
346  * The scroller will adjust the view to glue itself as follows.
347  *
348  *  x=0.0, for showing the left most region of the content.
349  *  x=1.0, for showing the right most region of the content.
350  *  y=0.0, for showing the bottom most region of the content.
351  *  y=1.0, for showing the top most region of the content.
352  *
353  * Default values for x and y are 0.0
354  */
355 EAPI void                         elm_scroller_gravity_set(Evas_Object *obj, double x, double y);
356
357 /**
358  * @brief Get scrolling gravity values for a scroller
359  *
360  * @param obj The scroller object
361  * @param x The scrolling horizontal gravity
362  * @param y The scrolling vertical gravity
363  *
364  * This gets gravity values for a scroller.
365  *
366  * @see elm_scroller_gravity_set()
367  *
368  */
369 EAPI void                         elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y);
370
371 /**
372  * @}
373  */