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)
downloadefl-9b87eaee0884f55899a05d271b098b8b3e11c221.tar.gz
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)
efl_gfx_hint_align_set(btn, val, y);
else if (opt == 'y')
efl_gfx_hint_align_set(btn, x, val);
-
- efl_pack_layout_request(layout);
}
static 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)
return calc2->comp_factor <= calc1->comp_factor ? -1 : 1;
}
+static void
+_on_child_size_changed(void *data, const Efl_Event *event EINA_UNUSED)
+{
+ Efl_Ui_Relative_Layout_Data *pd = data;
+
+ efl_pack_layout_request(pd->obj);
+}
+
+static void
+_on_child_hints_changed(void *data, const Efl_Event *event EINA_UNUSED)
+{
+ Efl_Ui_Relative_Layout_Data *pd = data;
+
+ efl_pack_layout_request(pd->obj);
+}
+
+static void
+_on_child_del(void *data, const Efl_Event *event)
+{
+ Efl_Ui_Relative_Layout_Data *pd = data;
+
+ if (eina_hash_del_by_key(pd->children, &event->object))
+ efl_pack_layout_request(pd->obj);
+ else
+ ERR("child(%p(%s)) is not registered", event->object,
+ efl_class_name_get(event->object));
+}
+
+EFL_CALLBACKS_ARRAY_DEFINE(efl_ui_relative_layout_callbacks,
+ { EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _on_child_size_changed },
+ { EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, _on_child_hints_changed },
+ { EFL_EVENT_DEL, _on_child_del }
+);
+
static Efl_Ui_Relative_Layout_Child *
_efl_ui_relative_layout_register(Efl_Ui_Relative_Layout_Data *pd, Eo *child)
{
@@ -48,6 +82,7 @@ _efl_ui_relative_layout_register(Efl_Ui_Relative_Layout_Data *pd, Eo *child)
efl_key_data_set(child, "_elm_leaveme", pd->obj);
efl_canvas_object_clipper_set(child, pd->clipper);
+ efl_event_callback_array_add(child, efl_ui_relative_layout_callbacks(), pd);
efl_canvas_group_member_add(pd->obj, child);
efl_canvas_group_change(pd->obj);
@@ -539,7 +574,7 @@ _efl_ui_relative_layout_unregister(Eo *obj, Efl_Ui_Relative_Layout_Data *pd, Efl
efl_canvas_group_member_remove(obj, child);
efl_canvas_object_clipper_set(child, NULL);
efl_key_data_set(child, "_elm_leaveme", NULL);
-
+ efl_event_callback_array_del(child, efl_ui_relative_layout_callbacks(), pd);
efl_pack_layout_request(obj);
}
else