jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=03ec8204bf62e8a0f3491ac2dd8fb46f431833da
commit 03ec8204bf62e8a0f3491ac2dd8fb46f431833da Author: Jean-Philippe Andre <jp.an...@samsung.com> Date: Mon Jul 18 18:00:26 2016 +0900 tests: Show use of eo_override for custom layout This requires the previous fix in eo to actually work. --- src/bin/elementary/test_ui_box.c | 25 ++++++++++++++----------- src/bin/elementary/test_ui_grid.c | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c index 435376f..e5e1a35 100644 --- a/src/bin/elementary/test_ui_box.c +++ b/src/bin/elementary/test_ui_box.c @@ -147,8 +147,7 @@ left_check_cb(void *data, const Eo_Event *event) } static void -_custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, - Efl_Pack *pack, const void *data EINA_UNUSED) +_custom_layout_update(Eo *pack, const void *data EINA_UNUSED) { Eina_Iterator *it = efl_content_iterate(pack); int count = efl_content_count(pack), i = 0; @@ -177,21 +176,25 @@ _custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, /* Common Eo Class boilerplate. */ static const Eo_Op_Description custom_engine_op_desc[] = { - EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, _custom_engine_layout_do), + EO_OP_FUNC_OVERRIDE(efl_pack_layout_update, _custom_layout_update), }; -static const Eo_Class_Description custom_engine_class_desc = { - EO_VERSION, "Custom Layout Engine", EO_CLASS_TYPE_INTERFACE, - EO_CLASS_DESCRIPTION_OPS(custom_engine_op_desc), NULL, 0, NULL, NULL -}; - -EO_DEFINE_CLASS(_test_ui_box_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_LAYOUT_INTERFACE, NULL) - static void custom_check_cb(void *data, const Eo_Event *event) { Eina_Bool chk = elm_check_selected_get(event->object); - efl_pack_layout_engine_set(data, chk ? _test_ui_box_custom_engine_class_get() : NULL, NULL); + Eo *obj = data; + + // Overriding just the one function we need + eo_override(obj, chk ? EO_OVERRIDE_OPS(custom_engine_op_desc) + : ((Eo_Ops) { NULL, 0 })); + + // Layout request is required as the pack object doesn't know the layout + // function was just overridden. + efl_pack_layout_request(obj); + + // See also test_ui_grid.c for another method for custom layouts (create + // a custom layout engine). } void diff --git a/src/bin/elementary/test_ui_grid.c b/src/bin/elementary/test_ui_grid.c index 55a2d79..136d902 100644 --- a/src/bin/elementary/test_ui_grid.c +++ b/src/bin/elementary/test_ui_grid.c @@ -72,6 +72,8 @@ weights_cb(void *data, const Eo_Event *event) efl_gfx_size_hint_weight_set(objects[6], 1, 1); break; case CUSTOM: + // See also test_ui_box.c for another solution for custom layouts + // using eo_override. efl_pack_layout_engine_set(grid, CUSTOM_ENGINE_CLASS, NULL); break; } --