furrymyad pushed a commit to branch efl-1.16.

http://git.enlightenment.org/core/efl.git/commit/?id=d8da59ba0bb5cc4773871d1d7d9ec6c17f7b1a96

commit d8da59ba0bb5cc4773871d1d7d9ec6c17f7b1a96
Author: Vitalii Vorobiov <[email protected]>
Date:   Thu Apr 28 15:38:50 2016 +0300

    Edje_Edit: update function that return image usage to include sets
    
    Image can be also used not only inside of any image parts, but also
    inside of any sets (and plenty of times)
---
 src/lib/edje/Edje_Edit.h |  6 +++++-
 src/lib/edje/edje_edit.c | 30 +++++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 6a564e2..e5eabc2 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -5562,7 +5562,11 @@ EAPI Eina_Bool edje_edit_image_replace(Evas_Object *obj, 
const char *name, const
 EAPI Eina_Bool edje_edit_image_rename(Evas_Object *obj, const char *name, 
const char *new_name);
 
 /** Get list of (Edje_Part_Image_Use *) - group-part-state triplets where given
- * image is used
+ * image is used.
+ *
+ * Important! Image can also be used inside of set and plenty of times, so for 
each use
+ * inside of set triplet would set "set's" name into group name, and it's state
+ * value would be -1. Every other fields will be 0.
  *
  * Use edje_edit_image_usage_list_free() when you don't need it anymore.
  *
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index c030508..67071a1 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -8825,12 +8825,14 @@ edje_edit_image_rename(Evas_Object *obj, const char 
*name, const char *new_name)
 EAPI Eina_List *
 edje_edit_image_usage_list_get(Evas_Object *obj, const char *name, Eina_Bool 
first_only)
 {
-   Eina_List *result = NULL;
+   Eina_List *result = NULL, *l;
    Eina_Iterator *it;
    Edje_Part_Collection_Directory_Entry *pce;
    Edje_Part_Image_Use *item;
    Edje_Part *part;
    Edje_Part_Description_Image *part_desc_image;
+   Edje_Image_Directory_Set *de = NULL;
+   Edje_Image_Directory_Set_Entry *dim = NULL;
    unsigned int i, j, k;
    int image_id;
 
@@ -8846,7 +8848,7 @@ edje_edit_image_usage_list_get(Evas_Object *obj, const 
char *name, Eina_Bool fir
 
    it = eina_hash_iterator_data_new(ed->file->collection);
 
-   #define ITEM_ADD()                                                          
\
+#define ITEM_ADD()                                                             
\
   item = (Edje_Part_Image_Use *)calloc(1, sizeof(Edje_Part_Image_Use));        
\
   item->group = eina_stringshare_add(pce->entry);                              
\
   item->part = eina_stringshare_add(part->name);                               
\
@@ -8854,7 +8856,15 @@ edje_edit_image_usage_list_get(Evas_Object *obj, const 
char *name, Eina_Bool fir
   item->state.value = part_desc_image->common.state.value;                     
\
   result = eina_list_append(result, item);
 
-   #define FIND_IN_PART_DESCRIPTION()                        \
+#define ITEM_SET_ADD()                                                  \
+  item = (Edje_Part_Image_Use *)calloc(1, sizeof(Edje_Part_Image_Use)); \
+  item->group = eina_stringshare_add(de->name);                         \
+  item->part = NULL;                                                    \
+  item->state.name = NULL;                                              \
+  item->state.value = -1;                                               \
+  result = eina_list_append(result, item);
+
+#define FIND_IN_PART_DESCRIPTION()                           \
   if ((part_desc_image->image.id == image_id) &&             \
       (!part_desc_image->image.set))                         \
     {                                                        \
@@ -8896,6 +8906,20 @@ edje_edit_image_usage_list_get(Evas_Object *obj, const 
char *name, Eina_Bool fir
                }
           }
      }
+
+   /* NOW CHECKING IF IMAGE IS USED INSIDE OF SET */
+   for (i = 0; i < ed->file->image_dir->sets_count; ++i)
+     {
+        de = ed->file->image_dir->sets + i;
+        EINA_LIST_FOREACH(de->entries, l, dim)
+          {
+             if (dim->id == image_id)
+               {
+                  ITEM_SET_ADD()
+               }
+          }
+     }
+
    #undef ITEM_ADD
    #undef FIND_IN_PART_DESCRIPTION
 end:

-- 


Reply via email to