efl_ui_popup: Code refactorying for elm_layout_sizing_eval

Use flags for group calculation, size calculation and align calculation.

If the flag for size calculation is set to be false, then size is not
calculated in the efl_canvas_group_calcualte().
(The flag for align calculation works the same way.)

Efl.Ui.Popup's sub classes can set the above flags false before they
call efl_canvas_group_calculate() with its super class not to calculate
size or align by its super class.
This commit is contained in:
Jaehyun Cho 2017-12-13 18:06:59 +09:00
parent df032058fd
commit 0722992790
6 changed files with 69 additions and 46 deletions

View File

@ -79,13 +79,24 @@ EOLIAN static void
_efl_ui_popup_efl_gfx_size_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Size2D size)
{
efl_gfx_size_set(efl_super(obj, MY_CLASS), size);
_calc_align(obj);
//Add align calc only
Eina_Bool needs_size_calc = pd->needs_size_calc;
elm_layout_sizing_eval(obj);
pd->needs_size_calc = needs_size_calc;
}
static void
_parent_geom_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
_calc_align(data);
Eo *obj = data;
EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, pd);
//Add align calc only
Eina_Bool needs_size_calc = pd->needs_size_calc;
elm_layout_sizing_eval(obj);
pd->needs_size_calc = needs_size_calc;
}
EOLIAN static void
@ -111,7 +122,11 @@ EOLIAN static void
_efl_ui_popup_align_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd, Efl_Ui_Popup_Align type)
{
pd->align = type;
_calc_align(obj);
//Add align calc only
Eina_Bool needs_size_calc = pd->needs_size_calc;
elm_layout_sizing_eval(obj);
pd->needs_size_calc = needs_size_calc;
}
EOLIAN static Efl_Ui_Popup_Align
@ -240,7 +255,7 @@ _efl_ui_popup_efl_object_destructor(Eo *obj, Efl_Ui_Popup_Data *pd)
}
static void
_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
_sizing_eval(Eo *obj)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
Evas_Coord minw = -1, minh = -1;
@ -256,15 +271,24 @@ _sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
new_size.w = (minw > size.w ? minw : size.w);
new_size.h = (minh > size.h ? minh : size.h);
efl_gfx_size_set(obj, new_size);
_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;
if (pd->needs_group_calc) return;
pd->needs_group_calc = EINA_TRUE;
/* These flags can be modified by sub classes not to calculate size or align
* their super classes.
* e.g. Efl.Ui.Popup.Alert.Scroll class sets the flag as follows not to
* calculate size by its super class.
*
* ppd->needs_size_calc = EINA_FALSE;
* efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
*/
pd->needs_size_calc = EINA_TRUE;
pd->needs_align_calc = EINA_TRUE;
evas_object_smart_changed(obj);
}
@ -276,10 +300,19 @@ _efl_ui_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Data *pd)
* calculation.
* The actual size calculation is done here when the object is rendered to
* avoid duplicate size calculations. */
if (pd->needs_size_calc)
if (pd->needs_group_calc)
{
_sizing_eval(obj, pd);
pd->needs_size_calc = EINA_FALSE;
if (pd->needs_size_calc)
{
_sizing_eval(obj);
pd->needs_size_calc = EINA_FALSE;
}
if (pd->needs_align_calc)
{
_calc_align(obj);
pd->needs_align_calc = EINA_FALSE;
}
pd->needs_group_calc = EINA_FALSE;
}
}

View File

