elm_box: Fix support of aspect hints

Test scenario: ephoto without a recent patch (47fe2b9ab03c151b0f4).
Before any further explanation, ephoto was definitely misusing the
aspect API here. A label most definitely shouldn't be sized based on an
aspect ratio, that's just crazy (you really want to make it as tall as
it's wide?)

If a box has an aspected item, it needs to run its min calc loop twice:
 1. Once to determine the "true" min size in the direction of the box
    (ie.  in X in case of a horizontal box), and
 2. Once more in order to apply the aspect ratio to aspected items and
    augment the perpendicular min size (ie. Y for horizontal).

After that, it can go and layout the items based on the available size.

As we may guess from the above description (1) determines min W and
(2) determines min H (in horizontal mode).

BUT, there were two problems:
 - The wrong item min size was used inside the 2nd loop (the code was
   not symmetrical between horizontal and vertical modes). These are the
   changes in _smart_extents_non_homogeneous_calc.
 - The box min length was based on the actual size of aspected items,
   rather than their min size. This goes against the observation. These
   are the changes in _smart_extents_calculate.

Ref T5888

@fix
This commit is contained in:
Jean-Philippe Andre 2017-08-21 18:25:39 +09:00
parent 7270a98d8c
commit 85d04a74d4
1 changed files with 7 additions and 3 deletions

View File

@ -184,7 +184,7 @@ _smart_extents_non_homogeneous_calc(Evas_Object_Box_Data *priv, int w, int h, in
if (horizontal)
{
/* use min size to start */
ww = *rw;
ww = mnw;
if ((expand > 0) && (wx > 0.0))
{
/* add remaining container value after applying weight hint */
@ -195,7 +195,7 @@ _smart_extents_non_homogeneous_calc(Evas_Object_Box_Data *priv, int w, int h, in
}
else
{
hh = *rh;
hh = mnh;
if ((expand > 0) && (wy > 0.0))
{
oh = ((h - cminh) * wy) / expand;
@ -334,8 +334,12 @@ _smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int w, in
/* 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, &minw, &minh, &maxw, &maxh, expand, horizontal, 1);
_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);