elementary: leverage sizing information from model if available to avoid unecessary...
authorCedric BAIL <cedric.bail@free.fr>
Fri, 23 Aug 2019 19:48:16 +0000 (12:48 -0700)
committerJongmin Lee <jm105.lee@samsung.com>
Fri, 20 Sep 2019 21:20:40 +0000 (06:20 +0900)
With the new Efl unified infrastructure, we do delay a lot of the computation to finalize,
by filling the object information before finalize we reduce unecessary computation.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D9948

src/lib/elementary/efl_ui_widget_factory.c

index c9d5759..c65bda5 100644 (file)
@@ -72,12 +72,29 @@ 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;
+   Eina_Value *property, *width, *height;
    char *style;
 
    if (!pd->style) return ;
 
    model = efl_ui_view_model_get(ui_view);
+
+   // Fetch min size from model if available to avoid recalculcating it
+   width = efl_model_property_get(model, "self.width");
+   height = efl_model_property_get(model, "self.height");
+   if (eina_value_type_get(width) != EINA_VALUE_TYPE_ERROR &&
+       eina_value_type_get(height) != EINA_VALUE_TYPE_ERROR)
+     {
+        Eina_Size2D s;
+
+        if (!eina_value_int_convert(width, &s.w)) s.w = 0;
+        if (!eina_value_int_convert(height, &s.h)) s.h = 0;
+
+        efl_gfx_hint_size_min_set(ui_view, s);
+     }
+   eina_value_free(width);
+   eina_value_free(height);
+
    // 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 ;