Changeset View
Changeset View
Standalone View
Standalone View
src/lib/elementary/efl_ui_box_stack.c
1 | #define EFL_GFX_HINT_PROTECTED | 1 | #define EFL_GFX_HINT_PROTECTED | ||
---|---|---|---|---|---|
2 | 2 | | |||
3 | #include "efl_ui_box_private.h" | 3 | #include "efl_ui_box_private.h" | ||
4 | #include "efl_ui_container_layout.h" | ||||
4 | 5 | | |||
5 | #define MY_CLASS EFL_UI_BOX_STACK_CLASS | 6 | #define MY_CLASS EFL_UI_BOX_STACK_CLASS | ||
6 | 7 | | |||
8 | typedef struct _Item_Calc Item_Calc; | ||||
9 | | ||||
10 | struct _Item_Calc | ||||
11 | { | ||||
12 | Evas_Object *obj; | ||||
13 | Efl_Ui_Container_Item_Hints hints[2]; /* 0 is x-axis, 1 is y-axis */ | ||||
14 | }; | ||||
15 | | ||||
7 | EOLIAN static void | 16 | EOLIAN static void | ||
8 | _efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED) | 17 | _efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED) | ||
9 | { | 18 | { | ||
10 | Evas_Object_Box_Option *opt; | 19 | Evas_Object_Box_Option *opt; | ||
11 | Evas_Object_Box_Data *bd; | 20 | Evas_Object_Box_Data *bd; | ||
12 | Eina_Size2D min = { 0, 0 }, cmin; | 21 | Efl_Ui_Container_Layout_Calc box_calc[2]; | ||
22 | Efl_Ui_Container_Item_Hints *hints; | ||||
23 | Item_Calc *items, *item; | ||||
13 | Eina_List *l; | 24 | Eina_List *l; | ||
25 | Eina_Size2D want = { 0, 0 }; | ||||
26 | Evas_Object *old_child = NULL; | ||||
27 | int i = 0, count; | ||||
14 | 28 | | |||
15 | EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS)); | 29 | EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS)); | ||
16 | ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); | 30 | ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); | ||
17 | bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS); | 31 | bd = efl_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS); | ||
18 | 32 | | |||
19 | evas_object_box_layout_stack(wd->resize_obj, bd, NULL); | 33 | count = eina_list_count(bd->children); | ||
34 | if (!count) | ||||
35 | { | ||||
36 | efl_gfx_hint_size_min_set(obj, EINA_SIZE2D(0, 0)); | ||||
37 | return; | ||||
38 | } | ||||
39 | | ||||
40 | _efl_ui_container_layout_init(obj, box_calc); | ||||
41 | | ||||
42 | items = alloca(count * sizeof(*items)); | ||||
43 | #ifdef DEBUG | ||||
44 | memset(items, 0, count * sizeof(*items)); | ||||
Jaehyun_Cho: It seems that there is a reason why this memory initialization is required only for debugging… | |||||
Not Done ReplyI have no idea.. it is copied from efl_ui_box_layout.c:57 written by jpeg. YOhoho: I have no idea.. it is copied from efl_ui_box_layout.c:57 written by jpeg. | |||||
Not Done ReplyThank you. It seems that it purely helps the debugging ;) e.g. alloca() does not initialize memory so it seems that the initial dirty memory may make debugging difficult. Jaehyun_Cho: Thank you. It seems that it purely helps the debugging ;)
e.g. alloca() does not initialize… | |||||
45 | #endif | ||||
20 | 46 | | |||
21 | /* Note: legacy evas_object_box_layout_stack sets the box min size to be | | |||
22 | * the MAX() of the children's sizes, rather than their min sizes. By fixing | | |||
23 | * that, we can implement elm_win_resize_object_add() with a Efl.Ui.Box. */ | | |||
24 | EINA_LIST_FOREACH(bd->children, l, opt) | 47 | EINA_LIST_FOREACH(bd->children, l, opt) | ||
25 | { | 48 | { | ||
26 | Evas_Object *child = opt->obj; | 49 | item = &items[i++]; | ||
50 | item->obj = opt->obj; | ||||
51 | hints = item->hints; | ||||
52 | | ||||
53 | _efl_ui_container_layout_item_init(opt->obj, hints); | ||||
27 | 54 | | |||
28 | cmin = efl_gfx_hint_size_combined_min_get(child); | 55 | if (want.w < hints[0].space) | ||
29 | if (cmin.w > min.w) min.w = cmin.w; | 56 | want.w = hints[0].space; | ||
30 | if (cmin.h > min.h) min.h = cmin.h; | 57 | if (want.h < hints[1].space) | ||
58 | want.h = hints[1].space; | ||||
31 | } | 59 | } | ||
32 | efl_gfx_hint_size_restricted_min_set(obj, min); | 60 | | ||
61 | if (box_calc[0].size < want.w) | ||||
62 | box_calc[0].size = want.w; | ||||
63 | if (box_calc[1].size < want.h) | ||||
64 | box_calc[1].size = want.h; | ||||
65 | | ||||
66 | for (i = 0; i < count; i++) | ||||
67 | { | ||||
68 | hints = items[i].hints; | ||||
69 | Eina_Rect item_geom; | ||||
70 | | ||||
71 | hints[0].space = box_calc[0].size - | ||||
72 | (hints[0].margin[0] + hints[0].margin[1]); | ||||
73 | hints[1].space = box_calc[1].size - | ||||
74 | (hints[1].margin[0] + hints[1].margin[1]); | ||||
75 | | ||||
76 | item_geom.w = ((hints[0].weight > 0) && hints[0].fill) ? hints[0].space : 0; | ||||
77 | item_geom.h = ((hints[1].weight > 0) && hints[1].fill) ? hints[1].space : 0; | ||||
78 | | ||||
79 | _efl_ui_container_layout_min_max_calc(hints, &item_geom.w, &item_geom.h, | ||||
80 | (hints[0].aspect > 0) && (hints[1].aspect > 0)); | ||||
81 | | ||||
82 | item_geom.x = box_calc[0].pos + hints[0].margin[0] + | ||||
83 | (hints[0].space - item_geom.w) * hints[0].align; | ||||
84 | item_geom.y = box_calc[1].pos + hints[1].margin[0] + | ||||
85 | (hints[1].space - item_geom.h) * hints[1].align; | ||||
86 | | ||||
87 | efl_gfx_entity_geometry_set(items[i].obj, item_geom); | ||||
88 | | ||||
89 | if (old_child) | ||||
90 | efl_gfx_stack_above(items[i].obj, old_child); | ||||
91 | old_child = items[i].obj; | ||||
92 | } | ||||
93 | | ||||
94 | want.w += (box_calc[0].margin[0] + box_calc[0].margin[1]); | ||||
95 | want.h += (box_calc[1].margin[0] + box_calc[1].margin[1]); | ||||
96 | | ||||
97 | efl_gfx_hint_size_restricted_min_set(obj, want); | ||||
98 | | ||||
99 | efl_event_callback_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL); | ||||
33 | } | 100 | } | ||
34 | 101 | | |||
35 | #include "efl_ui_box_stack.eo.c" | 102 | #include "efl_ui_box_stack.eo.c" |
It seems that there is a reason why this memory initialization is required only for debugging mode. But I don't know why..
Could you tell me the reason?