summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-04-27 15:25:46 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-04-27 15:25:46 +0100
commit215e9ca9b394018db468fac5d6b13f97ac0f9e37 (patch)
treec2e2f8a201370f7cf8133dca6d8866161035e992 /src
parent994f520bfdc5244c1d0acdb33965b71a63ef7996 (diff)
edje - add color-class fallback for lookups in prep for proper theme cc
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/edje_util.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index af465288e7..16171b6c41 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -5877,6 +5877,32 @@ _edje_color_class_find(const Edje *ed, const char *color_class)
5877 cc = eina_hash_find(ed->file->color_hash, color_class); 5877 cc = eina_hash_find(ed->file->color_hash, color_class);
5878 if (cc) return cc; 5878 if (cc) return cc;
5879 5879
5880 // fall back to parent class. expecting classes like:
5881 // /bg <- fallback for /bg/*
5882 // /bg/normal <- fallback for /bg/normal/*
5883 // /bg/normal/button <- mid grey
5884 // etc.
5885 if (color_class[0] == '/')
5886 {
5887 size_t len = strlen(color_class);
5888 char *color_class_parent = alloca(len + 1);
5889 const char *src = color_class;
5890 char *last_slash = NULL, *dst = color_class_parent;
5891
5892 for (;; src++, dst++)
5893 {
5894 *dst = *src;
5895 if (*dst == '/') last_slash = dst;
5896 if (*dst == 0) break;
5897 }
5898 if (last_slash)
5899 {
5900 if (last_slash == color_class_parent)
5901 return NULL;
5902 *last_slash = 0;
5903 }
5904 return _edje_color_class_find(ed, color_class_parent);
5905 }
5880 return NULL; 5906 return NULL;
5881} 5907}
5882 5908
@@ -5924,6 +5950,32 @@ _edje_color_class_recursive_find(const Edje *ed, const char *color_class)
5924 cc = _edje_color_class_recursive_find_helper(ed, ed->file->color_hash, color_class); 5950 cc = _edje_color_class_recursive_find_helper(ed, ed->file->color_hash, color_class);
5925 if (cc) return cc; 5951 if (cc) return cc;
5926 5952
5953 // fall back to parent class. expecting classes like:
5954 // /bg <- fallback for /bg/*
5955 // /bg/normal <- fallback for /bg/normal/*
5956 // /bg/normal/button <- mid grey
5957 // etc.
5958 if (color_class[0] == '/')
5959 {
5960 size_t len = strlen(color_class);
5961 char *color_class_parent = alloca(len + 1);
5962 const char *src = color_class;
5963 char *last_slash = NULL, *dst = color_class_parent;
5964
5965 for (;; src++, dst++)
5966 {
5967 *dst = *src;
5968 if (*dst == '/') last_slash = dst;
5969 if (*dst == 0) break;
5970 }
5971 if (last_slash)
5972 {
5973 if (last_slash == color_class_parent)
5974 return NULL;
5975 *last_slash = 0;
5976 }
5977 return _edje_color_class_recursive_find(ed, color_class_parent);
5978 }
5927 return NULL; 5979 return NULL;
5928} 5980}
5929 5981