tests: Show use of eo_override for custom layout

This requires the previous fix in eo to actually work.
This commit is contained in:
Jean-Philippe Andre 2016-07-18 18:00:26 +09:00
parent cae939e208
commit 03ec8204bf
2 changed files with 16 additions and 11 deletions

View File

@ -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

View File

@ -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;
}