From: antognolli Date: Mon, 13 Jul 2009 19:17:35 +0000 (+0000) Subject: Created new function edje_edit_image_data_add(). X-Git-Tag: 2.0_alpha~163^2~867 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=772c94f0befa45ebff4cb95ab28bbeeb1f5218e1;p=framework%2Fuifw%2Fedje.git Created new function edje_edit_image_data_add(). Now it's possible to add an image that is already inside the eet (with a default key name) to the edje image collection. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@41320 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Edje_Edit.h b/src/lib/Edje_Edit.h index adc17a0..a8525f1 100644 --- a/src/lib/Edje_Edit.h +++ b/src/lib/Edje_Edit.h @@ -1575,6 +1575,21 @@ edje_edit_image_add( const char* path ///< The name of the image file to include in the edje ); +/**Add an image entry to the image collection + * + * This function adds the given image entry to the edje image collection. The + * image needs to be inside the eet already, with key name "images/id". After + * you have to create a new image_part that use this image, referring to it as + * "name". Note that all the parts in the edje share the same image collection, + * thus you can/must use the same image for different part. + */ +EAPI unsigned char /// @return TRUE on success or FALSE on failure +edje_edit_image_data_add( + Evas_Object *obj, ///< The edje object + const char *name, ///< The image entry name + int id ///< The image id +); + /**Get normal image name for a given part state. Remember to free the returned string using edje_edit_string_free().*/ EAPI const char * ///@return The name of the image used by state edje_edit_state_image_get( diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c index b8afb17..48cb607 100644 --- a/src/lib/edje_edit.c +++ b/src/lib/edje_edit.c @@ -3443,6 +3443,53 @@ edje_edit_image_add(Evas_Object *obj, const char* path) return 1; } +EAPI unsigned char +edje_edit_image_data_add(Evas_Object *obj, const char *name, int id) +{ + Eina_List *l; + Edje_Image_Directory_Entry *de; + Edje_Image_Directory_Entry *i, *t; + int free_id = 0; + + GET_ED_OR_RETURN(0); + + if (!name) return 0; + if (!ed->file) return 0; + if (!ed->path) return 0; + + /* Create Image_Directory if not exist */ + if (!ed->file->image_dir) + ed->file->image_dir = mem_alloc(sizeof(Edje_Image_Directory)); + + /* Loop trough image directory to find if image exist */ + t = NULL; + EINA_LIST_FOREACH(ed->file->image_dir->entries, l, i) + { + if (!i) return 0; + if (i->id == id) t = i; + } + + /* Create Image Entry */ + if (!t) + de = mem_alloc(sizeof(Edje_Image_Directory_Entry)); + else + { + de = t; + free(de->entry); + } + de->entry = mem_strdup(name); + de->id = id; + de->source_type = 1; + de->source_param = 1; + + /* Add image to Image Directory */ + if (!t) + ed->file->image_dir->entries = + eina_list_append(ed->file->image_dir->entries, de); + + return 1; +} + EAPI int edje_edit_image_id_get(Evas_Object *obj, const char *image_name) {