summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-03 14:48:58 +0200
committerCedric Bail <cedric.bail@free.fr>2019-09-17 20:22:08 -0700
commitd6d814e749184eee27ed31a694efedf061aa2d30 (patch)
tree631bfa17a5eb829758a1dea98565bd717509a9df
parent2b42b0ad330e5ac628e022a3bc43734dbd6d3763 (diff)
downloadefl-d6d814e749184eee27ed31a694efedf061aa2d30.tar.gz
efl: split Efl.Ui.Factory.create stage into constructing and building
constructing is called during construction time, building is called after finalize. This is usefull for theme related properties that can only be set after the theme is applied, which happens during finalize. Being event allow the user of the factory to add more initialization without needing to implement any new class. Differential Revision: https://phab.enlightenment.org/D9952
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c10
-rw-r--r--src/lib/efl/interfaces/efl_ui_factory.eo16
-rw-r--r--src/lib/elementary/efl_ui_caching_factory.c5
-rw-r--r--src/lib/elementary/efl_ui_image_factory.c19
-rw-r--r--src/lib/elementary/efl_ui_image_factory.eo1
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.c33
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.eo1
-rw-r--r--src/lib/elementary/efl_ui_widget_factory.c34
-rw-r--r--src/lib/elementary/efl_ui_widget_factory.eo2
9 files changed, 73 insertions, 48 deletions
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index f9d7b801c2..c7fbc5c896 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -119,15 +119,11 @@ __efl_internal_init(void)
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;
}
diff --git a/src/lib/efl/interfaces/efl_ui_factory.eo b/src/lib/efl/interfaces/efl_ui_factory.eo
index 3a531af533..f21c84ae93 100644
--- a/src/lib/efl/interfaces/efl_ui_factory.eo
+++ b/src/lib/efl/interfaces/efl_ui_factory.eo
@@ -26,18 +26,12 @@ interface @beta Efl.Ui.Factory extends Efl.Ui.Property_Bind, Efl.Ui.Factory_Bind
ui_view: Efl.Gfx.Entity; [[Efl canvas]]
}
}
- 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.]]
}
}
diff --git a/src/lib/elementary/efl_ui_caching_factory.c b/src/lib/elementary/efl_ui_caching_factory.c
index 245830f161..ae608d7e65 100644
--- a/src/lib/elementary/efl_ui_caching_factory.c
+++ b/src/lib/elementary/efl_ui_caching_factory.c
@@ -254,8 +254,9 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
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);
}
diff --git a/src/lib/elementary/efl_ui_image_factory.c b/src/lib/elementary/efl_ui_image_factory.c
index 336a94ac45..615f202d38 100644
--- a/src/lib/elementary/efl_ui_image_factory.c
+++ b/src/lib/elementary/efl_ui_image_factory.c
@@ -15,12 +15,23 @@ typedef struct _Efl_Ui_Image_Factory_Data
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;
@@ -35,14 +46,6 @@ _efl_ui_image_factory_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Ui_Image_Fa
efl_destructor(efl_super(obj, MY_CLASS));
}
-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)
diff --git a/src/lib/elementary/efl_ui_image_factory.eo b/src/lib/elementary/efl_ui_image_factory.eo
index 57acc7ea12..5ebcc1cd32 100644
--- a/src/lib/elementary/efl_ui_image_factory.eo
+++ b/src/lib/elementary/efl_ui_image_factory.eo
@@ -5,7 +5,6 @@ class @beta Efl.Ui.Image_Factory extends Efl.Ui.Caching_Factory
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Ui.Factory.create;
- Efl.Ui.Factory.building;
Efl.Ui.Property_Bind.property_bind;
}
}
diff --git a/src/lib/elementary/efl_ui_layout_factory.c b/src/lib/elementary/efl_ui_layout_factory.c
index ed9d975d40..cfc2749dd3 100644
--- a/src/lib/elementary/efl_ui_layout_factory.c
+++ b/src/lib/elementary/efl_ui_layout_factory.c
@@ -44,6 +44,22 @@ _factory_bind(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, vo
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)
{
@@ -54,6 +70,8 @@ _efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Dat
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;
}
@@ -70,21 +88,6 @@ _efl_ui_layout_factory_efl_object_destructor(Eo *obj, Efl_Ui_Layout_Factory_Data
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)
diff --git a/src/lib/elementary/efl_ui_layout_factory.eo b/src/lib/elementary/efl_ui_layout_factory.eo
index 0d35d21706..ac15fcc73d 100644
--- a/src/lib/elementary/efl_ui_layout_factory.eo
+++ b/src/lib/elementary/efl_ui_layout_factory.eo
@@ -15,7 +15,6 @@ class @beta Efl.Ui.Layout_Factory extends Efl.Ui.Caching_Factory
implements {
Efl.Object.constructor;
Efl.Object.destructor;
- Efl.Ui.Factory.building;
Efl.Ui.Property_Bind.property_bind;
Efl.Ui.Factory_Bind.factory_bind;
}
diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c
index 4b1523dd01..be1909022b 100644
--- a/src/lib/elementary/efl_ui_widget_factory.c
+++ b/src/lib/elementary/efl_ui_widget_factory.c
@@ -69,8 +69,22 @@ _efl_ui_widget_factory_item_class_get(const Eo *obj EINA_UNUSED,
}
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, const Efl_Event *ev)
{
+ Efl_Gfx_Entity *ui_view = ev->info;
+ Efl_Ui_Widget_Factory_Data *pd = data;
+
+ /* NOP */
+ (void)(ui_view);
+ (void)(pd);
+}
+
+
+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;
@@ -122,6 +136,21 @@ _efl_ui_widget_factory_efl_ui_factory_building(const Eo *factory EINA_UNUSED, Ef
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,
@@ -131,7 +160,8 @@ _efl_ui_widget_create(const Efl_Ui_Factory *factory,
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;
}
diff --git a/src/lib/elementary/efl_ui_widget_factory.eo b/src/lib/elementary/efl_ui_widget_factory.eo
index fdf537c1a7..27408185a2 100644
--- a/src/lib/elementary/efl_ui_widget_factory.eo
+++ b/src/lib/elementary/efl_ui_widget_factory.eo
@@ -18,9 +18,9 @@ class @beta Efl.Ui.Widget_Factory extends Efl.Loop_Consumer implements Efl.Ui.Fa
}
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;
}