* edje: fix some issue during destruction of edje_part_description,

and move tweens to an array.


SVN revision: 50765
This commit is contained in:
Cedric BAIL 2010-08-03 12:58:31 +00:00
parent 465a55b467
commit 74f7480e41
7 changed files with 173 additions and 70 deletions

View File

@ -129,7 +129,7 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl
epdi = (Edje_Part_Description_Image*) epd2;
/* There is an animation if both description are different or if description is an image with tweens */
if (epd2 != NULL && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tween_list)))
if (epd2 != NULL && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count)))
{
if (!ep->param2)
{
@ -1563,7 +1563,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
{
image_count = 2;
if (ep->param2)
image_count += eina_list_count(((Edje_Part_Description_Image*) ep->param2->description)->image.tween_list);
image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count;
image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
FROM_DOUBLE(0.5))));
if (image_num > (image_count - 1))
@ -1589,8 +1589,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
{
Edje_Part_Image_Id *imid;
imid = eina_list_nth(((Edje_Part_Description_Image*) ep->param2->description)->image.tween_list,
image_num - 1);
imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1];
image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
}
}

View File

@ -393,16 +393,50 @@ _edje_description_convert(int type,
switch (type)
{
case EDJE_PART_TYPE_RECTANGLE:
result = eina_mempool_malloc(ce->mp.RECTANGLE, sizeof (Edje_Part_Description_Common));
result = eina_mempool_malloc(ce->mp.RECTANGLE,
sizeof (Edje_Part_Description_Common));
break;
case EDJE_PART_TYPE_SWALLOW:
result = eina_mempool_malloc(ce->mp.SWALLOW, sizeof (Edje_Part_Description_Common));
result = eina_mempool_malloc(ce->mp.SWALLOW,
sizeof (Edje_Part_Description_Common));
break;
case EDJE_PART_TYPE_GROUP:
result = eina_mempool_malloc(ce->mp.GROUP, sizeof (Edje_Part_Description_Common));
result = eina_mempool_malloc(ce->mp.GROUP,
sizeof (Edje_Part_Description_Common));
break;
#define CONVERT_ALLOC_POOL(Short, Type, Name) \
case EDJE_PART_TYPE_IMAGE:
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id *id;
unsigned int i = 0;
img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image));
img->image.tweens_count = eina_list_count(oed->image.tween_list);
img->image.tweens = calloc(img->image.tweens_count,
sizeof (Edje_Part_Image_Id*));
if (!img->image.tweens)
{
eina_mempool_free(ce->mp.IMAGE, img);
return NULL;
}
EINA_LIST_FREE(oed->image.tween_list, id)
img->image.tweens[i++] = id;
img->image.id = oed->image.id;
img->image.scale_hint = oed->image.scale_hint;
img->image.set = oed->image.set;
img->image.border = oed->image.border;
img->image.fill = oed->image.fill;
result = &img->common;
break;
}
#define CONVERT_ALLOC_POOL(Short, Type, Name) \
case EDJE_PART_TYPE_##Short: \
{ \
Edje_Part_Description_##Type *Name; \
@ -413,7 +447,6 @@ _edje_description_convert(int type,
break; \
}
CONVERT_ALLOC_POOL(IMAGE, Image, image);
CONVERT_ALLOC_POOL(TEXT, Text, text);
CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text);
CONVERT_ALLOC_POOL(BOX, Box, box);

View File

