aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib/edje_calc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/lib/edje_calc.c')
-rw-r--r--libraries/edje/src/lib/edje_calc.c447
1 files changed, 260 insertions, 187 deletions
diff --git a/libraries/edje/src/lib/edje_calc.c b/libraries/edje/src/lib/edje_calc.c
index d9fd51d..213e266 100644
--- a/libraries/edje/src/lib/edje_calc.c
+++ b/libraries/edje/src/lib/edje_calc.c
@@ -8,7 +8,8 @@ static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep,
8 Edje_Real_Part *center, Edje_Real_Part *light, Edje_Real_Part *persp, 8 Edje_Real_Part *center, Edje_Real_Part *light, Edje_Real_Part *persp,
9 Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y, 9 Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y,
10 Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y, 10 Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y,
11 Edje_Real_Part *confine_to, Edje_Calc_Params *params); 11 Edje_Real_Part *confine_to, Edje_Calc_Params *params,
12 FLOAT_T pos);
12 13
13void 14void
14_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2) 15_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2)
@@ -115,6 +116,7 @@ _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T
115 ep->description_pos = npos; 116 ep->description_pos = npos;
116 117
117 ed->dirty = 1; 118 ed->dirty = 1;
119 ed->recalc_call = 1;
118#ifdef EDJE_CALC_CACHE 120#ifdef EDJE_CALC_CACHE
119 ep->invalidate = 1; 121 ep->invalidate = 1;
120#endif 122#endif
@@ -304,6 +306,179 @@ _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
304 return ret; 306 return ret;
305} 307}
306 308
309static int
310_edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid)
311{
312 Edje_Image_Directory_Set_Entry *entry;
313 Edje_Image_Directory_Set *set = NULL;
314 Eina_List *l;
315 int w = 0;
316 int h = 0;
317 int id;
318
319 if (!st && !imid)
320 return -1;
321
322 if (st && !st->image.set)
323 return st->image.id;
324
325 if (imid && !imid->set)
326 return imid->id;
327
328 if (imid)
329 id = imid->id;
330 else
331 id = st->image.id;
332
333 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
334
335 if (eps && *eps)
336 {
337 if ((*eps)->id == id)
338 set = (*eps)->set;
339
340 if (set)
341 if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w)
342 if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h)
343 return (*eps)->entry->id;
344 }
345
346 if (!set)
347 set = ed->file->image_dir->sets + id;
348
349 EINA_LIST_FOREACH(set->entries, l, entry)
350 {
351 if (entry->size.min.w <= w && w <= entry->size.max.w)
352 if (entry->size.min.h <= h && h <= entry->size.max.h)
353 {
354 if (eps)
355 {
356 if (!*eps)
357 *eps = calloc(1, sizeof (Edje_Real_Part_Set));
358
359 if (*eps)
360 {
361 (*eps)->entry = entry;
362 (*eps)->set = set;
363 (*eps)->id = id;
364 }
365 }
366 return entry->id;
367 }
368 }
369
370 return -1;
371}
372
373static void
374_edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T pos)
375{
376 int image_id;
377 int image_count, image_num;
378
379 image_id = _edje_image_find(ep->object, ed,
380 &ep->param1.set,
381 (Edje_Part_Description_Image*) ep->param1.description,
382 NULL);
383 if (image_id < 0)
384 {
385 Edje_Image_Directory_Entry *ie;
386
387 if (!ed->file->image_dir) ie = NULL;
388 else ie = ed->file->image_dir->entries + (-image_id) - 1;
389 if ((ie) &&
390 (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
391 (ie->entry))
392 {
393 evas_object_image_file_set(ep->object, ie->entry, NULL);
394 }
395 }
396 else
397 {
398 image_count = 2;
399 if (ep->param2)
400 image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count;
401 image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
402 FROM_DOUBLE(0.5))));
403 if (image_num > (image_count - 1))
404 image_num = image_count - 1;
405 if (image_num == 0)
406 {
407 image_id = _edje_image_find(ep->object, ed,
408 &ep->param1.set,
409 (Edje_Part_Description_Image*) ep->param1.description,
410 NULL);
411 }
412 else
413 if (ep->param2)
414 {
415 if (image_num == (image_count - 1))
416 {
417 image_id = _edje_image_find(ep->object, ed,
418 &ep->param2->set,
419 (Edje_Part_Description_Image*) ep->param2->description,
420 NULL);
421 }
422 else
423 {
424 Edje_Part_Image_Id *imid;
425
426 imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1];
427 image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
428 }
429 }
430 if (image_id < 0)
431 {
432 ERR("¨Part \"%s\" has description, "
433 "\"%s\" %3.3f with a missing image id!!!",
434 ep->part->name,
435 ep->param1.description->state.name,
436 ep->param1.description->state.value);
437 }
438 else
439 {
440 char buf[1024];
441
442 /* Replace snprint("edje/images/%i") == memcpy + itoa */
443#define IMAGES "edje/images/"
444 memcpy(buf, IMAGES, strlen(IMAGES));
445 eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */
446
447 evas_object_image_file_set(ep->object, ed->file->path, buf);
448 if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
449 {
450 ERR("Error loading image collection \"%s\" from "
451 "file \"%s\". Missing EET Evas loader module?",
452 buf, ed->file->path);
453 switch (evas_object_image_load_error_get(ep->object))
454 {
455 case EVAS_LOAD_ERROR_GENERIC:
456 ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
457 break;
458 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
459 ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
460 break;
461 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
462 ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
463 break;
464 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
465 ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
466 break;
467 case EVAS_LOAD_ERROR_CORRUPT_FILE:
468 ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
469 break;
470 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
471 ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
472 break;
473 default:
474 ERR("Error type: ???");
475 break;
476 }
477 }
478 }
479 }
480}
481
307static void 482static void
308_edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state) 483_edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state)
309{ 484{
@@ -398,6 +573,7 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl
398 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc); 573 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
399 574
400 ed->dirty = 1; 575 ed->dirty = 1;
576 ed->recalc_call = 1;
401#ifdef EDJE_CALC_CACHE 577#ifdef EDJE_CALC_CACHE
402 ep->invalidate = 1; 578 ep->invalidate = 1;
403#endif 579#endif
@@ -423,17 +599,23 @@ _edje_recalc(Edje *ed)
423 return; 599 return;
424 } 600 }
425 } 601 }
426 if (ed->postponed) return; 602// XXX: dont need this with current smart calc infra. remove me later
427 evas_object_smart_changed(ed->obj); 603// if (ed->postponed) return;
428 ed->postponed = 1; 604// if (!ed->calc_only)
605 evas_object_smart_changed(ed->obj);
606// XXX: dont need this with current smart calc infra. remove me later
607// ed->postponed = 1;
429} 608}
430 609
431void 610void
432_edje_recalc_do(Edje *ed) 611_edje_recalc_do(Edje *ed)
433{ 612{
434 unsigned int i; 613 unsigned int i;
614 Eina_Bool need_calc;
435 615
436 ed->postponed = 0; 616// XXX: dont need this with current smart calc infra. remove me later
617// ed->postponed = 0;
618 need_calc = evas_object_smart_need_recalculate_get(ed->obj);
437 evas_object_smart_need_recalculate_set(ed->obj, 0); 619 evas_object_smart_need_recalculate_set(ed->obj, 0);
438 if (!ed->dirty) return; 620 if (!ed->dirty) return;
439 ed->have_mapped_part = 0; 621 ed->have_mapped_part = 0;
@@ -460,6 +642,14 @@ _edje_recalc_do(Edje *ed)
460 ed->all_part_change = 0; 642 ed->all_part_change = 0;
461 ed->text_part_change = 0; 643 ed->text_part_change = 0;
462#endif 644#endif
645 if (!ed->calc_only)
646 {
647 if (ed->recalc_call)
648 evas_object_smart_callback_call(ed->obj, "recalc", NULL);
649 }
650 else
651 evas_object_smart_need_recalculate_set(ed->obj, need_calc);
652 ed->recalc_call = 0;
463} 653}
464 654
465void 655void
@@ -527,6 +717,7 @@ _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
527 ep->drag->tmp.x = 0; 717 ep->drag->tmp.x = 0;
528 ep->drag->need_reset = 0; 718 ep->drag->need_reset = 0;
529 ed->dirty = 1; 719 ed->dirty = 1;
720 ed->recalc_call = 1;
530 } 721 }
531 722
532 if (ep->drag->y != y || ep->drag->tmp.y) 723 if (ep->drag->y != y || ep->drag->tmp.y)
@@ -535,6 +726,7 @@ _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
535 ep->drag->tmp.y = 0; 726 ep->drag->tmp.y = 0;
536 ep->drag->need_reset = 0; 727 ep->drag->need_reset = 0;
537 ed->dirty = 1; 728 ed->dirty = 1;
729 ed->recalc_call = 1;
538 } 730 }
539 731
540#ifdef EDJE_CALC_CACHE 732#ifdef EDJE_CALC_CACHE
@@ -598,11 +790,13 @@ _edje_part_recalc_single_rel(Edje *ed,
598} 790}
599 791
600static Edje_Internal_Aspect 792static Edje_Internal_Aspect
601_edje_part_recalc_single_aspect(Edje_Real_Part *ep, 793_edje_part_recalc_single_aspect(Edje *ed,
794 Edje_Real_Part *ep,
602 Edje_Part_Description_Common *desc, 795 Edje_Part_Description_Common *desc,
603 Edje_Calc_Params *params, 796 Edje_Calc_Params *params,
604 int *minw, int *minh, 797 int *minw, int *minh,
605 int *maxw, int *maxh) 798 int *maxw, int *maxh,
799 FLOAT_T pos)
606{ 800{
607 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE; 801 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE;
608 FLOAT_T aspect, amax, amin; 802 FLOAT_T aspect, amax, amin;
@@ -612,6 +806,17 @@ _edje_part_recalc_single_aspect(Edje_Real_Part *ep,
612 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h)); 806 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h));
613 amax = desc->aspect.max; 807 amax = desc->aspect.max;
614 amin = desc->aspect.min; 808 amin = desc->aspect.min;
809 if (desc->aspect.prefer == EDJE_ASPECT_PREFER_SOURCE &&
810 ep->part->type == EDJE_PART_TYPE_IMAGE)
811 {
812 Evas_Coord w, h;
813
814 /* We only need pose to find the right image that would be displayed,
815 and the right aspect ratio in that case */
816 _edje_real_part_image_set(ed, ep, pos);
817 evas_object_image_size_get(ep->object, &w, &h);
818 amin = amax = DIV(FROM_INT(w), FROM_INT(h));
819 }
615 if ((ep->swallow_params.aspect.w > 0) && 820 if ((ep->swallow_params.aspect.w > 0) &&
616 (ep->swallow_params.aspect.h > 0)) 821 (ep->swallow_params.aspect.h > 0))
617 amin = amax = 822 amin = amax =
@@ -693,6 +898,7 @@ _edje_part_recalc_single_aspect(Edje_Real_Part *ep,
693 if ((amin > ZERO) && (aspect < amin)) 898 if ((amin > ZERO) && (aspect < amin))
694 new_h = DIV(FROM_INT(params->w), amin); 899 new_h = DIV(FROM_INT(params->w), amin);
695 break; 900 break;
901 case EDJE_ASPECT_PREFER_SOURCE:
696 case EDJE_ASPECT_PREFER_BOTH: 902 case EDJE_ASPECT_PREFER_BOTH:
697 /* keep both dimensions in check */ 903 /* keep both dimensions in check */
698 /* adjust for max aspect (width / height) */ 904 /* adjust for max aspect (width / height) */
@@ -1255,6 +1461,7 @@ _edje_part_recalc_single_min(Edje_Part_Description_Common *desc,
1255 minh = tmp; 1461 minh = tmp;
1256 break; 1462 break;
1257 } 1463 }
1464 case EDJE_ASPECT_PREFER_SOURCE:
1258 case EDJE_ASPECT_PREFER_BOTH: 1465 case EDJE_ASPECT_PREFER_BOTH:
1259 tmp = minh * params->w / h; 1466 tmp = minh * params->w / h;
1260 if (tmp >= minw) 1467 if (tmp >= minw)
@@ -1321,6 +1528,7 @@ _edje_part_recalc_single_max(Edje_Part_Description_Common *desc,
1321 maxh = tmp; 1528 maxh = tmp;
1322 break; 1529 break;
1323 } 1530 }
1531 case EDJE_ASPECT_PREFER_SOURCE:
1324 case EDJE_ASPECT_PREFER_BOTH: 1532 case EDJE_ASPECT_PREFER_BOTH:
1325 tmp = maxh * params->w / h; 1533 tmp = maxh * params->w / h;
1326 if (tmp <= maxw) 1534 if (tmp <= maxw)
@@ -1481,6 +1689,15 @@ _edje_part_recalc_single_min_max(FLOAT_T sc,
1481 if (ep->swallow_params.min.w > desc->min.w) 1689 if (ep->swallow_params.min.w > desc->min.w)
1482 *minw = ep->swallow_params.min.w; 1690 *minw = ep->swallow_params.min.w;
1483 1691
1692 if (ep->edje->calc_only)
1693 {
1694 if (desc->minmul.have)
1695 {
1696 FLOAT_T mmw = desc->minmul.w;
1697 if (mmw != FROM_INT(1)) *minw = TO_INT(SCALE(mmw, *minw));
1698 }
1699 }
1700
1484 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */ 1701 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */
1485 if ((ep->swallow_params.max.w <= 0) || 1702 if ((ep->swallow_params.max.w <= 0) ||
1486 (ep->swallow_params.max.w == EDJE_INF_MAX_W)) 1703 (ep->swallow_params.max.w == EDJE_INF_MAX_W))
@@ -1508,6 +1725,8 @@ _edje_part_recalc_single_min_max(FLOAT_T sc,
1508 *maxw = ep->swallow_params.max.w; 1725 *maxw = ep->swallow_params.max.w;
1509 } 1726 }
1510 } 1727 }
1728 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1729 (desc->minmul.w != FROM_INT(1))) *maxw = *minw;
1511 if (*maxw >= 0) 1730 if (*maxw >= 0)
1512 { 1731 {
1513 if (*maxw < *minw) *maxw = *minw; 1732 if (*maxw < *minw) *maxw = *minw;
@@ -1518,6 +1737,16 @@ _edje_part_recalc_single_min_max(FLOAT_T sc,
1518 if (ep->swallow_params.min.h > desc->min.h) 1737 if (ep->swallow_params.min.h > desc->min.h)
1519 *minh = ep->swallow_params.min.h; 1738 *minh = ep->swallow_params.min.h;
1520 1739
1740 if (ep->edje->calc_only)
1741 {
1742 if (desc->minmul.have)
1743 {
1744 FLOAT_T mmh = desc->minmul.h;
1745 if (mmh != FROM_INT(1)) *minh = TO_INT(SCALE(mmh, *minh));
1746 }
1747 }
1748
1749
1521 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */ 1750 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
1522 if ((ep->swallow_params.max.h <= 0) || 1751 if ((ep->swallow_params.max.h <= 0) ||
1523 (ep->swallow_params.max.h == EDJE_INF_MAX_H)) 1752 (ep->swallow_params.max.h == EDJE_INF_MAX_H))
@@ -1544,7 +1773,9 @@ _edje_part_recalc_single_min_max(FLOAT_T sc,
1544 if (ep->swallow_params.max.h < *maxh) 1773 if (ep->swallow_params.max.h < *maxh)
1545 *maxh = ep->swallow_params.max.h; 1774 *maxh = ep->swallow_params.max.h;
1546 } 1775 }
1547 } 1776 }
1777 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1778 (desc->minmul.h != FROM_INT(1))) *maxh = *minh;
1548 if (*maxh >= 0) 1779 if (*maxh >= 0)
1549 { 1780 {
1550 if (*maxh < *minh) *maxh = *minh; 1781 if (*maxh < *minh) *maxh = *minh;
@@ -1665,7 +1896,8 @@ _edje_part_recalc_single(Edje *ed,
1665 Edje_Real_Part *rel2_to_x, 1896 Edje_Real_Part *rel2_to_x,
1666 Edje_Real_Part *rel2_to_y, 1897 Edje_Real_Part *rel2_to_y,
1667 Edje_Real_Part *confine_to, 1898 Edje_Real_Part *confine_to,
1668 Edje_Calc_Params *params) 1899 Edje_Calc_Params *params,
1900 FLOAT_T pos)
1669{ 1901{
1670 Edje_Color_Class *cc = NULL; 1902 Edje_Color_Class *cc = NULL;
1671 Edje_Internal_Aspect apref; 1903 Edje_Internal_Aspect apref;
@@ -1675,12 +1907,12 @@ _edje_part_recalc_single(Edje *ed,
1675 sc = ed->scale; 1907 sc = ed->scale;
1676 if (sc == ZERO) sc = _edje_scale; 1908 if (sc == ZERO) sc = _edje_scale;
1677 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh); 1909 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh);
1678 1910
1679 /* relative coords of top left & bottom right */ 1911 /* relative coords of top left & bottom right */
1680 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params); 1912 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params);
1681 1913
1682 /* aspect */ 1914 /* aspect */
1683 apref = _edje_part_recalc_single_aspect(ep, desc, params, &minw, &minh, &maxw, &maxh); 1915 apref = _edje_part_recalc_single_aspect(ed, ep, desc, params, &minw, &minh, &maxw, &maxh, pos);
1684 1916
1685 /* size step */ 1917 /* size step */
1686 _edje_part_recalc_single_step(desc, params); 1918 _edje_part_recalc_single_step(desc, params);
@@ -1855,77 +2087,13 @@ _edje_table_recalc_apply(Edje *ed __UNUSED__,
1855 } 2087 }
1856} 2088}
1857 2089
1858static int
1859_edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid)
1860{
1861 Edje_Image_Directory_Set_Entry *entry;
1862 Edje_Image_Directory_Set *set = NULL;
1863 Eina_List *l;
1864 int w = 0;
1865 int h = 0;
1866 int id;
1867
1868 if (!st && !imid)
1869 return -1;
1870
1871 if (st && !st->image.set)
1872 return st->image.id;
1873
1874 if (imid && !imid->set)
1875 return imid->id;
1876
1877 if (imid)
1878 id = imid->id;
1879 else
1880 id = st->image.id;
1881
1882 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1883
1884 if (eps && *eps)
1885 {
1886 if ((*eps)->id == id)
1887 set = (*eps)->set;
1888
1889 if (set)
1890 if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w)
1891 if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h)
1892 return (*eps)->entry->id;
1893 }
1894
1895 if (!set)
1896 set = ed->file->image_dir->sets + id;
1897
1898 EINA_LIST_FOREACH(set->entries, l, entry)
1899 {
1900 if (entry->size.min.w <= w && w <= entry->size.max.w)
1901 if (entry->size.min.h <= h && h <= entry->size.max.h)
1902 {
1903 if (eps)
1904 {
1905 if (!*eps)
1906 *eps = calloc(1, sizeof (Edje_Real_Part_Set));
1907
1908 if (*eps)
1909 {
1910 (*eps)->entry = entry;
1911 (*eps)->set = set;
1912 (*eps)->id = id;
1913 }
1914 }
1915 return entry->id;
1916 }
1917 }
1918
1919 return -1;
1920}
1921
1922static void 2090static void
1923_edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos) 2091_edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos)
1924{ 2092{
1925 Edje_Real_Part *pp; 2093 Edje_Real_Part *pp;
1926 int part_id = -1; 2094 int part_id = -1;
1927 2095
1928 if (pos >= 0.5) 2096 if (pos >= FROM_DOUBLE(0.5))
1929 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id; 2097 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
1930 else 2098 else
1931 part_id = chosen_desc->proxy.id; 2099 part_id = chosen_desc->proxy.id;
@@ -1967,8 +2135,6 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
1967static void 2135static void
1968_edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos) 2136_edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos)
1969{ 2137{
1970 int image_id;
1971 int image_count, image_num;
1972 FLOAT_T sc; 2138 FLOAT_T sc;
1973 2139
1974 sc = ed->scale; 2140 sc = ed->scale;
@@ -2003,107 +2169,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
2003 else if (chosen_desc->image.border.no_fill == 2) 2169 else if (chosen_desc->image.border.no_fill == 2)
2004 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID); 2170 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID);
2005 2171
2006 image_id = _edje_image_find(ep->object, ed, 2172 _edje_real_part_image_set(ed, ep, pos);
2007 &ep->param1.set,
2008 (Edje_Part_Description_Image*) ep->param1.description,
2009 NULL);
2010 if (image_id < 0)
2011 {
2012 Edje_Image_Directory_Entry *ie;
2013
2014 if (!ed->file->image_dir) ie = NULL;
2015 else ie = ed->file->image_dir->entries + (-image_id) - 1;
2016 if ((ie) &&
2017 (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
2018 (ie->entry))
2019 {
2020 evas_object_image_file_set(ep->object, ie->entry, NULL);
2021 }
2022 }
2023 else
2024 {
2025 image_count = 2;
2026 if (ep->param2)
2027 image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count;
2028 image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
2029 FROM_DOUBLE(0.5))));
2030 if (image_num > (image_count - 1))
2031 image_num = image_count - 1;
2032 if (image_num == 0)
2033 {
2034 image_id = _edje_image_find(ep->object, ed,
2035 &ep->param1.set,
2036 (Edje_Part_Description_Image*) ep->param1.description,
2037 NULL);
2038 }
2039 else
2040 if (ep->param2)
2041 {
2042 if (image_num == (image_count - 1))
2043 {
2044 image_id = _edje_image_find(ep->object, ed,
2045 &ep->param2->set,
2046 (Edje_Part_Description_Image*) ep->param2->description,
2047 NULL);
2048 }
2049 else
2050 {
2051 Edje_Part_Image_Id *imid;
2052
2053 imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1];
2054 image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
2055 }
2056 }
2057 if (image_id < 0)
2058 {
2059 ERR("¨Part \"%s\" has description, "
2060 "\"%s\" %3.3f with a missing image id!!!",
2061 ep->part->name,
2062 ep->param1.description->state.name,
2063 ep->param1.description->state.value);
2064 }
2065 else
2066 {
2067 char buf[1024];
2068
2069 /* Replace snprint("edje/images/%i") == memcpy + itoa */
2070#define IMAGES "edje/images/"
2071 memcpy(buf, IMAGES, strlen(IMAGES));
2072 eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */
2073
2074 evas_object_image_file_set(ep->object, ed->file->path, buf);
2075 if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
2076 {
2077 ERR("Error loading image collection \"%s\" from "
2078 "file \"%s\". Missing EET Evas loader module?",
2079 buf, ed->file->path);
2080 switch (evas_object_image_load_error_get(ep->object))
2081 {
2082 case EVAS_LOAD_ERROR_GENERIC:
2083 ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
2084 break;
2085 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
2086 ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
2087 break;
2088 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
2089 ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
2090 break;
2091 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
2092 ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
2093 break;
2094 case EVAS_LOAD_ERROR_CORRUPT_FILE:
2095 ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
2096 break;
2097 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
2098 ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
2099 break;
2100 default:
2101 ERR("Error type: ???");
2102 break;
2103 }
2104 }
2105 }
2106 }
2107} 2173}
2108 2174
2109static Edje_Real_Part * 2175static Edje_Real_Part *
@@ -2299,13 +2365,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2299 Edje_Real_Part *pp; 2365 Edje_Real_Part *pp;
2300 int part_id = -1; 2366 int part_id = -1;
2301 2367
2302 if (pos >= 0.5) 2368 if (pos >= FROM_DOUBLE(0.5))
2303 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id; 2369 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2304 else 2370 else
2305 part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id; 2371 part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id;
2306 2372
2307 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL); 2373 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL);
2374#ifdef EDJE_CALC_CACHE
2308 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE; 2375 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE;
2376#endif
2309 } 2377 }
2310 2378
2311 /* Recalc if needed the map center && light source */ 2379 /* Recalc if needed the map center && light source */
@@ -2355,7 +2423,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2355 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0], 2423 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
2356 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y, 2424 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
2357 confine_to, 2425 confine_to,
2358 p1); 2426 p1, pos);
2359 2427
2360#ifdef EDJE_CALC_CACHE 2428#ifdef EDJE_CALC_CACHE
2361 ep->param1.state = ed->state; 2429 ep->param1.state = ed->state;
@@ -2400,10 +2468,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2400 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change)) 2468 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2401#endif 2469#endif
2402 { 2470 {
2403 _edje_part_recalc_single(ed, ep, ep->param2->description, chosen_desc, center[1], light[1], persp[1], 2471 _edje_part_recalc_single(ed, ep, ep->param2->description,
2404 ep->param2->rel1_to_x, ep->param2->rel1_to_y, ep->param2->rel2_to_x, ep->param2->rel2_to_y, 2472 chosen_desc,
2473 center[1], light[1], persp[1],
2474 ep->param2->rel1_to_x,
2475 ep->param2->rel1_to_y,
2476 ep->param2->rel2_to_x,
2477 ep->param2->rel2_to_y,
2405 confine_to, 2478 confine_to,
2406 p2); 2479 p2, pos);
2407#ifdef EDJE_CALC_CACHE 2480#ifdef EDJE_CALC_CACHE
2408 ep->param2->state = ed->state; 2481 ep->param2->state = ed->state;
2409#endif 2482#endif
@@ -2449,7 +2522,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2449 p3->req.y = INTP(p1->req.y, p2->req.y, pos); 2522 p3->req.y = INTP(p1->req.y, p2->req.y, pos);
2450 p3->req.w = INTP(p1->req.w, p2->req.w, pos); 2523 p3->req.w = INTP(p1->req.w, p2->req.w, pos);
2451 p3->req.h = INTP(p1->req.h, p2->req.h, pos); 2524 p3->req.h = INTP(p1->req.h, p2->req.h, pos);
2452 2525
2453 if (ep->part->dragable.x) 2526 if (ep->part->dragable.x)
2454 { 2527 {
2455 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos); 2528 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos);
@@ -2543,11 +2616,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
2543 } 2616 }
2544 else if (p1->persp_on) 2617 else if (p1->persp_on)
2545 { 2618 {
2546 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.light)); 2619 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.persp));
2547 } 2620 }
2548 else if (p2->persp_on) 2621 else if (p2->persp_on)
2549 { 2622 {
2550 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.light)); 2623 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.persp));
2551 } 2624 }
2552 } 2625 }
2553 2626