From 4a18da6fb51830089b53981c5881f36d304cb501 Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 11 Mar 2011 17:46:29 +0000 Subject: [PATCH] edje: add PROXY part. example: collections { group { name: "main"; parts { part { name: "sub1"; type: GROUP; source: "sub1"; description { rel1.relative: 0.5 0.5; rel2.relative: 1.0 1.0; } } part { name: "pro2"; type: PROXY; description { rel1.relative: 0.0 0.5; rel2.relative: 0.5 1.0; source: "sub1"; color: 255 0 0 128; map { on: 1; smooth: 1; rotation { z: 30; } } } } } } group { name: "sub1"; parts { part { name: "rect"; type: RECT; description { rel1.relative: 0.0 0.0; rel2.relative: 0.5 0.5; color: 255 0 0 255; map { on: 1; smooth: 1; rotation { z: -30; } } } } part { name: "pro1"; type: PROXY; description { rel1.relative: 0.5 0.0; rel2.relative: 1.0 0.7; color: 128 128 0 128; source: rect; } } } } } git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@57694 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 3 + src/bin/edje_cc_handlers.c | 341 ++++++++++++++++++++++++++++++++++----------- src/lib/Edje.h | 3 +- src/lib/edje_cache.c | 1 + src/lib/edje_calc.c | 93 ++++++++++--- src/lib/edje_data.c | 31 +++++ src/lib/edje_load.c | 4 + src/lib/edje_private.h | 18 +++ 8 files changed, 395 insertions(+), 99 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35e07fb..76a8e50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -57,4 +57,7 @@ * Correctly propagate recursive event with existing and non existing part. +2011-03-11 Cedric BAIL + + * Add PROXY part. diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index 0c97d59..5bdb832 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -156,6 +156,7 @@ static void st_collections_group_parts_part_table_items_item_span(void); static void ob_collections_group_parts_part_description(void); static void st_collections_group_parts_part_description_inherit(void); +static void st_collections_group_parts_part_description_source(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); @@ -400,6 +401,7 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.table.items.item.position", st_collections_group_parts_part_table_items_item_position}, {"collections.group.parts.part.table.items.item.span", st_collections_group_parts_part_table_items_item_span}, {"collections.group.parts.part.description.inherit", st_collections_group_parts_part_description_inherit}, + {"collections.group.parts.part.description.source", st_collections_group_parts_part_description_source}, {"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}, @@ -777,6 +779,23 @@ statement_handler_num(void) return sizeof(statement_handlers) / sizeof (New_Object_Handler); } +static void +_edje_part_description_fill(Edje_Part_Description_Spec_Fill *fill) +{ + fill->smooth = 1; + fill->pos_rel_x = FROM_DOUBLE(0.0); + fill->pos_abs_x = 0; + fill->rel_x = FROM_DOUBLE(1.0); + fill->abs_x = 0; + fill->pos_rel_y = FROM_DOUBLE(0.0); + fill->pos_abs_y = 0; + fill->rel_y = FROM_DOUBLE(1.0); + fill->abs_y = 0; + fill->angle = 0; + fill->spread = 0; + fill->type = EDJE_FILL_TYPE_SCALE; +} + static Edje_Part_Description_Common * _edje_part_description_alloc(unsigned char type, const char *collection, const char *part) { @@ -815,22 +834,25 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c ed = mem_alloc(SZ(Edje_Part_Description_Image)); ed->image.id = -1; - ed->image.fill.smooth = 1; - ed->image.fill.pos_rel_x = FROM_DOUBLE(0.0); - ed->image.fill.pos_abs_x = 0; - ed->image.fill.rel_x = FROM_DOUBLE(1.0); - ed->image.fill.abs_x = 0; - ed->image.fill.pos_rel_y = FROM_DOUBLE(0.0); - ed->image.fill.pos_abs_y = 0; - ed->image.fill.rel_y = FROM_DOUBLE(1.0); - ed->image.fill.abs_y = 0; - ed->image.fill.angle = 0; - ed->image.fill.spread = 0; - ed->image.fill.type = EDJE_FILL_TYPE_SCALE; + + _edje_part_description_fill(&ed->image.fill); result = &ed->common; break; } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = mem_alloc(SZ(Edje_Part_Description_Proxy)); + + ed->proxy.id = -1; + + _edje_part_description_fill(&ed->proxy.fill); + + result = &ed->common; + break; + } case EDJE_PART_TYPE_BOX: { Edje_Part_Description_Box *ed; @@ -2215,6 +2237,7 @@ st_collections_group_parts_part_type(void) "BOX", EDJE_PART_TYPE_BOX, "TABLE", EDJE_PART_TYPE_TABLE, "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, + "PROXY", EDJE_PART_TYPE_PROXY, NULL); if (ep->default_desc || ep->other.desc_count > 0) @@ -3673,6 +3696,15 @@ st_collections_group_parts_part_description_inherit(void) break; } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ped = (Edje_Part_Description_Proxy*) ed; + Edje_Part_Description_Proxy *pparent = (Edje_Part_Description_Proxy*) parent; + + ped->proxy.id = pparent->proxy.id; + + break; + } case EDJE_PART_TYPE_BOX: { Edje_Part_Description_Box *bed = (Edje_Part_Description_Box *) ed; @@ -3718,6 +3750,48 @@ st_collections_group_parts_part_description_inherit(void) /** @page edcref + + @property + source + @parameters + [another part's name] + @effect + Causes the part to use another part content as the content of this part. + Only work with PROXY part. + @endproperty +*/ +static void +st_collections_group_parts_part_description_source(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description_Proxy *ed; + char *name; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = pc->parts[pc->parts_count - 1]; + + if (ep->type != EDJE_PART_TYPE_PROXY) + { + ERR("%s: Error. parse error %s:%i. " + "source attributes in non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + name = parse_str(0); + + data_queue_part_lookup(pc, name, &(ed->proxy.id)); + free(name); +} + +/** + @page edcref @property state @parameters @@ -4760,25 +4834,43 @@ st_collections_group_parts_part_description_fill_smooth(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(1); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; - ed->image.fill.smooth = parse_bool(0); + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->smooth = parse_bool(0); } /** @@ -4847,28 +4939,46 @@ st_collections_group_parts_part_description_fill_type(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(1); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } - ed->image.fill.type = parse_enum(0, - "SCALE", EDJE_FILL_TYPE_SCALE, - "TILE", EDJE_FILL_TYPE_TILE, - NULL); + fill->type = parse_enum(0, + "SCALE", EDJE_FILL_TYPE_SCALE, + "TILE", EDJE_FILL_TYPE_TILE, + NULL); } /** @@ -4907,26 +5017,44 @@ st_collections_group_parts_part_description_fill_origin_relative(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(2); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } - ed->image.fill.pos_rel_x = FROM_DOUBLE(parse_float_range(0, -999999999.0, 999999999.0)); - ed->image.fill.pos_rel_y = FROM_DOUBLE(parse_float_range(1, -999999999.0, 999999999.0)); + fill->pos_rel_x = FROM_DOUBLE(parse_float_range(0, -999999999.0, 999999999.0)); + fill->pos_rel_y = FROM_DOUBLE(parse_float_range(1, -999999999.0, 999999999.0)); } /** @@ -4944,26 +5072,45 @@ st_collections_group_parts_part_description_fill_origin_offset(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(2); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; - ed->image.fill.pos_abs_x = parse_int(0); - ed->image.fill.pos_abs_y = parse_int(1); + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } + + fill->pos_abs_x = parse_int(0); + fill->pos_abs_y = parse_int(1); } /** @@ -5004,26 +5151,44 @@ st_collections_group_parts_part_description_fill_size_relative(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(2); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } - ed->image.fill.rel_x = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); - ed->image.fill.rel_y = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0)); + fill->rel_x = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0)); + fill->rel_y = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0)); } /** @@ -5041,26 +5206,44 @@ st_collections_group_parts_part_description_fill_size_offset(void) { Edje_Part_Collection *pc; Edje_Part *ep; - Edje_Part_Description_Image *ed; + Edje_Part_Description_Spec_Fill *fill; check_arg_count(2); pc = eina_list_data_get(eina_list_last(edje_collections)); ep = pc->parts[pc->parts_count - 1]; - if (ep->type != EDJE_PART_TYPE_IMAGE) + switch (ep->type) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); - } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *ed; - ed = (Edje_Part_Description_Image*) ep->default_desc; - if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + ed = (Edje_Part_Description_Image*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Image*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->image.fill; + } + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *ed; + + ed = (Edje_Part_Description_Proxy*) ep->default_desc; + if (ep->other.desc_count) ed = (Edje_Part_Description_Proxy*) ep->other.desc[ep->other.desc_count - 1]; + + fill = &ed->proxy.fill; + } + default: + { + ERR("%s: Error. parse error %s:%i. " + "image and proxy attributes in non-IMAGE, non-PROXY part.", + progname, file_in, line - 1); + exit(-1); + } + } - ed->image.fill.abs_x = parse_int(0); - ed->image.fill.abs_y = parse_int(1); + fill->abs_x = parse_int(0); + fill->abs_y = parse_int(1); } diff --git a/src/lib/Edje.h b/src/lib/Edje.h index 74f5635..064d7d9 100644 --- a/src/lib/Edje.h +++ b/src/lib/Edje.h @@ -110,7 +110,8 @@ typedef enum _Edje_Part_Type EDJE_PART_TYPE_BOX = 8, EDJE_PART_TYPE_TABLE = 9, EDJE_PART_TYPE_EXTERNAL = 10, - EDJE_PART_TYPE_LAST = 11 + EDJE_PART_TYPE_PROXY = 11, + EDJE_PART_TYPE_LAST = 12 } Edje_Part_Type; typedef enum _Edje_Text_Effect diff --git a/src/lib/edje_cache.c b/src/lib/edje_cache.c index 6368ba0..b463a8a 100644 --- a/src/lib/edje_cache.c +++ b/src/lib/edje_cache.c @@ -60,6 +60,7 @@ _edje_file_coll_open(Edje_File *edf, const char *coll) INIT_EMP_BOTH(RECTANGLE, Edje_Part_Description_Common, ce); INIT_EMP_BOTH(TEXT, Edje_Part_Description_Text, ce); INIT_EMP_BOTH(IMAGE, Edje_Part_Description_Image, ce); + INIT_EMP_BOTH(PROXY, Edje_Part_Description_Proxy, ce); INIT_EMP_BOTH(SWALLOW, Edje_Part_Description_Common, ce); INIT_EMP_BOTH(TEXTBLOCK, Edje_Part_Description_Text, ce); INIT_EMP_BOTH(GROUP, Edje_Part_Description_Common, ce); diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 5358217..efd1ecf 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -176,6 +176,7 @@ _edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src EDIT_ALLOC_POOL_RTL(TEXT, Text, text); EDIT_ALLOC_POOL_RTL(TEXTBLOCK, Text, text); EDIT_ALLOC_POOL_RTL(IMAGE, Image, image); + EDIT_ALLOC_POOL_RTL(PROXY, Proxy, proxy); EDIT_ALLOC_POOL_RTL(BOX, Box, box); EDIT_ALLOC_POOL_RTL(TABLE, Table, table); EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params); @@ -1316,36 +1317,36 @@ _edje_part_recalc_single_drag(Edje_Real_Part *ep, static void _edje_part_recalc_single_fill(Edje_Real_Part *ep, - Edje_Part_Description_Spec_Image *desc, + Edje_Part_Description_Spec_Fill *fill, Edje_Calc_Params *params) { int fw; int fh; - params->smooth = desc->fill.smooth; + params->smooth = fill->smooth; - if (desc->fill.type == EDJE_FILL_TYPE_TILE) + if (fill->type == EDJE_FILL_TYPE_TILE) evas_object_image_size_get(ep->object, &fw, NULL); else fw = params->w; - params->type.common.fill.x = desc->fill.pos_abs_x - + TO_INT(SCALE(desc->fill.pos_rel_x, fw)); - params->type.common.fill.w = desc->fill.abs_x - + TO_INT(SCALE(desc->fill.rel_x, fw)); + params->type.common.fill.x = fill->pos_abs_x + + TO_INT(SCALE(fill->pos_rel_x, fw)); + params->type.common.fill.w = fill->abs_x + + TO_INT(SCALE(fill->rel_x, fw)); - if (desc->fill.type == EDJE_FILL_TYPE_TILE) + if (fill->type == EDJE_FILL_TYPE_TILE) evas_object_image_size_get(ep->object, NULL, &fh); else fh = params->h; - params->type.common.fill.y = desc->fill.pos_abs_y - + TO_INT(SCALE(desc->fill.pos_rel_y, fh)); - params->type.common.fill.h = desc->fill.abs_y - + TO_INT(SCALE(desc->fill.rel_y, fh)); + params->type.common.fill.y = fill->pos_abs_y + + TO_INT(SCALE(fill->pos_rel_y, fh)); + params->type.common.fill.h = fill->abs_y + + TO_INT(SCALE(fill->rel_y, fh)); - params->type.common.fill.angle = desc->fill.angle; - params->type.common.fill.spread = desc->fill.spread; + params->type.common.fill.angle = fill->angle; + params->type.common.fill.spread = fill->spread; } static void @@ -1484,7 +1485,9 @@ _edje_part_recalc_single(Edje *ed, /* fill */ if (ep->part->type == EDJE_PART_TYPE_IMAGE) - _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image, params); + _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params); + else if (ep->part->type == EDJE_PART_TYPE_PROXY) + _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params); /* colors */ if ((desc->color_class) && (*desc->color_class)) @@ -1563,6 +1566,7 @@ _edje_part_recalc_single(Edje *ed, case EDJE_PART_TYPE_TABLE: case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_PROXY: break; case EDJE_PART_TYPE_GRADIENT: /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */ @@ -1653,6 +1657,52 @@ _edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part } static void +_edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos) +{ + Edje_Real_Part *pp; + int part_id; + + if (p3->type.common.fill.w == 0 || p3->type.common.fill.h == 0) + { + evas_object_image_source_set(ep->object, NULL); + return ; + } + + if (pos >= 0.5) { + part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id; + } else { + part_id = chosen_desc->proxy.id; + } + + pp = ed->table_parts[part_id % ed->table_parts_size]; + + switch (pp->part->type) + { + case EDJE_PART_TYPE_IMAGE: + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + case EDJE_PART_TYPE_PROXY: + evas_object_image_source_set(ep->object, pp->object); + break; + case EDJE_PART_TYPE_GRADIENT: + /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */ + break; + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_EXTERNAL: + evas_object_image_source_set(ep->object, pp->swallowed_object); + break; + } + + evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y, + p3->type.common.fill.w, p3->type.common.fill.h); + evas_object_image_smooth_scale_set(ep->object, p3->smooth); +} + +static void _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos) { int image_id; @@ -2049,14 +2099,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) switch (part_type) { case EDJE_PART_TYPE_IMAGE: - p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos); - p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos); - p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos); - p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos); p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos); p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos); p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos); p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos); + case EDJE_PART_TYPE_PROXY: + p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos); + p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos); + p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos); + p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos); break; case EDJE_PART_TYPE_TEXT: p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos); @@ -2113,6 +2164,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) evas_object_image_scale_hint_set(ep->object, img_desc->image.scale_hint); } + case EDJE_PART_TYPE_PROXY: case EDJE_PART_TYPE_RECTANGLE: case EDJE_PART_TYPE_TEXTBLOCK: case EDJE_PART_TYPE_BOX: @@ -2153,6 +2205,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) case EDJE_PART_TYPE_TEXT: _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc); break; + case EDJE_PART_TYPE_PROXY: + _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy*) chosen_desc, pos); + break; case EDJE_PART_TYPE_IMAGE: _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image*) chosen_desc, pos); break; diff --git a/src/lib/edje_data.c b/src/lib/edje_data.c index 23881b7..ea4bb24 100644 --- a/src/lib/edje_data.c +++ b/src/lib/edje_data.c @@ -28,6 +28,7 @@ Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_group = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_image = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_text = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_box = NULL; @@ -38,6 +39,7 @@ Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_group_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_image_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_text_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock_pointer = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description_box_pointer = NULL; @@ -69,6 +71,7 @@ Eet_Data_Descriptor *_edje_edd_edje_external_param = NULL; EMP(RECTANGLE, rectangle); EMP(TEXT, text); EMP(IMAGE, image); +EMP(PROXY, proxy); EMP(SWALLOW, swallow); EMP(TEXTBLOCK, textblock); EMP(GROUP, group); @@ -97,6 +100,7 @@ struct { { EDJE_PART_TYPE_BOX, "box" }, { EDJE_PART_TYPE_TABLE, "table" }, { EDJE_PART_TYPE_EXTERNAL, "external" }, + { EDJE_PART_TYPE_PROXY, "proxy" } }; static const char * @@ -176,6 +180,7 @@ _edje_edd_shutdown(void) FREED(_edje_edd_edje_part_description_swallow); FREED(_edje_edd_edje_part_description_group); FREED(_edje_edd_edje_part_description_image); + FREED(_edje_edd_edje_part_description_proxy); FREED(_edje_edd_edje_part_description_text); FREED(_edje_edd_edje_part_description_textblock); FREED(_edje_edd_edje_part_description_box); @@ -186,6 +191,7 @@ _edje_edd_shutdown(void) FREED(_edje_edd_edje_part_description_swallow_pointer); FREED(_edje_edd_edje_part_description_group_pointer); FREED(_edje_edd_edje_part_description_image_pointer); + FREED(_edje_edd_edje_part_description_proxy_pointer); FREED(_edje_edd_edje_part_description_text_pointer); FREED(_edje_edd_edje_part_description_textblock_pointer); FREED(_edje_edd_edje_part_description_box_pointer); @@ -283,6 +289,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.RECTANGLE", count.RECTANGLE, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXT", count.TEXT, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.IMAGE", count.IMAGE, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.PROXY", count.PROXY, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SWALLOW", count.SWALLOW, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXTBLOCK", count.TEXTBLOCK, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.GROUP", count.GROUP, EET_T_INT); @@ -549,6 +556,27 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.spread", image.fill.spread, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.type", image.fill.type, EET_T_CHAR); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Proxy); + eddc.func.mem_free = mem_free_proxy; + eddc.func.mem_alloc = mem_alloc_proxy; + _edje_edd_edje_part_description_proxy = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, common); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.id", proxy.id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.smooth", proxy.fill.smooth, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_rel_x", proxy.fill.pos_rel_x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_abs_x", proxy.fill.pos_abs_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.rel_x", proxy.fill.rel_x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.abs_x", proxy.fill.abs_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_rel_y", proxy.fill.pos_rel_y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_abs_y", proxy.fill.pos_abs_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.rel_y", proxy.fill.rel_y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.abs_y", proxy.fill.abs_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.angle", proxy.fill.angle, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.spread", proxy.fill.spread, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.type", proxy.fill.type, EET_T_CHAR); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text); eddc.func.mem_free = mem_free_text; eddc.func.mem_alloc = mem_alloc_text; @@ -648,6 +676,7 @@ _edje_edd_init(void) EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_swallow); EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_group); EDJE_DEFINE_POINTER_TYPE(Part_Description_Image, part_description_image); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Proxy, part_description_proxy); EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_text); EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_textblock); EDJE_DEFINE_POINTER_TYPE(Part_Description_Box, part_description_box); @@ -663,6 +692,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "swallow", _edje_edd_edje_part_description_swallow); EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "group", _edje_edd_edje_part_description_group); EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "image", _edje_edd_edje_part_description_image); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "proxy", _edje_edd_edje_part_description_proxy); EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "text", _edje_edd_edje_part_description_text); EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "textblock", _edje_edd_edje_part_description_textblock); EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "box", _edje_edd_edje_part_description_box); @@ -686,6 +716,7 @@ _edje_edd_init(void) EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "swallow", swallow); EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "group", group); EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "image", image); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "proxy", proxy); EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "text", text); EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "textblock", textblock); EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "box", box); diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c index fef632d..1e828b1 100644 --- a/src/lib/edje_load.c +++ b/src/lib/edje_load.c @@ -464,6 +464,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g case EDJE_PART_TYPE_RECTANGLE: rp->object = evas_object_rectangle_add(ed->evas); break; + case EDJE_PART_TYPE_PROXY: case EDJE_PART_TYPE_IMAGE: rp->object = evas_object_image_add(ed->evas); break; @@ -1257,6 +1258,7 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collec eina_mempool_del(ce->mp.RECTANGLE); eina_mempool_del(ce->mp.TEXT); eina_mempool_del(ce->mp.IMAGE); + eina_mempool_del(ce->mp.PROXY); eina_mempool_del(ce->mp.SWALLOW); eina_mempool_del(ce->mp.TEXTBLOCK); eina_mempool_del(ce->mp.GROUP); @@ -1269,6 +1271,7 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collec eina_mempool_del(ce->mp_rtl.RECTANGLE); eina_mempool_del(ce->mp_rtl.TEXT); eina_mempool_del(ce->mp_rtl.IMAGE); + eina_mempool_del(ce->mp_rtl.PROXY); eina_mempool_del(ce->mp_rtl.SWALLOW); eina_mempool_del(ce->mp_rtl.TEXTBLOCK); eina_mempool_del(ce->mp_rtl.GROUP); @@ -1344,6 +1347,7 @@ _edje_collection_free_part_description_free(int type, FREE_POOL(RECTANGLE, ce, desc); FREE_POOL(TEXT, ce, desc); FREE_POOL(IMAGE, ce, desc); + FREE_POOL(PROXY, ce, desc); FREE_POOL(SWALLOW, ce, desc); FREE_POOL(TEXTBLOCK, ce, desc); FREE_POOL(GROUP, ce, desc); diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index b73ab7d..0b044e6 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -277,6 +277,7 @@ typedef struct _Edje_Part_Api Edje_Part_Api; typedef struct _Edje_Part_Dragable Edje_Part_Dragable; typedef struct _Edje_Part_Image_Id Edje_Part_Image_Id; typedef struct _Edje_Part_Description_Image Edje_Part_Description_Image; +typedef struct _Edje_Part_Description_Proxy Edje_Part_Description_Proxy; typedef struct _Edje_Part_Description_Text Edje_Part_Description_Text; typedef struct _Edje_Part_Description_Box Edje_Part_Description_Box; typedef struct _Edje_Part_Description_Table Edje_Part_Description_Table; @@ -285,6 +286,7 @@ typedef struct _Edje_Part_Description_Common Edje_Part_Description_Commo 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_Proxy Edje_Part_Description_Spec_Proxy; typedef struct _Edje_Part_Description_Spec_Text Edje_Part_Description_Spec_Text; typedef struct _Edje_Part_Description_Spec_Box Edje_Part_Description_Spec_Box; typedef struct _Edje_Part_Description_Spec_Table Edje_Part_Description_Spec_Table; @@ -575,6 +577,7 @@ struct _Edje_Program_After /* the action to run after another action */ TYPE RECTANGLE; \ TYPE TEXT; \ TYPE IMAGE; \ + TYPE PROXY; \ TYPE SWALLOW; \ TYPE TEXTBLOCK; \ TYPE GROUP; \ @@ -829,6 +832,8 @@ struct _Edje_Part_Description_Spec_Border struct _Edje_Part_Description_Spec_Image { + Edje_Part_Description_Spec_Fill fill; + Edje_Part_Image_Id **tweens; /* list of Edje_Part_Image_Id */ unsigned int tweens_count; /* number of tweens */ @@ -837,7 +842,13 @@ struct _Edje_Part_Description_Spec_Image Eina_Bool set; /* if image condition it's content */ Edje_Part_Description_Spec_Border border; +}; + +struct _Edje_Part_Description_Spec_Proxy +{ Edje_Part_Description_Spec_Fill fill; + + int id; /* the part id to use as a source for this state */ }; struct _Edje_Part_Description_Spec_Text @@ -893,6 +904,12 @@ struct _Edje_Part_Description_Image Edje_Part_Description_Spec_Image image; }; +struct _Edje_Part_Description_Proxy +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Proxy proxy; +}; + struct _Edje_Part_Description_Text { Edje_Part_Description_Common common; @@ -1426,6 +1443,7 @@ extern Eina_Mempool *_edje_real_part_state_mp; extern Eina_Mempool *_emp_RECTANGLE; extern Eina_Mempool *_emp_TEXT; extern Eina_Mempool *_emp_IMAGE; +extern Eina_Mempool *_emp_PROXY; extern Eina_Mempool *_emp_SWALLOW; extern Eina_Mempool *_emp_TEXTBLOCK; extern Eina_Mempool *_emp_GROUP; -- 2.7.4