edje: add min: SOURCE, max: SOURCE.

SVN revision: 67555
This commit is contained in:
Cedric BAIL 2012-01-26 18:24:00 +00:00
parent a45dd94b03
commit a4c58712c3
5 changed files with 87 additions and 12 deletions

View File

@ -307,3 +307,7 @@
2012-01-25 Cedric Bail
* Only store the image used by active group.
2012-01-26 Cedric Bail
* Add min: SOURCE, max: SOURCE.

View File

@ -5,10 +5,11 @@ Changes since Edje 1.1.0:
Additions:
* "recalc" smart callback for object size changes
* "recalc" smart callback for object size changes.
* EDJE_ASPECT_PREFER_SOURCE.
* edje.version() Lua function.
* minmul edc property
* minmul edc property.
* add min: SOURCE and max: SOURCE.
Improvements:
* speedup load time of Edje file.

View File

@ -4633,18 +4633,40 @@ st_collections_group_parts_part_description_fixed(void)
@property
min
@parameters
[width] [height]
[width] [height] or SOURCE
@effect
The minimum size of the state.
When min is defined to SOURCE, it will look at the original
image size and enforce it minimal size to match at least the
original one. The part must be an IMAGE part.
@endproperty
*/
static void
st_collections_group_parts_part_description_min(void)
{
check_arg_count(2);
check_min_arg_count(1);
current_desc->min.w = parse_float_range(0, 0, 0x7fffffff);
current_desc->min.h = parse_float_range(1, 0, 0x7fffffff);
if (is_param(1)) {
current_desc->min.w = parse_float_range(0, 0, 0x7fffffff);
current_desc->min.h = parse_float_range(1, 0, 0x7fffffff);
} else {
Edje_Part_Description_Image *desc;
char *tmp;
tmp = parse_str(0);
if (current_part->type != EDJE_PART_TYPE_IMAGE ||
!tmp || strcmp(tmp, "SOURCE") != 0)
{
ERR("%s: Error. parse error %s:%i. "
"Only IMAGE part can have a min: SOURCE; defined",
progname, file_in, line - 1);
exit(-1);
}
desc = (Edje_Part_Description_Image *) current_desc;
desc->image.min.limit = EINA_TRUE;
}
}
/**
@ -4673,18 +4695,40 @@ st_collections_group_parts_part_description_minmul(void)
@property
max
@parameters
[width] [height]
[width] [height] or SOURCE
@effect
The maximum size of the state. A size of -1.0 means that it will be ignored in one direction.
When max is set to SOURCE, edje will enforce the part to be
not more than the original image size. The part must be an
IMAGE part.
@endproperty
*/
static void
st_collections_group_parts_part_description_max(void)
{
check_arg_count(2);
check_min_arg_count(1);
current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff);
current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff);
if (is_param(1)) {
current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff);
current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff);
} else {
Edje_Part_Description_Image *desc;
char *tmp;
tmp = parse_str(0);
if (current_part->type != EDJE_PART_TYPE_IMAGE ||
!tmp || strcmp(tmp, "SOURCE") != 0)
{
ERR("%s: Error. parse error %s:%i. "
"Only IMAGE part can have a max: SOURCE; defined",
progname, file_in, line - 1);
exit(-1);
}
desc = (Edje_Part_Description_Image *) current_desc;
desc->image.max.limit = EINA_TRUE;
}
}
/**

View File

@ -1746,7 +1746,6 @@ _edje_part_recalc_single_min_max(FLOAT_T sc,
}
}
/* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
if ((ep->swallow_params.max.h <= 0) ||
(ep->swallow_params.max.h == EDJE_INF_MAX_H))
@ -1959,6 +1958,30 @@ _edje_part_recalc_single(Edje *ed,
if (lminh > minh) minh = lminh;
}
}
else if ((ep->part->type == EDJE_PART_TYPE_BOX) &&
((((Edje_Part_Description_Image *)chosen_desc)->image.min.limit) ||
(((Edje_Part_Description_Image *)chosen_desc)->image.max.limit)))
{
Evas_Coord w, h;
/* We only need pos to find the right image that would be displayed */
/* Yes, if someone set aspect preference to SOURCE and also max,min
to SOURCE, it will be under efficient, but who cares at the
moment. */
_edje_real_part_image_set(ed, ep, pos);
evas_object_image_size_get(ep->object, &w, &h);
if (((Edje_Part_Description_Image *)chosen_desc)->image.min.limit)
{
if (w > minw) minw = w;
if (h > minh) minh = h;
}
if (((Edje_Part_Description_Image *)chosen_desc)->image.max.limit)
{
if (w < maxw) maxw = w;
if (h < maxh) maxh = h;
}
}
/* remember what our size is BEFORE we go limit it */
params->req.x = params->x;

View File

@ -839,7 +839,7 @@ struct _Edje_Part_Description_Common
unsigned char have;
FLOAT_T w, h;
} minmul;
Edje_Size min, max;
Edje_Position step; /* size stepping by n pixels, 0 = none */
Edje_Aspect_Prefer aspect;
@ -913,6 +913,9 @@ struct _Edje_Part_Description_Spec_Image
int id; /* the image id to use */
int scale_hint; /* evas scale hint */
Eina_Bool set; /* if image condition it's content */
struct {
Eina_Bool limit; /* should we limit ourself to the size of the image */
} min, max;
Edje_Part_Description_Spec_Border border;
};