summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-08-23 14:29:55 -0700
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-10 10:06:38 +0200
commitd7ff9f1786fb3b7cdcc629c0e085172b2a86cbe5 (patch)
tree73b2cb21894b40fb87cadf86d3cf9ff559971efb
parent9bd0aa4f7f7bc99db04102c379b819c4c1ecdc00 (diff)
elementary: Efl.Ui.Widget_Factory bind widget property before finalizing the widget.
In the same vain as previous patch this will initialize more of the widget during its creation and reduce unecessary recalc.
-rw-r--r--src/lib/elementary/efl_ui_widget_factory.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c
index a0e0a44c38..b4b4d7a54c 100644
--- a/src/lib/elementary/efl_ui_widget_factory.c
+++ b/src/lib/elementary/efl_ui_widget_factory.c
@@ -69,16 +69,30 @@ _efl_ui_widget_factory_item_class_get(const Eo *obj EINA_UNUSED,
69} 69}
70 70
71static void 71static void
72_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) 72_efl_ui_widget_factory_efl_ui_factory_building(const Eo *factory EINA_UNUSED, Efl_Ui_Widget_Factory_Data *pd, Efl_Gfx_Entity *ui_view)
73{ 73{
74 const Efl_Model *model; 74 const Efl_Model *model;
75 Eina_Value *property, *width, *height; 75 Eina_Value *property, *width, *height;
76 Efl_Ui_Bind_Part_Data *bpd;
77 Eina_Iterator *it;
76 char *style; 78 char *style;
77 79
78 if (!pd->style) return ;
79
80 model = efl_ui_view_model_get(ui_view); 80 model = efl_ui_view_model_get(ui_view);
81 81
82 // Bind all property before the object is finalize
83 it = eina_hash_iterator_data_new(pd->parts);
84 EINA_ITERATOR_FOREACH(it, bpd)
85 {
86 Efl_Ui_Property_Bind_Data *bppd;
87 Eina_List *l;
88
89 EINA_LIST_FOREACH(bpd->properties, l, bppd)
90 efl_ui_property_bind(efl_part(ui_view, bpd->part),
91 bppd->part_property,
92 bppd->model_property);
93 }
94 eina_iterator_free(it);
95
82 // Fetch min size from model if available to avoid recalculcating it 96 // Fetch min size from model if available to avoid recalculcating it
83 width = efl_model_property_get(model, "self.width"); 97 width = efl_model_property_get(model, "self.width");
84 height = efl_model_property_get(model, "self.height"); 98 height = efl_model_property_get(model, "self.height");
@@ -96,6 +110,8 @@ _efl_ui_widget_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui
96 eina_value_free(height); 110 eina_value_free(height);
97 111
98 // As we have already waited for the property to be ready, we should get the right style now 112 // As we have already waited for the property to be ready, we should get the right style now
113 if (!pd->style) return ;
114
99 property = efl_model_property_get(model, pd->style); 115 property = efl_model_property_get(model, pd->style);
100 if (!property) return ; 116 if (!property) return ;
101 117
@@ -109,31 +125,13 @@ _efl_ui_widget_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui
109static Efl_Ui_Widget * 125static Efl_Ui_Widget *
110_efl_ui_widget_create(const Efl_Ui_Factory *factory, 126_efl_ui_widget_create(const Efl_Ui_Factory *factory,
111 const Efl_Class *klass, Eo *parent, 127 const Efl_Class *klass, Eo *parent,
112 Efl_Model *model, 128 Efl_Model *model)
113 const Eina_Hash *parts)
114{ 129{
115 Efl_Ui_Bind_Part_Data *bpd;
116 Eina_Iterator *it;
117 Efl_Ui_Widget *w; 130 Efl_Ui_Widget *w;
118 131
119 w = efl_add(klass, parent, 132 w = efl_add(klass, parent,
120 efl_ui_view_model_set(efl_added, model), 133 efl_ui_view_model_set(efl_added, model),
121 efl_ui_factory_building(factory, efl_added)); 134 efl_ui_factory_building(factory, efl_added));
122 if (!parts) return w;
123
124 it = eina_hash_iterator_data_new(parts);
125 EINA_ITERATOR_FOREACH(it, bpd)
126 {
127 Efl_Ui_Property_Bind_Data *bppd;
128 Eina_List *l;
129
130 EINA_LIST_FOREACH(bpd->properties, l, bppd)
131 efl_ui_property_bind(efl_part(w, bpd->part),
132 bppd->part_property,
133 bppd->model_property);
134 }
135 eina_iterator_free(it);
136
137 return w; 135 return w;
138} 136}
139 137
@@ -143,7 +141,7 @@ _efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v EIN
143 Efl_Ui_Widget_Factory_Request *r = data; 141 Efl_Ui_Widget_Factory_Request *r = data;
144 Efl_Ui_Widget *w; 142 Efl_Ui_Widget *w;
145 143
146 w = _efl_ui_widget_create(r->factory, r->pd->klass, r->parent, model, r->pd->parts); 144 w = _efl_ui_widget_create(r->factory, r->pd->klass, r->parent, model);
147 if (!w) return eina_value_error_init(ENOMEM); 145 if (!w) return eina_value_error_init(ENOMEM);
148 return eina_value_object_init(w); 146 return eina_value_object_init(w);
149} 147}
@@ -185,7 +183,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
185 183
186 EINA_ITERATOR_FOREACH(models, model) 184 EINA_ITERATOR_FOREACH(models, model)
187 { 185 {
188 w = _efl_ui_widget_create(obj, pd->klass, parent, model, pd->parts); 186 w = _efl_ui_widget_create(obj, pd->klass, parent, model);
189 187
190 if (!w) return efl_loop_future_rejected(obj, ENOMEM); 188 if (!w) return efl_loop_future_rejected(obj, ENOMEM);
191 eina_value_array_append(&r, w); 189 eina_value_array_append(&r, w);