summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>2013-12-23 09:51:43 +0900
committerCedric BAIL <cedric.bail@samsung.com>2013-12-23 10:47:32 +0900
commit641d823cbbd68aab83cdcced0bc1847005957da5 (patch)
tree401c9293f61ff4a4d9328c0daeec4eb6bbd044ce /src/lib
parent7a3cd879d2c63a76834620ead93e0b45ba196b32 (diff)
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>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/edje/edje_calc.c42
-rw-r--r--src/lib/edje/edje_edit.c2
-rw-r--r--src/lib/edje/edje_embryo.c2
-rw-r--r--src/lib/edje/edje_load.c4
-rw-r--r--src/lib/edje/edje_lua.c2
-rw-r--r--src/lib/edje/edje_private.h11
6 files changed, 39 insertions, 24 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index dbb1464bbd..5406e58508 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -280,8 +280,8 @@ _edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src
280} 280}
281 281
282Edje_Part_Description_Common * 282Edje_Part_Description_Common *
283_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name, 283_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *state_name,
284 double val) 284 double state_val, Eina_Bool approximate)
285{ 285{
286 Edje_Part *ep = rp->part; 286 Edje_Part *ep = rp->part;
287 Edje_Part_Description_Common *ret = NULL; 287 Edje_Part_Description_Common *ret = NULL;
@@ -297,39 +297,47 @@ _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
297 calloc(ep->other.desc_count, 297 calloc(ep->other.desc_count,
298 sizeof (Edje_Part_Description_Common *)); 298 sizeof (Edje_Part_Description_Common *));
299 299
300 if (!strcmp(name, "default") && val == 0.0) 300 if (!strcmp(state_name, "default") && state_val == 0.0)
301 return _edje_get_description_by_orientation(ed, 301 return _edje_get_description_by_orientation(ed,
302 ep->default_desc, &ep->default_desc_rtl, ep->type); 302 ep->default_desc, &ep->default_desc_rtl, ep->type);
303 303
304 if (!strcmp(name, "custom")) 304 if (!strcmp(state_name, "custom"))
305 return rp->custom ? 305 return rp->custom ?
306 _edje_get_description_by_orientation(ed, rp->custom->description, 306 _edje_get_description_by_orientation(ed, rp->custom->description,
307 &rp->custom->description_rtl, ep->type) : NULL; 307 &rp->custom->description_rtl, ep->type) : NULL;
308 308
309 if (!strcmp(name, "default")) 309 if (!strcmp(state_name, "default") && approximate)
310 { 310 {
311 ret = _edje_get_description_by_orientation(ed, ep->default_desc, 311 ret = _edje_get_description_by_orientation(ed, ep->default_desc,
312 &ep->default_desc_rtl, 312 &ep->default_desc_rtl,
313 ep->type); 313 ep->type);
314 314
315 min_dst = ABS(ep->default_desc->state.value - val); 315 min_dst = ABS(ep->default_desc->state.value - state_val);
316 } 316 }
317 317
318 for (i = 0; i < ep->other.desc_count; ++i) 318 for (i = 0; i < ep->other.desc_count; ++i)
319 { 319 {
320 d = ep->other.desc[i]; 320 d = ep->other.desc[i];
321 321
322 if (d->state.name && (d->state.name == name || 322 if (d->state.name && (d->state.name == state_name ||
323 !strcmp(d->state.name, name))) 323 !strcmp(d->state.name, state_name)))
324 { 324 {
325 double dst; 325 if (!approximate && d->state.value == state_val)
326 326 {
327 dst = ABS(d->state.value - val); 327 return _edje_get_description_by_orientation(ed, d,
328 if (dst < min_dst) 328 &ep->other.desc_rtl[i], ep->type);
329 }
330 else
329 { 331 {
330 ret = _edje_get_description_by_orientation(ed, d, 332 double dst;
331 &ep->other.desc_rtl[i], ep->type); 333
332 min_dst = dst; 334 dst = ABS(d->state.value - state_val);
335 if (dst < min_dst)
336 {
337 ret = _edje_get_description_by_orientation(ed, d,
338 &ep->other.desc_rtl[i], ep->type);
339 min_dst = dst;
340 }
333 } 341 }
334 } 342 }
335 } 343 }
@@ -540,12 +548,12 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl
540 548
541 if (!d1) d1 = "default"; 549 if (!d1) d1 = "default";
542 550
543 epd1 = _edje_part_description_find(ed, ep, d1, v1); 551 epd1 = _edje_part_description_find(ed, ep, d1, v1, EINA_TRUE);
544 if (!epd1) 552 if (!epd1)
545 epd1 = ep->part->default_desc; /* never NULL */ 553 epd1 = ep->part->default_desc; /* never NULL */
546 554
547 if (d2) 555 if (d2)
548 epd2 = _edje_part_description_find(ed, ep, d2, v2); 556 epd2 = _edje_part_description_find(ed, ep, d2, v2, EINA_TRUE);
549 557
550 epdi = (Edje_Part_Description_Image*) epd2; 558 epdi = (Edje_Part_Description_Image*) epd2;
551 559
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 2bfd2e3348..9a6b6b0192 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -266,7 +266,7 @@ _edje_part_description_find_byname(Edje_Edit *eed, const char *part, const char
266 rp = _edje_real_part_get(eed->base, part); 266 rp = _edje_real_part_get(eed->base, part);
267 if (!rp) return NULL; 267 if (!rp) return NULL;
268 268
269 pd = _edje_part_description_find(eed->base, rp, state, value); 269 pd = _edje_part_description_find(eed->base, rp, state, value, EINA_FALSE);
270 270
271 return pd; 271 return pd;
272} 272}
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index 9283b44333..5fa5ba308e 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -1718,7 +1718,7 @@ _edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
1718 1718
1719 val = EMBRYO_CELL_TO_FLOAT(params[3]); 1719 val = EMBRYO_CELL_TO_FLOAT(params[3]);
1720 1720
1721 if (!(parent = _edje_part_description_find(ed, rp, name, val))) 1721 if (!(parent = _edje_part_description_find(ed, rp, name, val, EINA_TRUE)))
1722 return 0; 1722 return 0;
1723 1723
1724 /* now create the custom state */ 1724 /* now create the custom state */
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index f50351eb47..517fc2d7b4 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -579,8 +579,8 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
579 _edje_ref(ed); 579 _edje_ref(ed);
580 rp->part = ep; 580 rp->part = ep;
581 eina_array_push(&parts, rp); 581 eina_array_push(&parts, rp);
582 rp->param1.description = 582 rp->param1.description =
583 _edje_part_description_find(ed, rp, "default", 0.0); 583 _edje_part_description_find(ed, rp, "default", 0.0, EINA_TRUE);
584 rp->chosen_description = rp->param1.description; 584 rp->chosen_description = rp->param1.description;
585 if (!rp->param1.description) 585 if (!rp->param1.description)
586 ERR("no default part description for '%s'!", 586 ERR("no default part description for '%s'!",
diff --git a/src/lib/edje/edje_lua.c b/src/lib/edje/edje_lua.c
index 1a0d1c1865..339f0ad6d5 100644
--- a/src/lib/edje/edje_lua.c
+++ b/src/lib/edje/edje_lua.c
@@ -3916,7 +3916,7 @@ _edje_lua_part_fn_custom_state(lua_State *L)
3916 3916
3917 name = (char *)luaL_checkstring(L, 2); // state name 3917 name = (char *)luaL_checkstring(L, 2); // state name
3918 val = luaL_checknumber(L, 3); // state val 3918 val = luaL_checknumber(L, 3); // state val
3919 if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val))) 3919 if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val, EINA_TRUE)))
3920 { 3920 {
3921 lua_pushnil(L); 3921 lua_pushnil(L);
3922 return 1; 3922 return 1;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 3340f623b7..73731da23a 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1945,9 +1945,16 @@ EAPI extern Eina_Mempool *_emp_SPACER;
1945EAPI extern Eina_Mempool *_emp_part; 1945EAPI extern Eina_Mempool *_emp_part;
1946 1946
1947void _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); 1947void _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);
1948
1949/** Find the description of the part by state name and state value.
1950 * The param 'approximate' on the approximate calculation of the state value,
1951 * it used for amination calculate, when used transition from 0.0 to 1.0.
1952 * If need exact matching state name and value set EINA_FALSE to 'approximate'.
1953 */
1948Edje_Part_Description_Common *_edje_part_description_find(Edje *ed, 1954Edje_Part_Description_Common *_edje_part_description_find(Edje *ed,
1949 Edje_Real_Part *rp, 1955 Edje_Real_Part *rp,
1950 const char *name, double val); 1956 const char *state_name, double val,
1957 Eina_Bool approximate);
1951void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2); 1958void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2);
1952void _edje_recalc(Edje *ed); 1959void _edje_recalc(Edje *ed);
1953void _edje_recalc_do(Edje *ed); 1960void _edje_recalc_do(Edje *ed);