efl_ui_popup: Update size calculation logic
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 8 Dec 2017 09:11:09 +0000 (18:11 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Mon, 11 Dec 2017 04:33:12 +0000 (13:33 +0900)
Instead of doing size calculation whenever elm_layout_sizing_eval() is
called, do size calculation when the object is rendered like
efl_ui_layout.

src/lib/elementary/efl_ui_popup.c
src/lib/elementary/efl_ui_popup.eo
src/lib/elementary/efl_ui_popup_private.h

index 14ba8dc..3143a25 100644 (file)
@@ -239,8 +239,8 @@ _efl_ui_popup_efl_object_destructor(Eo *obj, Efl_Ui_Popup_Data *pd)
    efl_destructor(efl_super(obj, MY_CLASS));
 }
 
-EOLIAN static void
-_efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
+static void
+_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
 {
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
    Evas_Coord minw = -1, minh = -1;
@@ -260,6 +260,29 @@ _efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
    _calc_align(obj);
 }
 
+EOLIAN static void
+_efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd)
+{
+   if (pd->needs_size_calc) return;
+   pd->needs_size_calc = EINA_TRUE;
+
+   evas_object_smart_changed(obj);
+}
+
+EOLIAN static void
+_efl_ui_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Data *pd)
+{
+   /* When elm_layout_sizing_eval() is called, just flag is set instead of size
+    * calculation.
+    * The actual size calculation is done here when the object is rendered to
+    * avoid duplicate size calculations. */
+   if (pd->needs_size_calc)
+     {
+        _sizing_eval(obj, pd);
+        pd->needs_size_calc = EINA_FALSE;
+     }
+}
+
 /* Standard widget overrides */
 
 ELM_PART_CONTENT_DEFAULT_GET(efl_ui_popup, "elm.swallow.content")
index af18344..62067e7 100644 (file)
@@ -54,6 +54,7 @@ class Efl.Ui.Popup(Efl.Ui.Layout, Efl.Content)
    implements {
       Efl.Object.constructor;
       Efl.Object.destructor;
+      Efl.Canvas.Group.group_calculate;
       Efl.Gfx.position { set; }
       Efl.Gfx.size { set;}
       Efl.Gfx.visible { set; }
index a62a654..f018812 100644 (file)
@@ -9,6 +9,7 @@ struct _Efl_Ui_Popup_Data
    Efl_Ui_Popup_Align align;
    Ecore_Timer       *timer;
    double             timeout;
+   Eina_Bool          needs_size_calc : 1;
 };
 
 #endif