6d1a0d2a04d64bc95f870d492e3beae762e32922
[framework/uifw/elementary.git] / src / lib / elm_box.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_box.h"
4
5 static const char SIG_CHILD_ADDED[] = "child,added";
6 static const char SIG_CHILD_REMOVED[] = "child,removed";
7
8 static const Evas_Smart_Cb_Description _signals[] = {
9   {SIG_CHILD_ADDED, ""},
10   {SIG_CHILD_REMOVED, ""},
11   {NULL, NULL}
12 };
13
14
15 typedef struct _Widget_Data Widget_Data;
16 typedef struct _Transition_Animation_Data Transition_Animation_Data;
17
18 struct _Widget_Data
19 {
20    Evas_Object *box;
21    Eina_Bool horizontal:1;
22    Eina_Bool homogeneous:1;
23 };
24
25 struct _Elm_Box_Transition
26 {
27    double initial_time;
28    double duration;
29    Eina_Bool animation_ended:1;
30    Eina_Bool recalculate:1;
31    Ecore_Animator *animator;
32
33    struct
34      {
35         Evas_Object_Box_Layout layout;
36         void *data;
37         void(*free_data)(void *data);
38      } start, end;
39
40    void(*transition_end_cb)(void *data);
41    void *transition_end_data;
42    void (*transition_end_free_data)(void *data);
43    Eina_List *objs;
44    Evas_Object *box;
45 };
46
47 struct _Transition_Animation_Data
48 {
49    Evas_Object *obj;
50    struct
51      {
52         Evas_Coord x, y, w, h;
53      } start, end;
54 };
55
56 static const char *widtype = NULL;
57 static void _del_hook(Evas_Object *obj);
58 static void _sizing_eval(Evas_Object *obj);
59 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
60 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
61
62 static void
63 _del_pre_hook(Evas_Object *obj)
64 {
65    Widget_Data *wd = elm_widget_data_get(obj);
66    if (!wd) return;
67    evas_object_event_callback_del_full
68       (wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
69    evas_object_box_remove_all(wd->box, EINA_FALSE);
70 }
71
72 static void
73 _del_hook(Evas_Object *obj)
74 {
75    Widget_Data *wd = elm_widget_data_get(obj);
76    if (!wd) return;
77    free(wd);
78 }
79
80 static void *
81 _elm_box_list_data_get(const Eina_List *list)
82 {
83    Evas_Object_Box_Option *opt = eina_list_data_get(list);
84    return opt->obj;
85 }
86
87 static void
88 _cb_proxy_child_added(void *data, Evas_Object *o __UNUSED__, void *event_info)
89 {
90    Evas_Object *box = data;
91    Evas_Object_Box_Option *opt = event_info;
92    evas_object_smart_callback_call(box, SIG_CHILD_ADDED, opt->obj);
93 }
94
95 static void
96 _cb_proxy_child_removed(void *data, Evas_Object *o __UNUSED__, void *event_info)
97 {
98    Evas_Object *box = data;
99    Evas_Object *child = event_info;
100    evas_object_smart_callback_call(box, SIG_CHILD_REMOVED, child);
101 }
102
103 static Eina_Bool
104 _elm_box_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
105 {
106    Widget_Data *wd = elm_widget_data_get(obj);
107    const Eina_List *items;
108    void *(*list_data_get) (const Eina_List *list);
109
110    if ((!wd) || (!wd->box))
111      return EINA_FALSE;
112
113    /* Focus chain */
114    /* TODO: Change this to use other chain */
115    if ((items = elm_widget_focus_custom_chain_get(obj)))
116      list_data_get = eina_list_data_get;
117    else
118      {
119         Evas_Object_Box_Data *bd = evas_object_smart_data_get(wd->box);
120         items = bd->children;
121         list_data_get = _elm_box_list_data_get;
122
123         if (!items) return EINA_FALSE;
124      }
125
126    return elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
127 }
128
129 static void
130 _theme_hook(Evas_Object *obj)
131 {
132    Widget_Data *wd = elm_widget_data_get(obj);
133    if (!wd) return;
134    _elm_widget_mirrored_reload(obj);
135    evas_object_smart_calculate(wd->box);
136 }
137
138 static void
139 _sizing_eval(Evas_Object *obj)
140 {
141    Widget_Data *wd = elm_widget_data_get(obj);
142    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
143    Evas_Coord w, h;
144    if (!wd) return;
145    evas_object_size_hint_min_get(wd->box, &minw, &minh);
146    evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
147    evas_object_size_hint_min_set(obj, minw, minh);
148    evas_object_size_hint_max_set(obj, maxw, maxh);
149    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
150    if (w < minw) w = minw;
151    if (h < minh) h = minh;
152    if ((maxw >= 0) && (w > maxw)) w = maxw;
153    if ((maxh >= 0) && (h > maxh)) h = maxh;
154    evas_object_resize(obj, w, h);
155 }
156
157 static void
158 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
159 {
160    _sizing_eval(data);
161 }
162
163 static void
164 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
165 {
166    _sizing_eval(obj);
167 }
168
169 static void
170 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
171 {
172    Evas_Object *obj = (Evas_Object *) data;
173    Widget_Data *wd = elm_widget_data_get(obj);
174    if (!wd) return;
175    _els_box_layout(o, priv, wd->horizontal, wd->homogeneous,
176                    elm_widget_mirrored_get(obj));
177 }
178
179 static Eina_Bool
180 _transition_animation(void *data)
181 {
182    evas_object_smart_changed(data);
183    return ECORE_CALLBACK_RENEW;
184 }
185
186 static void
187 _transition_layout_child_added(void *data, Evas_Object *obj __UNUSED__, void *event_info)
188 {
189    Transition_Animation_Data *tad;
190    Evas_Object_Box_Option *opt = event_info;
191    Elm_Box_Transition *layout_data = data;
192
193    tad = calloc(1, sizeof(Transition_Animation_Data));
194    if (!tad) return;
195    tad->obj = opt->obj;
196    layout_data->objs = eina_list_append(layout_data->objs, tad);
197    layout_data->recalculate = EINA_TRUE;
198 }
199
200 static void
201 _transition_layout_child_removed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
202 {
203    Eina_List *l;
204    Transition_Animation_Data *tad;
205    Elm_Box_Transition *layout_data = data;
206
207    EINA_LIST_FOREACH(layout_data->objs, l, tad)
208      {
209         if (tad->obj == event_info)
210           {
211              free(eina_list_data_get(l));
212              layout_data->objs = eina_list_remove_list(layout_data->objs, l);
213              layout_data->recalculate = EINA_TRUE;
214              break;
215           }
216      }
217 }
218
219 static void
220 _transition_layout_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
221 {
222    Elm_Box_Transition *layout_data = data;
223    layout_data->recalculate = EINA_TRUE;
224 }
225
226 static void
227 _transition_layout_calculate_coords(Evas_Object *obj, Evas_Object_Box_Data *priv,
228                                     Elm_Box_Transition *layout_data)
229 {
230    Eina_List *l;
231    Transition_Animation_Data *tad;
232    Evas_Coord x, y, w, h;
233    const double curtime = ecore_loop_time_get();
234
235    layout_data->duration =
236       layout_data->duration - (curtime - layout_data->initial_time);
237    layout_data->initial_time = curtime;
238
239    evas_object_geometry_get(obj, &x, &y, &w, &h);
240    EINA_LIST_FOREACH(layout_data->objs, l, tad)
241      {
242         evas_object_geometry_get(tad->obj, &tad->start.x, &tad->start.y,
243                                  &tad->start.w, &tad->start.h);
244         tad->start.x = tad->start.x - x;
245         tad->start.y = tad->start.y - y;
246      }
247    layout_data->end.layout(obj, priv, layout_data->end.data);
248    EINA_LIST_FOREACH(layout_data->objs, l, tad)
249      {
250         evas_object_geometry_get(tad->obj, &tad->end.x, &tad->end.y,
251                                  &tad->end.w, &tad->end.h);
252         tad->end.x = tad->end.x - x;
253         tad->end.y = tad->end.y - y;
254      }
255 }
256
257 static Eina_Bool
258 _transition_layout_load_children_list(Evas_Object_Box_Data *priv,
259                                       Elm_Box_Transition *layout_data)
260 {
261    Eina_List *l;
262    Evas_Object_Box_Option *opt;
263    Transition_Animation_Data *tad;
264
265    EINA_LIST_FREE(layout_data->objs, tad)
266       free(tad);
267
268    EINA_LIST_FOREACH(priv->children, l, opt)
269      {
270         tad = calloc(1, sizeof(Transition_Animation_Data));
271         if (!tad)
272           {
273              EINA_LIST_FREE(layout_data->objs, tad)
274                 free(tad);
275              layout_data->objs = NULL;
276              return EINA_FALSE;
277           }
278         tad->obj = opt->obj;
279         layout_data->objs = eina_list_append(layout_data->objs, tad);
280      }
281    return EINA_TRUE;
282 }
283
284 static Eina_Bool
285 _transition_layout_animation_start(Evas_Object *obj, Evas_Object_Box_Data *priv,
286                                    Elm_Box_Transition *layout_data, Eina_Bool(*transition_animation_cb)(void *data))
287 {
288    layout_data->start.layout(obj, priv, layout_data->start.data);
289    layout_data->box = obj;
290    layout_data->initial_time = ecore_loop_time_get();
291
292    if (!_transition_layout_load_children_list(priv, layout_data))
293      return EINA_FALSE;
294    _transition_layout_calculate_coords(obj, priv, layout_data);
295
296    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
297                                   _transition_layout_obj_resize_cb, layout_data);
298    evas_object_smart_callback_add(obj, SIG_CHILD_ADDED,
299                                   _transition_layout_child_added, layout_data);
300    evas_object_smart_callback_add(obj, SIG_CHILD_REMOVED,
301                                   _transition_layout_child_removed, layout_data);
302    if (!layout_data->animator)
303      layout_data->animator = ecore_animator_add(transition_animation_cb, obj);
304    layout_data->animation_ended = EINA_FALSE;
305    return EINA_TRUE;
306 }
307
308 static void
309 _transition_layout_animation_stop(Elm_Box_Transition *layout_data)
310 {
311    layout_data->animation_ended = EINA_TRUE;
312    if (layout_data->animator)
313      {
314         ecore_animator_del(layout_data->animator);
315         layout_data->animator = NULL;
316      }
317
318    if (layout_data->transition_end_cb)
319      layout_data->transition_end_cb(layout_data->transition_end_data);
320 }
321
322 static void
323 _transition_layout_animation_exec(Evas_Object *obj, Evas_Object_Box_Data *priv __UNUSED__,
324                                   Elm_Box_Transition *layout_data, const double curtime)
325 {
326    Eina_List *l;
327    Transition_Animation_Data *tad;
328    Evas_Coord x, y, w, h;
329    Evas_Coord cur_x, cur_y, cur_w, cur_h;
330    double progress = 0.0;
331
332    progress = (curtime - layout_data->initial_time) / layout_data->duration;
333    evas_object_geometry_get(obj, &x, &y, &w, &h);
334
335    EINA_LIST_FOREACH(layout_data->objs, l, tad)
336      {
337         cur_x = x + tad->start.x + ((tad->end.x - tad->start.x) * progress);
338         cur_y = y + tad->start.y + ((tad->end.y - tad->start.y) * progress);
339         cur_w = tad->start.w + ((tad->end.w - tad->start.w) * progress);
340         cur_h = tad->start.h + ((tad->end.h - tad->start.h) * progress);
341         evas_object_move(tad->obj, cur_x, cur_y);
342         evas_object_resize(tad->obj, cur_w, cur_h);
343      }
344 }
345
346 EAPI Evas_Object *
347 elm_box_add(Evas_Object *parent)
348 {
349    Evas_Object *obj;
350    Evas *e;
351    Widget_Data *wd;
352
353    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
354
355    ELM_SET_WIDTYPE(widtype, "box");
356    elm_widget_type_set(obj, "box");
357    elm_widget_sub_object_add(parent, obj);
358    elm_widget_data_set(obj, wd);
359    elm_widget_del_hook_set(obj, _del_hook);
360    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
361    elm_widget_focus_next_hook_set(obj, _elm_box_focus_next_hook);
362    elm_widget_can_focus_set(obj, EINA_FALSE);
363    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
364    elm_widget_theme_hook_set(obj, _theme_hook);
365
366    wd->box = evas_object_box_add(e);
367    /*evas_object_box_layout_set(wd->box, evas_object_box_layout_vertical,
368      NULL, NULL);*/
369    evas_object_box_layout_set(wd->box, _layout, obj, NULL);
370
371    evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
372                                   _changed_size_hints, obj);
373    elm_widget_resize_object_set(obj, wd->box);
374    elm_widget_sub_object_add(obj, wd->box);
375
376    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
377
378    evas_object_smart_callbacks_descriptions_set(obj, _signals);
379    evas_object_smart_callback_add
380      (wd->box, SIG_CHILD_ADDED, _cb_proxy_child_added, obj);
381    evas_object_smart_callback_add
382      (wd->box, SIG_CHILD_REMOVED, _cb_proxy_child_removed, obj);
383
384    return obj;
385 }
386
387 EAPI void
388 elm_box_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
389 {
390    ELM_CHECK_WIDTYPE(obj, widtype);
391    Widget_Data *wd = elm_widget_data_get(obj);
392    if (!wd) return;
393    wd->horizontal = !!horizontal;
394    evas_object_smart_calculate(wd->box);
395  /*if (wd->horizontal)
396      {
397         if (wd->homogeneous)
398           evas_object_box_layout_set(wd->box,
399                                      evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
400         else
401           evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
402                                      NULL, NULL);
403      }
404    else
405      {
406         if (wd->homogeneous)
407           evas_object_box_layout_set(wd->box,
408                                      evas_object_box_layout_homogeneous_vertical, NULL, NULL);
409         else
410           evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
411                                      NULL, NULL);
412      } */
413 }
414
415 EAPI Eina_Bool
416 elm_box_horizontal_get(const Evas_Object *obj)
417 {
418    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
419    Widget_Data *wd = elm_widget_data_get(obj);
420    if (!wd) return EINA_FALSE;
421    return wd->horizontal;
422 }
423
424 EAPI void
425 elm_box_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
426 {
427    ELM_CHECK_WIDTYPE(obj, widtype);
428    Widget_Data *wd = elm_widget_data_get(obj);
429    if (!wd) return;
430    wd->homogeneous = !!homogeneous;
431    evas_object_smart_calculate(wd->box);
432  /*if (wd->horizontal)
433      {
434         if (wd->homogeneous)
435           evas_object_box_layout_set(wd->box,
436                                      evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
437         else
438           evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
439                                      NULL, NULL);
440      }
441    else
442      {
443         if (wd->homogeneous)
444           evas_object_box_layout_set(wd->box,
445                                      evas_object_box_layout_homogeneous_vertical, NULL, NULL);
446         else
447           evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
448                                      NULL, NULL);
449      } */
450 }
451
452 EINA_DEPRECATED EAPI void
453 elm_box_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
454 {
455    elm_box_homogeneous_set(obj, homogenous);
456 }
457
458 EAPI Eina_Bool
459 elm_box_homogeneous_get(const Evas_Object *obj)
460 {
461    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
462    Widget_Data *wd = elm_widget_data_get(obj);
463    if (!wd) return EINA_FALSE;
464    return wd->homogeneous;
465 }
466
467 EINA_DEPRECATED EAPI Eina_Bool
468 elm_box_homogenous_get(const Evas_Object *obj)
469 {
470    return elm_box_homogeneous_get(obj);
471 }
472
473 EAPI void
474 elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj)
475 {
476    ELM_CHECK_WIDTYPE(obj, widtype);
477    Widget_Data *wd = elm_widget_data_get(obj);
478    if (!wd) return;
479    elm_widget_sub_object_add(obj, subobj);
480    evas_object_box_prepend(wd->box, subobj);
481 }
482
483 EAPI void
484 elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj)
485 {
486    ELM_CHECK_WIDTYPE(obj, widtype);
487    Widget_Data *wd = elm_widget_data_get(obj);
488    if (!wd) return;
489    elm_widget_sub_object_add(obj, subobj);
490    evas_object_box_append(wd->box, subobj);
491 }
492
493 EAPI void
494 elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before)
495 {
496    ELM_CHECK_WIDTYPE(obj, widtype);
497    Widget_Data *wd = elm_widget_data_get(obj);
498    if (!wd) return;
499    elm_widget_sub_object_add(obj, subobj);
500    evas_object_box_insert_before(wd->box, subobj, before);
501 }
502
503 EAPI void
504 elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after)
505 {
506    ELM_CHECK_WIDTYPE(obj, widtype);
507    Widget_Data *wd = elm_widget_data_get(obj);
508    if (!wd) return;
509    elm_widget_sub_object_add(obj, subobj);
510    evas_object_box_insert_after(wd->box, subobj, after);
511 }
512
513 EAPI void
514 elm_box_clear(Evas_Object *obj)
515 {
516    ELM_CHECK_WIDTYPE(obj, widtype);
517    Widget_Data *wd = elm_widget_data_get(obj);
518    if (!wd) return;
519    evas_object_box_remove_all(wd->box, EINA_TRUE);
520 }
521
522 EAPI void
523 elm_box_unpack(Evas_Object *obj, Evas_Object *subobj)
524 {
525    ELM_CHECK_WIDTYPE(obj, widtype);
526    Widget_Data *wd = elm_widget_data_get(obj);
527    if (!wd) return;
528    evas_object_box_remove(wd->box, subobj);
529 }
530
531 EAPI void
532 elm_box_unpack_all(Evas_Object *obj)
533 {
534    ELM_CHECK_WIDTYPE(obj, widtype);
535    Widget_Data *wd = elm_widget_data_get(obj);
536    if (!wd) return;
537    evas_object_box_remove_all(wd->box, EINA_FALSE);
538 }
539
540 EAPI void
541 elm_box_layout_set(Evas_Object *obj, Evas_Object_Box_Layout cb, const void *data, void (*free_data)(void *data))
542 {
543    ELM_CHECK_WIDTYPE(obj, widtype);
544    Widget_Data *wd = elm_widget_data_get(obj);
545    if (!wd) return;
546
547    if (cb)
548      evas_object_box_layout_set(wd->box, cb, data, free_data);
549    else
550      evas_object_box_layout_set(wd->box, _layout, obj, NULL);
551 }
552
553 EAPI void
554 elm_box_layout_transition(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data)
555 {
556    Elm_Box_Transition *box_data = data;
557    const double curtime = ecore_loop_time_get();
558
559    if (box_data->animation_ended)
560      {
561         box_data->end.layout(obj, priv, box_data->end.data);
562         return;
563      }
564
565    if (!box_data->animator)
566      {
567         if (!_transition_layout_animation_start(obj, priv, box_data,
568                                                 _transition_animation))
569           return;
570      }
571    else
572      {
573         if (box_data->recalculate)
574           {
575              _transition_layout_calculate_coords(obj, priv, box_data);
576              box_data->recalculate = EINA_FALSE;
577           }
578      }
579
580    if ((curtime >= box_data->duration + box_data->initial_time))
581      _transition_layout_animation_stop(box_data);
582    else
583      _transition_layout_animation_exec(obj, priv, box_data, curtime);
584 }
585
586 EAPI Elm_Box_Transition *
587 elm_box_transition_new(const double duration,
588                        Evas_Object_Box_Layout start_layout, void *start_layout_data,
589                        void(*start_layout_free_data)(void *data),
590                        Evas_Object_Box_Layout end_layout, void *end_layout_data,
591                        void(*end_layout_free_data)(void *data),
592                        void(*transition_end_cb)(void *data),
593                        void *transition_end_data)
594 {
595    Elm_Box_Transition *box_data;
596
597    EINA_SAFETY_ON_NULL_RETURN_VAL(start_layout, NULL);
598    EINA_SAFETY_ON_NULL_RETURN_VAL(end_layout, NULL);
599
600    box_data = calloc(1, sizeof(Elm_Box_Transition));
601    if (!box_data)
602      return NULL;
603
604    box_data->start.layout = start_layout;
605    box_data->start.data = start_layout_data;
606    box_data->start.free_data = start_layout_free_data;
607    box_data->end.layout = end_layout;
608    box_data->end.data = end_layout_data;
609    box_data->end.free_data = end_layout_free_data;
610    box_data->duration = duration;
611    box_data->transition_end_cb = transition_end_cb;
612    box_data->transition_end_data = transition_end_data;
613    return box_data;
614 }
615
616 EAPI void
617 elm_box_transition_free(void *data)
618 {
619    EINA_SAFETY_ON_NULL_RETURN(data);
620
621    Transition_Animation_Data *tad;
622    Elm_Box_Transition *box_data = data;
623    if ((box_data->start.free_data) && (box_data->start.data))
624      box_data->start.free_data(box_data->start.data);
625    if ((box_data->end.free_data) && (box_data->end.data))
626      box_data->end.free_data(box_data->end.data);
627    EINA_LIST_FREE(box_data->objs, tad)
628       free(tad);
629    evas_object_event_callback_del(box_data->box, EVAS_CALLBACK_RESIZE, _transition_layout_obj_resize_cb);
630    evas_object_smart_callback_del(box_data->box, SIG_CHILD_ADDED, _transition_layout_child_added);
631    evas_object_smart_callback_del(box_data->box, SIG_CHILD_REMOVED, _transition_layout_child_removed);
632    if (box_data->animator)
633      {
634         ecore_animator_del(box_data->animator);
635         box_data->animator = NULL;
636      }
637    free(data);
638 }
639
640 EAPI const Eina_List *
641 elm_box_children_get(const Evas_Object *obj)
642 {
643    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
644    Widget_Data *wd = elm_widget_data_get(obj);
645    if (!wd) return NULL;
646    return evas_object_box_children_get(wd->box);
647 }
648
649 EAPI void
650 elm_box_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical)
651 {
652    ELM_CHECK_WIDTYPE(obj, widtype);
653    Widget_Data *wd = elm_widget_data_get(obj);
654    if (!wd) return;
655    evas_object_box_padding_set(wd->box, horizontal, vertical);
656 }
657
658 EAPI void
659 elm_box_padding_get(const Evas_Object *obj, Evas_Coord *horizontal, Evas_Coord *vertical)
660 {
661    ELM_CHECK_WIDTYPE(obj, widtype);
662    Widget_Data *wd = elm_widget_data_get(obj);
663    if (!wd) return;
664    evas_object_box_padding_get(wd->box, horizontal, vertical);
665 }
666
667 EAPI void
668 elm_box_align_set(Evas_Object *obj, double horizontal, double vertical)
669 {
670    ELM_CHECK_WIDTYPE(obj, widtype);
671    Widget_Data *wd = elm_widget_data_get(obj);
672    if (!wd) return;
673    evas_object_size_hint_align_set(wd->box, horizontal, vertical);
674 }
675
676 EAPI void
677 elm_box_align_get(const Evas_Object *obj, double *horizontal, double *vertical)
678 {
679    ELM_CHECK_WIDTYPE(obj, widtype);
680    Widget_Data *wd = elm_widget_data_get(obj);
681    if (!wd) return;
682    evas_object_size_hint_align_get(wd->box, horizontal, vertical);
683 }
684
685 EAPI void
686 elm_box_recalculate(Evas_Object *obj)
687 {
688    ELM_CHECK_WIDTYPE(obj, widtype);
689    Widget_Data *wd = elm_widget_data_get(obj);
690    if (!wd) return;
691    evas_object_smart_need_recalculate_set(wd->box, EINA_TRUE);
692    evas_object_smart_calculate(wd->box);
693 }