Merge remote-tracking branch 'remotes/origin/upstream'
[framework/uifw/elementary.git] / src / lib / elm_box.h
1 /**
2  * @defgroup Box Box
3  *
4  * @image html img/widget/box/preview-00.png
5  * @image latex img/widget/box/preview-00.eps width=\textwidth
6  *
7  * @image html img/box.png
8  * @image latex img/box.eps width=\textwidth
9  *
10  * A box arranges objects in a linear fashion, governed by a layout function
11  * that defines the details of this arrangement.
12  *
13  * By default, the box will use an internal function to set the layout to
14  * a single row, either vertical or horizontal. This layout is affected
15  * by a number of parameters, such as the homogeneous flag set by
16  * elm_box_homogeneous_set(), the values given by elm_box_padding_set() and
17  * elm_box_align_set() and the hints set to each object in the box.
18  *
19  * For this default layout, it's possible to change the orientation with
20  * elm_box_horizontal_set(). The box will start in the vertical orientation,
21  * placing its elements ordered from top to bottom. When horizontal is set,
22  * the order will go from left to right. If the box is set to be
23  * homogeneous, every object in it will be assigned the same space, that
24  * of the largest object. Padding can be used to set some spacing between
25  * the cell given to each object. The alignment of the box, set with
26  * elm_box_align_set(), determines how the bounding box of all the elements
27  * will be placed within the space given to the box widget itself.
28  *
29  * The size hints of each object also affect how they are placed and sized
30  * within the box. evas_object_size_hint_min_set() will give the minimum
31  * size the object can have, and the box will use it as the basis for all
32  * latter calculations. Elementary widgets set their own minimum size as
33  * needed, so there's rarely any need to use it manually.
34  *
35  * evas_object_size_hint_weight_set(), when not in homogeneous mode, is
36  * used to tell whether the object will be allocated the minimum size it
37  * needs or if the space given to it should be expanded. It's important
38  * to realize that expanding the size given to the object is not the same
39  * thing as resizing the object. It could very well end being a small
40  * widget floating in a much larger empty space. If not set, the weight
41  * for objects will normally be 0.0 for both axis, meaning the widget will
42  * not be expanded. To take as much space possible, set the weight to
43  * EVAS_HINT_EXPAND (defined to 1.0) for the desired axis to expand.
44  *
45  * Besides how much space each object is allocated, it's possible to control
46  * how the widget will be placed within that space using
47  * evas_object_size_hint_align_set(). By default, this value will be 0.5
48  * for both axis, meaning the object will be centered, but any value from
49  * 0.0 (left or top, for the @c x and @c y axis, respectively) to 1.0
50  * (right or bottom) can be used. The special value EVAS_HINT_FILL, which
51  * is -1.0, means the object will be resized to fill the entire space it
52  * was allocated.
53  *
54  * In addition, customized functions to define the layout can be set, which
55  * allow the application developer to organize the objects within the box
56  * in any number of ways.
57  *
58  * The special elm_box_layout_transition() function can be used
59  * to switch from one layout to another, animating the motion of the
60  * children of the box.
61  *
62  * @note Objects should not be added to box objects using _add() calls.
63  *
64  * Some examples on how to use boxes follow:
65  * @li @ref box_example_01
66  * @li @ref box_example_02
67  *
68  * @{
69  */
70 /**
71  * @typedef Elm_Box_Transition
72  *
73  * Opaque handler containing the parameters to perform an animated
74  * transition of the layout the box uses.
75  *
76  * @see elm_box_transition_new()
77  * @see elm_box_layout_set()
78  * @see elm_box_layout_transition()
79  */
80 typedef struct _Elm_Box_Transition Elm_Box_Transition;
81
82 /**
83  * Add a new box to the parent
84  *
85  * By default, the box will be in vertical mode and non-homogeneous.
86  *
87  * @param parent The parent object
88  * @return The new object or NULL if it cannot be created
89  */
90 EAPI Evas_Object        *elm_box_add(Evas_Object *parent);
91
92 /**
93  * Set the horizontal orientation
94  *
95  * By default, box object arranges their contents vertically from top to
96  * bottom.
97  * By calling this function with @p horizontal as EINA_TRUE, the box will
98  * become horizontal, arranging contents from left to right.
99  *
100  * @note This flag is ignored if a custom layout function is set.
101  *
102  * @param obj The box object
103  * @param horizontal The horizontal flag (EINA_TRUE = horizontal,
104  * EINA_FALSE = vertical)
105  */
106 EAPI void                elm_box_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
107
108 /**
109  * Get the horizontal orientation
110  *
111  * @param obj The box object
112  * @return EINA_TRUE if the box is set to horizontal mode, EINA_FALSE otherwise
113  */
114 EAPI Eina_Bool           elm_box_horizontal_get(const Evas_Object *obj);
115
116 /**
117  * Set the box to arrange its children homogeneously
118  *
119  * If enabled, homogeneous layout makes all items the same size, according
120  * to the size of the largest of its children.
121  *
122  * @note This flag is ignored if a custom layout function is set.
123  *
124  * @param obj The box object
125  * @param homogeneous The homogeneous flag
126  */
127 EAPI void                elm_box_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous);
128
129 /**
130  * Get whether the box is using homogeneous mode or not
131  *
132  * @param obj The box object
133  * @return EINA_TRUE if it's homogeneous, EINA_FALSE otherwise
134  */
135 EAPI Eina_Bool           elm_box_homogeneous_get(const Evas_Object *obj);
136
137 /**
138  * Add an object to the beginning of the pack list
139  *
140  * Pack @p subobj into the box @p obj, placing it first in the list of
141  * children objects. The actual position the object will get on screen
142  * depends on the layout used. If no custom layout is set, it will be at
143  * the top or left, depending if the box is vertical or horizontal,
144  * respectively.
145  *
146  * @param obj The box object
147  * @param subobj The object to add to the box
148  *
149  * @see elm_box_pack_end()
150  * @see elm_box_pack_before()
151  * @see elm_box_pack_after()
152  * @see elm_box_unpack()
153  * @see elm_box_unpack_all()
154  * @see elm_box_clear()
155  */
156 EAPI void                elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj);
157
158 /**
159  * Add an object at the end of the pack list
160  *
161  * Pack @p subobj into the box @p obj, placing it last in the list of
162  * children objects. The actual position the object will get on screen
163  * depends on the layout used. If no custom layout is set, it will be at
164  * the bottom or right, depending if the box is vertical or horizontal,
165  * respectively.
166  *
167  * @param obj The box object
168  * @param subobj The object to add to the box
169  *
170  * @see elm_box_pack_start()
171  * @see elm_box_pack_before()
172  * @see elm_box_pack_after()
173  * @see elm_box_unpack()
174  * @see elm_box_unpack_all()
175  * @see elm_box_clear()
176  */
177 EAPI void                elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj);
178
179 /**
180  * Adds an object to the box before the indicated object
181  *
182  * This will add the @p subobj to the box indicated before the object
183  * indicated with @p before. If @p before is not already in the box, results
184  * are undefined. Before means either to the left of the indicated object or
185  * above it depending on orientation.
186  *
187  * @param obj The box object
188  * @param subobj The object to add to the box
189  * @param before The object before which to add it
190  *
191  * @see elm_box_pack_start()
192  * @see elm_box_pack_end()
193  * @see elm_box_pack_after()
194  * @see elm_box_unpack()
195  * @see elm_box_unpack_all()
196  * @see elm_box_clear()
197  */
198 EAPI void                elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before);
199
200 /**
201  * Adds an object to the box after the indicated object
202  *
203  * This will add the @p subobj to the box indicated after the object
204  * indicated with @p after. If @p after is not already in the box, results
205  * are undefined. After means either to the right of the indicated object or
206  * below it depending on orientation.
207  *
208  * @param obj The box object
209  * @param subobj The object to add to the box
210  * @param after The object after which to add it
211  *
212  * @see elm_box_pack_start()
213  * @see elm_box_pack_end()
214  * @see elm_box_pack_before()
215  * @see elm_box_unpack()
216  * @see elm_box_unpack_all()
217  * @see elm_box_clear()
218  */
219 EAPI void                elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after);
220
221 /**
222  * Clear the box of all children
223  *
224  * Remove all the elements contained by the box, deleting the respective
225  * objects.
226  *
227  * @param obj The box object
228  *
229  * @see elm_box_unpack()
230  * @see elm_box_unpack_all()
231  */
232 EAPI void                elm_box_clear(Evas_Object *obj);
233
234 /**
235  * Unpack a box item
236  *
237  * Remove the object given by @p subobj from the box @p obj without
238  * deleting it.
239  *
240  * @param obj The box object
241  * @param subobj The object to unpack
242  *
243  * @see elm_box_unpack_all()
244  * @see elm_box_clear()
245  */
246 EAPI void                elm_box_unpack(Evas_Object *obj, Evas_Object *subobj);
247
248 /**
249  * Remove all items from the box, without deleting them
250  *
251  * Clear the box from all children, but don't delete the respective objects.
252  * If no other references of the box children exist, the objects will never
253  * be deleted, and thus the application will leak the memory. Make sure
254  * when using this function that you hold a reference to all the objects
255  * in the box @p obj.
256  *
257  * @param obj The box object
258  *
259  * @see elm_box_clear()
260  * @see elm_box_unpack()
261  */
262 EAPI void                elm_box_unpack_all(Evas_Object *obj);
263
264 /**
265  * Retrieve a list of the objects packed into the box
266  *
267  * Returns a new @c Eina_List with a pointer to @c Evas_Object in its nodes.
268  * The order of the list corresponds to the packing order the box uses.
269  *
270  * You must free this list with eina_list_free() once you are done with it.
271  *
272  * @param obj The box object
273  */
274 <<<<<<< HEAD
275 EAPI const Eina_List    *elm_box_children_get(const Evas_Object *obj);
276 =======
277 EAPI Eina_List    *elm_box_children_get(const Evas_Object *obj);
278 >>>>>>> remotes/origin/upstream
279
280 /**
281  * Set the space (padding) between the box's elements.
282  *
283  * Extra space in pixels that will be added between a box child and its
284  * neighbors after its containing cell has been calculated. This padding
285  * is set for all elements in the box, besides any possible padding that
286  * individual elements may have through their size hints.
287  *
288  * @param obj The box object
289  * @param horizontal The horizontal space between elements
290  * @param vertical The vertical space between elements
291  */
292 EAPI void                elm_box_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical);
293
294 /**
295  * Get the space (padding) between the box's elements.
296  *
297  * @param obj The box object
298  * @param horizontal The horizontal space between elements
299  * @param vertical The vertical space between elements
300  *
301  * @see elm_box_padding_set()
302  */
303 EAPI void                elm_box_padding_get(const Evas_Object *obj, Evas_Coord *horizontal, Evas_Coord *vertical);
304
305 /**
306 <<<<<<< HEAD
307  * Set the alignment of the whole bouding box of contents.
308 =======
309  * Set the alignment of the whole bounding box of contents.
310 >>>>>>> remotes/origin/upstream
311  *
312  * Sets how the bounding box containing all the elements of the box, after
313  * their sizes and position has been calculated, will be aligned within
314  * the space given for the whole box widget.
315  *
316  * @param obj The box object
317  * @param horizontal The horizontal alignment of elements
318  * @param vertical The vertical alignment of elements
319  */
320 EAPI void                elm_box_align_set(Evas_Object *obj, double horizontal, double vertical);
321
322 /**
323 <<<<<<< HEAD
324  * Get the alignment of the whole bouding box of contents.
325 =======
326  * Get the alignment of the whole bounding box of contents.
327 >>>>>>> remotes/origin/upstream
328  *
329  * @param obj The box object
330  * @param horizontal The horizontal alignment of elements
331  * @param vertical The vertical alignment of elements
332  *
333  * @see elm_box_align_set()
334  */
335 EAPI void                elm_box_align_get(const Evas_Object *obj, double *horizontal, double *vertical);
336
337 /**
338  * Force the box to recalculate its children packing.
339  *
340  * If any children was added or removed, box will not calculate the
341  * values immediately rather leaving it to the next main loop
342  * iteration. While this is great as it would save lots of
343  * recalculation, whenever you need to get the position of a just
344  * added item you must force recalculate before doing so.
345  *
346  * @param obj The box object.
347  */
348 EAPI void                elm_box_recalculate(Evas_Object *obj);
349
350 /**
351  * Set the layout defining function to be used by the box
352  *
353  * Whenever anything changes that requires the box in @p obj to recalculate
354  * the size and position of its elements, the function @p cb will be called
355  * to determine what the layout of the children will be.
356  *
357  * Once a custom function is set, everything about the children layout
358  * is defined by it. The flags set by elm_box_horizontal_set() and
359  * elm_box_homogeneous_set() no longer have any meaning, and the values
360  * given by elm_box_padding_set() and elm_box_align_set() are up to this
361  * layout function to decide if they are used and how. These last two
362  * will be found in the @c priv parameter, of type @c Evas_Object_Box_Data,
363  * passed to @p cb. The @c Evas_Object the function receives is not the
364  * Elementary widget, but the internal Evas Box it uses, so none of the
365  * functions described here can be used on it.
366  *
367  * Any of the layout functions in @c Evas can be used here, as well as the
368  * special elm_box_layout_transition().
369  *
370  * The final @p data argument received by @p cb is the same @p data passed
371  * here, and the @p free_data function will be called to free it
372  * whenever the box is destroyed or another layout function is set.
373  *
374  * Setting @p cb to NULL will revert back to the default layout function.
375  *
376  * @param obj The box object
377  * @param cb The callback function used for layout
378  * @param data Data that will be passed to layout function
379  * @param free_data Function called to free @p data
380  *
381  * @see elm_box_layout_transition()
382  */
383 <<<<<<< HEAD
384 EAPI void                elm_box_layout_set(Evas_Object *obj, Evas_Object_Box_Layout cb, const void *data, void (*free_data)(void *data));
385 =======
386 EAPI void                elm_box_layout_set(Evas_Object *obj, Evas_Object_Box_Layout cb, const void *data, Ecore_Cb free_data);
387 >>>>>>> remotes/origin/upstream
388
389 /**
390  * Special layout function that animates the transition from one layout to another
391  *
392  * Normally, when switching the layout function for a box, this will be
393  * reflected immediately on screen on the next render, but it's also
394  * possible to do this through an animated transition.
395  *
396  * This is done by creating an ::Elm_Box_Transition and setting the box
397  * layout to this function.
398  *
399  * For example:
400  * @code
401  * Elm_Box_Transition *t = elm_box_transition_new(1.0,
402  *                            evas_object_box_layout_vertical, // start
403  *                            NULL, // data for initial layout
404  *                            NULL, // free function for initial data
405  *                            evas_object_box_layout_horizontal, // end
406  *                            NULL, // data for final layout
407  *                            NULL, // free function for final data
408  *                            anim_end, // will be called when animation ends
409  *                            NULL); // data for anim_end function\
410  * elm_box_layout_set(box, elm_box_layout_transition, t,
411  *                    elm_box_transition_free);
412  * @endcode
413  *
414  * @note This function can only be used with elm_box_layout_set(). Calling
415  * it directly will not have the expected results.
416  *
417  * @see elm_box_transition_new
418  * @see elm_box_transition_free
419  * @see elm_box_layout_set
420  */
421 EAPI void                elm_box_layout_transition(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data);
422
423 /**
424  * Create a new ::Elm_Box_Transition to animate the switch of layouts
425  *
426  * If you want to animate the change from one layout to another, you need
427  * to set the layout function of the box to elm_box_layout_transition(),
428  * passing as user data to it an instance of ::Elm_Box_Transition with the
429  * necessary information to perform this animation. The free function to
430  * set for the layout is elm_box_transition_free().
431  *
432  * The parameters to create an ::Elm_Box_Transition sum up to how long
433  * will it be, in seconds, a layout function to describe the initial point,
434  * another for the final position of the children and one function to be
435  * called when the whole animation ends. This last function is useful to
436  * set the definitive layout for the box, usually the same as the end
437  * layout for the animation, but could be used to start another transition.
438  *
439  * @param duration The duration of the transition in seconds
440  * @param start_layout The layout function that will be used to start the animation
441  * @param start_layout_data The data to be passed the @p start_layout function
442  * @param start_layout_free_data Function to free @p start_layout_data
443  * @param end_layout The layout function that will be used to end the animation
444  * @param end_layout_data Data param passed to @p end_layout
445  * @param end_layout_free_data The data to be passed the @p end_layout function
446  * @param end_layout_free_data Function to free @p end_layout_data
447  * @param transition_end_cb Callback function called when animation ends
448  * @param transition_end_data Data to be passed to @p transition_end_cb
449  * @return An instance of ::Elm_Box_Transition
450  *
451  * @see elm_box_transition_new
452  * @see elm_box_layout_transition
453  */
454 <<<<<<< HEAD
455 EAPI Elm_Box_Transition *elm_box_transition_new(const double duration, Evas_Object_Box_Layout start_layout, void *start_layout_data, void (*start_layout_free_data)(void *data), Evas_Object_Box_Layout end_layout, void *end_layout_data, void (*end_layout_free_data)(void *data), void (*transition_end_cb)(void *data), void *transition_end_data);
456 =======
457 EAPI Elm_Box_Transition *elm_box_transition_new(const double duration, Evas_Object_Box_Layout start_layout, void *start_layout_data, void (*start_layout_free_data)(void *data), Evas_Object_Box_Layout end_layout, void *end_layout_data, Ecore_Cb end_layout_free_data, Ecore_Cb transition_end_cb, void *transition_end_data);
458 >>>>>>> remotes/origin/upstream
459
460 /**
461  * Free a Elm_Box_Transition instance created with elm_box_transition_new().
462  *
463  * This function is mostly useful as the @c free_data parameter in
464  * elm_box_layout_set() when elm_box_layout_transition().
465  *
466  * @param data The Elm_Box_Transition instance to be freed.
467  *
468  * @see elm_box_transition_new
469  * @see elm_box_layout_transition
470  */
471 EAPI void                elm_box_transition_free(void *data);
472
473 /**
474  * @}
475  */