@ -7,7 +7,8 @@ typedef struct _Old_Edje_External_Directory Old_Edje_External_Directory;
typedef struct _Old_Edje_Part Old_Edje_Part;
typedef struct _Old_Edje_Part_Collection Old_Edje_Part_Collection;
typedef struct _Old_Edje_Part_Description Old_Edje_Part_Description;
typedef struct _Edje_Data Edje_Data;
typedef struct _Old_Edje_Part_Description_Spec_Image Old_Edje_Part_Description_Spec_Image;
typedef struct _Edje_Data Edje_Data;
struct _Edje_Data
{
@ -108,10 +109,21 @@ struct _Old_Edje_Part
Edje_Part_Api api;
};
struct _Old_Edje_Part_Description_Spec_Image
{
Eina_List *tween_list; /* list of Edje_Part_Image_Id */
int id; /* the image id to use */
int scale_hint; /* evas scale hint */
Eina_Bool set; /* if image condition it's content */
Edje_Part_Description_Spec_Border border;
Edje_Part_Description_Spec_Fill fill;
};
struct _Old_Edje_Part_Description
{
Edje_Part_Description_Common common;
Edje_Part_Description_Spec_Image image;
Old_Edje_Part_Description_Spec_Image image;
Edje_Part_Description_Spec_Text text;
Edje_Part_Description_Spec_Box box;
Edje_Part_Description_Spec_Table table;

View File

@ -2882,9 +2882,8 @@ EAPI Eina_Bool
edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, double val_from, const char *to, double val_to)
{
Edje_Part_Description_Common *pdfrom, *pdto;
Edje_Part_Image_Id *i;
Edje_External_Param *p;
Eina_List *l;
GET_RP_OR_RETURN(EINA_FALSE);
pdfrom = _edje_part_description_find_byname(eed, part, from, val_from);
@ -2923,20 +2922,30 @@ edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, doubl
{
Edje_Part_Description_Image *img_to = (Edje_Part_Description_Image*) pdto;
Edje_Part_Description_Image *img_from = (Edje_Part_Description_Image*) pdfrom;
unsigned int i;
img_to->image = img_from->image;
/* Update pointers. */
EINA_LIST_FREE(img_to->image.tween_list, i)
free(i);
for (i = 0; i < img_to->image.tweens_count; ++i)
free(img_to->image.tweens[i]);
free(img_to->image.tweens);
EINA_LIST_FOREACH(img_from->image.tween_list, l, i)
img_to->image.tweens_count = img_from->image.tweens_count;
img_to->image.tweens = calloc(img_to->image.tweens_count,
sizeof (Edje_Part_Image_Id*));
if (!img_to->image.tweens)
break;
for (i = 0; i < img_to->image.tweens_count; ++i)
{
Edje_Part_Image_Id *new_i;
new_i = _alloc(sizeof(Edje_Part_Image_Id));
/* error checking? What to do if failed? Rollbacgk, abort? */
new_i->id = i->id;
img_to->image.tween_list = eina_list_append(img_to->image.tween_list, new_i);
if (!new_i) continue ;
*new_i = *img_from->image.tweens[i];
img_to->image.tweens[i] = new_i;
}
}
case EDJE_PART_TYPE_TEXT:
@ -2975,6 +2984,7 @@ edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, doubl
{
Edje_Part_Description_External *ext_to = (Edje_Part_Description_External*) pdto;
Edje_Part_Description_External *ext_from = (Edje_Part_Description_External*) pdfrom;
Eina_List *l;
/* XXX: optimize this, most likely we don't need to remove and add */
EINA_LIST_FREE(ext_to->external_params, p)
@ -4221,9 +4231,9 @@ EAPI Eina_List *
edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *state, double value)
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id *i;
Eina_List *tweens = NULL, *l;
Eina_List *tweens = NULL;
const char *name;
unsigned int i;
GET_PD_OR_RETURN(NULL);
@ -4231,9 +4241,9 @@ edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *
img = (Edje_Part_Description_Image *) pd;
EINA_LIST_FOREACH(img->image.tween_list, l, i)
for (i = 0; i < img->image.tweens_count; ++i)
{
name = _edje_image_name_find(obj, i->id);
name = _edje_image_name_find(obj, img->image.tweens[i]->id);
//printf(" t: %s\n", name);
tweens = eina_list_append(tweens, eina_stringshare_add(name));
}
@ -4245,6 +4255,7 @@ EAPI Eina_Bool
edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state, double value, const char *tween)
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id **tmp;
Edje_Part_Image_Id *i;
int id;
@ -4261,7 +4272,16 @@ edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state,
img = (Edje_Part_Description_Image *) pd;
/* add to tween list */
img->image.tween_list = eina_list_append(img->image.tween_list, i);
tmp = realloc(img->image.tweens,
sizeof (Edje_Part_Image_Id*) * img->image.tweens_count);
if (!tmp)
{
free(i);
return EINA_FALSE;
}
tmp[img->image.tweens_count++] = i;
img->image.tweens = tmp;
return EINA_TRUE;
}
@ -4270,24 +4290,27 @@ EAPI Eina_Bool
edje_edit_state_tween_del(Evas_Object *obj, const char *part, const char *state, double value, const char *tween)
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id *i;
Eina_List *l;
int id;
unsigned int i;
int search;
GET_PD_OR_RETURN(EINA_FALSE);
img = (Edje_Part_Description_Image *) pd;
if (!img->image.tween_list) return EINA_FALSE;
if (!img->image.tweens_count) return EINA_FALSE;
id = _edje_image_id_find(obj, tween);
if (id < 0) return EINA_FALSE;
search = _edje_image_id_find(obj, tween);
if (search < 0) return EINA_FALSE;
EINA_LIST_FOREACH(img->image.tween_list, l, i)
for (i = 0; i < img->image.tweens_count; ++i)
{
if (i->id == id)
if (img->image.tweens[i]->id == search)
{
img->image.tween_list = eina_list_remove_list(img->image.tween_list, l);
img->image.tweens_count--;
free(img->image.tweens[i]);
memmove(img->image.tweens + i,
img->image.tweens + i + 1,
sizeof (Edje_Part_Description_Image*) * (img->image.tweens_count - i));
return EINA_TRUE;
}
}
@ -6108,6 +6131,24 @@ _edje_edit_description_save(int type, Edje_Part_Description_Common *desc)
switch (type)
{
case EDJE_PART_TYPE_IMAGE:
{
Edje_Part_Description_Image *img = (Edje_Part_Description_Image*) desc;
unsigned int i;
for (i = 0; i < img->image.tweens_count; ++i)
result->image.tween_list = eina_list_append(result->image.tween_list,
img->image.tweens[i]);
result->image.id = img->image.id;
result->image.scale_hint = img->image.scale_hint;
result->image.set = img->image.set;
result->image.border = img->image.border;
result->image.fill = img->image.fill;
break;
}
#define COPY_OLD(Short, Type, Name) \
case EDJE_PART_TYPE_##Short: \
{ \
@ -6117,7 +6158,6 @@ _edje_edit_description_save(int type, Edje_Part_Description_Common *desc)
break; \
}
COPY_OLD(IMAGE, Image, image);
COPY_OLD(TEXT, Text, text);
COPY_OLD(TEXTBLOCK, Text, text);
COPY_OLD(BOX, Box, box);
@ -6229,7 +6269,10 @@ _edje_edit_collection_save(Eet_File *eetf, Edje_Part_Collection *epc)
EINA_LIST_FREE(oepc.parts, oep)
{
EINA_LIST_FREE(oep->other_desc, oepd)
free(oepd);
{
eina_list_free(oepd->image.tween_list);
free(oepd);
}
eina_list_free(oep->items);
free(oep);
}

View File

@ -1558,8 +1558,6 @@ _edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
Edje *ed = embryo_program_data_get(ep);
Edje_Real_Part *rp;
Edje_Part_Description_Common *parent, *d = NULL;
Edje_Part_Image_Id *iid;
Eina_List *l;
char *name;
float val;
@ -1643,18 +1641,24 @@ _edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
img_desc = (Edje_Part_Description_Image*) d;
parent_img_desc = (Edje_Part_Description_Image*) parent;
img_desc->image.tween_list = NULL;
EINA_LIST_FOREACH(parent_img_desc->image.tween_list, l, iid)
img_desc->image.tweens_count = parent_img_desc->image.tweens_count;
img_desc->image.tweens = calloc(img_desc->image.tweens_count,
sizeof(Edje_Part_Image_Id*));
if (img_desc->image.tweens)
{
Edje_Part_Image_Id *iid_new;
unsigned int i;
iid_new = calloc(1, sizeof(Edje_Part_Image_Id));
if (!iid_new) continue;
for (i = 0; i < parent_img_desc->image.tweens_count; ++i)
{
Edje_Part_Image_Id *iid_new;
iid_new->id = iid->id;
iid_new = calloc(1, sizeof(Edje_Part_Image_Id));
if (!iid_new) continue;
img_desc->image.tween_list = eina_list_append(img_desc->image.tween_list, iid_new);
*iid_new = *parent_img_desc->image.tweens[i];
img_desc->image.tweens[i] = iid_new;
}
}
}

