edje - fix up colorclass lookups to always be recrusvie now

This commit is contained in:
Carsten Haitzler 2021-08-09 19:03:38 +01:00
parent a5c7c65658
commit 276513f58b
5 changed files with 6 additions and 56 deletions

View File

@ -2560,7 +2560,7 @@ _edje_part_recalc_single_filter(Edje *ed,
if (r && (r[1] == ')') && (r[2] == '\0'))
{
*r = '\0';
cc = _edje_color_class_find(ed, ccname);
cc = _edje_color_class_recursive_find(ed, ccname);
if (cc)
{
static const char fmt[] =

View File

@ -1619,7 +1619,7 @@ _edje_embryo_fn_get_color_class(Embryo_Program *ep, Embryo_Cell *params)
ed = embryo_program_data_get(ep);
GETSTR(class, params[1]);
if (!class) return 0;
c_class = _edje_color_class_find(ed, class);
c_class = _edje_color_class_recursive_find(ed, class);
if (!c_class) return 0;
SETINT(c_class->r, params[2]);
SETINT(c_class->g, params[3]);

View File

@ -1458,7 +1458,7 @@ _elua_color_class(lua_State *L) // Stack usage [-(10|14), +(11|15), ?]
edje_color_class_set(class, r, g, b, a, r, g, b, a, r, g, b, a);
}
c_class = _edje_color_class_find(ed, class);
c_class = _edje_color_class_recursive_find(ed, class);
if (!c_class) return 0;
_elua_ret(L, "%r %g %b %a", c_class->r, c_class->g, c_class->b, c_class->a);

View File

@ -2538,7 +2538,6 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part);
Edje_Real_Part *_edje_real_part_recursive_get(Edje **ed, const char *part);
Edje_Color_Class *_edje_color_class_find(const Edje *ed, const char *color_class);
// The color_class has to be a pointer to an Eet owned string.
Edje_Color_Class *_edje_color_class_recursive_find(const Edje *ed, const char *color_class);
void _edje_color_class_on_del(Edje *ed, Edje_Part *ep);

View File

@ -840,7 +840,7 @@ _edje_color_class_active_iterator_next(Eina_Iterator *it, void **data)
It is being assumed that the color key are the same for all object here.
This can some times not be the case, but for now we should be fine.
*/
cc = _edje_color_class_find(ed, tuple->key);
cc = _edje_color_class_recursive_find(ed, tuple->key);
if (!cc) return EINA_FALSE;
et->cc = *cc;
@ -972,7 +972,7 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_get(const Eo *obj EINA_UNUSED
if (!color_class)
cc = NULL;
else
cc = _edje_color_class_find(ed, color_class);
cc = _edje_color_class_recursive_find(ed, color_class);
return _edje_color_class_get_internal(cc, layer, r, g, b, a);
}
@ -986,7 +986,7 @@ edje_object_color_class_description_get(const Evas_Object *obj, const char *colo
EOLIAN const char *
_efl_canvas_layout_efl_gfx_color_class_color_class_description_get(const Eo *obj EINA_UNUSED, Edje *ed, const char *color_class)
{
Edje_Color_Class *cc = _edje_color_class_find(ed, color_class);
Edje_Color_Class *cc = _edje_color_class_recursive_find(ed, color_class);
return cc ? cc->desc : NULL;
}
@ -5854,55 +5854,6 @@ _edje_hash_find_helper(const Eina_Hash *hash, const char *key)
return data;
}
Edje_Color_Class *
_edje_color_class_find(const Edje *ed, const char *color_class)
{
Edje_Color_Class *cc = NULL;
if ((!ed) || (!color_class)) return NULL;
/* first look through the object scope */
cc = eina_hash_find(ed->color_classes, color_class);
if (cc) return cc;
/* next look through the global scope */
cc = eina_hash_find(_edje_color_class_hash, color_class);
if (cc) return cc;
/* finally, look through the file scope */
if (ed->file)
cc = eina_hash_find(ed->file->color_hash, color_class);
if (cc) return cc;
// fall back to parent class. expecting classes like:
// /bg <- fallback for /bg/*
// /bg/normal <- fallback for /bg/normal/*
// /bg/normal/button <- mid grey
// etc.
if (color_class[0] == '/')
{
size_t len = strlen(color_class);
char *color_class_parent = alloca(len + 1);
const char *src = color_class;
char *last_slash = NULL, *dst = color_class_parent;
for (;; src++, dst++)
{
*dst = *src;
if (*dst == '/') last_slash = dst;
if (*dst == 0) break;
}
if (last_slash)
{
if (last_slash == color_class_parent)
return NULL;
*last_slash = 0;
}
return _edje_color_class_find(ed, color_class_parent);
}
return NULL;
}
Edje_Color_Class *
_edje_color_class_recursive_find_helper(const Edje *ed, Eina_Hash *hash, const char *color_class)
{