forked from enlightenment/efl
edje: edje_calc - update _edje_part_description_find
Add to fuction prototype new param: Eina_Bool approximation. If need exact matching state name and value set EINA_FALSE to 'approximate'. In other cases used EINA_TRUE. Reviewers: cedric, raster, seoz CC: cedric Differential Revision: https://phab.enlightenment.org/D400 Signed-off-by: Cedric BAIL <cedric.bail@samsung.com>
This commit is contained in:
parent
7a3cd879d2
commit
641d823cbb
|
@ -280,8 +280,8 @@ _edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src
|
|||
}
|
||||
|
||||
Edje_Part_Description_Common *
|
||||
_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
|
||||
double val)
|
||||
_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *state_name,
|
||||
double state_val, Eina_Bool approximate)
|
||||
{
|
||||
Edje_Part *ep = rp->part;
|
||||
Edje_Part_Description_Common *ret = NULL;
|
||||
|
@ -297,39 +297,47 @@ _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
|
|||
calloc(ep->other.desc_count,
|
||||
sizeof (Edje_Part_Description_Common *));
|
||||
|
||||
if (!strcmp(name, "default") && val == 0.0)
|
||||
if (!strcmp(state_name, "default") && state_val == 0.0)
|
||||
return _edje_get_description_by_orientation(ed,
|
||||
ep->default_desc, &ep->default_desc_rtl, ep->type);
|
||||
|
||||
if (!strcmp(name, "custom"))
|
||||
if (!strcmp(state_name, "custom"))
|
||||
return rp->custom ?
|
||||
_edje_get_description_by_orientation(ed, rp->custom->description,
|
||||
&rp->custom->description_rtl, ep->type) : NULL;
|
||||
|
||||
if (!strcmp(name, "default"))
|
||||
if (!strcmp(state_name, "default") && approximate)
|
||||
{
|
||||
ret = _edje_get_description_by_orientation(ed, ep->default_desc,
|
||||
&ep->default_desc_rtl,
|
||||
ep->type);
|
||||
|
||||
min_dst = ABS(ep->default_desc->state.value - val);
|
||||
min_dst = ABS(ep->default_desc->state.value - state_val);
|
||||
}
|
||||
|
||||
for (i = 0; i < ep->other.desc_count; ++i)
|
||||
{
|
||||
d = ep->other.desc[i];
|
||||
|
||||
if (d->state.name && (d->state.name == name ||
|
||||
!strcmp(d->state.name, name)))
|
||||
if (d->state.name && (d->state.name == state_name ||
|
||||
!strcmp(d->state.name, state_name)))
|
||||
{
|
||||
double dst;
|
||||
|
||||
dst = ABS(d->state.value - val);
|
||||
if (dst < min_dst)
|
||||
if (!approximate && d->state.value == state_val)
|
||||
{
|
||||
ret = _edje_get_description_by_orientation(ed, d,
|
||||
&ep->other.desc_rtl[i], ep->type);
|
||||
min_dst = dst;
|
||||
return _edje_get_description_by_orientation(ed, d,
|
||||
&ep->other.desc_rtl[i], ep->type);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dst;
|
||||
|
||||
dst = ABS(d->state.value - state_val);
|
||||
if (dst < min_dst)
|
||||
{
|
||||
ret = _edje_get_description_by_orientation(ed, d,
|
||||
&ep->other.desc_rtl[i], ep->type);
|
||||
min_dst = dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -540,12 +548,12 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl
|
|||
|
||||
if (!d1) d1 = "default";
|
||||
|
||||
epd1 = _edje_part_description_find(ed, ep, d1, v1);
|
||||
epd1 = _edje_part_description_find(ed, ep, d1, v1, EINA_TRUE);
|
||||
if (!epd1)
|
||||
epd1 = ep->part->default_desc; /* never NULL */
|
||||
|
||||
if (d2)
|
||||
epd2 = _edje_part_description_find(ed, ep, d2, v2);
|
||||
epd2 = _edje_part_description_find(ed, ep, d2, v2, EINA_TRUE);
|
||||
|
||||
epdi = (Edje_Part_Description_Image*) epd2;
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ _edje_part_description_find_byname(Edje_Edit *eed, const char *part, const char
|
|||
rp = _edje_real_part_get(eed->base, part);
|
||||
if (!rp) return NULL;
|
||||
|
||||
pd = _edje_part_description_find(eed->base, rp, state, value);
|
||||
pd = _edje_part_description_find(eed->base, rp, state, value, EINA_FALSE);
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
|
|
@ -1718,7 +1718,7 @@ _edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
|
|||
|
||||
val = EMBRYO_CELL_TO_FLOAT(params[3]);
|
||||
|
||||
if (!(parent = _edje_part_description_find(ed, rp, name, val)))
|
||||
if (!(parent = _edje_part_description_find(ed, rp, name, val, EINA_TRUE)))
|
||||
return 0;
|
||||
|
||||
/* now create the custom state */
|
||||
|
|
|
@ -579,8 +579,8 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
|
|||
_edje_ref(ed);
|
||||
rp->part = ep;
|
||||
eina_array_push(&parts, rp);
|
||||
rp->param1.description =
|
||||
_edje_part_description_find(ed, rp, "default", 0.0);
|
||||
rp->param1.description =
|
||||
_edje_part_description_find(ed, rp, "default", 0.0, EINA_TRUE);
|
||||
rp->chosen_description = rp->param1.description;
|
||||
if (!rp->param1.description)
|
||||
ERR("no default part description for '%s'!",
|
||||
|
|
|
@ -3916,7 +3916,7 @@ _edje_lua_part_fn_custom_state(lua_State *L)
|
|||
|
||||
name = (char *)luaL_checkstring(L, 2); // state name
|
||||
val = luaL_checknumber(L, 3); // state val
|
||||
if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val)))
|
||||
if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val, EINA_TRUE)))
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
|
|
|
@ -1945,9 +1945,16 @@ EAPI extern Eina_Mempool *_emp_SPACER;
|
|||
EAPI extern Eina_Mempool *_emp_part;
|
||||
|
||||
void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2, FLOAT_T v3, FLOAT_T v4);
|
||||
|
||||
/** Find the description of the part by state name and state value.
|
||||
* The param 'approximate' on the approximate calculation of the state value,
|
||||
* it used for amination calculate, when used transition from 0.0 to 1.0.
|
||||
* If need exact matching state name and value set EINA_FALSE to 'approximate'.
|
||||
*/
|
||||
Edje_Part_Description_Common *_edje_part_description_find(Edje *ed,
|
||||
Edje_Real_Part *rp,
|
||||
const char *name, double val);
|
||||
Edje_Real_Part *rp,
|
||||
const char *state_name, double val,
|
||||
Eina_Bool approximate);
|
||||
void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2);
|
||||
void _edje_recalc(Edje *ed);
|
||||
void _edje_recalc_do(Edje *ed);
|
||||
|
|
Loading…
Reference in New Issue