@ -7,6 +7,7 @@
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_popup_private.h"
#include "efl_ui_popup_alert_scroll_private.h"
#include "efl_ui_popup_alert_scroll_part.eo.h"
#include "elm_part_helper.h"
@ -129,15 +130,6 @@ _sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd)
_scroller_sizing_eval(obj, pd, EINA_SIZE2D(obj_minw, obj_minh), EINA_SIZE2D(scr_minw, scr_minh));
}
EOLIAN static void
_efl_ui_popup_alert_scroll_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_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_alert_scroll_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd)
{
@ -145,11 +137,15 @@ _efl_ui_popup_alert_scroll_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popu
* calculation.
* The actual size calculation is done here when the object is rendered to
* avoid duplicate size calculations. */
if (pd->needs_size_calc)
EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
if (ppd->needs_group_calc)
{
_sizing_eval(obj, pd);
pd->needs_size_calc = EINA_FALSE;
//Not to calculate size by super class
ppd->needs_size_calc = EINA_FALSE;
efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
}
}
@ -281,7 +277,6 @@ _efl_ui_popup_alert_scroll_efl_object_constructor(Eo *obj,
pd->size = EINA_SIZE2D(0, 0);
pd->max_size = EINA_SIZE2D(-1, -1);
pd->needs_size_calc = EINA_FALSE;
return obj;
}
@ -298,9 +293,4 @@ ELM_PART_OVERRIDE_TEXT_GET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL,
/* Efl.Part end */
/* Internal EO APIs and hidden overrides */
#define EFL_UI_POPUP_ALERT_SCROLL_EXTRA_OPS \
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert_scroll)
#include "efl_ui_popup_alert_scroll.eo.c"

View File

@ -10,7 +10,6 @@ struct _Efl_Ui_Popup_Alert_Scroll_Data
Eo *content;
Eina_Size2D size;
Eina_Size2D max_size;
Eina_Bool needs_size_calc : 1;
};
#endif

View File

@ -5,6 +5,7 @@
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_popup_private.h"
#include "efl_ui_popup_alert_text_private.h"
#include "efl_ui_popup_alert_text_part.eo.h"
#include "elm_part_helper.h"
@ -147,15 +148,6 @@ _sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd)
_scroller_sizing_eval(obj, pd, EINA_SIZE2D(obj_minw, obj_minh), text_min);
}
EOLIAN static void
_efl_ui_popup_alert_text_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Text_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_alert_text_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd)
{
@ -163,11 +155,15 @@ _efl_ui_popup_alert_text_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_
* calculation.
* The actual size calculation is done here when the object is rendered to
* avoid duplicate size calculations. */
if (pd->needs_size_calc)
EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
if (ppd->needs_group_calc)
{
_sizing_eval(obj, pd);
pd->needs_size_calc = EINA_FALSE;
//Not to calculate size by super class
ppd->needs_size_calc = EINA_FALSE;
efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
}
}
@ -287,7 +283,6 @@ _efl_ui_popup_alert_text_efl_object_constructor(Eo *obj,
pd->size = EINA_SIZE2D(0, 0);
pd->max_size = EINA_SIZE2D(-1, -1);
pd->needs_size_calc = EINA_FALSE;
return obj;
}
@ -304,9 +299,4 @@ ELM_PART_OVERRIDE_TEXT_GET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl
/* Efl.Part end */
/* Internal EO APIs and hidden overrides */
#define EFL_UI_POPUP_ALERT_TEXT_EXTRA_OPS \
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert_text)
#include "efl_ui_popup_alert_text.eo.c"

View File

@ -10,7 +10,6 @@ struct _Efl_Ui_Popup_Alert_Text_Data
Eo *message;
Eina_Size2D size;
Eina_Size2D max_size;
Eina_Bool needs_size_calc : 1;
};
#endif

View File

@ -9,7 +9,19 @@ struct _Efl_Ui_Popup_Data
Efl_Ui_Popup_Align align;
Ecore_Timer *timer;
double timeout;
Eina_Bool needs_group_calc : 1;
Eina_Bool needs_size_calc : 1;
Eina_Bool needs_align_calc : 1;
};
#define EFL_UI_POPUP_DATA_GET_OR_RETURN(o, ptr, ...) \
Efl_Ui_Popup_Data *ptr; \
ptr = efl_data_scope_get(o, EFL_UI_POPUP_CLASS); \
if (EINA_UNLIKELY(!ptr)) \
{ \
CRI("no ui popup data for object %p (%s)", \
o, evas_object_type_get(o)); \
return __VA_ARGS__; \
}
#endif