raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cd4508150d3ce07ae7e431af7a86216d5c19a494

commit cd4508150d3ce07ae7e431af7a86216d5c19a494
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Mon Apr 6 19:33:30 2020 +0100

    elm icon/image efl ui image - respect aspect hints at all if set
    
    these did not even look at aspect hints when calculating sizing. that
    means any attempt to set them would lead to... nothing useful. this
    handles horiz/vert/both cases (as best as is possible).
    
    @fix
    
    This reverts previous commit and fixes it in the box layout to respect
    aspect in elm boxes. note - this probably needs doing in other
    containers too like table...
    
    Revert "elm icon/image efl ui image - respect aspect hints at all if set"
---
 src/lib/elementary/efl_ui_image.c | 29 +----------------------------
 src/lib/elementary/els_box.c      | 30 +++++++++++++++++++-----------
 2 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index 47bd561138..1ba7fe5037 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -764,11 +764,8 @@ _key_action_activate(Evas_Object *obj, const char *params 
EINA_UNUSED)
 static void
 _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
 {
-   Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1, asp_w = 0, asp_h = 0;
-   Evas_Coord w, h;
+   Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
    Eina_Size2D sz;
-   Eina_Rect geom;
-   Evas_Aspect_Control asp = EVAS_ASPECT_CONTROL_NONE;
    double ts;
 
    sd->in_calc = EINA_TRUE;
@@ -781,13 +778,10 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, 
Efl_Ui_Image_Data *sd)
    ts = sd->scale;
    sd->scale = 1.0;
    sz = efl_gfx_view_size_get(obj);
-   geom = efl_gfx_entity_geometry_get(obj);
 
    sd->scale = ts;
    evas_object_size_hint_combined_min_get(obj, &minw, &minh);
 
-   evas_object_size_hint_aspect_get(obj, &asp, &asp_w, &asp_h);
-
    if (sd->no_scale)
      {
         maxw = minw = sz.w;
@@ -816,27 +810,6 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, 
Efl_Ui_Image_Data *sd)
              maxh = sz.h * sd->scale;
           }
      }
-   switch (asp)
-     {
-      case EVAS_ASPECT_CONTROL_HORIZONTAL:
-        if (asp_w > 0) h = (geom.w * asp_h) / asp_w;
-        if (h > minh) minh = h;
-        break;
-      case EVAS_ASPECT_CONTROL_VERTICAL:
-        if (asp_h > 0) w = (geom.h * asp_w) / asp_h;
-        if (w > minw) minw = w;
-        break;
-      case EVAS_ASPECT_CONTROL_BOTH:
-        if (asp_w > 0) h = (geom.w * asp_h) / asp_w;
-        if (h > minh) minh = h;
-        if (asp_h > 0) w = (geom.h * asp_w) / asp_h;
-        if (w > minw) minw = w;
-        break;
-      case EVAS_ASPECT_CONTROL_NEITHER:
-      case EVAS_ASPECT_CONTROL_NONE:
-      default:
-        break;
-     }
 
    efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh));
    efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh));
diff --git a/src/lib/elementary/els_box.c b/src/lib/elementary/els_box.c
index b870c9deeb..9d7b4644bf 100644
--- a/src/lib/elementary/els_box.c
+++ b/src/lib/elementary/els_box.c
@@ -329,17 +329,22 @@ _smart_extents_calculate(Evas_Object *box, 
Evas_Object_Box_Data *priv, int w, in
    else
      {
         /* returns true if at least one item has aspect hint */
-        if (_smart_extents_non_homogeneous_calc(priv, w, h, &minw, &minh, 
&maxw, &maxh, expand, horizontal, 0))
+        if (_smart_extents_non_homogeneous_calc(priv, w, h, &minw, &minh,
+                                                &maxw, &maxh, expand,
+                                                horizontal, EINA_FALSE))
           {
              /* aspect can only be accurately calculated after the full 
(non-aspected) min size of the box has
               * been calculated due to the use of this min size during aspect 
calculations
               */
              int aminw = minw;
              int aminh = minh;
-             _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, 
horizontal);
-             _smart_extents_non_homogeneous_calc(priv, w, h, &aminw, &aminh, 
&maxw, &maxh, expand, horizontal, 1);
-             if (horizontal) minh = aminh;
-             else minw = aminw;
+             _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh,
+                                         horizontal);
+             _smart_extents_non_homogeneous_calc(priv, w, h, &aminw, &aminh,
+                                                 &maxw, &maxh, expand,
+                                                 horizontal, EINA_TRUE);
+             if (horizontal) minw = aminw;
+             else minh = aminh;
           }
      }
    _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, horizontal);
@@ -454,11 +459,13 @@ _els_box_layout(Evas_Object *o, Evas_Object_Box_Data 
*priv, Eina_Bool horizontal
                }
              hh = h;
 
-             _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh, ww, 
hh, aspect, asx / (double)asy);
-             /* non-homogeneous, aspected, expending items are calculated 
based on object size
-              * during extents calc, so use this for positioning during layout 
as well
+             _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh,
+                                     ww, hh, aspect, asx / (double)asy);
+             /* non-homogeneous, aspected, expending items are calculated
+              * based on object size during extents calc, so use this for
+              * positioning during layout as well
               */
-             if (xw && aspect && (!homogeneous))
+             if (aspect && (!homogeneous))
                ww = ow;
              evas_object_move(obj,
                               ((!rtl) ? (xx + pad_l) : (x + (w - (xx - x) - 
ww) + pad_r))
@@ -489,8 +496,9 @@ _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, 
Eina_Bool horizontal
                }
              ww = w;
 
-             _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh, ww, 
hh, aspect, asx / (double)asy);
-             if (xh && aspect && (!homogeneous))
+             _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh,
+                                     ww, hh, aspect, asx / (double)asy);
+             if (aspect && (!homogeneous))
                hh = oh;
              evas_object_move(obj,
                               xx + (Evas_Coord)(((double)(ww - ow)) * ax) + 
pad_l,

-- 


Reply via email to