summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-04-24 20:32:45 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2019-04-24 20:32:45 +0900
commit9b87eaee0884f55899a05d271b098b8b3e11c221 (patch)
treed7f4415b3c742ee35bf675b4356684b623faaca6
parent336500469ae2b2d2d4655cf5361d13612b8874b3 (diff)
ui.relative_layout: add callbacks to update layout
Summary: If the size or hints of a child changes, relative_layout need to update layout. And, if a child is deleted, it should be unregisterd from relative_layout. Depends on D8625 Test Plan: elementary_test -to 'efl.ui.relative_layout' Reviewers: Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8626
-rw-r--r--src/bin/elementary/test_ui_relative_layout.c2
-rw-r--r--src/lib/elementary/efl_ui_relative_layout.c37
2 files changed, 36 insertions, 3 deletions
diff --git a/src/bin/elementary/test_ui_relative_layout.c b/src/bin/elementary/test_ui_relative_layout.c
index dbb1647eee..f1d58af0cd 100644
--- a/src/bin/elementary/test_ui_relative_layout.c
+++ b/src/bin/elementary/test_ui_relative_layout.c
@@ -120,8 +120,6 @@ _slider_changed_align_cb(void *data, const Efl_Event *event)
120 efl_gfx_hint_align_set(btn, val, y); 120 efl_gfx_hint_align_set(btn, val, y);
121 else if (opt == 'y') 121 else if (opt == 'y')
122 efl_gfx_hint_align_set(btn, x, val); 122 efl_gfx_hint_align_set(btn, x, val);
123
124 efl_pack_layout_request(layout);
125} 123}
126 124
127static void 125static void
diff --git a/src/lib/elementary/efl_ui_relative_layout.c b/src/lib/elementary/efl_ui_relative_layout.c
index 17bf97d8b5..827b3d601c 100644
--- a/src/lib/elementary/efl_ui_relative_layout.c
+++ b/src/lib/elementary/efl_ui_relative_layout.c
@@ -24,6 +24,40 @@ _chain_sort_cb(const void *l1, const void *l2)
24 return calc2->comp_factor <= calc1->comp_factor ? -1 : 1; 24 return calc2->comp_factor <= calc1->comp_factor ? -1 : 1;
25} 25}
26 26
27static void
28_on_child_size_changed(void *data, const Efl_Event *event EINA_UNUSED)
29{
30 Efl_Ui_Relative_Layout_Data *pd = data;
31
32 efl_pack_layout_request(pd->obj);
33}
34
35static void
36_on_child_hints_changed(void *data, const Efl_Event *event EINA_UNUSED)
37{
38 Efl_Ui_Relative_Layout_Data *pd = data;
39
40 efl_pack_layout_request(pd->obj);
41}
42
43static void
44_on_child_del(void *data, const Efl_Event *event)
45{
46 Efl_Ui_Relative_Layout_Data *pd = data;
47
48 if (eina_hash_del_by_key(pd->children, &event->object))
49 efl_pack_layout_request(pd->obj);
50 else
51 ERR("child(%p(%s)) is not registered", event->object,
52 efl_class_name_get(event->object));
53}
54
55EFL_CALLBACKS_ARRAY_DEFINE(efl_ui_relative_layout_callbacks,
56 { EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _on_child_size_changed },
57 { EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, _on_child_hints_changed },
58 { EFL_EVENT_DEL, _on_child_del }
59);
60
27static Efl_Ui_Relative_Layout_Child * 61static Efl_Ui_Relative_Layout_Child *
28_efl_ui_relative_layout_register(Efl_Ui_Relative_Layout_Data *pd, Eo *child) 62_efl_ui_relative_layout_register(Efl_Ui_Relative_Layout_Data *pd, Eo *child)
29{ 63{
@@ -48,6 +82,7 @@ _efl_ui_relative_layout_register(Efl_Ui_Relative_Layout_Data *pd, Eo *child)
48 82
49 efl_key_data_set(child, "_elm_leaveme", pd->obj); 83 efl_key_data_set(child, "_elm_leaveme", pd->obj);
50 efl_canvas_object_clipper_set(child, pd->clipper); 84 efl_canvas_object_clipper_set(child, pd->clipper);
85 efl_event_callback_array_add(child, efl_ui_relative_layout_callbacks(), pd);
51 efl_canvas_group_member_add(pd->obj, child); 86 efl_canvas_group_member_add(pd->obj, child);
52 efl_canvas_group_change(pd->obj); 87 efl_canvas_group_change(pd->obj);
53 88
@@ -539,7 +574,7 @@ _efl_ui_relative_layout_unregister(Eo *obj, Efl_Ui_Relative_Layout_Data *pd, Efl
539 efl_canvas_group_member_remove(obj, child); 574 efl_canvas_group_member_remove(obj, child);
540 efl_canvas_object_clipper_set(child, NULL); 575 efl_canvas_object_clipper_set(child, NULL);
541 efl_key_data_set(child, "_elm_leaveme", NULL); 576 efl_key_data_set(child, "_elm_leaveme", NULL);
542 577 efl_event_callback_array_del(child, efl_ui_relative_layout_callbacks(), pd);
543 efl_pack_layout_request(obj); 578 efl_pack_layout_request(obj);
544 } 579 }
545 else 580 else