summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYoungBok Shin <id213sin@gmail.com>2020-02-17 18:59:09 +0900
committerHermet Park <hermetpark@gmail.com>2020-02-17 18:59:09 +0900
commit2fe158ce652860b2aa5a2e883e6b2beb0ee1c670 (patch)
treea1de907a23578f956f7f0c695ea53e3e77b5b3c1 /src/bin
parentba8c349eedd35608f94996aada44ab8d1c404d4a (diff)
edje: add json file support feature
Summary: It also starts to support following new edc properties. This is backported patch from Tizen 5.0 1. frame desc { "default" vector { frame: 0.5; // 0.0 ~ 1.0 } } 2. actions program { "vector_animation"; // VG_ANIM_PLAY, VG_ANIM_PLAY_BACK, VG_ANIM_LOOP, // VG_ANIM_STOP, VG_ANIM_PAUSE, VG_ANIM_RESUME action: VG_ANIM_PLAY; target: "your_vector_part"; } @feature Co-authored-by: Jaehyun Cho <jae_hyun.cho@samsung.com> - Fix to remove Efl.Canvas.Animation_Player on edje Test Plan: {F3840540} {F3840542} {F3840543} make and test attached file edje_cc -beta -id ./ json_edc.edc json.edj gcc -o test test_edc.c -g `pkg-config --cflags --libs evas elementary rlottie` ./test Reviewers: Hermet, Jaehyun_Cho, id213sin Reviewed By: Hermet Subscribers: segfaultxavi, raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11228
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/edje/edje_cc_handlers.c56
-rw-r--r--src/bin/edje/edje_cc_out.c51
2 files changed, 96 insertions, 11 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 6b7ec172e7..59a0f377a8 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -516,6 +516,9 @@ static void st_collections_group_parts_part_description_params_bool(void);
516static void st_collections_group_parts_part_description_params_choice(void); 516static void st_collections_group_parts_part_description_params_choice(void);
517static void st_collections_group_parts_part_description_params_smart(void); 517static void st_collections_group_parts_part_description_params_smart(void);
518 518
519/* vector part parameter */
520static void st_collections_group_parts_part_description_vector_frame(void);
521
519static void ob_collections_group_programs_program(void); 522static void ob_collections_group_programs_program(void);
520static void st_collections_group_programs_program_name(void); 523static void st_collections_group_programs_program_name(void);
521static void st_collections_group_programs_program_signal(void); 524static void st_collections_group_programs_program_signal(void);
@@ -1047,6 +1050,7 @@ New_Statement_Handler statement_handlers[] =
1047 {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool}, 1050 {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool},
1048 {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice}, 1051 {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice},
1049 {"collections.group.parts.part.description.params.*", st_collections_group_parts_part_description_params_smart}, 1052 {"collections.group.parts.part.description.params.*", st_collections_group_parts_part_description_params_smart},
1053 {"collections.group.parts.part.description.vector.frame", st_collections_group_parts_part_description_vector_frame},
1050 IMAGE_STATEMENTS("collections.group.parts.part.description.") 1054 IMAGE_STATEMENTS("collections.group.parts.part.description.")
1051 { 1055 {
1052 "collections.group.parts.part.description.font", st_fonts_font 1056 "collections.group.parts.part.description.font", st_fonts_font
@@ -1590,6 +1594,7 @@ New_Object_Handler object_handlers[] =
1590 {"collections.group.parts.part.description.map.zoom", NULL}, 1594 {"collections.group.parts.part.description.map.zoom", NULL},
1591 {"collections.group.parts.part.description.perspective", NULL}, 1595 {"collections.group.parts.part.description.perspective", NULL},
1592 {"collections.group.parts.part.description.params", NULL}, 1596 {"collections.group.parts.part.description.params", NULL},
1597 {"collections.group.parts.part.description.vector", NULL},
1593 {"collections.group.parts.part.description.color_classes", NULL}, /* dup */ 1598 {"collections.group.parts.part.description.color_classes", NULL}, /* dup */
1594 {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */ 1599 {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */
1595 {"collections.group.parts.part.description.text_classes", NULL}, /* dup */ 1600 {"collections.group.parts.part.description.text_classes", NULL}, /* dup */
@@ -2545,6 +2550,7 @@ _handle_vector_image(void)
2545 { 2550 {
2546 ed->vg.set = EINA_TRUE; 2551 ed->vg.set = EINA_TRUE;
2547 ed->vg.id = edje_file->image_dir->vectors[i].id; 2552 ed->vg.id = edje_file->image_dir->vectors[i].id;
2553 ed->vg.type = edje_file->image_dir->vectors[i].type;
2548 break; 2554 break;
2549 } 2555 }
2550 } 2556 }
@@ -2587,6 +2593,7 @@ st_images_vector(void)
2587 Edje_Vector_Directory_Entry *vector; 2593 Edje_Vector_Directory_Entry *vector;
2588 const char *tmp; 2594 const char *tmp;
2589 unsigned int i; 2595 unsigned int i;
2596 size_t entry_len;
2590 2597
2591 check_min_arg_count(1); 2598 check_min_arg_count(1);
2592 2599
@@ -2618,6 +2625,16 @@ st_images_vector(void)
2618 2625
2619 vector->entry = tmp; 2626 vector->entry = tmp;
2620 vector->id = edje_file->image_dir->vectors_count - 1; 2627 vector->id = edje_file->image_dir->vectors_count - 1;
2628
2629 entry_len = strlen(vector->entry);
2630 if ((entry_len > 5) && !strncmp(vector->entry + entry_len - 5, ".json", 5))
2631 {
2632 vector->type = EDJE_VECTOR_FILE_TYPE_JSON;
2633 }
2634 else
2635 {
2636 vector->type = EDJE_VECTOR_FILE_TYPE_SVG;
2637 }
2621} 2638}
2622 2639
2623/** 2640/**
@@ -8960,6 +8977,8 @@ st_collections_group_parts_part_description_inherit(void)
8960 Edje_Part_Description_Vector *iparent = (Edje_Part_Description_Vector *)parent; 8977 Edje_Part_Description_Vector *iparent = (Edje_Part_Description_Vector *)parent;
8961 ied->vg.set = iparent->vg.set; 8978 ied->vg.set = iparent->vg.set;
8962 ied->vg.id = iparent->vg.id; 8979 ied->vg.id = iparent->vg.id;
8980 ied->vg.type = iparent->vg.type;
8981 ied->vg.frame = iparent->vg.frame;
8963 break; 8982 break;
8964 } 8983 }
8965 } 8984 }
@@ -15235,6 +15254,25 @@ st_collections_group_parts_part_description_params_choice(void)
15235 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE); 15254 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE);
15236} 15255}
15237 15256
15257static void
15258st_collections_group_parts_part_description_vector_frame(void)
15259{
15260 Edje_Part_Description_Vector *ed;
15261
15262 check_arg_count(1);
15263
15264 if (current_part->type != EDJE_PART_TYPE_VECTOR)
15265 {
15266 ERR("parse error %s:%i. vector attributes in non-VECTOR part.",
15267 file_in, line - 1);
15268 exit(-1);
15269 }
15270
15271 ed = (Edje_Part_Description_Vector *)current_desc;
15272
15273 ed->vg.frame = parse_float_range(0, 0.0, 1.0);
15274}
15275
15238/** @edcsubsection{collections_group_parts_description_links, 15276/** @edcsubsection{collections_group_parts_description_links,
15239 * Group.Parts.Part.Description.Links} */ 15277 * Group.Parts.Part.Description.Links} */
15240 15278
@@ -15747,6 +15785,12 @@ st_collections_group_programs_program_action(void)
15747 "PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP, 15785 "PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP,
15748 "PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET, 15786 "PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET,
15749 "PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE, 15787 "PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE,
15788 "VG_ANIM_STOP", EDJE_ACTION_TYPE_VG_ANIM_STOP,
15789 "VG_ANIM_PAUSE", EDJE_ACTION_TYPE_VG_ANIM_PAUSE,
15790 "VG_ANIM_RESUME", EDJE_ACTION_TYPE_VG_ANIM_RESUME,
15791 "VG_ANIM_PLAY", EDJE_ACTION_TYPE_VG_ANIM_PLAY,
15792 "VG_ANIM_PLAY_BACK", EDJE_ACTION_TYPE_VG_ANIM_REWIND,
15793 "VG_ANIM_LOOP", EDJE_ACTION_TYPE_VG_ANIM_LOOP,
15750 NULL); 15794 NULL);
15751 if (ep->action == EDJE_ACTION_TYPE_STATE_SET) 15795 if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
15752 { 15796 {
@@ -15908,6 +15952,12 @@ st_collections_group_programs_program_action(void)
15908 case EDJE_ACTION_TYPE_ACTION_STOP: 15952 case EDJE_ACTION_TYPE_ACTION_STOP:
15909 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR: 15953 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR:
15910 case EDJE_ACTION_TYPE_PHYSICS_STOP: 15954 case EDJE_ACTION_TYPE_PHYSICS_STOP:
15955 case EDJE_ACTION_TYPE_VG_ANIM_STOP:
15956 case EDJE_ACTION_TYPE_VG_ANIM_PAUSE:
15957 case EDJE_ACTION_TYPE_VG_ANIM_RESUME:
15958 case EDJE_ACTION_TYPE_VG_ANIM_PLAY:
15959 case EDJE_ACTION_TYPE_VG_ANIM_REWIND:
15960 case EDJE_ACTION_TYPE_VG_ANIM_LOOP:
15911 check_arg_count(1); 15961 check_arg_count(1);
15912 break; 15962 break;
15913 15963
@@ -16187,6 +16237,12 @@ _program_target_add(char *name)
16187 case EDJE_ACTION_TYPE_PHYSICS_STOP: 16237 case EDJE_ACTION_TYPE_PHYSICS_STOP:
16188 case EDJE_ACTION_TYPE_PHYSICS_ROT_SET: 16238 case EDJE_ACTION_TYPE_PHYSICS_ROT_SET:
16189#endif 16239#endif
16240 case EDJE_ACTION_TYPE_VG_ANIM_STOP:
16241 case EDJE_ACTION_TYPE_VG_ANIM_PAUSE:
16242 case EDJE_ACTION_TYPE_VG_ANIM_RESUME:
16243 case EDJE_ACTION_TYPE_VG_ANIM_PLAY:
16244 case EDJE_ACTION_TYPE_VG_ANIM_REWIND:
16245 case EDJE_ACTION_TYPE_VG_ANIM_LOOP:
16190 data_queue_part_lookup(pc, name, &(et->id)); 16246 data_queue_part_lookup(pc, name, &(et->id));
16191 break; 16247 break;
16192 16248
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index f932eac9e9..4c192efe6e 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -1428,19 +1428,48 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1428 if (!f) continue; 1428 if (!f) continue;
1429 eina_file_close(f); 1429 eina_file_close(f);
1430 1430
1431 if (efl_file_set(vg, eina_strbuf_string_get(buf))) 1431 if (vector->type == EDJE_VECTOR_FILE_TYPE_JSON)
1432 error_and_abort(ef, "Failed to parse svg : %s", vector->entry); 1432 {
1433 if (efl_file_load(vg)) 1433 char *json_data = NULL;
1434 error_and_abort(ef, "Failed to parse svg : %s", vector->entry); 1434 int json_data_len = 0;
1435 1435
1436 eina_strbuf_reset(buf); 1436 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1437 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id); 1437 if (!f) continue;
1438 if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1439 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1440 1438
1441 *vector_num += 1; 1439 json_data_len = (int) eina_file_size_get(f);
1442 found = EINA_TRUE; 1440 json_data = eina_file_map_all(f, EINA_FILE_POPULATE);
1443 break; 1441
1442 eina_strbuf_reset(buf);
1443 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1444 eet_write(ef, eina_strbuf_string_get(buf), json_data, json_data_len, EET_COMPRESSION_NONE);
1445
1446 eina_file_map_free(f, json_data);
1447 eina_file_close(f);
1448
1449 *vector_num += 1;
1450 found = EINA_TRUE;
1451 break;
1452 }
1453 else
1454 {
1455 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1456 if (!f) continue;
1457 eina_file_close(f);
1458
1459 if (efl_file_set(vg, eina_strbuf_string_get(buf)))
1460 error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1461 if (efl_file_load(vg))
1462 error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1463
1464 eina_strbuf_reset(buf);
1465 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1466 if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1467 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1468
1469 *vector_num += 1;
1470 found = EINA_TRUE;
1471 break;
1472 }
1444 } 1473 }
1445 if (!found) 1474 if (!found)
1446 error_and_abort(ef, "Unable to find the svg :%s", vector->entry); 1475 error_and_abort(ef, "Unable to find the svg :%s", vector->entry);