aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/bin/edje_cc_handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/bin/edje_cc_handlers.c')
-rw-r--r--libraries/edje/src/bin/edje_cc_handlers.c251
1 files changed, 207 insertions, 44 deletions
diff --git a/libraries/edje/src/bin/edje_cc_handlers.c b/libraries/edje/src/bin/edje_cc_handlers.c
index f74fa12..14ac0b7 100644
--- a/libraries/edje/src/bin/edje_cc_handlers.c
+++ b/libraries/edje/src/bin/edje_cc_handlers.c
@@ -106,6 +106,7 @@ static void st_collections_group_script_only(void);
106static void st_collections_group_alias(void); 106static void st_collections_group_alias(void);
107static void st_collections_group_min(void); 107static void st_collections_group_min(void);
108static void st_collections_group_max(void); 108static void st_collections_group_max(void);
109static void st_collections_group_broadcast_signal(void);
109static void st_collections_group_data_item(void); 110static void st_collections_group_data_item(void);
110static void st_collections_group_orientation(void); 111static void st_collections_group_orientation(void);
111 112
@@ -317,6 +318,7 @@ New_Statement_Handler statement_handlers[] =
317 {"collections.group.alias", st_collections_group_alias}, 318 {"collections.group.alias", st_collections_group_alias},
318 {"collections.group.min", st_collections_group_min}, 319 {"collections.group.min", st_collections_group_min},
319 {"collections.group.max", st_collections_group_max}, 320 {"collections.group.max", st_collections_group_max},
321 {"collections.group.broadcast_signal", st_collections_group_broadcast_signal},
320 {"collections.group.orientation", st_collections_group_orientation}, 322 {"collections.group.orientation", st_collections_group_orientation},
321 {"collections.group.data.item", st_collections_group_data_item}, 323 {"collections.group.data.item", st_collections_group_data_item},
322 {"collections.group.limits.horizontal", st_collections_group_limits_horizontal}, 324 {"collections.group.limits.horizontal", st_collections_group_limits_horizontal},
@@ -833,6 +835,39 @@ _edje_part_description_fill(Edje_Part_Description_Spec_Fill *fill)
833 fill->type = EDJE_FILL_TYPE_SCALE; 835 fill->type = EDJE_FILL_TYPE_SCALE;
834} 836}
835 837
838static void
839_edje_part_description_image_remove(Edje_Part_Description_Image *ed)
840{
841 unsigned int j;
842
843 if (!ed) return;
844
845 data_queue_image_remove(&(ed->image.id), &(ed->image.set));
846
847 for (j = 0; j < ed->image.tweens_count; ++j)
848 data_queue_image_remove(&(ed->image.tweens[j]->id),
849 &(ed->image.tweens[j]->set));
850}
851
852void
853part_description_image_cleanup(Edje_Part *ep)
854{
855 Edje_Part_Description_Image *ed;
856 unsigned int j;
857
858 if (ep->type != EDJE_PART_TYPE_IMAGE)
859 return ;
860
861 ed = (Edje_Part_Description_Image*) ep->default_desc;
862 _edje_part_description_image_remove(ed);
863
864 for (j = 0; j < ep->other.desc_count; j++)
865 {
866 ed = (Edje_Part_Description_Image*) ep->other.desc[j];
867 _edje_part_description_image_remove(ed);
868 }
869}
870
836static Edje_Part_Description_Common * 871static Edje_Part_Description_Common *
837_edje_part_description_alloc(unsigned char type, const char *collection, const char *part) 872_edje_part_description_alloc(unsigned char type, const char *collection, const char *part)
838{ 873{
@@ -2118,6 +2153,7 @@ ob_collections_group(void)
2118 pc = mem_alloc(SZ(Edje_Part_Collection)); 2153 pc = mem_alloc(SZ(Edje_Part_Collection));
2119 edje_collections = eina_list_append(edje_collections, pc); 2154 edje_collections = eina_list_append(edje_collections, pc);
2120 pc->id = current_de->id; 2155 pc->id = current_de->id;
2156 pc->broadcast_signal = EINA_TRUE; /* This was the behaviour by default in Edje 1.1 */
2121 2157
2122 cd = mem_alloc(SZ(Code)); 2158 cd = mem_alloc(SZ(Code));
2123 codes = eina_list_append(codes, cd); 2159 codes = eina_list_append(codes, cd);
@@ -2139,8 +2175,10 @@ ob_collections_group(void)
2139static void 2175static void
2140st_collections_group_name(void) 2176st_collections_group_name(void)
2141{ 2177{
2178 Edje_Part_Collection_Directory_Entry *alias;
2142 Edje_Part_Collection_Directory_Entry *older; 2179 Edje_Part_Collection_Directory_Entry *older;
2143 Edje_Part_Collection *current_pc; 2180 Edje_Part_Collection *current_pc;
2181 Eina_List *l = NULL;
2144 2182
2145 check_arg_count(1); 2183 check_arg_count(1);
2146 2184
@@ -2150,31 +2188,24 @@ st_collections_group_name(void)
2150 current_pc->part = current_de->entry; 2188 current_pc->part = current_de->entry;
2151 2189
2152 older = eina_hash_find(edje_file->collection, current_de->entry); 2190 older = eina_hash_find(edje_file->collection, current_de->entry);
2191 if (older) eina_hash_del(edje_file->collection, current_de->entry, older);
2192 eina_hash_direct_add(edje_file->collection, current_de->entry, current_de);
2193 if (!older) return;
2153 2194
2154 if (older) 2195 EINA_LIST_FOREACH(aliases, l, alias)
2155 { 2196 if (strcmp(alias->entry, current_de->entry) == 0)
2156 Edje_Part_Collection *pc; 2197 {
2157 Eina_List *l; 2198 Edje_Part_Collection *pc;
2158 Code *cd; 2199
2159 int i = 0; 2200 pc = eina_list_nth(edje_collections, older->id);
2160 2201 INF("overriding alias ('%s' => '%s') by group '%s'",
2161 pc = eina_list_nth(edje_collections, older->id); 2202 alias->entry, pc->part,
2162 cd = eina_list_nth(codes, older->id); 2203 current_de->entry);
2163 2204 aliases = eina_list_remove_list(aliases, l);
2164 eina_hash_del(edje_file->collection, current_de->entry, older); 2205 free(alias);
2165 edje_collections = eina_list_remove(edje_collections, pc); 2206 break;
2166 codes = eina_list_remove(codes, cd); 2207 }
2167
2168 EINA_LIST_FOREACH(edje_collections, l, pc)
2169 {
2170 older = eina_hash_find(edje_file->collection, pc->part);
2171
2172 pc->id = i++;
2173 if (older) older->id = pc->id;
2174 }
2175 }
2176 2208
2177 eina_hash_direct_add(edje_file->collection, current_de->entry, current_de);
2178} 2209}
2179 2210
2180typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data; 2211typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data;
@@ -2242,6 +2273,14 @@ st_collections_group_inherit(void)
2242 progname, file_in, line - 1, parent_name); 2273 progname, file_in, line - 1, parent_name);
2243 exit(-1); 2274 exit(-1);
2244 } 2275 }
2276 if (pc2 == pc)
2277 {
2278 ERR("%s: Error. parse error %s:%i. You are trying to inherit '%s' from itself. That's not possible."
2279 "If there is another group of the same name, you want to inherit from that group and have the"
2280 "same name as that group, there is a trick ! Just put the inherit before the directive that set"
2281 "the name !", progname, file_in, line - 1, parent_name);
2282 exit(-1);
2283 }
2245 2284
2246 if (pc2->data) 2285 if (pc2->data)
2247 { 2286 {
@@ -2463,6 +2502,8 @@ static void
2463st_collections_group_alias(void) 2502st_collections_group_alias(void)
2464{ 2503{
2465 Edje_Part_Collection_Directory_Entry *alias; 2504 Edje_Part_Collection_Directory_Entry *alias;
2505 Edje_Part_Collection_Directory_Entry *tmp;
2506 Eina_List *l;
2466 2507
2467 check_arg_count(1); 2508 check_arg_count(1);
2468 2509
@@ -2470,6 +2511,20 @@ st_collections_group_alias(void)
2470 alias->id = current_de->id; 2511 alias->id = current_de->id;
2471 alias->entry = parse_str(0); 2512 alias->entry = parse_str(0);
2472 2513
2514 EINA_LIST_FOREACH(aliases, l, tmp)
2515 if (strcmp(alias->entry, tmp->entry) == 0)
2516 {
2517 Edje_Part_Collection *pc;
2518
2519 pc = eina_list_nth(edje_collections, tmp->id);
2520 INF("overriding alias ('%s' => '%s') to ('%s' => '%s')",
2521 tmp->entry, pc->part,
2522 alias->entry, current_de->entry);
2523 aliases = eina_list_remove_list(aliases, l);
2524 free(tmp);
2525 break;
2526 }
2527
2473 aliases = eina_list_append(aliases, alias); 2528 aliases = eina_list_append(aliases, alias);
2474} 2529}
2475 2530
@@ -2520,6 +2575,28 @@ st_collections_group_max(void)
2520} 2575}
2521 2576
2522/** 2577/**
2578 @page edcref
2579 @property
2580 broadcast_signal
2581 @parameters
2582 [broadcast]
2583 @effect
2584 Signal got automatically broadcasted to all sub group part. Default to
2585 true since 1.1.
2586 @endproperty
2587*/
2588static void
2589st_collections_group_broadcast_signal(void)
2590{
2591 Edje_Part_Collection *pc;
2592
2593 check_arg_count(1);
2594
2595 pc = eina_list_data_get(eina_list_last(edje_collections));
2596 pc->broadcast_signal = parse_bool(0);
2597}
2598
2599/**
2523 @page edcref 2600 @page edcref
2524 @block 2601 @block
2525 script 2602 script
@@ -2947,21 +3024,57 @@ st_collections_group_parts_part_name(void)
2947static void 3024static void
2948st_collections_group_parts_part_type(void) 3025st_collections_group_parts_part_type(void)
2949{ 3026{
3027 unsigned int type;
3028
2950 check_arg_count(1); 3029 check_arg_count(1);
2951 3030
2952 current_part->type = parse_enum(0, 3031 type = parse_enum(0,
2953 "NONE", EDJE_PART_TYPE_NONE, 3032 "NONE", EDJE_PART_TYPE_NONE,
2954 "RECT", EDJE_PART_TYPE_RECTANGLE, 3033 "RECT", EDJE_PART_TYPE_RECTANGLE,
2955 "TEXT", EDJE_PART_TYPE_TEXT, 3034 "TEXT", EDJE_PART_TYPE_TEXT,
2956 "IMAGE", EDJE_PART_TYPE_IMAGE, 3035 "IMAGE", EDJE_PART_TYPE_IMAGE,
2957 "SWALLOW", EDJE_PART_TYPE_SWALLOW, 3036 "SWALLOW", EDJE_PART_TYPE_SWALLOW,
2958 "TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK, 3037 "TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK,
2959 "GROUP", EDJE_PART_TYPE_GROUP, 3038 "GROUP", EDJE_PART_TYPE_GROUP,
2960 "BOX", EDJE_PART_TYPE_BOX, 3039 "BOX", EDJE_PART_TYPE_BOX,
2961 "TABLE", EDJE_PART_TYPE_TABLE, 3040 "TABLE", EDJE_PART_TYPE_TABLE,
2962 "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, 3041 "EXTERNAL", EDJE_PART_TYPE_EXTERNAL,
2963 "PROXY", EDJE_PART_TYPE_PROXY, 3042 "PROXY", EDJE_PART_TYPE_PROXY,
2964 NULL); 3043 NULL);
3044
3045 /* handle type change of inherited part */
3046 if (type != current_part->type)
3047 {
3048 Edje_Part_Description_Common *new, *previous;
3049 Edje_Part_Collection *pc;
3050 Edje_Part *ep;
3051 unsigned int i;
3052
3053 /* we don't free old part as we don't remove all reference to them */
3054 part_description_image_cleanup(current_part);
3055
3056 pc = eina_list_data_get(eina_list_last(edje_collections));
3057 ep = current_part;
3058
3059 previous = ep->default_desc;
3060 if (previous)
3061 {
3062 new = _edje_part_description_alloc(type, pc->part, ep->name);
3063 memcpy(new, previous, sizeof (Edje_Part_Description_Common));
3064
3065 ep->default_desc = new;
3066 }
3067
3068 for (i = 0; i < ep->other.desc_count; i++)
3069 {
3070 previous = ep->other.desc[i];
3071 new = _edje_part_description_alloc(type, pc->part, ep->name);
3072 memcpy(new, previous, sizeof (Edje_Part_Description_Common));
3073 ep->other.desc[i] = new;
3074 }
3075 }
3076
3077 current_part->type = type;
2965} 3078}
2966 3079
2967/** 3080/**
@@ -4292,6 +4405,7 @@ st_collections_group_parts_part_description_inherit(void)
4292 4405
4293 ied->image = iparent->image; 4406 ied->image = iparent->image;
4294 4407
4408 data_queue_image_remove(&ied->image.id, &ied->image.set);
4295 data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set); 4409 data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set);
4296 4410
4297 ied->image.tweens = calloc(iparent->image.tweens_count, 4411 ied->image.tweens = calloc(iparent->image.tweens_count,
@@ -4303,6 +4417,7 @@ st_collections_group_parts_part_description_inherit(void)
4303 iid = iparent->image.tweens[i]; 4417 iid = iparent->image.tweens[i];
4304 4418
4305 iid_new = mem_alloc(SZ(Edje_Part_Image_Id)); 4419 iid_new = mem_alloc(SZ(Edje_Part_Image_Id));
4420 data_queue_image_remove(&ied->image.id, &ied->image.set);
4306 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set)); 4421 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set));
4307 ied->image.tweens[i] = iid_new; 4422 ied->image.tweens[i] = iid_new;
4308 } 4423 }
@@ -4445,6 +4560,9 @@ st_collections_group_parts_part_description_state(void)
4445 if ((ep->default_desc->state.name && !strcmp(s, ep->default_desc->state.name) && ed->state.value == ep->default_desc->state.value) || 4560 if ((ep->default_desc->state.name && !strcmp(s, ep->default_desc->state.name) && ed->state.value == ep->default_desc->state.value) ||
4446 (!ep->default_desc->state.name && !strcmp(s, "default") && ed->state.value == ep->default_desc->state.value)) 4561 (!ep->default_desc->state.name && !strcmp(s, "default") && ed->state.value == ep->default_desc->state.value))
4447 { 4562 {
4563 if (ep->type == EDJE_PART_TYPE_IMAGE)
4564 _edje_part_description_image_remove((Edje_Part_Description_Image*) ed);
4565
4448 free(ed); 4566 free(ed);
4449 ep->other.desc_count--; 4567 ep->other.desc_count--;
4450 ep->other.desc = realloc(ep->other.desc, 4568 ep->other.desc = realloc(ep->other.desc,
@@ -4458,6 +4576,9 @@ st_collections_group_parts_part_description_state(void)
4458 { 4576 {
4459 if (!strcmp(s, ep->other.desc[i]->state.name) && ed->state.value == ep->other.desc[i]->state.value) 4577 if (!strcmp(s, ep->other.desc[i]->state.name) && ed->state.value == ep->other.desc[i]->state.value)
4460 { 4578 {
4579 if (ep->type == EDJE_PART_TYPE_IMAGE)
4580 _edje_part_description_image_remove((Edje_Part_Description_Image*) ed);
4581
4461 free(ed); 4582 free(ed);
4462 ep->other.desc_count--; 4583 ep->other.desc_count--;
4463 ep->other.desc = realloc(ep->other.desc, 4584 ep->other.desc = realloc(ep->other.desc,
@@ -4538,18 +4659,38 @@ st_collections_group_parts_part_description_fixed(void)
4538 @property 4659 @property
4539 min 4660 min
4540 @parameters 4661 @parameters
4541 [width] [height] 4662 [width] [height] or SOURCE
4542 @effect 4663 @effect
4543 The minimum size of the state. 4664 The minimum size of the state.
4665
4666 When min is defined to SOURCE, it will look at the original
4667 image size and enforce it minimal size to match at least the
4668 original one. The part must be an IMAGE or a GROUP part.
4544 @endproperty 4669 @endproperty
4545*/ 4670*/
4546static void 4671static void
4547st_collections_group_parts_part_description_min(void) 4672st_collections_group_parts_part_description_min(void)
4548{ 4673{
4549 check_arg_count(2); 4674 check_min_arg_count(1);
4675
4676 if (is_param(1)) {
4677 current_desc->min.w = parse_float_range(0, 0, 0x7fffffff);
4678 current_desc->min.h = parse_float_range(1, 0, 0x7fffffff);
4679 } else {
4680 char *tmp;
4681
4682 tmp = parse_str(0);
4683 if ((current_part->type != EDJE_PART_TYPE_IMAGE && current_part->type != EDJE_PART_TYPE_GROUP) ||
4684 !tmp || strcmp(tmp, "SOURCE") != 0)
4685 {
4686 ERR("%s: Error. parse error %s:%i. "
4687 "Only IMAGE and GROUP part can have a min: SOURCE; defined",
4688 progname, file_in, line - 1);
4689 exit(-1);
4690 }
4550 4691
4551 current_desc->min.w = parse_float_range(0, 0, 0x7fffffff); 4692 current_desc->min.limit = EINA_TRUE;
4552 current_desc->min.h = parse_float_range(1, 0, 0x7fffffff); 4693 }
4553} 4694}
4554 4695
4555/** 4696/**
@@ -4578,18 +4719,38 @@ st_collections_group_parts_part_description_minmul(void)
4578 @property 4719 @property
4579 max 4720 max
4580 @parameters 4721 @parameters
4581 [width] [height] 4722 [width] [height] or SOURCE
4582 @effect 4723 @effect
4583 The maximum size of the state. A size of -1.0 means that it will be ignored in one direction. 4724 The maximum size of the state. A size of -1.0 means that it will be ignored in one direction.
4725
4726 When max is set to SOURCE, edje will enforce the part to be
4727 not more than the original image size. The part must be an
4728 IMAGE part.
4584 @endproperty 4729 @endproperty
4585*/ 4730*/
4586static void 4731static void
4587st_collections_group_parts_part_description_max(void) 4732st_collections_group_parts_part_description_max(void)
4588{ 4733{
4589 check_arg_count(2); 4734 check_min_arg_count(1);
4735
4736 if (is_param(1)) {
4737 current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff);
4738 current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff);
4739 } else {
4740 char *tmp;
4590 4741
4591 current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff); 4742 tmp = parse_str(0);
4592 current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff); 4743 if (current_part->type != EDJE_PART_TYPE_IMAGE ||
4744 !tmp || strcmp(tmp, "SOURCE") != 0)
4745 {
4746 ERR("%s: Error. parse error %s:%i. "
4747 "Only IMAGE part can have a max: SOURCE; defined",
4748 progname, file_in, line - 1);
4749 exit(-1);
4750 }
4751
4752 current_desc->max.limit = EINA_TRUE;
4753 }
4593} 4754}
4594 4755
4595/** 4756/**
@@ -5039,6 +5200,7 @@ st_collections_group_parts_part_description_image_normal(void)
5039 char *name; 5200 char *name;
5040 5201
5041 name = parse_str(0); 5202 name = parse_str(0);
5203 data_queue_image_remove(&(ed->image.id), &(ed->image.set));
5042 data_queue_image_lookup(name, &(ed->image.id), &(ed->image.set)); 5204 data_queue_image_lookup(name, &(ed->image.id), &(ed->image.set));
5043 free(name); 5205 free(name);
5044 } 5206 }
@@ -5083,6 +5245,7 @@ st_collections_group_parts_part_description_image_tween(void)
5083 sizeof (Edje_Part_Image_Id*) * ed->image.tweens_count); 5245 sizeof (Edje_Part_Image_Id*) * ed->image.tweens_count);
5084 ed->image.tweens[ed->image.tweens_count - 1] = iid; 5246 ed->image.tweens[ed->image.tweens_count - 1] = iid;
5085 name = parse_str(0); 5247 name = parse_str(0);
5248 data_queue_image_remove(&(iid->id), &(iid->set));
5086 data_queue_image_lookup(name, &(iid->id), &(iid->set)); 5249 data_queue_image_lookup(name, &(iid->id), &(iid->set));
5087 free(name); 5250 free(name);
5088 } 5251 }