From 83e505b5c607523af726406a26e4c3a507a7e4c8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 1 Jun 2010 13:31:07 +0000 Subject: [PATCH] * edje: Add image set support. Ease support of Freedesktop multiple size image. Sample: ------- images { .. set { name: "image_name_used"; image { image: "500x500.png" LOSSY 90; size: 201 201 500 500; } image { image: "200x200.png" COMP; size: 51 51 200 200; } image { image: "50x50.png" COMP; size: 11 11 50 50; } image { image: "10x10.png" COMP; size: 0 0 10 10; } } .. } SVN revision: 49369 --- legacy/edje/src/bin/edje_cc.h | 2 +- legacy/edje/src/bin/edje_cc_handlers.c | 272 ++++++++++++++++++++++++- legacy/edje/src/bin/edje_cc_out.c | 34 +++- legacy/edje/src/lib/edje_calc.c | 89 +++++++- legacy/edje/src/lib/edje_data.c | 24 +++ legacy/edje/src/lib/edje_edit.c | 6 + legacy/edje/src/lib/edje_embryo.c | 2 + legacy/edje/src/lib/edje_load.c | 6 + legacy/edje/src/lib/edje_private.h | 40 +++- 9 files changed, 460 insertions(+), 15 deletions(-) diff --git a/legacy/edje/src/bin/edje_cc.h b/legacy/edje/src/bin/edje_cc.h index 828c6cdda6..2479b0fdca 100644 --- a/legacy/edje/src/bin/edje_cc.h +++ b/legacy/edje/src/bin/edje_cc.h @@ -105,7 +105,7 @@ void data_setup(void); void data_write(void); void data_queue_part_lookup(Edje_Part_Collection *pc, char *name, int *dest); void data_queue_program_lookup(Edje_Part_Collection *pc, char *name, int *dest); -void data_queue_image_lookup(char *name, int *dest); +void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set); void data_queue_part_slave_lookup(int *master, int *slave); void data_queue_image_slave_lookup(int *master, int *slave); void data_queue_spectrum_lookup(char *name, int *dest); diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c index c10d89e9d3..33c45095b7 100644 --- a/legacy/edje/src/bin/edje_cc_handlers.c +++ b/legacy/edje/src/bin/edje_cc_handlers.c @@ -73,6 +73,11 @@ static void st_externals_external(void); static void st_images_image(void); +static void ob_images_set(void); +static void st_images_set_name(void); +static void ob_images_set_image(void); +static void st_images_set_image_image(void); +static void st_images_set_image_size(void); static void st_fonts_font(void); @@ -261,6 +266,9 @@ New_Statement_Handler statement_handlers[] = { {"externals.external", st_externals_external}, {"images.image", st_images_image}, + {"images.set.name", st_images_set_name}, + {"images.set.image.image", st_images_set_image_image}, + {"images.set.image.size", st_images_set_image_size}, {"fonts.font", st_fonts_font}, {"data.item", st_data_item}, {"data.file", st_data_file}, @@ -276,7 +284,13 @@ New_Statement_Handler statement_handlers[] = {"spectra.spectrum.color", st_spectrum_color}, {"collections.externals.external", st_externals_external}, /* dup */ {"collections.image", st_images_image}, /* dup */ + {"collections.set.name", st_images_set_name}, /* dup */ + {"collections.set.image.image", st_images_set_image_image}, /* dup */ + {"collections.set.image.size", st_images_set_image_size}, /* dup */ {"collections.images.image", st_images_image}, /* dup */ + {"collections.images.set.name", st_images_set_name}, /* dup */ + {"collections.images.set.image.image", st_images_set_image_image}, /* dup */ + {"collections.images.set.image.size", st_images_set_image_size}, /* dup */ {"collections.font", st_fonts_font}, /* dup */ {"collections.fonts.font", st_fonts_font}, /* dup */ {"collections.styles.style.name", st_styles_style_name}, /* dup */ @@ -295,7 +309,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.data.item", st_collections_group_data_item}, {"collections.group.externals.external", st_externals_external}, /* dup */ {"collections.group.image", st_images_image}, /* dup */ + {"collections.group.set.name", st_images_set_name}, + {"collections.group.set.image.image", st_images_set_image_image}, + {"collections.group.set.image.size", st_images_set_image_size}, {"collections.group.images.image", st_images_image}, /* dup */ + {"collections.group.images.set.name", st_images_set_name}, + {"collections.group.images.set.image.image", st_images_set_image_image}, + {"collections.group.images.set.image.size", st_images_set_image_size}, {"collections.group.font", st_fonts_font}, /* dup */ {"collections.group.fonts.font", st_fonts_font}, /* dup */ {"collections.group.styles.style.name", st_styles_style_name}, /* dup */ @@ -306,7 +326,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.color_classes.color_class.color2", st_color_class_color2}, /* dup */ {"collections.group.color_classes.color_class.color3", st_color_class_color3}, /* dup */ {"collections.group.parts.image", st_images_image}, /* dup */ + {"collections.group.parts.set.name", st_images_set_name}, + {"collections.group.parts.set.image.image", st_images_set_image_image}, + {"collections.group.parts.set.image.size", st_images_set_image_size}, {"collections.group.parts.images.image", st_images_image}, /* dup */ + {"collections.group.parts.images.set.name", st_images_set_name}, + {"collections.group.parts.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.font", st_fonts_font}, /* dup */ {"collections.group.parts.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.styles.style.name", st_styles_style_name}, /* dup */ @@ -342,7 +368,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.select_mode", st_collections_group_parts_part_select_mode}, {"collections.group.parts.part.multiline", st_collections_group_parts_part_multiline}, {"collections.group.parts.part.image", st_images_image}, /* dup */ + {"collections.group.parts.part.set.name", st_images_set_name}, + {"collections.group.parts.part.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.images.set.name", st_images_set_name}, + {"collections.group.parts.part.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.styles.style.name", st_styles_style_name}, /* dup */ @@ -401,7 +433,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal}, {"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween}, {"collections.group.parts.part.description.image.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.image.set.name", st_images_set_name}, + {"collections.group.parts.part.description.image.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.image.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.description.image.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.image.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.image.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.image.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.description.image.border", st_collections_group_parts_part_description_image_border}, {"collections.group.parts.part.description.image.middle", st_collections_group_parts_part_description_image_middle}, {"collections.group.parts.part.description.image.border_scale", st_collections_group_parts_part_description_image_border_scale}, @@ -465,6 +503,9 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool}, {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice}, {"collections.group.parts.part.description.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.description.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.description.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.description.styles.style.name", st_styles_style_name}, /* dup */ @@ -475,7 +516,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.color_classes.color_class.color2", st_color_class_color2}, /* dup */ {"collections.group.parts.part.description.color_classes.color_class.color3", st_color_class_color3}, /* dup */ {"collections.group.parts.part.description.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.programs.set.name", st_images_set_name}, + {"collections.group.parts.part.description.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.programs.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.description.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.description.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.part.description.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.description.programs.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.description.programs.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.description.programs.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.description.programs.program.name", st_collections_group_programs_program_name}, /* dup */ @@ -497,7 +544,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.program.after", st_collections_group_programs_program_after}, /* dup */ {"collections.group.parts.part.description.program.api", st_collections_group_programs_program_api}, /* dup */ {"collections.group.parts.part.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.part.programs.set.name", st_images_set_name}, + {"collections.group.parts.part.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.programs.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.part.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.part.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.part.programs.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.part.programs.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.programs.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.programs.program.name", st_collections_group_programs_program_name}, /* dup */ @@ -519,7 +572,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.program.after", st_collections_group_programs_program_after}, /* dup */ {"collections.group.parts.part.program.api", st_collections_group_programs_program_api}, /* dup */ {"collections.group.parts.programs.image", st_images_image}, /* dup */ + {"collections.group.parts.programs.set.name", st_images_set_name}, + {"collections.group.parts.programs.set.image.image", st_images_set_image_image}, + {"collections.group.parts.programs.set.image.size", st_images_set_image_size}, {"collections.group.parts.programs.images.image", st_images_image}, /* dup */ + {"collections.group.parts.programs.images.set.name", st_images_set_name}, + {"collections.group.parts.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.parts.programs.images.set.image.size", st_images_set_image_size}, {"collections.group.parts.programs.font", st_fonts_font}, /* dup */ {"collections.group.parts.programs.fonts.font", st_fonts_font}, /* dup */ {"collections.group.parts.programs.program.name", st_collections_group_programs_program_name}, /* dup */ @@ -562,7 +621,13 @@ New_Statement_Handler statement_handlers[] = {"collections.group.programs.program.after", st_collections_group_programs_program_after}, {"collections.group.programs.program.api", st_collections_group_programs_program_api}, {"collections.group.programs.image", st_images_image}, /* dup */ + {"collections.group.programs.set.name", st_images_set_name}, + {"collections.group.programs.set.image.image", st_images_set_image_image}, + {"collections.group.programs.set.image.size", st_images_set_image_size}, {"collections.group.programs.images.image", st_images_image}, /* dup */ + {"collections.group.programs.images.set.name", st_images_set_name}, + {"collections.group.programs.images.set.image.image", st_images_set_image_image}, + {"collections.group.programs.images.set.image.size", st_images_set_image_size}, {"collections.group.programs.font", st_fonts_font}, /* dup */ {"collections.group.programs.fonts.font", st_fonts_font} /* dup */ }; @@ -571,6 +636,8 @@ New_Object_Handler object_handlers[] = { {"externals", NULL}, {"images", NULL}, + {"images.set", ob_images_set}, + {"images.set.image", ob_images_set_image}, {"fonts", NULL}, {"data", NULL}, {"styles", NULL}, @@ -581,7 +648,11 @@ New_Object_Handler object_handlers[] = {"spectra.spectrum", ob_spectrum}, {"collections", ob_collections}, {"collections.externals", NULL}, /* dup */ + {"collections.set", ob_images_set}, /* dup */ + {"collections.set.image", ob_images_set_image}, /* dup */ {"collections.images", NULL}, /* dup */ + {"collections.images.set", ob_images_set}, /* dup */ + {"collections.images.set.image", ob_images_set_image}, /* dup */ {"collections.fonts", NULL}, /* dup */ {"collections.styles", NULL}, /* dup */ {"collections.styles.style", ob_styles_style}, /* dup */ @@ -592,14 +663,22 @@ New_Object_Handler object_handlers[] = {"collections.group.script", ob_collections_group_script}, {"collections.group.lua_script", ob_collections_group_lua_script}, {"collections.group.externals", NULL}, /* dup */ + {"collections.group.set", ob_images_set}, /* dup */ + {"collections.group.set.image", ob_images_set_image}, /* dup */ {"collections.group.images", NULL}, /* dup */ + {"collections.group.images.set", ob_images_set}, /* dup */ + {"collections.group.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.fonts", NULL}, /* dup */ {"collections.group.styles", NULL}, /* dup */ {"collections.group.styles.style", ob_styles_style}, /* dup */ {"collections.group.color_classes", NULL}, /* dup */ {"collections.group.color_classes.color_class", ob_color_class}, /* dup */ {"collections.group.parts", NULL}, + {"collections.group.parts.set", ob_images_set}, /* dup */ + {"collections.group.parts.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.images", NULL}, /* dup */ + {"collections.group.parts.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.fonts", NULL}, /* dup */ {"collections.group.parts.styles", NULL}, /* dup */ {"collections.group.parts.styles.style", ob_styles_style}, /* dup */ @@ -607,7 +686,11 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.color_classes.color_class", ob_color_class}, /* dup */ {"collections.group.parts.part", ob_collections_group_parts_part}, {"collections.group.parts.part.dragable", NULL}, + {"collections.group.parts.part.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.images", NULL}, /* dup */ + {"collections.group.parts.part.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.fonts", NULL}, /* dup */ {"collections.group.parts.part.styles", NULL}, /* dup */ {"collections.group.parts.part.styles.style", ob_styles_style}, /* dup */ @@ -623,13 +706,19 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.description.rel1", NULL}, {"collections.group.parts.part.description.rel2", NULL}, {"collections.group.parts.part.description.image", NULL}, /* dup */ + {"collections.group.parts.part.description.image.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.image.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.description.image.images", NULL}, /* dup */ + {"collections.group.parts.part.description.image.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.image.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.description.fill", NULL}, {"collections.group.parts.part.description.fill.origin", NULL}, {"collections.group.parts.part.description.fill.size", NULL}, {"collections.group.parts.part.description.text", NULL}, {"collections.group.parts.part.description.text.fonts", NULL}, /* dup */ {"collections.group.parts.part.description.images", NULL}, /* dup */ + {"collections.group.parts.part.description.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.description.fonts", NULL}, /* dup */ {"collections.group.parts.part.description.styles", NULL}, /* dup */ {"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */ @@ -648,7 +737,11 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.description.program.script", ob_collections_group_programs_program_script}, /* dup */ {"collections.group.parts.part.description.program.lua_script", ob_collections_group_programs_program_lua_script}, /* dup */ {"collections.group.parts.part.description.programs", NULL}, /* dup */ + {"collections.group.parts.part.description.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.description.programs.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.description.programs.images", NULL}, /* dup */ + {"collections.group.parts.part.description.programs.images.set", ob_images_set}, + {"collections.group.parts.part.description.programs.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.description.programs.fonts", NULL}, /* dup */ {"collections.group.parts.part.description.programs.program", ob_collections_group_programs_program}, /* dup */ {"collections.group.parts.part.description.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ @@ -659,7 +752,11 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.program.script", ob_collections_group_programs_program_script}, /* dup */ {"collections.group.parts.part.program.lua_script", ob_collections_group_programs_program_lua_script}, /* dup */ {"collections.group.parts.part.programs", NULL}, /* dup */ + {"collections.group.parts.part.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.programs.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.programs.images", NULL}, /* dup */ + {"collections.group.parts.part.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.part.programs.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.part.programs.fonts", NULL}, /* dup */ {"collections.group.parts.part.programs.program", ob_collections_group_programs_program}, /* dup */ {"collections.group.parts.part.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ @@ -670,7 +767,11 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.program.script", ob_collections_group_programs_program_script}, /* dup */ {"collections.group.parts.program.lua_script", ob_collections_group_programs_program_lua_script}, /* dup */ {"collections.group.parts.programs", NULL}, /* dup */ + {"collections.group.parts.programs.set", ob_images_set}, /* dup */ + {"collections.group.parts.programs.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.programs.images", NULL}, /* dup */ + {"collections.group.parts.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.parts.programs.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.parts.programs.fonts", NULL}, /* dup */ {"collections.group.parts.programs.program", ob_collections_group_programs_program}, /* dup */ {"collections.group.parts.programs.program.script", ob_collections_group_programs_program_script}, /* dup */ @@ -681,7 +782,11 @@ New_Object_Handler object_handlers[] = {"collections.group.program.script", ob_collections_group_programs_program_script}, /* dup */ {"collections.group.program.lua_script", ob_collections_group_programs_program_lua_script}, /* dup */ {"collections.group.programs", NULL}, + {"collections.group.programs.set", ob_images_set}, /* dup */ + {"collections.group.programs.set.image", ob_images_set_image}, /* dup */ {"collections.group.programs.images", NULL}, /* dup */ + {"collections.group.programs.images.set", ob_images_set}, /* dup */ + {"collections.group.programs.images.set.image", ob_images_set_image}, /* dup */ {"collections.group.programs.fonts", NULL}, /* dup */ {"collections.group.programs.program", ob_collections_group_programs_program}, {"collections.group.programs.program.script", ob_collections_group_programs_program_script}, @@ -778,14 +883,33 @@ st_externals_external(void) images { image: "filename1.ext" COMP; image: "filename2.ext" LOSSY 99; + set { + name: "image_name_used"; + image { + image: "filename3.ext" LOSSY 90; + size: 201 201 500 500; + } + image { + image: "filename4.ext" COMP; + size: 51 51 200 200; + } + image { + image: "filename5.ext" COMP; + size: 11 11 50 50; + } + image { + image: "filename6.ext" RAW; + size: 0 0 10 10; + } + } .. } @description The "images" block is used to list each image file that will be used in the theme along with its compression method (if any). - Besides the domcument's root, additional "images" blocks can be + Besides the document's root, additional "images" blocks can be included inside other blocks, normally "collections", "group" and - "part", easing mantienance of the file list when the theme is split + "part", easing maintenance of the file list when the theme is split among multiple files. @endblock @@ -864,6 +988,146 @@ st_images_image(void) } } +/** + @page edcref + + @block + set + @context + set { + name: "image_name_used"; + image { + image: "filename3.ext" LOSSY 90; + size: 201 201 500 500; + } + image { + image: "filename4.ext" COMP; + size: 51 51 200 200; + } + image { + image: "filename5.ext" COMP; + size: 11 11 50 50; + } + image { + image: "filename6.ext" RAW; + size: 0 0 10 10; + } + } + @description + The "set" block is used to define an image with different content depending on their size. + Besides the document's root, additional "set" blocks can be + included inside other blocks, normally "collections", "group" and + "part", easing maintenance of the file list when the theme is split + among multiple files. + @endblock + */ +static void +ob_images_set(void) +{ + Edje_Image_Directory_Set *set; + + if (!edje_file->image_dir) + edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory)); + set = mem_alloc(SZ(Edje_Image_Directory_Set)); + set->id = eina_list_count(edje_file->image_dir->sets); + edje_file->image_dir->sets = eina_list_append(edje_file->image_dir->sets, set); +} + +/** + @page edcref + + @property + name + @parameters + [image name] + @effect + Define the name that refer to this image description. + @endproperty +*/ +static void +st_images_set_name(void) +{ + Edje_Image_Directory_Set *set; + + check_arg_count(1); + + set = eina_list_data_get(eina_list_last(edje_file->image_dir->sets)); + set->name = parse_str(0); +} + +static void +ob_images_set_image(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + + set = eina_list_data_get(eina_list_last(edje_file->image_dir->sets)); + + entry = mem_alloc(SZ(Edje_Image_Directory_Set_Entry)); + + set->entries = eina_list_append(set->entries, entry); +} + +static void +st_images_set_image_image(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + Edje_Image_Directory_Entry *img; + Eina_List *l; + + set = eina_list_data_get(eina_list_last(edje_file->image_dir->sets)); + entry = eina_list_data_get(eina_list_last(set->entries)); + + /* Add the image to the global pool with the same syntax. */ + st_images_image(); + + entry->name = parse_str(0); + + EINA_LIST_FOREACH(edje_file->image_dir->entries, l, img) + if (!strcmp(img->entry, entry->name)) + { + entry->id = img->id; + return; + } +} + +/** + @page edcref + + @property + size + @parameters + [minw minh maxw mawh] + @effect + Define the minimal and maximal size that will select the specified image. + @endproperty +*/ +static void +st_images_set_image_size(void) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set; + + set = eina_list_data_get(eina_list_last(edje_file->image_dir->sets)); + entry = eina_list_data_get(eina_list_last(set->entries)); + + entry->size.min.w = parse_int(0); + entry->size.min.h = parse_int(1); + entry->size.max.w = parse_int(2); + entry->size.max.h = parse_int(3); + + if (entry->size.min.w > entry->size.max.w + || entry->size.min.h > entry->size.max.h) + { + ERR("%s: Error. parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", + progname, file_in, line - 1, + entry->size.min.w, entry->size.min.h, + entry->size.max.w, entry->size.max.h); + exit(-1); + } +} + /** @page edcref @@ -4024,7 +4288,7 @@ st_collections_group_parts_part_description_image_normal(void) char *name; name = parse_str(0); - data_queue_image_lookup(name, &(ed->image.id)); + data_queue_image_lookup(name, &(ed->image.id), &(ed->image.set)); free(name); } } @@ -4070,7 +4334,7 @@ st_collections_group_parts_part_description_image_tween(void) iid = mem_alloc(SZ(Edje_Part_Image_Id)); ed->image.tween_list = eina_list_append(ed->image.tween_list, iid); name = parse_str(0); - data_queue_image_lookup(name, &(iid->id)); + data_queue_image_lookup(name, &(iid->id), &(iid->set)); free(name); } } diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index b7b8cbc946..ec19d58fb1 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -40,7 +40,7 @@ typedef struct _External_Lookup External_Lookup; typedef struct _Part_Lookup Part_Lookup; typedef struct _Program_Lookup Program_Lookup; typedef struct _Group_Lookup Group_Lookup; -typedef struct _String_Lookup Image_Lookup; +typedef struct _Image_Lookup Image_Lookup; typedef struct _String_Lookup Spectrum_Lookup; typedef struct _Slave_Lookup Slave_Lookup; typedef struct _Code_Lookup Code_Lookup; @@ -76,6 +76,13 @@ struct _String_Lookup int *dest; }; +struct _Image_Lookup +{ + char *name; + int *dest; + Eina_Bool *set; +}; + struct _Slave_Lookup { int *master; @@ -87,6 +94,7 @@ struct _Code_Lookup char *ptr; int len; int val; + Eina_Bool set; }; static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char *ptr, int len)); @@ -208,6 +216,7 @@ check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) Eina_List *l; Edje_Part_Description *data; + /* FIXME: check image set and sort them. */ if (!epd) error_and_abort(ef, "Collection %i: default description missing " "for part \"%s\"\n", pc->id, ep->name); @@ -1160,7 +1169,7 @@ data_queue_program_lookup(Edje_Part_Collection *pc, char *name, int *dest) } void -data_queue_image_lookup(char *name, int *dest) +data_queue_image_lookup(char *name, int *dest, Eina_Bool *set) { Image_Lookup *il; @@ -1168,6 +1177,7 @@ data_queue_image_lookup(char *name, int *dest) image_lookups = eina_list_append(image_lookups, il); il->name = mem_strdup(name); il->dest = dest; + il->set = set; } void @@ -1328,9 +1338,26 @@ data_process_lookups(void) *(il->dest) = -de->id - 1; else *(il->dest) = de->id; + *(il->set) = EINA_FALSE; break; } } + + if (!l) + { + Edje_Image_Directory_Set *set; + + EINA_LIST_FOREACH(edje_file->image_dir->sets, l, set) + { + if ((set->name) && (!strcmp(set->name, il->name))) + { + handle_slave_lookup(image_slave_lookups, il->dest, set->id); + *(il->dest) = set->id; + *(il->set) = EINA_TRUE; + break; + } + } + } } if (!l) @@ -1547,7 +1574,7 @@ _data_queue_image_pc_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, cha cl->ptr = ptr; cl->len = len; - data_queue_image_lookup(name, &(cl->val)); + data_queue_image_lookup(name, &(cl->val), &(cl->set)); code_lookups = eina_list_append(code_lookups, cl); } @@ -1601,6 +1628,7 @@ data_process_script_lookups(void) char buf[12]; int n; + /* FIXME !! Handle set in program */ n = eina_convert_itoa(cl->val, buf); if (n > cl->len) { diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c index 6e48ccd43f..692b7161d5 100644 --- a/legacy/edje/src/lib/edje_calc.c +++ b/legacy/edje/src/lib/edje_calc.c @@ -122,7 +122,10 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl if (epd2 != NULL && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epd2->image.tween_list))) { if (!ep->param2) - ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State)); + { + ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State)); + memset(ep->param2, 0, sizeof (Edje_Real_Part_State)); + } else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params); ep->param2->external_params = NULL; @@ -132,6 +135,8 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl { if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params); + if (ep->param2) + free(ep->param2->set); eina_mempool_free(_edje_real_part_state_mp, ep->param2); ep->param2 = NULL; } @@ -1506,6 +1511,70 @@ _edje_table_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Para } } +static int +_edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description *st, Edje_Part_Image_Id *imid) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set = NULL; + Eina_List *l; + int w = 0; + int h = 0; + int id; + + if (!st && !imid) + return -1; + + if (st && !st->image.set) + return st->image.id; + + if (imid && !imid->set) + return imid->id; + + if (imid) + id = imid->id; + else + id = st->image.id; + + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + + if (eps && *eps) + { + if ((*eps)->id == id) + set = (*eps)->set; + + if (set) + if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w) + if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h) + return (*eps)->entry->id; + } + + if (!set) + set = eina_list_nth(ed->file->image_dir->sets, id); + + EINA_LIST_FOREACH(set->entries, l, entry) + { + if (entry->size.min.w <= w && w <= entry->size.max.w) + if (entry->size.min.h <= h && h <= entry->size.max.h) + { + if (eps) + { + if (!*eps) + *eps = calloc(1, sizeof (Edje_Real_Part_Set)); + + if (*eps) + { + (*eps)->entry = entry; + (*eps)->set = set; + (*eps)->id = id; + } + } + return entry->id; + } + } + + return -1; +} + static void _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description *chosen_desc, FLOAT_T pos) { @@ -1530,7 +1599,9 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE); else if (chosen_desc->border.no_fill == 2) evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID); - image_id = ep->param1.description->image.id; + + image_id = _edje_image_find(ep->object, ed, + &ep->param1.set, ep->param1.description, NULL); if (image_id < 0) { Edje_Image_Directory_Entry *ie; @@ -1554,19 +1625,27 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj if (image_num > (image_count - 1)) image_num = image_count - 1; if (image_num == 0) - image_id = ep->param1.description->image.id; + { + image_id = _edje_image_find(ep->object, ed, + &ep->param1.set, ep->param1.description, + NULL); + } else if (ep->param2) { if (image_num == (image_count - 1)) - image_id = ep->param2->description->image.id; + { + image_id = _edje_image_find(ep->object, ed, + &ep->param2->set, ep->param2->description, + NULL); + } else { Edje_Part_Image_Id *imid; imid = eina_list_nth(ep->param2->description->image.tween_list, image_num - 1); - if (imid) image_id = imid->id; + image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid); } } if (image_id < 0) diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c index e62f16e934..3b1465c412 100644 --- a/legacy/edje/src/lib/edje_data.c +++ b/legacy/edje/src/lib/edje_data.c @@ -15,6 +15,8 @@ EAPI Eet_Data_Descriptor *_edje_edd_edje_font_directory = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL; +EAPI Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL; +EAPI Eet_Data_Descriptor *_edje_edd_edje_image_directory_set_entry = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_spectrum_directory = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_spectrum_directory_entry = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_spectrum_color = NULL; @@ -65,6 +67,8 @@ _edje_edd_shutdown(void) FREED(_edje_edd_edje_part_description); FREED(_edje_edd_edje_part_image_id); FREED(_edje_edd_edje_external_param); + FREED(_edje_edd_edje_image_directory_set); + FREED(_edje_edd_edje_image_directory_set_entry); } void @@ -104,10 +108,28 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry); + _edje_edd_edje_image_directory_set_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.w", size.min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.h", size.min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.w", size.max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.h", size.max.h, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set); + _edje_edd_edje_image_directory_set = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "entries", entries, _edje_edd_edje_image_directory_set_entry); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory); _edje_edd_edje_image_directory = eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory, Edje_Image_Directory, "entries", entries, _edje_edd_edje_image_directory_entry); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory, Edje_Image_Directory, "sets", sets, _edje_edd_edje_image_directory_set); /* spectrum directory */ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Spectrum_Color); @@ -238,6 +260,7 @@ _edje_edd_init(void) _edje_edd_edje_part_image_id = eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "set", set, EET_T_UCHAR); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param); _edje_edd_edje_external_param = @@ -280,6 +303,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.id_x", rel2.id_x, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.id_y", rel2.id_y, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "image.id", image.id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "image.set", image.set, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description, Edje_Part_Description, "image.tween_list", image.tween_list, _edje_edd_edje_part_image_id); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.l", border.l, EET_T_INT); diff --git a/legacy/edje/src/lib/edje_edit.c b/legacy/edje/src/lib/edje_edit.c index 90e4e65512..2fcefa509d 100644 --- a/legacy/edje/src/lib/edje_edit.c +++ b/legacy/edje/src/lib/edje_edit.c @@ -287,7 +287,13 @@ _edje_real_part_free(Edje_Real_Part *rp) _edje_collection_free_part_description_free(rp->custom->description, 0); free(rp->drag); + + if (rp->param2) + free(rp->param2->set); eina_mempool_free(_edje_real_part_state_mp, rp->param2); + + if (rp->custom) + free(rp->custom->set); eina_mempool_free(_edje_real_part_state_mp, rp->custom); _edje_unref(rp->edje); diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index 14c5d7a46e..4ad0e4a5bb 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -1595,6 +1595,8 @@ _edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params) return 0; } + memset(rp->custom, 0, sizeof (Edje_Real_Part_State)); + *d = *parent; d->state.name = (char *)eina_stringshare_add("custom"); diff --git a/legacy/edje/src/lib/edje_load.c b/legacy/edje/src/lib/edje_load.c index 42cdcf7ba9..865fd2587b 100644 --- a/legacy/edje/src/lib/edje_load.c +++ b/legacy/edje/src/lib/edje_load.c @@ -907,8 +907,14 @@ _edje_file_del(Edje *ed) /* Cleanup optional part. */ free(rp->drag); + free(rp->param1.set); + if (rp->param2) + free(rp->param2->set); eina_mempool_free(_edje_real_part_state_mp, rp->param2); + + if (rp->custom) + free(rp->custom->set); eina_mempool_free(_edje_real_part_state_mp, rp->custom); _edje_unref(rp->edje); diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index 7e8a582088..21aa8ad7bc 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -219,6 +219,8 @@ typedef struct _Edje_Font_Directory Edje_Font_Directory; typedef struct _Edje_Font_Directory_Entry Edje_Font_Directory_Entry; typedef struct _Edje_Image_Directory Edje_Image_Directory; typedef struct _Edje_Image_Directory_Entry Edje_Image_Directory_Entry; +typedef struct _Edje_Image_Directory_Set Edje_Image_Directory_Set; +typedef struct _Edje_Image_Directory_Set_Entry Edje_Image_Directory_Set_Entry; typedef struct _Edje_Spectrum_Directory Edje_Spectrum_Directory; typedef struct _Edje_Spectrum_Directory_Entry Edje_Spectrum_Directory_Entry; typedef struct _Edje_Program Edje_Program; @@ -399,6 +401,7 @@ struct _Edje_External_Directory_Entry struct _Edje_Image_Directory { Eina_List *entries; /* a list of Edje_Image_Directory_Entry */ + Eina_List *sets; /* a list of Edje_Image_Directory_Set */ }; struct _Edje_Image_Directory_Entry @@ -409,6 +412,27 @@ struct _Edje_Image_Directory_Entry int id; /* the id no. of the image */ }; +struct _Edje_Image_Directory_Set +{ + char *name; + Eina_List *entries; + + int id; +}; + +struct _Edje_Image_Directory_Set_Entry +{ + char *name; + int id; + + struct { + struct { + int w; + int h; + } min, max; + } size; +}; + /*----------*/ struct _Edje_Spectrum_Directory @@ -601,6 +625,7 @@ struct _Edje_Part struct _Edje_Part_Image_Id { int id; + Eina_Bool set; }; struct _Edje_Part_Description @@ -633,6 +658,7 @@ struct _Edje_Part_Description 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 */ } image; struct { @@ -744,6 +770,7 @@ struct _Edje_Part_Description typedef struct _Edje Edje; typedef struct _Edje_Real_Part_State Edje_Real_Part_State; typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag; +typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set; typedef struct _Edje_Real_Part Edje_Real_Part; typedef struct _Edje_Running_Program Edje_Running_Program; typedef struct _Edje_Signal_Callback Edje_Signal_Callback; @@ -913,6 +940,14 @@ struct _Edje_Calc_Params unsigned char smooth : 1; // 1 }; // 96 +struct _Edje_Real_Part_Set +{ + Edje_Image_Directory_Set_Entry *entry; // 4 + Edje_Image_Directory_Set *set; // 4 + + int id; // 4 +}; + struct _Edje_Real_Part_State { Edje_Part_Description *description; // 4 @@ -925,8 +960,9 @@ struct _Edje_Real_Part_State Edje_Calc_Params p; // 96 #endif void *external_params; // 4 -}; // 24 -// WITH EDJE_CALC_CACHE 124 + Edje_Real_Part_Set *set; // 4 +}; // 28 +// WITH EDJE_CALC_CACHE 128 struct _Edje_Real_Part_Drag {