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 };
+ Efl_Gfx_Entity *item;
int len, i;
- EINA_VALUE_ARRAY_FOREACH(&v, len, i, event.item)
- {
- event.model = efl_ui_view_model_get(event.item);
-
- efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_CREATED, &event);
- }
+ EINA_VALUE_ARRAY_FOREACH(&v, len, i, item)
+ efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_ITEM_CREATED, item);
return v;
}
This object represents a Factory in the factory pattern. Objects should be created via the method
@Efl.Ui.View_Factory.create_with_event, which will in turn call the necessary APIs from this interface.
Objects created this way should be removed using @.release.
+
+ It is recommended to not create your own @Efl.Ui.Factory and use event handler as much as possible.
]]
methods {
create @protected {
ui_view: Efl.Gfx.Entity; [[Object to remove.]]
}
}
- building @const {
- [[This function is called during the creation of an UI object between the @Efl.Object.constructor and
- @Efl.Object.finalize call.
-
- Note: If the @Efl.Ui.Factory does keep a cache of objects, this won't be called when objects are pulled out
- of the cache.]]
- params {
- ui_view: Efl.Gfx.Entity; [[The UI object being created.]]
- }
- }
}
events {
- created: Efl.Ui.Factory_Item_Created_Event; [[Event triggered when an item has been successfully created.]]
+ item,constructing: Efl.Gfx.Entity; [[Event triggered when an item is under construction (between the @Efl.Object.constructor and @Efl.Object.finalize call on the item).
+ Note: If the @Efl.Ui.Factory does keep a cache of objects, this won't be called when objects are pulled out of the cache.]]
+ item,building: Efl.Gfx.Entity; [[Event triggered when an item has processed @Efl.Object.finalize, but before all the factory are done building it.
+ Note: if the @Efl.Ui.Factory does keep a cache of object, this will be called when object are pulled out of the cache.]]
+ item,created: Efl.Gfx.Entity; [[Event triggered when an item has been successfully created by the factory and is about to be used by an @Efl.Ui.View.]]
}
}
EINA_ITERATOR_FOREACH(models, model)
{
w = efl_add(pd->klass, parent,
- efl_ui_factory_building(obj, efl_added),
- efl_ui_view_model_set(efl_added, model));
+ efl_ui_view_model_set(efl_added, model),
+ efl_event_callback_call(obj, EFL_UI_FACTORY_EVENT_ITEM_CONSTRUCTING, efl_added));
+ efl_event_callback_call(obj, EFL_UI_FACTORY_EVENT_ITEM_BUILDING, w);
eina_value_array_append(&gr->done, w);
}
Eina_Stringshare *property;
} Efl_Ui_Image_Factory_Data;
+static void
+_efl_ui_image_factory_building(void *data, const Efl_Event *ev)
+{
+ Efl_Ui_Image_Factory_Data *pd = data;
+ Efl_Gfx_Entity *ui_view = ev->info;
+
+ efl_ui_property_bind(ui_view, "filename", pd->property);
+}
+
EOLIAN static Eo *
_efl_ui_image_factory_efl_object_constructor(Eo *obj, Efl_Ui_Image_Factory_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
efl_ui_widget_factory_item_class_set(obj, EFL_UI_IMAGE_CLASS);
+ efl_event_callback_add(obj, EFL_UI_FACTORY_EVENT_ITEM_BUILDING, _efl_ui_image_factory_building, pd);
+
pd->property = NULL;
return obj;
efl_destructor(efl_super(obj, MY_CLASS));
}
-EOLIAN static void
-_efl_ui_image_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Factory_Data *pd, Efl_Gfx_Entity *ui_view)
-{
- efl_ui_property_bind(ui_view, "filename", pd->property);
-
- efl_ui_factory_building(efl_super(obj, EFL_UI_IMAGE_FACTORY_CLASS), ui_view);
-}
-
EOLIAN static Eina_Future *
_efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *pd,
Eina_Iterator *models, Efl_Gfx_Entity *parent)
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Ui.Factory.create;
- Efl.Ui.Factory.building;
Efl.Ui.Property_Bind.property_bind;
}
}
return EINA_TRUE;
}
+static void
+_efl_ui_layout_factory_building(void *data, const Efl_Event *event)
+{
+ Efl_Ui_Layout_Factory_Data *pd = data;
+ Efl_Gfx_Entity *ui_view = event->info;
+
+ if (pd->klass || pd->group || pd->style)
+ efl_ui_layout_theme_set(ui_view, pd->klass, pd->group, pd->style);
+
+ eina_hash_foreach(pd->bind.properties, _property_bind, ui_view);
+ eina_hash_foreach(pd->bind.factories, _factory_bind, ui_view);
+
+ efl_gfx_hint_weight_set(ui_view, EFL_GFX_HINT_EXPAND, 0);
+ efl_gfx_hint_fill_set(ui_view, EINA_TRUE, EINA_TRUE);
+}
+
EOLIAN static Eo *
_efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd)
{
pd->bind.properties = eina_hash_stringshared_new(EINA_FREE_CB(eina_stringshare_del));
pd->bind.factories = eina_hash_stringshared_new(EINA_FREE_CB(efl_unref));
+ efl_event_callback_add(obj, EFL_UI_FACTORY_EVENT_ITEM_BUILDING, _efl_ui_layout_factory_building, pd);
+
return obj;
}
efl_destructor(efl_super(obj, MY_CLASS));
}
-static void
-_efl_ui_layout_factory_efl_ui_factory_building(const Eo *obj, Efl_Ui_Layout_Factory_Data *pd, Efl_Gfx_Entity *ui_view)
-{
- if (pd->klass || pd->group || pd->style)
- efl_ui_layout_theme_set(ui_view, pd->klass, pd->group, pd->style);
-
- eina_hash_foreach(pd->bind.properties, _property_bind, ui_view);
- eina_hash_foreach(pd->bind.factories, _factory_bind, ui_view);
-
- efl_gfx_hint_weight_set(ui_view, EFL_GFX_HINT_EXPAND, 0);
- efl_gfx_hint_fill_set(ui_view, EINA_TRUE, EINA_TRUE);
-
- efl_ui_factory_building(efl_super(obj, EFL_UI_LAYOUT_FACTORY_CLASS), ui_view);
-}
-
EOLIAN static void
_efl_ui_layout_factory_efl_ui_factory_bind_factory_bind(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd,
const char *key, Efl_Ui_Factory *factory)
implements {
Efl.Object.constructor;
Efl.Object.destructor;
- Efl.Ui.Factory.building;
Efl.Ui.Property_Bind.property_bind;
Efl.Ui.Factory_Bind.factory_bind;
}
}
static void
-_efl_ui_widget_factory_efl_ui_factory_building(const Eo *factory EINA_UNUSED, Efl_Ui_Widget_Factory_Data *pd, Efl_Gfx_Entity *ui_view)
+_efl_ui_widget_factory_constructing(void *data EINA_UNUSED, const Efl_Event *ev)
{
+ Efl_Gfx_Entity *ui_view = ev->info;
+
+ /* NOP */
+ (void)(ui_view);
+}
+
+
+static void
+_efl_ui_widget_factory_building(void *data, const Efl_Event *ev)
+{
+ Efl_Gfx_Entity *ui_view = ev->info;
+ Efl_Ui_Widget_Factory_Data *pd = data;
const Efl_Model *model;
Eina_Value *property, *width, *height;
Efl_Ui_Bind_Part_Data *bpd;
eina_value_free(property);
}
+EFL_CALLBACKS_ARRAY_DEFINE(item_callbacks,
+ { EFL_UI_FACTORY_EVENT_ITEM_CONSTRUCTING, _efl_ui_widget_factory_constructing },
+ { EFL_UI_FACTORY_EVENT_ITEM_BUILDING, _efl_ui_widget_factory_building })
+
+static Eo *
+_efl_ui_widget_factory_efl_object_constructor(Efl_Ui_Widget_Factory *obj,
+ Efl_Ui_Widget_Factory_Data *pd)
+{
+ obj = efl_constructor(efl_super(obj, EFL_UI_WIDGET_FACTORY_CLASS));
+
+ efl_event_callback_array_add(obj, item_callbacks(), pd);
+
+ return obj;
+}
+
static Efl_Ui_Widget *
_efl_ui_widget_create(const Efl_Ui_Factory *factory,
const Efl_Class *klass, Eo *parent,
w = efl_add(klass, parent,
efl_ui_view_model_set(efl_added, model),
- efl_ui_factory_building(factory, efl_added));
+ efl_event_callback_call((Efl_Ui_Factory *) factory, EFL_UI_FACTORY_EVENT_ITEM_CONSTRUCTING, efl_added));
+ efl_event_callback_call((Efl_Ui_Factory *) factory, EFL_UI_FACTORY_EVENT_ITEM_BUILDING, w);
return w;
}
This factory is designed to build @Efl.Ui.Widget and optionally set their
@Efl.Ui.Widget.style if it was connected with @Efl.Ui.Property_Bind.property_bind "$style".
-
]]
methods {
@property item_class {
}
implements {
+ Efl.Object.constructor;
Efl.Ui.Factory.create;
Efl.Ui.Factory.release;
- Efl.Ui.Factory.building;
Efl.Ui.Property_Bind.property_bind;
Efl.Part.part_get;
}