efl: Use Eina.Size2D for size hint restricted min
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 18 Sep 2017 05:49:08 +0000 (14:49 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Mon, 18 Sep 2017 05:57:52 +0000 (14:57 +0900)
This is the "internal" or "intrinsic" minimum size, to be set by EFL and
not by applications.

src/lib/edje/edje_calc.c
src/lib/efl/interfaces/efl_gfx_size_hint.eo
src/lib/elementary/efl_ui_box_stack.c
src/lib/elementary/efl_ui_panes.c
src/lib/elementary/efl_ui_win.c
src/lib/evas/canvas/evas_object_main.c
src/lib/evas/include/evas_private.h

index 16d30218b5d71ef270e590929516d1617003f2a7..1500ab0e8e81b956eaa1f888f3157ca50dd7ebc2 100644 (file)
@@ -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)
index 123912c39b6528ba05b145454490924f9bf1213e..85905ffe257cba5cd86c09912c5771e1d0e60c21 100644 (file)
@@ -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 {
index c50ea05960db68dab24c6f1bcb2bf4d2ae3ccd60..3b8f2faed29b10e3d742d1fd5a7e29764c4b5fb9 100644 (file)
@@ -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"
index 2353ba57cf46fac96cd671e66818101350dbeb87..6fc48e37ebc3cd557c5211a93f2a055ed9bca9f0 100644 (file)
@@ -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);
 }
 
index c32754e97c004fd6bbe3c590719daaefb0d0181e..8e1b357058e69257125ee2c33dad673a03ee81bb 100644 (file)
@@ -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;
index 86301401f63c86b1501368c4b17d2eec3a5ec9d5..be06e108932a241af674eb44f52d2306fc3af6ca 100644 (file)
@@ -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
index e998e1c5e77f10ca1bec8d2de0d159a38500d466..f071e24bb38cd30a494d43cd81a52ee8e16eae7e 100644 (file)
@@ -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;