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