View File

@ -1206,8 +1206,6 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collec
void
_edje_collection_free_part_description_clean(int type, Edje_Part_Description_Common *desc, Eina_Bool free_strings)
{
Edje_Part_Image_Id *pi;
if (free_strings && desc->color_class) eina_stringshare_del(desc->color_class);
switch (type)
@ -1215,11 +1213,14 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com
case EDJE_PART_TYPE_IMAGE:
{
Edje_Part_Description_Image *img;
unsigned int i;
img = (Edje_Part_Description_Image *) desc;
EINA_LIST_FREE(img->image.tween_list, pi)
free(pi);
for (i = 0; i < img->image.tweens_count; ++i)
free(img->image.tweens[i]);
free(img->image.tweens);
break;
}
case EDJE_PART_TYPE_EXTERNAL:
{
@ -1229,6 +1230,7 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com
if (external->external_params)
_edje_external_params_free(external->external_params, free_strings);
break;
}
case EDJE_PART_TYPE_TEXT:
case EDJE_PART_TYPE_TEXTBLOCK:
@ -1243,6 +1245,7 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com
if (text->text.style) eina_stringshare_del(text->text.style);
if (text->text.font) eina_stringshare_del(text->text.font);
}
break;
}
}

View File

@ -237,6 +237,8 @@ typedef struct _Edje_Part_Description_Box Edje_Part_Description_Box;
typedef struct _Edje_Part_Description_Table Edje_Part_Description_Table;
typedef struct _Edje_Part_Description_External Edje_Part_Description_External;
typedef struct _Edje_Part_Description_Common Edje_Part_Description_Common;
typedef struct _Edje_Part_Description_Spec_Fill Edje_Part_Description_Spec_Fill;
typedef struct _Edje_Part_Description_Spec_Border Edje_Part_Description_Spec_Border;
typedef struct _Edje_Part_Description_Spec_Image Edje_Part_Description_Spec_Image;
typedef struct _Edje_Part_Description_Spec_Text Edje_Part_Description_Spec_Text;
typedef struct _Edje_Part_Description_Spec_Box Edje_Part_Description_Spec_Box;
@ -708,33 +710,40 @@ struct _Edje_Part_Description_Common
unsigned char visible; /* is it shown */
};
struct _Edje_Part_Description_Spec_Fill
{
FLOAT_T pos_rel_x; /* fill offset x relative to area */
FLOAT_T rel_x; /* relative size compared to area */
FLOAT_T pos_rel_y; /* fill offset y relative to area */
FLOAT_T rel_y; /* relative size compared to area */
int pos_abs_x; /* fill offset x added to fill offset */
int abs_x; /* size of fill added to relative fill */
int pos_abs_y; /* fill offset y added to fill offset */
int abs_y; /* size of fill added to relative fill */
int angle; /* angle of fill -- currently only used by grads */
int spread; /* spread of fill -- currently only used by grads */
char smooth; /* fill with smooth scaling or not */
unsigned char type; /* fill coordinate from container (SCALE) or from source image (TILE) */
};
struct _Edje_Part_Description_Spec_Border
{
int l, r, t, b; /* border scaling on image fill */
unsigned char no_fill; /* do we fill the center of the image if bordered? 1 == NO!!!! */
unsigned char scale; /* scale image border by same as scale factor */
};
struct _Edje_Part_Description_Spec_Image
{
Eina_List *tween_list; /* list of Edje_Part_Image_Id */
Edje_Part_Image_Id **tweens; /* list of Edje_Part_Image_Id */
unsigned int tweens_count; /* number of tweens */
int id; /* the image id to use */
int scale_hint; /* evas scale hint */
Eina_Bool set; /* if image condition it's content */
struct {
int l, r, t, b; /* border scaling on image fill */
unsigned char no_fill; /* do we fill the center of the image if bordered? 1 == NO!!!! */
unsigned char scale; /* scale image border by same as scale factor */
} border;
struct {
FLOAT_T pos_rel_x; /* fill offset x relative to area */
FLOAT_T rel_x; /* relative size compared to area */
FLOAT_T pos_rel_y; /* fill offset y relative to area */
FLOAT_T rel_y; /* relative size compared to area */
int pos_abs_x; /* fill offset x added to fill offset */
int abs_x; /* size of fill added to relative fill */
int pos_abs_y; /* fill offset y added to fill offset */
int abs_y; /* size of fill added to relative fill */
int angle; /* angle of fill -- currently only used by grads */
int spread; /* spread of fill -- currently only used by grads */
char smooth; /* fill with smooth scaling or not */
unsigned char type; /* fill coordinate from container (SCALE) or from source image (TILE) */
} fill;
Edje_Part_Description_Spec_Border border;
Edje_Part_Description_Spec_Fill fill;
};
struct _Edje_Part_Description_Spec_Text