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