hmm - make min size calculation mroe accurate and handle corner cases...

SVN revision: 16760
This commit is contained in:
Carsten Haitzler 2005-09-19 06:51:49 +00:00
parent ab19b67038
commit 2c69e593a8
5 changed files with 95 additions and 6 deletions

View File

@ -42,6 +42,7 @@ static void st_collections_group_parts_part_description_inherit(void);
static void st_collections_group_parts_part_description_state(void);
static void st_collections_group_parts_part_description_visible(void);
static void st_collections_group_parts_part_description_align(void);
static void st_collections_group_parts_part_description_fixed(void);
static void st_collections_group_parts_part_description_min(void);
static void st_collections_group_parts_part_description_max(void);
static void st_collections_group_parts_part_description_step(void);
@ -149,6 +150,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.description.state", st_collections_group_parts_part_description_state},
{"collections.group.parts.part.description.visible", st_collections_group_parts_part_description_visible},
{"collections.group.parts.part.description.align", st_collections_group_parts_part_description_align},
{"collections.group.parts.part.description.fixed", st_collections_group_parts_part_description_fixed},
{"collections.group.parts.part.description.min", st_collections_group_parts_part_description_min},
{"collections.group.parts.part.description.max", st_collections_group_parts_part_description_max},
{"collections.group.parts.part.description.step", st_collections_group_parts_part_description_step},
@ -858,6 +860,8 @@ ob_collections_group_parts_part_description(void)
ed->align.y = 0.5;
ed->min.w = 0;
ed->min.h = 0;
ed->fixed.w = 0;
ed->fixed.h = 0;
ed->max.w = -1;
ed->max.h = -1;
ed->rel1.relative_x = 0.0;
@ -1082,6 +1086,23 @@ st_collections_group_parts_part_description_align(void)
ed->align.y = parse_float_range(1, 0.0, 1.0);
}
static void
st_collections_group_parts_part_description_fixed(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
Edje_Part_Description *ed;
check_arg_count(2);
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
ed->fixed.w = parse_float_range(0, 0, 1);
ed->fixed.h = parse_float_range(1, 0, 1);
}
static void
st_collections_group_parts_part_description_min(void)
{

View File

@ -344,6 +344,21 @@ main(int argc, char **argv)
evas_object_show(o);
o_edje = o;
/*
{
Evas_Coord mw, mh;
printf("---EMIT SIGNALS\n");
edje_object_signal_emit(o_edje, "icon_visible", "");
printf("---PROCESS SIGNALS\n");
edje_object_message_signal_process(o_edje);
printf("---MIN CALC\n");
edje_object_size_min_calc(o_edje, &mw, &mh);
printf("---MIN %ix%i\n", mw, mh);
evas_object_resize(o_edje, mw, mh);
}
*/
ecore_evas_callback_resize_set(ee, resize_cb);
ecore_evas_show(ee);

View File

@ -173,6 +173,8 @@ _edje_edd_setup(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "visible", visible, EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "align.x", align.x, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "align.y", align.y, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fixed.w", fixed.w, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fixed.h", fixed.h, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "min.w", min.w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "min.h", min.h, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "max.w", max.w, EET_T_INT);

View File

@ -354,6 +354,10 @@ struct _Edje_Part_Description
double x, y; /* 0 <-> 1.0 alignment within allocated space */
} align;
struct {
unsigned char w, h; /* width or height si fixed in side (cannot expand with edje object size) */
} fixed;
struct {
int w, h; /* min & max size, 0 = none */
} min, max;

View File

@ -820,6 +820,8 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
Evas_Coord pw, ph;
int maxw, maxh;
int ok;
int reset_maxwh;
Edje_Real_Part *pep = NULL;
ed = _edje_fetch(obj);
if ((!ed) || (!ed->collection))
@ -828,9 +830,12 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
if (minh) *minh = 0;
return;
}
reset_maxwh = 1;
ed->calc_only = 1;
pw = ed->w;
ph = ed->h;
again:
ed->w = 0;
ed->h = 0;
@ -844,7 +849,14 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
ok = 0;
ed->dirty = 1;
// printf("...CALC %s\n", ed->part);
_edje_recalc(ed);
if (reset_maxwh)
{
maxw = 0;
maxh = 0;
}
pep = NULL;
for (l = ed->parts; l; l = l->next)
{
Edje_Real_Part *ep;
@ -853,15 +865,31 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
ep = l->data;
w = ep->w - ep->req.w;
h = ep->h - ep->req.h;
if (w > maxw)
// printf("EP: %s size %ix%i, req %ix%i, dif %ix%i, max %ix%i\n",
// ep->part->name,
// ep->w, ep->h,
// ep->req.w, ep->req.h,
// w, h,
// maxw, maxh);
if (!((ep->chosen_description) &&
(ep->chosen_description->fixed.w)))
{
maxw = w;
ok = 1;
if (w > maxw)
{
maxw = w;
ok = 1;
pep = ep;
}
}
if (h > maxh)
if (!((ep->chosen_description) &&
(ep->chosen_description->fixed.h)))
{
maxh = h;
ok = 1;
if (h > maxh)
{
maxh = h;
ok = 1;
pep = ep;
}
}
}
if (ok)
@ -869,6 +897,25 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
ed->w += maxw;
ed->h += maxh;
}
if ((ed->w > 8000) || (ed->h > 8000))
{
printf("EDJE ERROR: An element in file %s, group %s has a non expandable\n"
"part not marked as fixed size in one dimension. This needs\n"
"to be fixed in the source .edc by adding:\n"
" fixed: 1 1;\n"
"to the part that cannot expand in size if the edje object does.\n",
ed->path, ed->part);
if (pep)
printf("The part suspected causing this problem is:\n"
" part: \"%s\"\n",
pep->part->name);
printf("Will recalc min size not allowing broken parts to affect the result.\n");
if (reset_maxwh)
{
reset_maxwh = 0;
goto again;
}
}
}
ed->min.w = ed->w;
ed->min.h = ed->h;