forked from enlightenment/efl
elementary: allow Efl.Ui.Factory to have a chance to call constructor function.
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9599
This commit is contained in:
parent
0248d504b3
commit
f6cdbc2d43
|
@ -22,6 +22,14 @@ interface @beta Efl.Ui.Factory extends Efl.Ui.Property_Bind, Efl.Ui.Factory_Bind
|
||||||
ui_view: Efl.Gfx.Entity; [[Efl canvas]]
|
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 object, this won't be called when object are pulled out of the cache.]]
|
||||||
|
params {
|
||||||
|
ui_view: Efl.Gfx.Entity; [[The UI object being created.]]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
created: Efl.Ui.Factory_Item_Created_Event; [[Event triggered when an item has been successfully created.]]
|
created: Efl.Ui.Factory_Item_Created_Event; [[Event triggered when an item has been successfully created.]]
|
||||||
|
|
|
@ -244,6 +244,7 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
EINA_ITERATOR_FOREACH(models, model)
|
EINA_ITERATOR_FOREACH(models, model)
|
||||||
{
|
{
|
||||||
w = efl_add(pd->klass, parent,
|
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));
|
||||||
eina_value_array_append(&gr->done, w);
|
eina_value_array_append(&gr->done, w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,6 @@ _efl_ui_layout_factory_bind(Eo *obj EINA_UNUSED, void *data, const Eina_Value va
|
||||||
|
|
||||||
EINA_VALUE_ARRAY_FOREACH(&value, len, i, layout)
|
EINA_VALUE_ARRAY_FOREACH(&value, len, i, layout)
|
||||||
{
|
{
|
||||||
efl_ui_layout_theme_set(layout, pd->klass, pd->group, pd->style);
|
|
||||||
|
|
||||||
eina_hash_foreach(pd->bind.properties, _property_bind, layout);
|
eina_hash_foreach(pd->bind.properties, _property_bind, layout);
|
||||||
eina_hash_foreach(pd->bind.factories, _factory_bind, layout);
|
eina_hash_foreach(pd->bind.factories, _factory_bind, layout);
|
||||||
|
|
||||||
|
@ -89,6 +87,14 @@ _efl_ui_layout_factory_bind(Eo *obj EINA_UNUSED, void *data, const Eina_Value va
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_efl_ui_layout_factory_efl_ui_factory_building(const Eo *obj, Efl_Ui_Layout_Factory_Data *pd, Efl_Gfx_Entity *ui_view)
|
||||||
|
{
|
||||||
|
efl_ui_layout_theme_set(ui_view, pd->klass, pd->group, pd->style);
|
||||||
|
|
||||||
|
efl_ui_factory_building(efl_super(obj, EFL_UI_LAYOUT_FACTORY_CLASS), ui_view);
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Future *
|
EOLIAN static Eina_Future *
|
||||||
_efl_ui_layout_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Layout_Factory_Data *pd,
|
_efl_ui_layout_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Layout_Factory_Data *pd,
|
||||||
Eina_Iterator *models, Efl_Gfx_Entity *parent)
|
Eina_Iterator *models, Efl_Gfx_Entity *parent)
|
||||||
|
|
|
@ -16,6 +16,7 @@ class @beta Efl.Ui.Layout_Factory extends Efl.Ui.Caching_Factory
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
Efl.Object.destructor;
|
Efl.Object.destructor;
|
||||||
Efl.Ui.Factory.create;
|
Efl.Ui.Factory.create;
|
||||||
|
Efl.Ui.Factory.building;
|
||||||
Efl.Ui.Property_Bind.property_bind;
|
Efl.Ui.Property_Bind.property_bind;
|
||||||
Efl.Ui.Factory_Bind.factory_bind;
|
Efl.Ui.Factory_Bind.factory_bind;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ struct _Efl_Ui_Widget_Factory_Data
|
||||||
struct _Efl_Ui_Widget_Factory_Request
|
struct _Efl_Ui_Widget_Factory_Request
|
||||||
{
|
{
|
||||||
Efl_Ui_Widget_Factory_Data *pd;
|
Efl_Ui_Widget_Factory_Data *pd;
|
||||||
|
Efl_Ui_Factory *factory;
|
||||||
Eo *parent;
|
Eo *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,9 +67,31 @@ _efl_ui_widget_factory_item_class_get(const Eo *obj EINA_UNUSED,
|
||||||
return pd->klass;
|
return pd->klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_efl_ui_widget_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui_Widget_Factory_Data *pd EINA_UNUSED, Efl_Gfx_Entity *ui_view)
|
||||||
|
{
|
||||||
|
const Efl_Model *model;
|
||||||
|
Eina_Value *property;
|
||||||
|
char *style;
|
||||||
|
|
||||||
|
if (!pd->style) return ;
|
||||||
|
|
||||||
|
model = efl_ui_view_model_get(ui_view);
|
||||||
|
// As we have already waited for the property to be ready, we should get the right style now
|
||||||
|
property = efl_model_property_get(model, pd->style);
|
||||||
|
if (!property) return ;
|
||||||
|
|
||||||
|
style = eina_value_to_string(property);
|
||||||
|
if (style) efl_ui_widget_style_set(ui_view, style);
|
||||||
|
free(style);
|
||||||
|
|
||||||
|
eina_value_free(property);
|
||||||
|
}
|
||||||
|
|
||||||
static Efl_Ui_Widget *
|
static Efl_Ui_Widget *
|
||||||
_efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
|
_efl_ui_widget_create(const Efl_Ui_Factory *factory,
|
||||||
const char *style, Efl_Model *model,
|
const Efl_Class *klass, Eo *parent,
|
||||||
|
Efl_Model *model,
|
||||||
const Eina_Hash *parts)
|
const Eina_Hash *parts)
|
||||||
{
|
{
|
||||||
Efl_Ui_Bind_Part_Data *bpd;
|
Efl_Ui_Bind_Part_Data *bpd;
|
||||||
|
@ -76,8 +99,8 @@ _efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
|
||||||
Efl_Ui_Widget *w;
|
Efl_Ui_Widget *w;
|
||||||
|
|
||||||
w = efl_add(klass, parent,
|
w = efl_add(klass, parent,
|
||||||
style ? efl_ui_widget_style_set(efl_added, style) : (void) 0,
|
efl_ui_view_model_set(efl_added, model),
|
||||||
efl_ui_view_model_set(efl_added, model));
|
efl_ui_factory_building(factory, efl_added));
|
||||||
if (!parts) return w;
|
if (!parts) return w;
|
||||||
|
|
||||||
it = eina_hash_iterator_data_new(parts);
|
it = eina_hash_iterator_data_new(parts);
|
||||||
|
@ -97,16 +120,12 @@ _efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Value
|
static Eina_Value
|
||||||
_efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v)
|
_efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Efl_Ui_Widget_Factory_Request *r = data;
|
Efl_Ui_Widget_Factory_Request *r = data;
|
||||||
Efl_Ui_Widget *w;
|
Efl_Ui_Widget *w;
|
||||||
const char *string = NULL;
|
|
||||||
|
|
||||||
if (!eina_value_string_get(&v, &string))
|
w = _efl_ui_widget_create(r->factory, r->pd->klass, r->parent, model, r->pd->parts);
|
||||||
return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED);
|
|
||||||
|
|
||||||
w = _efl_ui_widget_create(r->pd->klass, r->parent, string, model, r->pd->parts);
|
|
||||||
if (!w) return eina_value_error_init(ENOMEM);
|
if (!w) return eina_value_error_init(ENOMEM);
|
||||||
return eina_value_object_init(w);
|
return eina_value_object_init(w);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +141,7 @@ _efl_ui_widget_factory_create_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_
|
||||||
{
|
{
|
||||||
Efl_Ui_Widget_Factory_Request *r = data;
|
Efl_Ui_Widget_Factory_Request *r = data;
|
||||||
|
|
||||||
|
efl_unref(r->factory);
|
||||||
efl_unref(r->parent);
|
efl_unref(r->parent);
|
||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +167,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(models, model)
|
EINA_ITERATOR_FOREACH(models, model)
|
||||||
{
|
{
|
||||||
w = _efl_ui_widget_create(pd->klass, parent, NULL, model, pd->parts);
|
w = _efl_ui_widget_create(obj, pd->klass, parent, model, pd->parts);
|
||||||
|
|
||||||
if (!w) return efl_loop_future_rejected(obj, ENOMEM);
|
if (!w) return efl_loop_future_rejected(obj, ENOMEM);
|
||||||
eina_value_array_append(&r, w);
|
eina_value_array_append(&r, w);
|
||||||
|
@ -162,6 +182,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
|
||||||
|
|
||||||
r->pd = pd;
|
r->pd = pd;
|
||||||
r->parent = efl_ref(parent);
|
r->parent = efl_ref(parent);
|
||||||
|
r->factory = efl_ref(obj);
|
||||||
|
|
||||||
f = calloc(count + 1, sizeof (Eina_Future *));
|
f = calloc(count + 1, sizeof (Eina_Future *));
|
||||||
if (!f) return efl_loop_future_rejected(obj, ENOMEM);
|
if (!f) return efl_loop_future_rejected(obj, ENOMEM);
|
||||||
|
|
|
@ -20,6 +20,7 @@ class @beta Efl.Ui.Widget_Factory extends Efl.Loop_Consumer implements Efl.Ui.Fa
|
||||||
implements {
|
implements {
|
||||||
Efl.Ui.Factory.create;
|
Efl.Ui.Factory.create;
|
||||||
Efl.Ui.Factory.release;
|
Efl.Ui.Factory.release;
|
||||||
|
Efl.Ui.Factory.building;
|
||||||
Efl.Ui.Property_Bind.property_bind;
|
Efl.Ui.Property_Bind.property_bind;
|
||||||
Efl.Part.part_get;
|
Efl.Part.part_get;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue