efl_ui_popup: Update size calculation logic

Instead of doing size calculation whenever elm_layout_sizing_eval() is
called, do size calculation when the object is rendered like
efl_ui_layout.
This commit is contained in:
Jaehyun Cho 2017-12-08 18:11:09 +09:00
parent 0096a8aa3c
commit 10761cf2f5
3 changed files with 27 additions and 2 deletions

View 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")

View 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; }

View 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