jaehyun pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=0722992790ccce3d9e79fd6f0fa41917f02803ea
commit 0722992790ccce3d9e79fd6f0fa41917f02803ea Author: Jaehyun Cho <[email protected]> Date: Wed Dec 13 18:06:59 2017 +0900 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. --- src/lib/elementary/efl_ui_popup.c | 53 ++++++++++++++++++---- src/lib/elementary/efl_ui_popup_alert_scroll.c | 24 +++------- .../elementary/efl_ui_popup_alert_scroll_private.h | 1 - src/lib/elementary/efl_ui_popup_alert_text.c | 24 +++------- .../elementary/efl_ui_popup_alert_text_private.h | 1 - src/lib/elementary/efl_ui_popup_private.h | 12 +++++ 6 files changed, 69 insertions(+), 46 deletions(-) diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c index 3143a25fef..f8134d285b 100644 --- a/src/lib/elementary/efl_ui_popup.c +++ b/src/lib/elementary/efl_ui_popup.c @@ -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; } } diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll.c b/src/lib/elementary/efl_ui_popup_alert_scroll.c index 72a875cc25..dc6ef7e83c 100644 --- a/src/lib/elementary/efl_ui_popup_alert_scroll.c +++ b/src/lib/elementary/efl_ui_popup_alert_scroll.c @@ -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" @@ -130,26 +131,21 @@ _sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd) } 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) { /* 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) + 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" diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll_private.h b/src/lib/elementary/efl_ui_popup_alert_scroll_private.h index 290eaa75ad..9e3bb550a3 100644 --- a/src/lib/elementary/efl_ui_popup_alert_scroll_private.h +++ b/src/lib/elementary/efl_ui_popup_alert_scroll_private.h @@ -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 diff --git a/src/lib/elementary/efl_ui_popup_alert_text.c b/src/lib/elementary/efl_ui_popup_alert_text.c index e74b448ab7..4bad668fab 100644 --- a/src/lib/elementary/efl_ui_popup_alert_text.c +++ b/src/lib/elementary/efl_ui_popup_alert_text.c @@ -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" @@ -148,26 +149,21 @@ _sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd) } 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) { /* 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) + 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" diff --git a/src/lib/elementary/efl_ui_popup_alert_text_private.h b/src/lib/elementary/efl_ui_popup_alert_text_private.h index 5820425189..fb4cdd731c 100644 --- a/src/lib/elementary/efl_ui_popup_alert_text_private.h +++ b/src/lib/elementary/efl_ui_popup_alert_text_private.h @@ -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 diff --git a/src/lib/elementary/efl_ui_popup_private.h b/src/lib/elementary/efl_ui_popup_private.h index f018812389..3cf0eee24a 100644 --- a/src/lib/elementary/efl_ui_popup_private.h +++ b/src/lib/elementary/efl_ui_popup_private.h @@ -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 --
