cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=b992cc479e35a398e15f73439eb802127cb45cc7
commit b992cc479e35a398e15f73439eb802127cb45cc7 Author: Cedric BAIL <[email protected]> Date: Fri Dec 7 15:51:09 2018 -0800 efl: add facility to generate an event when an item is created by the factory. Reviewed-by: SangHyeon Jade Lee <[email protected]> Differential Revision: https://phab.enlightenment.org/D7446 --- src/lib/efl/Efl.h | 16 ++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 21 +++++++++++++++++++++ src/lib/efl/interfaces/efl_ui_factory.eo | 9 +++++++++ 3 files changed, 46 insertions(+) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 8548ac95c8..fc56d4a0b8 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -197,6 +197,22 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; */ EAPI Efl_Object *efl_part(const Eo *obj, const char *name); +/** + * @brief This triggers the create method of a factory and trigger the item created event. + * + * @param[in] factory The factory that will provide the item + * @param[in] model The model to use to fetch information from + * @param[in] parent The parent of the newly created item + * @return A future that will resolve with the newly created item. + * + * @since 1.22 + * @note This exists as we always want to trigger the event once all the logic + * of every factory in the chain has done what it planned to do. Basically we + * want the inverse of inheritance call like efl_super. So we do setup the future + * in this way. + */ +EAPI Eina_Future *efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent); + #else #ifndef EFL_NOLEGACY_API_SUPPORT diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index a21d7505aa..65c3234fd3 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -113,3 +113,24 @@ __efl_internal_init(void) { efl_model_init(); } + +static Eina_Value +_efl_ui_view_factory_item_created(Eo *factory, void *data EINA_UNUSED, const Eina_Value v) +{ + Efl_Ui_Factory_Item_Created_Event event = { NULL, NULL }; + + eina_value_pget(&v, &event.item); + event.model = efl_ui_view_model_get(event.item); + + efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_CREATED, &event); + + return v; +} + +EAPI Eina_Future * +efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent) +{ + return efl_future_then(efl_ui_factory_create(factory, model, parent), factory, + .success_type = EINA_VALUE_TYPE_OBJECT, + .success = _efl_ui_view_factory_item_created); +} diff --git a/src/lib/efl/interfaces/efl_ui_factory.eo b/src/lib/efl/interfaces/efl_ui_factory.eo index adbd93bbd1..b7848744de 100644 --- a/src/lib/efl/interfaces/efl_ui_factory.eo +++ b/src/lib/efl/interfaces/efl_ui_factory.eo @@ -1,3 +1,9 @@ +struct Efl.Ui.Factory_Item_Created_Event { + [[EFL Ui Factory event structure provided when an item was just created.]] + model: Efl.Model; [[The model already set on the new item.]] + item: Efl.Gfx.Entity; [[The item that was just created.]] +} + interface Efl.Ui.Factory (Efl.Ui.Model.Connect) { [[Efl UI factory interface]] @@ -24,4 +30,7 @@ interface Efl.Ui.Factory (Efl.Ui.Model.Connect) } } } + events { + created: Efl.Ui.Factory_Item_Created_Event; [[Event triggered when an item has been successfully created.]] + } } --
