2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include "elm_priv.h"
|
2011-10-06 22:56:07 -07:00
|
|
|
#include "els_box.h"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* calculate an object's aspected size */
|
|
|
|
static Eina_Bool
|
|
|
|
_box_object_aspect_calc(int *ow, int *oh, int minw, int minh, int maxw, int maxh,
|
|
|
|
int fw /* fill width */, int fh /* fill height */,
|
|
|
|
int ww /* "maximum" width */, int hh /* "maximum" height */,
|
|
|
|
Evas_Aspect_Control aspect, double ratio)
|
|
|
|
{
|
2016-02-12 02:50:55 -08:00
|
|
|
*ow = minw;
|
|
|
|
*oh = minh;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
|
|
|
|
switch (aspect)
|
|
|
|
{
|
|
|
|
case EVAS_ASPECT_CONTROL_HORIZONTAL:
|
|
|
|
/* set height using aspect+width */
|
|
|
|
if (fw) *ow = ww;
|
|
|
|
if ((maxw >= 0) && (maxw < *ow)) *ow = maxw;
|
|
|
|
*oh = ratio / *ow;
|
|
|
|
/* apply min/max */
|
|
|
|
if ((maxh >= 0) && (maxh < *oh)) *oh = maxh;
|
|
|
|
else if ((minh >= 0) && (minh > *oh)) *oh = minh;
|
|
|
|
else return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
case EVAS_ASPECT_CONTROL_VERTICAL:
|
|
|
|
/* set width using aspect+height */
|
|
|
|
if (fh) *oh = hh;
|
|
|
|
if ((maxh >= 0) && (maxh < *oh)) *oh = maxh;
|
|
|
|
*ow = ratio * *oh;
|
|
|
|
/* apply min/max */
|
|
|
|
if ((maxw >= 0) && (maxw < *ow)) *ow = maxw;
|
|
|
|
else if ((minw >= 0) && (minw > *ow)) *ow = minw;
|
|
|
|
else return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
case EVAS_ASPECT_CONTROL_BOTH:
|
|
|
|
/* try width then height */
|
|
|
|
|
|
|
|
/* set width using aspect+height */
|
|
|
|
if (fh) *oh = hh;
|
|
|
|
if ((maxh >= 0) && (maxh < *oh)) *oh = maxh;
|
|
|
|
*ow = ratio * *oh;
|
|
|
|
/* apply min/max */
|
|
|
|
if ((maxw >= 0) && (maxw < *ow)) *ow = maxw;
|
|
|
|
else if ((minw >= 0) && (minw > *ow)) *ow = minw;
|
|
|
|
else return EINA_TRUE;
|
|
|
|
/* set height using aspect+width */
|
|
|
|
if (fw) *ow = ww;
|
|
|
|
if ((maxw >= 0) && (maxw < *ow)) *ow = maxw;
|
|
|
|
*oh = ratio / *ow;
|
|
|
|
/* apply min/max */
|
|
|
|
if ((maxh >= 0) && (maxh < *oh)) *oh = maxh;
|
|
|
|
else if ((minh >= 0) && (minh > *oh)) *oh = minh;
|
|
|
|
else return EINA_TRUE;
|
|
|
|
/* fallthrough on BOTH failure */
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
/* on failure or ASPECT_NONE, use default size calc:
|
|
|
|
* - apply fill
|
|
|
|
* - apply max size constraints
|
|
|
|
*/
|
|
|
|
if (fw) *ow = ww;
|
|
|
|
if ((maxw >= 0) && (maxw < *ow)) *ow = maxw;
|
|
|
|
if (fh) *oh = hh;
|
|
|
|
if ((maxh >= 0) && (maxh < *oh)) *oh = maxh;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add box w/h padding to min/max totals */
|
|
|
|
static void
|
|
|
|
_smart_extents_padding_calc(Evas_Object_Box_Data *priv, int *minw, int *minh, int *maxw, int *maxh, Eina_Bool horizontal)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
if ((*maxw >= 0) && (*minw > *maxw)) *maxw = *minw;
|
|
|
|
if ((*maxh >= 0) && (*minh > *maxh)) *maxh = *minh;
|
|
|
|
c = eina_list_count(priv->children) - 1;
|
|
|
|
if (c > 0)
|
|
|
|
{
|
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
*minw += priv->pad.h * c;
|
|
|
|
if (*maxw != -1) *maxw += priv->pad.h * c;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*minh += priv->pad.v * c;
|
|
|
|
if (*maxh != -1) *maxh += priv->pad.v * c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate extents for non-homogeneous layout;
|
|
|
|
* called twice if aspected items exist
|
|
|
|
*/
|
|
|
|
static Eina_Bool
|
|
|
|
_smart_extents_non_homogeneous_calc(Evas_Object_Box_Data *priv, int w, int h, int *minw, int *minh, int *maxw, int *maxh, double expand, Eina_Bool horizontal, Eina_Bool do_aspect)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
|
|
|
Evas_Object_Box_Option *opt;
|
|
|
|
int mnw, mnh, mxw, mxh, cminw, cminh;
|
2016-02-12 11:45:20 -08:00
|
|
|
Evas_Coord pad_l, pad_r, pad_t, pad_b;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
Evas_Coord *rw, *rh, *rxw, *rxh, *rminw, *rminh, *rmaxw, *rmaxh;
|
|
|
|
Eina_Bool max = EINA_TRUE, asp = EINA_FALSE;
|
|
|
|
|
|
|
|
cminw = *minw, cminh = *minh;
|
2016-01-02 08:43:44 -08:00
|
|
|
*minw = *minh = 0;
|
|
|
|
*maxw = *maxh = -1;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* use pointers to values to simplify horizontal vs vertical calculations into
|
|
|
|
* a single algorithm for both orientations
|
|
|
|
*/
|
|
|
|
if (!horizontal)
|
|
|
|
{
|
|
|
|
rw = &mnw;
|
|
|
|
rh = &mnh;
|
|
|
|
rxw = &mxw;
|
|
|
|
rxh = &mxh;
|
|
|
|
rminw = minw;
|
|
|
|
rminh = minh;
|
|
|
|
rmaxw = maxw;
|
|
|
|
rmaxh = maxh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw = &mnh;
|
|
|
|
rh = &mnw;
|
|
|
|
rxw = &mxh;
|
|
|
|
rxh = &mxw;
|
|
|
|
rminw = minh;
|
|
|
|
rminh = minw;
|
|
|
|
rmaxw = maxh;
|
|
|
|
rmaxh = maxw;
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
|
|
|
{
|
|
|
|
Evas_Aspect_Control aspect = EVAS_ASPECT_CONTROL_NONE;
|
|
|
|
int asx, asy, ow = 0, oh = 0, *rrw, *rrh;
|
|
|
|
|
|
|
|
if (!horizontal)
|
|
|
|
rrw = &ow, rrh = &oh;
|
|
|
|
else
|
|
|
|
rrw = &oh, rrh = &ow;
|
|
|
|
|
2016-02-12 11:45:20 -08:00
|
|
|
evas_object_size_hint_padding_get(opt->obj, &pad_l, &pad_r, &pad_t, &pad_b);
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
|
2016-02-12 11:45:20 -08:00
|
|
|
mnw += pad_l + pad_r;
|
|
|
|
mnh += pad_t + pad_b;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
if (*rminw < *rw) *rminw = *rw;
|
|
|
|
*rminh += *rh;
|
|
|
|
|
|
|
|
evas_object_size_hint_aspect_get(opt->obj, &aspect, &asx, &asy);
|
|
|
|
if (aspect && ((asx < 1) || (asy < 1)))
|
|
|
|
{
|
|
|
|
aspect = EVAS_ASPECT_CONTROL_NONE;
|
|
|
|
ERR("Invalid aspect specified!");
|
|
|
|
}
|
|
|
|
/* return whether any aspected items exist */
|
|
|
|
asp |= !!aspect;
|
|
|
|
|
|
|
|
evas_object_size_hint_max_get(opt->obj, &mxw, &mxh);
|
2016-02-12 11:45:20 -08:00
|
|
|
if (mxw >= 0) mxw += pad_l + pad_r;
|
|
|
|
if (mxh >= 0) mxh += pad_t + pad_b;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
if (*rxh < 0)
|
|
|
|
{
|
|
|
|
*rmaxh = -1;
|
|
|
|
max = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (max) *rmaxh += *rxh;
|
|
|
|
|
|
|
|
if (do_aspect && aspect)
|
|
|
|
{
|
2016-01-07 11:58:23 -08:00
|
|
|
int ww, hh, fw = 0, fh = 0;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
double wx, wy, ax, ay;
|
|
|
|
|
|
|
|
evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
|
|
|
|
|
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
/* use min size to start */
|
|
|
|
ww = *rw;
|
|
|
|
if ((expand > 0) && (wx > 0.0))
|
|
|
|
{
|
|
|
|
/* add remaining container value after applying weight hint */
|
|
|
|
ow = ((w - cminw) * wx) / expand;
|
|
|
|
ww += ow;
|
|
|
|
}
|
|
|
|
hh = h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hh = *rh;
|
|
|
|
if ((expand > 0) && (wy > 0.0))
|
|
|
|
{
|
|
|
|
oh = ((h - cminh) * wy) / expand;
|
|
|
|
hh += oh;
|
|
|
|
}
|
|
|
|
ww = w;
|
|
|
|
}
|
|
|
|
evas_object_size_hint_align_get(opt->obj, &ax, &ay);
|
|
|
|
if (ax < 0) fw = 1;
|
|
|
|
if (ay < 0) fh = 1;
|
|
|
|
|
|
|
|
/* if aspecting succeeds, use aspected size for min size */
|
2016-01-13 12:37:50 -08:00
|
|
|
if (_box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh,
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
fw, fh, ww, hh, aspect, asx / (double)asy))
|
2016-01-13 12:37:50 -08:00
|
|
|
{
|
|
|
|
*rminh += (*rrh - *rh);
|
|
|
|
if (*rminw < *rrw) *rminw = *rrw;
|
|
|
|
}
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
}
|
|
|
|
if (*rxw >= 0)
|
|
|
|
{
|
|
|
|
if (*rmaxw == -1) *rmaxw = *rxw;
|
|
|
|
else if (*rmaxw > *rxw) *rmaxw = *rxw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return asp;
|
|
|
|
}
|
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
static void
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
_smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int w, int h, double expand, Eina_Bool horizontal, Eina_Bool homogeneous)
|
2009-02-25 11:50:45 -08:00
|
|
|
{
|
2011-08-29 05:52:41 -07:00
|
|
|
Evas_Coord minw, minh, mnw, mnh, maxw, maxh;
|
2016-02-12 11:45:20 -08:00
|
|
|
Evas_Coord pad_l, pad_r, pad_t, pad_b;
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2009-10-02 12:22:40 -07:00
|
|
|
Evas_Object_Box_Option *opt;
|
2011-05-26 02:22:43 -07:00
|
|
|
int c;
|
2009-09-25 20:36:29 -07:00
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
minw = 0;
|
|
|
|
minh = 0;
|
2011-08-29 05:52:41 -07:00
|
|
|
maxw = -1;
|
|
|
|
maxh = -1;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
c = eina_list_count(priv->children);
|
2009-10-02 12:22:40 -07:00
|
|
|
if (homogeneous)
|
2009-05-08 04:27:32 -07:00
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
Evas_Aspect_Control paspect = -1; //causes overflow
|
|
|
|
int pasx = -1, pasy = -1;
|
|
|
|
|
2011-04-01 04:20:18 -07:00
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
Evas_Aspect_Control aspect = EVAS_ASPECT_CONTROL_NONE;
|
|
|
|
int asx, asy, ow = 0, oh = 0, fw, fh, ww, hh;
|
|
|
|
double ax, ay;
|
|
|
|
|
|
|
|
evas_object_size_hint_align_get(opt->obj, &ax, &ay);
|
|
|
|
if (ax < 0) fw = 1;
|
|
|
|
if (ay < 0) fh = 1;
|
|
|
|
|
2016-02-12 11:45:20 -08:00
|
|
|
evas_object_size_hint_padding_get(opt->obj, &pad_l, &pad_r, &pad_t, &pad_b);
|
2011-04-01 04:20:18 -07:00
|
|
|
evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
|
2016-02-12 11:45:20 -08:00
|
|
|
mnw += pad_l + pad_r;
|
|
|
|
mnh += pad_t + pad_b;
|
2011-04-01 04:20:18 -07:00
|
|
|
if (minh < mnh) minh = mnh;
|
|
|
|
if (minw < mnw) minw = mnw;
|
2011-09-01 21:09:17 -07:00
|
|
|
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
evas_object_size_hint_aspect_get(opt->obj, &aspect, &asx, &asy);
|
|
|
|
if (aspect && ((asx < 1) || (asy < 1)))
|
|
|
|
{
|
|
|
|
aspect = EVAS_ASPECT_CONTROL_NONE;
|
|
|
|
ERR("Invalid aspect specified!");
|
|
|
|
}
|
2016-04-05 23:16:37 -07:00
|
|
|
if ((unsigned) paspect < 100) //value starts overflowed as UINT_MAX
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
{
|
|
|
|
/* this condition can cause some items to not be the same size,
|
|
|
|
* resulting in a non-homogeneous homogeneous layout
|
|
|
|
*/
|
|
|
|
if ((aspect != paspect) || (asx != pasx) || (asy != pasy))
|
|
|
|
ERR("Homogeneous box with differently-aspected items!");
|
|
|
|
}
|
|
|
|
|
2011-08-29 05:52:41 -07:00
|
|
|
evas_object_size_hint_max_get(opt->obj, &mnw, &mnh);
|
|
|
|
if (mnh >= 0)
|
|
|
|
{
|
2016-02-12 11:45:20 -08:00
|
|
|
if (mnh >= 0) mnh += pad_t + pad_b;
|
2013-01-08 20:57:54 -08:00
|
|
|
if (maxh == -1) maxh = mnh;
|
2011-08-29 05:52:41 -07:00
|
|
|
else if (maxh > mnh) maxh = mnh;
|
|
|
|
}
|
|
|
|
if (mnw >= 0)
|
|
|
|
{
|
2016-02-12 11:45:20 -08:00
|
|
|
if (mnw >= 0) mnw += pad_l + pad_r;
|
2011-08-29 05:52:41 -07:00
|
|
|
if (maxw == -1) maxw = mnw;
|
|
|
|
else if (maxw > mnw) maxw = mnw;
|
|
|
|
}
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
if (aspect)
|
|
|
|
{
|
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
ww = ((w - (c - 1) * priv->pad.h) / c);
|
|
|
|
hh = h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hh = ((h - (c - 1) * priv->pad.v) / c);
|
|
|
|
ww = w;
|
|
|
|
}
|
|
|
|
if (_box_object_aspect_calc(&ow, &oh, mnw, mnh, maxw, maxh,
|
|
|
|
fw, fh, ww, hh, aspect, asx / (double)asy))
|
|
|
|
{
|
|
|
|
if ((oh > mnh) && (minh < oh)) minh = oh;
|
|
|
|
if ((ow > mnw) && (minw < ow)) minw = ow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
paspect = aspect;
|
|
|
|
pasx = asx, pasy = asy;
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
|
|
|
if (horizontal)
|
2011-08-29 05:52:41 -07:00
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
minw *= c;
|
2011-08-29 05:52:41 -07:00
|
|
|
if (maxw != -1)
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
maxw *= c;
|
2011-08-29 05:52:41 -07:00
|
|
|
else maxw = -1;
|
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
else
|
2011-08-29 05:52:41 -07:00
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
minh *= c;
|
2011-08-29 05:52:41 -07:00
|
|
|
if (maxh != -1)
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
maxh *= c;
|
2011-08-29 05:52:41 -07:00
|
|
|
else maxh = -1;
|
|
|
|
}
|
2009-05-08 04:27:32 -07:00
|
|
|
}
|
2009-10-02 12:22:40 -07:00
|
|
|
else
|
2009-09-21 11:09:51 -07:00
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* 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))
|
2014-01-12 22:47:04 -08:00
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
_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);
|
2011-08-29 05:52:41 -07:00
|
|
|
}
|
2011-05-26 02:22:43 -07:00
|
|
|
}
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
_smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, horizontal);
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_size_hint_min_set(box, minw, minh);
|
2011-08-29 05:52:41 -07:00
|
|
|
evas_object_size_hint_max_set(box, maxw, maxh);
|
2009-09-21 11:09:51 -07:00
|
|
|
}
|
|
|
|
|
2009-09-11 06:43:02 -07:00
|
|
|
void
|
2014-01-13 10:26:16 -08:00
|
|
|
_els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, Eina_Bool horizontal, Eina_Bool homogeneous, Eina_Bool rtl)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h, xx, yy;
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
|
|
|
Evas_Object *obj;
|
2012-04-24 04:09:31 -07:00
|
|
|
Evas_Coord minw, minh;
|
2011-10-18 03:00:02 -07:00
|
|
|
int count = 0;
|
|
|
|
double expand = 0.0;
|
2009-09-25 20:36:29 -07:00
|
|
|
double ax, ay;
|
2014-01-12 22:47:04 -08:00
|
|
|
double wx, wy;
|
|
|
|
double *rwy;
|
2009-10-02 12:22:40 -07:00
|
|
|
Evas_Object_Box_Option *opt;
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* accummulate expand after switched x and y for horizontal mode */
|
|
|
|
if (!horizontal)
|
|
|
|
rwy = &wy;
|
|
|
|
else
|
|
|
|
rwy = &wx;
|
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
|
|
|
|
if (*rwy > 0.0) expand += *rwy;
|
|
|
|
}
|
|
|
|
_smart_extents_calculate(o, priv, w, h, expand, horizontal, homogeneous);
|
2016-01-08 12:03:38 -08:00
|
|
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_size_hint_min_get(o, &minw, &minh);
|
2014-12-31 12:30:57 -08:00
|
|
|
evas_object_box_align_get(o, &ax, &ay);
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* if object size is less than min, apply align to trigger viewporting */
|
2014-12-31 12:30:57 -08:00
|
|
|
if (w < minw)
|
|
|
|
{
|
|
|
|
x = x + ((w - minw) * (1.0 - ax));
|
|
|
|
w = minw;
|
|
|
|
}
|
|
|
|
if (h < minh)
|
|
|
|
{
|
|
|
|
y = y + ((h - minh) * (1.0 - ay));
|
|
|
|
h = minh;
|
|
|
|
}
|
2009-10-02 12:22:40 -07:00
|
|
|
count = eina_list_count(priv->children);
|
2011-05-29 19:31:21 -07:00
|
|
|
|
2010-10-22 14:41:27 -07:00
|
|
|
if (!expand)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2011-08-09 04:54:36 -07:00
|
|
|
if (rtl) ax = 1.0 - ax;
|
2011-04-01 04:20:18 -07:00
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
x += (double)(w - minw) * ax;
|
|
|
|
w = minw;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
y += (double)(h - minh) * ay;
|
|
|
|
h = minh;
|
|
|
|
}
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
xx = x;
|
|
|
|
yy = y;
|
2009-10-02 12:22:40 -07:00
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2009-09-25 20:36:29 -07:00
|
|
|
Evas_Coord mnw, mnh, mxw, mxh;
|
2016-02-12 11:45:20 -08:00
|
|
|
Evas_Coord pad_l, pad_r, pad_t, pad_b;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
int fw, fh, xw, xh;//fillw, fillw, expandw, expandh
|
|
|
|
Evas_Aspect_Control aspect = EVAS_ASPECT_CONTROL_NONE;
|
|
|
|
int asx, asy;
|
2009-09-25 20:36:29 -07:00
|
|
|
|
2011-04-01 04:20:18 -07:00
|
|
|
obj = opt->obj;
|
|
|
|
evas_object_size_hint_align_get(obj, &ax, &ay);
|
|
|
|
evas_object_size_hint_weight_get(obj, &wx, &wy);
|
2016-02-12 11:45:20 -08:00
|
|
|
evas_object_size_hint_padding_get(obj, &pad_l, &pad_r, &pad_t, &pad_b);
|
2011-04-01 04:20:18 -07:00
|
|
|
evas_object_size_hint_min_get(obj, &mnw, &mnh);
|
2016-02-12 11:45:20 -08:00
|
|
|
mnw += pad_l + pad_r;
|
|
|
|
mnh += pad_t + pad_b;
|
2011-04-01 04:20:18 -07:00
|
|
|
evas_object_size_hint_max_get(obj, &mxw, &mxh);
|
2016-02-12 11:45:20 -08:00
|
|
|
if (mxw >= 0) mxw += pad_l + pad_r;
|
|
|
|
if (mxh >= 0) mxh += pad_t + pad_b;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
evas_object_size_hint_aspect_get(obj, &aspect, &asx, &asy);
|
|
|
|
if (aspect && ((asx < 1) || (asy < 1)))
|
|
|
|
aspect = EVAS_ASPECT_CONTROL_NONE;
|
2011-04-01 04:20:18 -07:00
|
|
|
fw = fh = 0;
|
|
|
|
xw = xh = 0;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
/* align(-1) means fill to maximum apportioned size */
|
2011-04-01 04:20:18 -07:00
|
|
|
if (ax == -1.0) {fw = 1; ax = 0.5;}
|
|
|
|
if (ay == -1.0) {fh = 1; ay = 0.5;}
|
2011-08-09 04:54:36 -07:00
|
|
|
if (rtl) ax = 1.0 - ax;
|
2011-04-01 04:20:18 -07:00
|
|
|
if (wx > 0.0) xw = 1;
|
|
|
|
if (wy > 0.0) xh = 1;
|
|
|
|
if (horizontal)
|
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
Evas_Coord ww, hh, ow = 0, oh = 0;
|
2011-02-08 04:08:28 -08:00
|
|
|
|
2011-04-01 04:20:18 -07:00
|
|
|
if (homogeneous)
|
|
|
|
{
|
2015-02-23 00:59:52 -08:00
|
|
|
ww = ((w - (count - 1) * priv->pad.h) / (Evas_Coord)count);
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ww = mnw;
|
|
|
|
if ((expand > 0) && (xw))
|
|
|
|
{
|
2011-10-18 03:00:02 -07:00
|
|
|
ow = ((w - minw) * wx) / expand;
|
2011-04-01 04:20:18 -07:00
|
|
|
ww += ow;
|
|
|
|
}
|
|
|
|
}
|
2011-02-08 04:08:28 -08:00
|
|
|
hh = h;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
|
|
|
|
_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))
|
|
|
|
ww = ow;
|
2011-02-08 04:08:28 -08:00
|
|
|
evas_object_move(obj,
|
2016-02-12 11:45:20 -08:00
|
|
|
((!rtl) ? (xx + pad_l) : (x + (w - (xx - x) - ww) + pad_r))
|
2011-04-01 04:20:18 -07:00
|
|
|
+ (Evas_Coord)(((double)(ww - ow)) * ax),
|
2016-02-12 11:45:20 -08:00
|
|
|
yy + (Evas_Coord)(((double)(hh - oh)) * ay) + pad_t);
|
|
|
|
ow -= pad_l + pad_r;
|
|
|
|
oh -= pad_t + pad_b;
|
2011-02-08 04:08:28 -08:00
|
|
|
evas_object_resize(obj, ow, oh);
|
|
|
|
xx += ww;
|
2011-05-26 02:22:43 -07:00
|
|
|
xx += priv->pad.h;
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
Evas_Coord ww, hh, ow = 0, oh = 0;
|
2011-02-08 04:08:28 -08:00
|
|
|
|
2011-04-01 04:20:18 -07:00
|
|
|
if (homogeneous)
|
|
|
|
{
|
2015-02-23 00:59:52 -08:00
|
|
|
hh = ((h - (count - 1) * priv->pad.v) / (Evas_Coord)count);
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hh = mnh;
|
|
|
|
if ((expand > 0) && (xh))
|
|
|
|
{
|
2011-10-18 03:00:02 -07:00
|
|
|
oh = ((h - minh) * wy) / expand;
|
2011-04-01 04:20:18 -07:00
|
|
|
hh += oh;
|
|
|
|
}
|
|
|
|
}
|
2011-02-08 04:08:28 -08:00
|
|
|
ww = w;
|
box: implement aspected item layout
tl;dr: if you haven't used aspect hints on objects packed into boxes,
this commit has no effect on anything you've done
in some cases, using weight+align hints are not sufficient in order to
do a simple box packing of objects.
one example of this is when a box's size is not explicitly determined,
such as if it is packed with EXPAND into another container and contains
only objects with no min size hint, such as images. in this case, the box
will determine that its min size is extremely small, resulting in nearly-hidden
contents inside the box.
using aspect hints, this outcome is noticeably different. the expanded/filled
potential size of a box item is used to calculate the aspected size, and this
size, if it fits within min/max constraints, is then used to calculate the min
size of the box.
as a more concrete example:
* create box with maximum size 100x50
* pack 2x image into box
- set VERTICAL aspect, EXPAND, FILL
have 2x 50x50 images
also I added some docs
@feature
2015-12-31 12:47:51 -08:00
|
|
|
|
|
|
|
_box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh, ww, hh, aspect, asx / (double)asy);
|
|
|
|
if (xh && aspect && (!homogeneous))
|
|
|
|
hh = oh;
|
2011-02-08 04:08:28 -08:00
|
|
|
evas_object_move(obj,
|
2016-02-12 11:45:20 -08:00
|
|
|
xx + (Evas_Coord)(((double)(ww - ow)) * ax) + pad_l,
|
|
|
|
yy + (Evas_Coord)(((double)(hh - oh)) * ay) + pad_t);
|
|
|
|
ow -= pad_l + pad_r;
|
|
|
|
oh -= pad_t + pad_b;
|
2011-02-08 04:08:28 -08:00
|
|
|
evas_object_resize(obj, ow, oh);
|
|
|
|
yy += hh;
|
2011-05-26 02:22:43 -07:00
|
|
|
yy += priv->pad.v;
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
}
|