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)
{
{
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))
{
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);
}
}
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; \
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);
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
{
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;
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);
{
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);
+
+ 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;
- EINA_LIST_FOREACH(img_from->image.tween_list, l, i)
+ 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:
{
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)
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);
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));
}
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;
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;
}
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;
}
}
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: \
{ \
break; \
}
- COPY_OLD(IMAGE, Image, image);
COPY_OLD(TEXT, Text, text);
COPY_OLD(TEXTBLOCK, Text, text);
COPY_OLD(BOX, Box, box);
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);
}
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;
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;
+ }
}
}
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)
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:
{
if (external->external_params)
_edje_external_params_free(external->external_params, free_strings);
+ break;
}
case EDJE_PART_TYPE_TEXT:
case EDJE_PART_TYPE_TEXTBLOCK:
if (text->text.style) eina_stringshare_del(text->text.style);
if (text->text.font) eina_stringshare_del(text->text.font);
}
+ break;
}
}
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;
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