From 7d2b4b69166c0f2abaf0f0bdec3b0d04eb721517 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Mon, 18 Sep 2017 14:49:08 +0900 Subject: [PATCH] efl: Use Eina.Size2D for size hint restricted min This is the "internal" or "intrinsic" minimum size, to be set by EFL and not by applications. --- src/lib/edje/edje_calc.c | 22 ++++++------ src/lib/efl/interfaces/efl_gfx_size_hint.eo | 13 ++++--- src/lib/elementary/efl_ui_box_stack.c | 8 ++--- src/lib/elementary/efl_ui_panes.c | 12 +++---- src/lib/elementary/efl_ui_win.c | 8 ++--- src/lib/evas/canvas/evas_object_main.c | 39 ++++++++++----------- src/lib/evas/include/evas_private.h | 4 +-- 7 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 16d30218b5..1500ab0e8e 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -933,12 +933,12 @@ _edje_recalc_do(Edje *ed) if (ed->update_hints && ed->recalc_hints && !ed->calc_only) { - Evas_Coord w, h; + Eina_Size2D min; ed->recalc_hints = EINA_FALSE; - edje_object_size_min_calc(ed->obj, &w, &h); - efl_gfx_size_hint_restricted_min_set(ed->obj, w, h); + edje_object_size_min_calc(ed->obj, &min.w, &min.h); + efl_gfx_size_hint_restricted_min_set(ed->obj, min); } if (!ed->collection) return; @@ -3415,36 +3415,36 @@ _edje_part_recalc_single(Edje *ed, (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) || (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)))) { - Evas_Coord lminw = 0, lminh = 0; + Eina_Size2D lmin; efl_canvas_group_need_recalculate_set(ep->object, 1); efl_canvas_group_calculate(ep->object); - efl_gfx_size_hint_restricted_min_get(ep->object, &lminw, &lminh); + lmin = efl_gfx_size_hint_restricted_min_get(ep->object); if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h) { - if (lminw > minw) minw = lminw; + if (lmin.w > minw) minw = lmin.w; } if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v) { - if (lminh > minh) minh = lminh; + if (lmin.h > minh) minh = lmin.h; } } else if ((ep->part->type == EDJE_PART_TYPE_BOX) && ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) || (((Edje_Part_Description_Box *)chosen_desc)->box.min.v))) { - Evas_Coord lminw = 0, lminh = 0; + Eina_Size2D lmin; efl_canvas_group_need_recalculate_set(ep->object, 1); efl_canvas_group_calculate(ep->object); - efl_gfx_size_hint_restricted_min_get(ep->object, &lminw, &lminh); + lmin = efl_gfx_size_hint_restricted_min_get(ep->object); if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h) { - if (lminw > minw) minw = lminw; + if (lmin.w > minw) minw = lmin.w; } if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v) { - if (lminh > minh) minh = lminh; + if (lmin.h > minh) minh = lmin.h; } } else if (ep->part->type == EDJE_PART_TYPE_IMAGE) diff --git a/src/lib/efl/interfaces/efl_gfx_size_hint.eo b/src/lib/efl/interfaces/efl_gfx_size_hint.eo index 123912c39b..85905ffe25 100644 --- a/src/lib/efl/interfaces/efl_gfx_size_hint.eo +++ b/src/lib/efl/interfaces/efl_gfx_size_hint.eo @@ -124,11 +124,16 @@ interface Efl.Gfx.Size.Hint this size internally, so any change to it from an application might be ignored. Use @.hint_min instead. ]] - set @protected {} - get {} + set @protected { + [[This function is protected as it is meant for widgets to indicate + their "intrinsic" minimum size. + ]] + } + get { + [[Get the "intrinsic" minimum size of this object.]] + } values { - w: int; [[Integer to use as the minimum width hint.]] - h: int; [[Integer to use as the minimum height hint.]] + sz: Eina.Size2D; [[Minimum size (hint) in pixels.]] } } @property hint_combined_min { diff --git a/src/lib/elementary/efl_ui_box_stack.c b/src/lib/elementary/efl_ui_box_stack.c index c50ea05960..3b8f2faed2 100644 --- a/src/lib/elementary/efl_ui_box_stack.c +++ b/src/lib/elementary/efl_ui_box_stack.c @@ -9,7 +9,7 @@ _efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED) { Evas_Object_Box_Option *opt; Evas_Object_Box_Data *bd; - int minw = 0, minh = 0; + Eina_Size2D min = { 0, 0 }; Eina_List *l; EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, EFL_UI_BOX_CLASS)); @@ -27,10 +27,10 @@ _efl_ui_box_stack_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED) int mw = 0, mh = 0; efl_gfx_size_hint_combined_min_get(child, &mw, &mh); - if (mw > minw) minw = mw; - if (mh > minh) minh = mh; + if (mw > min.w) min.w = mw; + if (mh > min.h) min.h = mh; } - efl_gfx_size_hint_restricted_min_set(obj, minw, minh); + efl_gfx_size_hint_restricted_min_set(obj, min); } #include "efl_ui_box_stack.eo.c" diff --git a/src/lib/elementary/efl_ui_panes.c b/src/lib/elementary/efl_ui_panes.c index 2353ba57cf..6fc48e37eb 100644 --- a/src/lib/elementary/efl_ui_panes.c +++ b/src/lib/elementary/efl_ui_panes.c @@ -185,7 +185,7 @@ _efl_ui_panes_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Panes_Data *sd) ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); Eo *first_content, *second_content; - int minw, minh; + Eina_Size2D min; first_content = efl_content_get(efl_part(obj, "first")); second_content = efl_content_get(efl_part(obj, "second")); @@ -208,16 +208,16 @@ _efl_ui_panes_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Panes_Data *sd) if (sd->dir == EFL_UI_DIR_HORIZONTAL) { - minw = MAX(sd->first_min.w, sd->second_min.w); - minh = sd->first_min.h + sd->second_min.h; + min.w = MAX(sd->first_min.w, sd->second_min.w); + min.h = sd->first_min.h + sd->second_min.h; } else { - minw = sd->first_min.w + sd->second_min.w; - minh = MAX(sd->first_min.h, sd->second_min.h); + min.w = sd->first_min.w + sd->second_min.w; + min.h = MAX(sd->first_min.h, sd->second_min.h); } - efl_gfx_size_hint_restricted_min_set(obj, minw, minh); + efl_gfx_size_hint_restricted_min_set(obj, min); _set_min_size_new(obj); } diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index c32754e97c..8e1b357058 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -1614,7 +1614,7 @@ _elm_win_state_change(Ecore_Evas *ee) } if (ch_wm_rotation) { - efl_gfx_size_hint_restricted_min_set(obj, -1, -1); + efl_gfx_size_hint_restricted_min_set(obj, EINA_SIZE2D(-1, -1)); efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, -1)); #ifdef HAVE_ELEMENTARY_X ELM_WIN_DATA_ALIVE_CHECK(obj, sd); @@ -3495,7 +3495,7 @@ _elm_win_resize_objects_eval(Evas_Object *obj, Eina_Bool force_resize) } sd->tmp_updating_hints = 1; - efl_gfx_size_hint_restricted_min_set(obj, minw, minh); + efl_gfx_size_hint_restricted_min_set(obj, EINA_SIZE2D(minw, minh)); efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(maxw, maxh)); sd->tmp_updating_hints = 0; _elm_win_size_hints_update(obj, sd); @@ -6079,7 +6079,7 @@ _win_rotate(Evas_Object *obj, Efl_Ui_Win_Data *sd, int rotation, Eina_Bool resiz sd->rot = rotation; if (resize) TRAP(sd, rotation_with_resize_set, rotation); else TRAP(sd, rotation_set, rotation); - efl_gfx_size_hint_restricted_min_set(obj, -1, -1); + efl_gfx_size_hint_restricted_min_set(obj, EINA_SIZE2D(-1, -1)); efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, -1)); _elm_win_resize_objects_eval(obj, EINA_FALSE); #ifdef HAVE_ELEMENTARY_X @@ -8080,7 +8080,7 @@ _window_layout_stack(Evas_Object *o, Evas_Object_Box_Data *p, void *data) } if (minw < menuw) minw = menuw; - efl_gfx_size_hint_restricted_min_set(o, minw, minh); + efl_gfx_size_hint_restricted_min_set(o, EINA_SIZE2D(minw, minh)); evas_object_geometry_get(o, &x, &y, &w, &h); if (w < minw) w = minw; if (h < minh) h = minh; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 86301401f6..be06e10893 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1397,33 +1397,28 @@ evas_object_size_hint_display_mode_set(Eo *eo_obj, Evas_Display_Mode dispmode) evas_object_inform_call_changed_size_hints(eo_obj); } -EOLIAN static void -_efl_canvas_object_efl_gfx_size_hint_hint_restricted_min_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Coord *w, Evas_Coord *h) +EOLIAN static Eina_Size2D +_efl_canvas_object_efl_gfx_size_hint_hint_restricted_min_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) { if ((!obj->size_hints) || obj->delete_me) - { - if (w) *w = 0; - if (h) *h = 0; - return; - } - if (w) *w = obj->size_hints->min.w; - if (h) *h = obj->size_hints->min.h; + return EINA_SIZE2D(0, 0); + + return obj->size_hints->min; } EOLIAN static void -_efl_canvas_object_efl_gfx_size_hint_hint_restricted_min_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord w, Evas_Coord h) +_efl_canvas_object_efl_gfx_size_hint_hint_restricted_min_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Size2D sz) { if (obj->delete_me) return; evas_object_async_block(obj); if (EINA_UNLIKELY(!obj->size_hints)) { - if (!w && !h) return; + if (!sz.w && !sz.h) return; _evas_object_size_hint_alloc(eo_obj, obj); } - if ((obj->size_hints->min.w == w) && (obj->size_hints->min.h == h)) return; - obj->size_hints->min.w = w; - obj->size_hints->min.h = h; + if ((obj->size_hints->min.w == sz.w) && (obj->size_hints->min.h == sz.h)) return; + obj->size_hints->min = sz; evas_object_inform_call_changed_size_hints(eo_obj); } @@ -2043,9 +2038,8 @@ _efl_canvas_object_efl_object_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Dat unsigned int m; int r, g, b, a; //int requestw, requesth; - int minw, minh; Eina_Rect geom; - Eina_Size2D max; + Eina_Size2D max, min; short layer; Eina_Bool focus; Eina_Bool visible; @@ -2059,7 +2053,7 @@ _efl_canvas_object_efl_object_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Dat name = efl_name_get(eo_obj); // evas_object_name_get(eo_obj); geom = efl_gfx_geometry_get(eo_obj); scale = efl_canvas_object_scale_get(eo_obj); - efl_gfx_size_hint_restricted_min_get(eo_obj, &minw, &minh); + min = efl_gfx_size_hint_restricted_min_get(eo_obj); max = efl_gfx_size_hint_max_get(eo_obj); //efl_gfx_size_hint_request_get(eo_obj, &requestw, &requesth); efl_gfx_size_hint_align_get(eo_obj, &dblx, &dbly); @@ -2090,8 +2084,8 @@ _efl_canvas_object_efl_object_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Dat EFL_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE, scale); node = EFL_DBG_INFO_LIST_APPEND(group, "Min size"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, minw); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, minh); + EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, min.w); + EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, min.h); node = EFL_DBG_INFO_LIST_APPEND(group, "Max size"); EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, max.w); @@ -2577,13 +2571,16 @@ evas_object_size_hint_max_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord EAPI void evas_object_size_hint_min_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h) { - efl_gfx_size_hint_restricted_min_set(obj, w, h); + efl_gfx_size_hint_restricted_min_set(obj, EINA_SIZE2D(w, h)); } EAPI void evas_object_size_hint_min_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) { - efl_gfx_size_hint_restricted_min_get(obj, w, h); + Eina_Size2D sz; + sz = efl_gfx_size_hint_restricted_min_get(obj); + if (w) *w = sz.w; + if (h) *h = sz.h; } EAPI void diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index e998e1c5e7..f071e24bb3 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1019,8 +1019,8 @@ struct _Evas_Double_Pair struct _Evas_Size_Hints { - Evas_Size min, request; - Eina_Size2D user_min, max; + Evas_Size request; + Eina_Size2D min, user_min, max; Evas_Aspect aspect; Evas_Double_Pair align, weight; Evas_Border padding;