efl: add facility to generate an event when an item is created by the factory.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D7446
This commit is contained in:
parent
3ef87a251b
commit
b992cc479e
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.]]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue