1 #include "edje_private.h"
3 static void _edje_part_make_rtl(Edje_Part_Description_Common *desc);
4 static Edje_Part_Description_Common *_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type);
6 static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep,
7 Edje_Part_Description_Common *desc, Edje_Part_Description_Common *chosen_desc,
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,
10 Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y,
11 Edje_Real_Part *confine_to, Edje_Calc_Params *params,
15 _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2)
20 pos = CLAMP(pos, ZERO, FROM_INT(1));
25 #if 0 // old code - easy to enable for comparing float vs fixed point
26 /* take linear pos along timescale and use interpolation method */
29 case EDJE_TWEEN_MODE_SINUSOIDAL:
30 /* npos = (1.0 - cos(pos * PI)) / 2.0; */
31 npos = DIV2(SUB(FROM_INT(1),
36 case EDJE_TWEEN_MODE_ACCELERATE:
37 /* npos = 1.0 - sin((PI / 2.0) + (pos * PI / 2.0)); */
38 npos = SUB(FROM_INT(1),
44 case EDJE_TWEEN_MODE_DECELERATE:
45 /* npos = sin(pos * PI / 2.0); */
46 npos = SIN(MUL(fp_pos,
50 case EDJE_TWEEN_MODE_LINEAR:
59 switch (mode & EDJE_TWEEN_MODE_MASK)
61 case EDJE_TWEEN_MODE_SINUSOIDAL:
62 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
63 ECORE_POS_MAP_SINUSOIDAL,
67 case EDJE_TWEEN_MODE_ACCELERATE:
68 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
69 ECORE_POS_MAP_ACCELERATE,
73 case EDJE_TWEEN_MODE_DECELERATE:
74 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
75 ECORE_POS_MAP_DECELERATE,
79 case EDJE_TWEEN_MODE_LINEAR:
81 /* npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
87 case EDJE_TWEEN_MODE_ACCELERATE_FACTOR:
88 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
89 ECORE_POS_MAP_ACCELERATE_FACTOR,
93 case EDJE_TWEEN_MODE_DECELERATE_FACTOR:
94 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
95 ECORE_POS_MAP_DECELERATE_FACTOR,
99 case EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR:
100 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
101 ECORE_POS_MAP_SINUSOIDAL_FACTOR,
102 TO_DOUBLE(v1), 0.0));
105 case EDJE_TWEEN_MODE_DIVISOR_INTERP:
106 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
107 ECORE_POS_MAP_DIVISOR_INTERP,
108 TO_DOUBLE(v1), TO_DOUBLE(v2)));
111 case EDJE_TWEEN_MODE_BOUNCE:
112 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
113 ECORE_POS_MAP_BOUNCE,
114 TO_DOUBLE(v1), TO_DOUBLE(v2)));
117 case EDJE_TWEEN_MODE_SPRING:
118 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
119 ECORE_POS_MAP_SPRING,
120 TO_DOUBLE(v1), TO_DOUBLE(v2)));
128 if (npos == ep->description_pos) return;
130 ep->description_pos = npos;
134 #ifdef EDJE_CALC_CACHE
140 * Returns part description
144 * Converts part description to RTL-desc.
146 * @param desc Pointer to desc buffer.
150 _edje_part_make_rtl(Edje_Part_Description_Common *desc)
158 /* This makes alignment right-oriented */
159 desc->align.x = 1.0 - desc->align.x;
161 /* same as above for relative components */
162 t = desc->rel1.relative_x;
163 desc->rel1.relative_x = 1.0 - desc->rel2.relative_x;
164 desc->rel2.relative_x = 1.0 - t;
166 /* +1 and +1 are because how edje works with right
167 * side borders - nothing is printed beyond that limit
169 * rel2 is now to the left of rel1, and Edje assumes
170 * the opposite so we switch corners on x-axis to define
171 * offset from right to left */
172 i = desc->rel1.offset_x;
173 desc->rel1.offset_x = -(desc->rel2.offset_x + 1);
174 desc->rel2.offset_x = -(i + 1);
177 desc->rel1.id_x = desc->rel2.id_x;
182 * Returns part description
186 * Returns part description according to object orientation.
187 * When object is in RTL-orientation (RTL flag is set)
188 * this returns the RTL-desc of it.
189 * RTL-desc would be allocated if was not created by a previous call.
190 * The dst pointer is updated in case of an allocation.
192 * @param ed Edje object.
193 * @param src The Left To Right (LTR), original desc.
194 * @param dst Pointer to Right To Left (RTL) desc-list.
195 * @param type name of dec type. Example: "default".
197 * @return Edje part description.
200 static Edje_Part_Description_Common *
201 _edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type)
203 Edje_Part_Description_Common *desc_rtl = NULL;
204 Edje_Part_Collection_Directory_Entry *ce;
207 /* RTL flag is not set, return original description */
208 if (!edje_object_mirrored_get(ed->obj))
212 return *dst; /* Was allocated before and we should use it */
214 #define EDIT_ALLOC_POOL_RTL(Short, Type, Name) \
215 case EDJE_PART_TYPE_##Short: \
217 Edje_Part_Description_##Type * Name; \
218 Name = eina_mempool_malloc(ce->mp_rtl.Short, \
219 sizeof (Edje_Part_Description_##Type)); \
220 memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \
221 desc_rtl = &Name->common; \
222 memsize = sizeof(Edje_Part_Description_##Type); \
226 ce = eina_hash_find(ed->file->collection, ed->group);
230 case EDJE_PART_TYPE_RECTANGLE:
231 desc_rtl = eina_mempool_malloc(ce->mp_rtl.RECTANGLE,
232 sizeof (Edje_Part_Description_Common));
233 ce->count.RECTANGLE++;
234 memsize = sizeof(Edje_Part_Description_Common);
237 case EDJE_PART_TYPE_SWALLOW:
238 desc_rtl = eina_mempool_malloc(ce->mp_rtl.SWALLOW,
239 sizeof (Edje_Part_Description_Common));
241 memsize = sizeof(Edje_Part_Description_Common);
244 case EDJE_PART_TYPE_GROUP:
245 desc_rtl = eina_mempool_malloc(ce->mp_rtl.GROUP,
246 sizeof (Edje_Part_Description_Common));
248 memsize = sizeof(Edje_Part_Description_Common);
251 case EDJE_PART_TYPE_SPACER:
252 desc_rtl = eina_mempool_malloc(ce->mp_rtl.SPACER,
253 sizeof (Edje_Part_Description_Common));
255 memsize = sizeof(Edje_Part_Description_Common);
257 EDIT_ALLOC_POOL_RTL(TEXT, Text, text);
258 EDIT_ALLOC_POOL_RTL(TEXTBLOCK, Text, text);
259 EDIT_ALLOC_POOL_RTL(IMAGE, Image, image);
260 EDIT_ALLOC_POOL_RTL(PROXY, Proxy, proxy);
261 EDIT_ALLOC_POOL_RTL(BOX, Box, box);
262 EDIT_ALLOC_POOL_RTL(TABLE, Table, table);
263 EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params);
267 memcpy(desc_rtl, src, memsize);
269 _edje_part_make_rtl(desc_rtl);
275 Edje_Part_Description_Common *
276 _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
279 Edje_Part *ep = rp->part;
280 Edje_Part_Description_Common *ret = NULL;
281 Edje_Part_Description_Common *d;
283 double min_dst = 99999.0;
286 /* RTL flag is set, return RTL description */
287 if (edje_object_mirrored_get(ed->obj))
288 if (!ep->other.desc_rtl)
289 ep->other.desc_rtl = (Edje_Part_Description_Common **)
290 calloc(ep->other.desc_count,
291 sizeof (Edje_Part_Description_Common *));
293 if (!strcmp(name, "default") && val == 0.0)
294 return _edje_get_description_by_orientation(ed,
295 ep->default_desc, &ep->default_desc_rtl, ep->type);
297 if (!strcmp(name, "custom"))
299 _edje_get_description_by_orientation(ed, rp->custom->description,
300 &rp->custom->description_rtl, ep->type) : NULL;
302 if (!strcmp(name, "default"))
304 ret = _edje_get_description_by_orientation(ed, ep->default_desc,
305 &ep->default_desc_rtl,
308 min_dst = ABS(ep->default_desc->state.value - val);
311 for (i = 0; i < ep->other.desc_count; ++i)
313 d = ep->other.desc[i];
315 if (d->state.name && (d->state.name == name ||
316 !strcmp(d->state.name, name)))
320 dst = ABS(d->state.value - val);
323 ret = _edje_get_description_by_orientation(ed, d,
324 &ep->other.desc_rtl[i], ep->type);
334 _edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid)
336 Edje_Image_Directory_Set_Entry *entry;
337 Edje_Image_Directory_Set *set = NULL;
346 if (st && !st->image.set)
349 if (imid && !imid->set)
357 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
361 if ((*eps)->id == id)
365 if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w)
366 if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h)
367 return (*eps)->entry->id;
371 set = ed->file->image_dir->sets + id;
373 EINA_LIST_FOREACH(set->entries, l, entry)
375 if (entry->size.min.w <= w && w <= entry->size.max.w)
376 if (entry->size.min.h <= h && h <= entry->size.max.h)
381 *eps = calloc(1, sizeof (Edje_Real_Part_Set));
385 (*eps)->entry = entry;
398 _edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T pos)
401 int image_count, image_num;
403 image_id = _edje_image_find(ep->object, ed,
405 (Edje_Part_Description_Image *)ep->param1.description,
409 Edje_Image_Directory_Entry *ie;
411 if (!ed->file->image_dir) ie = NULL;
412 else ie = ed->file->image_dir->entries + (-image_id) - 1;
414 (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
417 evas_object_image_file_set(ep->object, ie->entry, NULL);
424 image_count += ((Edje_Part_Description_Image *)ep->param2->description)->image.tweens_count;
425 image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
427 if (image_num > (image_count - 1))
428 image_num = image_count - 1;
431 image_id = _edje_image_find(ep->object, ed,
433 (Edje_Part_Description_Image *)ep->param1.description,
439 if (image_num == (image_count - 1))
441 image_id = _edje_image_find(ep->object, ed,
443 (Edje_Part_Description_Image *)ep->param2->description,
448 Edje_Part_Image_Id *imid;
450 imid = ((Edje_Part_Description_Image *)ep->param2->description)->image.tweens[image_num - 1];
451 image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
456 ERR("¨Part \"%s\" description, "
457 "\"%s\" %3.3f with image %i index has a missing image id in a set of %i !!!",
459 ep->param1.description->state.name,
460 ep->param1.description->state.value,
468 /* Replace snprint("edje/images/%i") == memcpy + itoa */
469 #define IMAGES "edje/images/"
470 memcpy(buf, IMAGES, strlen(IMAGES));
471 eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */
473 evas_object_image_file_set(ep->object, ed->file->path, buf);
474 if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
476 ERR("Error loading image collection \"%s\" from "
477 "file \"%s\". Missing EET Evas loader module?",
478 buf, ed->file->path);
479 switch (evas_object_image_load_error_get(ep->object))
481 case EVAS_LOAD_ERROR_GENERIC:
482 ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
485 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
486 ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
489 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
490 ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
493 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
494 ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
497 case EVAS_LOAD_ERROR_CORRUPT_FILE:
498 ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
501 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
502 ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
506 ERR("Error type: ???");
515 _edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state)
517 state->rel1_to_x = state->rel1_to_y = NULL;
518 state->rel2_to_x = state->rel2_to_y = NULL;
520 if (state->description)
522 if (state->description->rel1.id_x >= 0)
523 state->rel1_to_x = ed->table_parts[state->description->rel1.id_x % ed->table_parts_size];
524 if (state->description->rel1.id_y >= 0)
525 state->rel1_to_y = ed->table_parts[state->description->rel1.id_y % ed->table_parts_size];
526 if (state->description->rel2.id_x >= 0)
527 state->rel2_to_x = ed->table_parts[state->description->rel2.id_x % ed->table_parts_size];
528 if (state->description->rel2.id_y >= 0)
529 state->rel2_to_y = ed->table_parts[state->description->rel2.id_y % ed->table_parts_size];
531 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
533 Edje_Part_Description_External *external;
535 external = (Edje_Part_Description_External *)state->description;
537 if (state->external_params)
538 _edje_external_parsed_params_free(ep->swallowed_object, state->external_params);
539 state->external_params = _edje_external_params_parse(ep->swallowed_object, external->external_params);
545 _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2)
547 Edje_Part_Description_Common *epd1;
548 Edje_Part_Description_Common *epd2 = NULL;
549 Edje_Part_Description_Common *chosen_desc;
551 Edje_Part_Description_Image *epdi;
553 if (!d1) d1 = "default";
555 epd1 = _edje_part_description_find(ed, ep, d1, v1);
557 epd1 = ep->part->default_desc; /* never NULL */
560 epd2 = _edje_part_description_find(ed, ep, d2, v2);
562 epdi = (Edje_Part_Description_Image *)epd2;
564 /* There is an animation if both description are different or if description is an image with tweens */
565 if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count)))
569 ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp,
570 sizeof(Edje_Real_Part_State));
571 memset(ep->param2, 0, sizeof(Edje_Real_Part_State));
573 else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
574 _edje_external_parsed_params_free(ep->swallowed_object,
575 ep->param2->external_params);
576 ep->param2->external_params = NULL;
581 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
582 _edje_external_parsed_params_free(ep->swallowed_object,
583 ep->param2->external_params);
585 free(ep->param2->set);
586 eina_mempool_free(_edje_real_part_state_mp, ep->param2);
590 chosen_desc = ep->chosen_description;
591 ep->param1.description = epd1;
592 ep->chosen_description = epd1;
594 _edje_real_part_rel_to_apply(ed, ep, &ep->param1);
598 ep->param2->description = epd2;
600 _edje_real_part_rel_to_apply(ed, ep, ep->param2);
602 if (ep->description_pos > FROM_DOUBLE(0.0))
603 ep->chosen_description = epd2;
606 if (chosen_desc != ep->chosen_description &&
607 ep->part->type == EDJE_PART_TYPE_EXTERNAL)
608 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
610 ed->recalc_hints = 1;
613 #ifdef EDJE_CALC_CACHE
619 _edje_recalc(Edje *ed)
621 if ((ed->freeze > 0) || (_edje_freeze_val > 0))
626 if (_edje_freeze_val > 0)
628 if (!ed->freeze_calc)
630 _edje_freeze_calc_count++;
631 _edje_freeze_calc_list = eina_list_append(_edje_freeze_calc_list, ed);
638 // XXX: dont need this with current smart calc infra. remove me later
639 // if (ed->postponed) return;
640 // if (!ed->calc_only)
641 evas_object_smart_changed(ed->obj);
642 // XXX: dont need this with current smart calc infra. remove me later
643 // ed->postponed = 1;
647 _edje_recalc_do(Edje *ed)
652 // XXX: dont need this with current smart calc infra. remove me later
653 // ed->postponed = 0;
654 need_calc = evas_object_smart_need_recalculate_get(ed->obj);
655 evas_object_smart_need_recalculate_set(ed->obj, 0);
656 if (!ed->dirty) return;
657 ed->have_mapped_part = 0;
660 for (i = 0; i < ed->table_parts_size; i++)
664 ep = ed->table_parts[i];
665 ep->calculated = FLAG_NONE;
666 ep->calculating = FLAG_NONE;
668 for (i = 0; i < ed->table_parts_size; i++)
672 ep = ed->table_parts[i];
673 if (ep->calculated != FLAG_XY)
674 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
676 if (!ed->calc_only) ed->recalc = 0;
677 #ifdef EDJE_CALC_CACHE
678 ed->all_part_change = 0;
679 ed->text_part_change = 0;
684 evas_object_smart_callback_call(ed->obj, "recalc", NULL);
687 evas_object_smart_need_recalculate_set(ed->obj, need_calc);
690 if (ed->update_hints && ed->recalc_hints && !ed->calc_only)
694 ed->recalc_hints = 0;
696 edje_object_size_min_calc(ed->obj, &w, &h);
697 evas_object_size_hint_min_set(ed->obj, w, h);
700 if (!ed->collection) return;
702 for (i = 0; i < ed->collection->limits.parts_count; i++)
708 part = ed->collection->limits.parts[i].part;
709 name = ed->collection->parts[part]->name;
710 limit = ed->table_parts[part]->chosen_description->limit;
714 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
715 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
719 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
723 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
730 if ((limit & 1) == 1)
732 if (ed->table_parts[part]->w > 0 &&
733 (ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_OVER))
735 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_OVER;
736 _edje_emit(ed, "limit,width,over", name);
738 else if (ed->table_parts[part]->w < 0 &&
739 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_BELOW)
741 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_BELOW;
742 _edje_emit(ed, "limit,width,below", name);
744 else if (ed->table_parts[part]->w == 0 &&
745 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_ZERO)
747 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_ZERO;
748 _edje_emit(ed, "limit,width,zero", name);
751 if ((limit & 2) == 2)
753 if (ed->table_parts[part]->h > 0 &&
754 (ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_OVER))
756 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_OVER;
757 _edje_emit(ed, "limit,height,over", name);
759 else if (ed->table_parts[part]->h < 0 &&
760 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_BELOW)
762 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_BELOW;
763 _edje_emit(ed, "limit,height,below", name);
765 else if (ed->table_parts[part]->h == 0 &&
766 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_ZERO)
768 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_ZERO;
769 _edje_emit(ed, "limit,height,zero", name);
776 _edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep)
778 _edje_part_recalc(ed, ep, FLAG_XY, NULL);
782 _edje_part_dragable_calc(Edje *ed __UNUSED__, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y)
786 if (ep->drag->confine_to)
788 FLOAT_T dx, dy, dw, dh;
791 if ((ep->part->dragable.x != 0) &&
792 (ep->part->dragable.y != 0)) ret = 3;
793 else if (ep->part->dragable.x != 0)
795 else if (ep->part->dragable.y != 0)
798 dx = FROM_INT(ep->x - ep->drag->confine_to->x);
799 dw = FROM_INT(ep->drag->confine_to->w - ep->w);
800 if (dw != ZERO) dx = DIV(dx, dw);
803 dy = FROM_INT(ep->y - ep->drag->confine_to->y);
804 dh = FROM_INT(ep->drag->confine_to->h - ep->h);
805 if (dh != ZERO) dy = DIV(dy, dh);
815 if (x) *x = ADD(FROM_INT(ep->drag->tmp.x), ep->drag->x);
816 if (y) *y = ADD(FROM_INT(ep->drag->tmp.y), ep->drag->y);
826 _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
828 /* check whether this part is dragable at all */
829 if (!ep->drag) return;
831 /* instead of checking for equality, we really should check that
832 * the difference is greater than foo, but I have no idea what
833 * value we would set foo to, because it would depend on the
834 * size of the dragable...
836 if (ep->drag->x != x || ep->drag->tmp.x)
840 ep->drag->need_reset = 0;
845 if (ep->drag->y != y || ep->drag->tmp.y)
849 ep->drag->need_reset = 0;
854 #ifdef EDJE_CALC_CACHE
857 _edje_recalc(ed); /* won't do anything if dirty flag isn't set */
861 _edje_part_recalc_single_rel(Edje *ed,
862 Edje_Real_Part *ep __UNUSED__,
863 Edje_Part_Description_Common *desc,
864 Edje_Real_Part *rel1_to_x,
865 Edje_Real_Part *rel1_to_y,
866 Edje_Real_Part *rel2_to_x,
867 Edje_Real_Part *rel2_to_y,
868 Edje_Calc_Params *params)
874 x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x),
875 SCALE(desc->rel1.relative_x, rel1_to_x->w));
877 x = ADD(FROM_INT(desc->rel1.offset_x),
878 SCALE(desc->rel1.relative_x, ed->w));
879 params->x = TO_INT(x);
882 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x),
883 SCALE(desc->rel2.relative_x, rel2_to_x->w)),
887 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x),
888 SCALE(desc->rel2.relative_x, ed->w)),
891 params->w = TO_INT(w);
894 y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y),
895 SCALE(desc->rel1.relative_y, rel1_to_y->h));
897 y = ADD(FROM_INT(desc->rel1.offset_y),
898 SCALE(desc->rel1.relative_y, ed->h));
899 params->y = TO_INT(y);
902 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y),
903 SCALE(desc->rel2.relative_y, rel2_to_y->h)),
907 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y),
908 SCALE(desc->rel2.relative_y, ed->h)),
911 params->h = TO_INT(h);
914 static Edje_Internal_Aspect
915 _edje_part_recalc_single_aspect(Edje *ed,
917 Edje_Part_Description_Common *desc,
918 Edje_Calc_Params *params,
919 int *minw, int *minh,
920 int *maxw, int *maxh,
923 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE;
924 FLOAT_T aspect, amax, amin;
925 FLOAT_T new_w = ZERO, new_h = ZERO, want_x, want_y, want_w, want_h;
927 if (params->h <= ZERO) aspect = FROM_INT(999999);
928 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h));
929 amax = desc->aspect.max;
930 amin = desc->aspect.min;
931 if (desc->aspect.prefer == EDJE_ASPECT_PREFER_SOURCE &&
932 ep->part->type == EDJE_PART_TYPE_IMAGE)
936 /* We only need pose to find the right image that would be displayed,
937 and the right aspect ratio in that case */
938 _edje_real_part_image_set(ed, ep, pos);
939 evas_object_image_size_get(ep->object, &w, &h);
940 amin = amax = DIV(FROM_INT(w), FROM_INT(h));
942 if ((ep->swallow_params.aspect.w > 0) &&
943 (ep->swallow_params.aspect.h > 0))
945 DIV(FROM_INT(ep->swallow_params.aspect.w),
946 FROM_INT(ep->swallow_params.aspect.h));
947 want_x = FROM_INT(params->x);
948 want_w = new_w = FROM_INT(params->w);
950 want_y = FROM_INT(params->y);
951 want_h = new_h = FROM_INT(params->h);
953 if ((amin > ZERO) && (amax > ZERO))
955 apref = desc->aspect.prefer;
956 if (ep->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE)
958 switch (ep->swallow_params.aspect.mode)
960 case EDJE_ASPECT_CONTROL_NEITHER:
961 apref = EDJE_ASPECT_PREFER_NONE;
964 case EDJE_ASPECT_CONTROL_HORIZONTAL:
965 apref = EDJE_ASPECT_PREFER_HORIZONTAL;
968 case EDJE_ASPECT_CONTROL_VERTICAL:
969 apref = EDJE_ASPECT_PREFER_VERTICAL;
972 case EDJE_ASPECT_CONTROL_BOTH:
973 apref = EDJE_ASPECT_PREFER_BOTH;
982 case EDJE_ASPECT_PREFER_NONE:
983 /* keep both dimensions in check */
984 /* adjust for min aspect (width / height) */
985 if ((amin > ZERO) && (aspect < amin))
987 new_h = DIV(FROM_INT(params->w), amin);
988 new_w = SCALE(amin, params->h);
990 /* adjust for max aspect (width / height) */
991 if ((amax > ZERO) && (aspect > amax))
993 new_h = DIV(FROM_INT(params->w), amax);
994 new_w = SCALE(amax, params->h);
996 if ((amax > ZERO) && (new_w < FROM_INT(params->w)))
998 new_w = FROM_INT(params->w);
999 new_h = DIV(FROM_INT(params->w), amax);
1001 if ((amax > ZERO) && (new_h < FROM_INT(params->h)))
1003 new_w = SCALE(amax, params->h);
1004 new_h = FROM_INT(params->h);
1008 /* prefer vertical size as determiner */
1009 case EDJE_ASPECT_PREFER_VERTICAL:
1010 /* keep both dimensions in check */
1011 /* adjust for max aspect (width / height) */
1012 if ((amax > ZERO) && (aspect > amax))
1013 new_w = SCALE(amax, params->h);
1014 /* adjust for min aspect (width / height) */
1015 if ((amin > ZERO) && (aspect < amin))
1016 new_w = SCALE(amin, params->h);
1019 /* prefer horizontal size as determiner */
1020 case EDJE_ASPECT_PREFER_HORIZONTAL:
1021 /* keep both dimensions in check */
1022 /* adjust for max aspect (width / height) */
1023 if ((amax > ZERO) && (aspect > amax))
1024 new_h = DIV(FROM_INT(params->w), amax);
1025 /* adjust for min aspect (width / height) */
1026 if ((amin > ZERO) && (aspect < amin))
1027 new_h = DIV(FROM_INT(params->w), amin);
1030 case EDJE_ASPECT_PREFER_SOURCE:
1031 case EDJE_ASPECT_PREFER_BOTH:
1032 /* keep both dimensions in check */
1033 /* adjust for max aspect (width / height) */
1034 if ((amax > ZERO) && (aspect > amax))
1036 new_w = SCALE(amax, params->h);
1037 new_h = DIV(FROM_INT(params->w), amax);
1039 /* adjust for min aspect (width / height) */
1040 if ((amin > ZERO) && (aspect < amin))
1042 new_w = SCALE(amin, params->h);
1043 new_h = DIV(FROM_INT(params->w), amin);
1051 if (!((amin > ZERO) && (amax > ZERO) &&
1052 (apref == EDJE_ASPECT_PREFER_NONE)))
1054 if ((*maxw >= 0) && (new_w > FROM_INT(*maxw)))
1055 new_w = FROM_INT(*maxw);
1056 if (new_w < FROM_INT(*minw))
1057 new_w = FROM_INT(*minw);
1059 if ((FROM_INT(*maxh) >= 0) && (new_h > FROM_INT(*maxh)))
1060 new_h = FROM_INT(*maxh);
1061 if (new_h < FROM_INT(*minh))
1062 new_h = FROM_INT(*minh);
1065 /* do real adjustment */
1066 if (apref == EDJE_ASPECT_PREFER_BOTH)
1068 if (amin == ZERO) amin = amax;
1071 /* fix h and vary w */
1072 if (new_w > FROM_INT(params->w))
1074 // params->w = new_w;
1075 // EXCEEDS BOUNDS in W
1076 new_h = DIV(FROM_INT(params->w), amin);
1077 new_w = FROM_INT(params->w);
1078 if (new_h > FROM_INT(params->h))
1080 new_h = FROM_INT(params->h);
1081 new_w = SCALE(amin, params->h);
1084 /* fix w and vary h */
1087 // params->h = new_h;
1088 // EXCEEDS BOUNDS in H
1089 new_h = FROM_INT(params->h);
1090 new_w = SCALE(amin, params->h);
1091 if (new_w > FROM_INT(params->w))
1093 new_h = DIV(FROM_INT(params->w), amin);
1094 new_w = FROM_INT(params->w);
1097 params->w = TO_INT(new_w);
1098 params->h = TO_INT(new_h);
1102 if (apref != EDJE_ASPECT_PREFER_BOTH)
1104 if ((amin > 0.0) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE))
1106 params->w = TO_INT(new_w);
1107 params->h = TO_INT(new_h);
1109 else if ((FROM_INT(params->h) - new_h) > (FROM_INT(params->w) - new_w))
1111 if (params->h < TO_INT(new_h))
1112 params->h = TO_INT(new_h);
1113 else if (params->h > TO_INT(new_h))
1114 params->h = TO_INT(new_h);
1115 if (apref == EDJE_ASPECT_PREFER_VERTICAL)
1116 params->w = TO_INT(new_w);
1120 if (params->w < TO_INT(new_w))
1121 params->w = TO_INT(new_w);
1122 else if (params->w > TO_INT(new_w))
1123 params->w = TO_INT(new_w);
1124 if (apref == EDJE_ASPECT_PREFER_HORIZONTAL)
1125 params->h = TO_INT(new_h);
1128 params->x = TO_INT(ADD(want_x,
1129 MUL(SUB(want_w, FROM_INT(params->w)),
1131 params->y = TO_INT(ADD(want_y,
1132 MUL(SUB(want_h, FROM_INT(params->h)),
1138 _edje_part_recalc_single_step(Edje_Part_Description_Common *desc,
1139 Edje_Calc_Params *params)
1141 if (desc->step.x > 0)
1146 steps = params->w / desc->step.x;
1147 new_w = desc->step.x * steps;
1148 if (params->w > new_w)
1150 params->x += TO_INT(SCALE(desc->align.x, (params->w - new_w)));
1155 if (desc->step.y > 0)
1160 steps = params->h / desc->step.y;
1161 new_h = desc->step.y * steps;
1162 if (params->h > new_h)
1164 params->y += TO_INT(SCALE(desc->align.y, (params->h - new_h)));
1171 _edje_part_recalc_single_textblock(FLOAT_T sc,
1174 Edje_Part_Description_Text *chosen_desc,
1175 Edje_Calc_Params *params,
1176 int *minw, int *minh,
1177 int *maxw, int *maxh)
1181 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
1182 const char *text = "";
1183 const char *style = "";
1184 Edje_Style *stl = NULL;
1188 if (chosen_desc->text.id_source >= 0)
1190 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1192 tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.style);
1193 if (tmp) style = tmp;
1197 ep->text.source = NULL;
1199 tmp = edje_string_get(&chosen_desc->text.style);
1200 if (tmp) style = tmp;
1203 if (chosen_desc->text.id_text_source >= 0)
1205 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1206 text = edje_string_get(&((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text);
1208 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1212 ep->text.text_source = NULL;
1213 text = edje_string_get(&chosen_desc->text.text);
1214 if (ep->text.text) text = ep->text.text;
1217 EINA_LIST_FOREACH(ed->file->styles, l, stl)
1219 if ((stl->name) && (!strcmp(stl->name, style))) break;
1223 if (ep->part->scale)
1224 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1230 if (evas_object_textblock_style_get(ep->object) != stl->style)
1231 evas_object_textblock_style_set(ep->object, stl->style);
1232 // FIXME: need to account for editing
1233 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1235 // do nothing - should be done elsewhere
1239 ptxt = evas_object_textblock_text_markup_get(ep->object);
1240 if (((!ptxt) && (text)) ||
1241 ((ptxt) && (text) && (strcmp(ptxt, text))) ||
1242 ((ptxt) && (!text)))
1243 evas_object_textblock_text_markup_set(ep->object, text);
1245 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
1250 if (!chosen_desc->text.min_x)
1252 evas_object_resize(ep->object, params->w, params->h);
1253 evas_object_textblock_size_formatted_get(ep->object, &tw,
1257 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1258 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1259 &ins_r, &ins_t, &ins_b);
1260 mw = ins_l + tw + ins_r;
1261 mh = ins_t + th + ins_b;
1263 if (minw && chosen_desc->text.min_x)
1265 if (mw > *minw) *minw = mw;
1267 if (minh && chosen_desc->text.min_y)
1269 if (mh > *minh) *minh = mh;
1273 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1278 if (!chosen_desc->text.max_x)
1280 evas_object_resize(ep->object, params->w, params->h);
1281 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
1284 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1285 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
1287 mw = ins_l + tw + ins_r;
1288 mh = ins_t + th + ins_b;
1290 if (maxw && chosen_desc->text.max_x)
1292 if (mw > *maxw) *maxw = mw;
1293 if (minw && (*maxw < *minw)) *maxw = *minw;
1295 if (maxh && chosen_desc->text.max_y)
1297 if (mh > *maxh) *maxh = mh;
1298 if (minh && (*maxh < *minh)) *maxh = *minh;
1301 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
1305 if (ep->part->scale) s = TO_DOUBLE(sc);
1306 evas_object_scale_set(ep->object, s);
1307 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
1308 if (chosen_desc->text.fit_x)
1310 if ((tw > 0) && (tw > params->w))
1312 s = (s * params->w) / (double)tw;
1313 evas_object_scale_set(ep->object, s);
1314 evas_object_textblock_size_formatted_get(ep->object,
1318 if (chosen_desc->text.fit_y)
1320 if ((th > 0) && (th > params->h))
1322 s = (s * params->h) / (double)th;
1323 evas_object_scale_set(ep->object, s);
1324 evas_object_textblock_size_formatted_get(ep->object,
1329 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
1334 _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
1335 Edje_Calc_Params *params,
1336 Edje_Part_Description_Text *chosen_desc)
1338 /* FIXME: this is just an hack. */
1341 if (sc == ZERO) sc = _edje_scale;
1342 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
1344 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
1345 NULL, NULL, NULL, NULL);
1350 _edje_part_recalc_single_text(FLOAT_T sc __UNUSED__,
1353 Edje_Part_Description_Text *desc,
1354 Edje_Part_Description_Text *chosen_desc,
1355 Edje_Calc_Params *params,
1356 int *minw, int *minh,
1357 int *maxw, int *maxh)
1358 #define RECALC_SINGLE_TEXT_USING_APPLY 1
1359 #if RECALC_SINGLE_TEXT_USING_APPLY
1363 * Original _edje_part_recalc_single_text() was not working as
1364 * expected since it was not doing size fit, range, ellipsis and so
1367 * The purpose of this function compared with
1368 * _edje_text_recalc_apply() is to be faster, not calling Evas update
1369 * functions. However for text this is quite difficult given that to
1370 * fit we need to set the font, size, style, etc. If it was done
1371 * correctly, we'd save some calls to move and some color sets,
1372 * however those shouldn't matter much in the overall picture.
1374 * I've changed this to force applying the value, it should be more
1375 * correct and not so slow. The previous code is kept below for
1376 * reference but should be removed before next release!
1378 * -- Gustavo Barbieri at 20-Aug-2011
1381 int tw, th, mw, mh, l, r, t, b, size;
1384 _edje_text_class_font_get(ed, desc, &size, &sfont);
1386 params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */
1388 _edje_text_recalc_apply(ed, ep, params, chosen_desc);
1390 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1392 if ((!chosen_desc) ||
1393 ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) &&
1394 (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y)))
1397 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1398 evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
1403 if (chosen_desc->text.max_x)
1405 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1407 if (chosen_desc->text.max_y)
1409 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1411 if (chosen_desc->text.min_x)
1413 if (mw > *minw) *minw = mw;
1415 if (chosen_desc->text.min_y)
1417 if (mh > *minh) *minh = mh;
1431 int inlined_font = 0;
1433 /* Update a object_text part */
1435 if (chosen_desc->text.id_source >= 0)
1436 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1438 ep->text.source = NULL;
1440 if (chosen_desc->text.id_text_source >= 0)
1441 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1443 ep->text.text_source = NULL;
1445 if (ep->text.text_source)
1446 text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text));
1448 text = edje_string_get(&chosen_desc->text.text);
1450 if (ep->text.source)
1451 font = _edje_text_class_font_get(ed, ((Edje_Part_Description_Text *)ep->text.source->chosen_description), &size, &sfont);
1453 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
1455 if (!font) font = "";
1457 if (ep->text.text_source)
1459 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1463 if (ep->text.text) text = ep->text.text;
1466 if (ep->text.source)
1468 if (ep->text.source->text.font) font = ep->text.source->text.font;
1469 if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
1473 if (ep->text.font) font = ep->text.font;
1474 if (ep->text.size > 0) size = ep->text.size;
1476 if (!text) text = "";
1478 /* check if the font is embedded in the .eet */
1479 if (ed->file->fonts)
1481 Edje_Font_Directory_Entry *fnt;
1483 fnt = eina_hash_find(ed->file->fonts, font);
1489 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
1490 font2 = alloca(len);
1491 sprintf(font2, "edje/fonts/%s", font);
1496 if (ep->part->scale)
1497 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1500 evas_object_text_font_source_set(ep->object, ed->path);
1502 else evas_object_text_font_source_set(ep->object, NULL);
1504 if ((_edje_fontset_append) && (font))
1508 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
1511 strcpy(font2, font);
1513 strcat(font2, _edje_fontset_append);
1514 evas_object_text_font_set(ep->object, font2, size);
1519 evas_object_text_font_set(ep->object, font, size);
1520 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) ||
1521 (chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1524 Evas_Text_Style_Type
1525 style = EVAS_TEXT_STYLE_PLAIN,
1526 shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT;
1527 const Evas_Text_Style_Type styles[] = {
1528 EVAS_TEXT_STYLE_PLAIN,
1529 EVAS_TEXT_STYLE_PLAIN,
1530 EVAS_TEXT_STYLE_OUTLINE,
1531 EVAS_TEXT_STYLE_SOFT_OUTLINE,
1532 EVAS_TEXT_STYLE_SHADOW,
1533 EVAS_TEXT_STYLE_SOFT_SHADOW,
1534 EVAS_TEXT_STYLE_OUTLINE_SHADOW,
1535 EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW,
1536 EVAS_TEXT_STYLE_FAR_SHADOW,
1537 EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
1538 EVAS_TEXT_STYLE_GLOW
1540 const Evas_Text_Style_Type shadows[] = {
1541 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT,
1542 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM,
1543 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT,
1544 EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT,
1545 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT,
1546 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP,
1547 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT,
1548 EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT
1551 if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC)
1552 < EDJE_TEXT_EFFECT_LAST)
1553 style = styles[ep->part->effect];
1555 [(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4];
1556 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow);
1558 evas_object_text_style_set(ep->object, style);
1559 evas_object_text_text_set(ep->object, text);
1560 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1561 if (chosen_desc->text.max_x)
1564 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1566 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1568 if (chosen_desc->text.max_y)
1571 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1573 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1575 if (chosen_desc->text.min_x)
1578 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1580 if (mw > *minw) *minw = mw;
1582 if (chosen_desc->text.min_y)
1585 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1587 if (mh > *minh) *minh = mh;
1590 if (sfont) free(sfont);
1593 /* FIXME: Do we really need to call it twice if chosen_desc ? */
1595 _edje_text_class_font_get(ed, desc, &size, &sfont);
1597 params->type.text.size = size;
1602 _edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min)
1608 *start += TO_INT(SCALE(align, (*length - min)));
1615 _edje_part_recalc_single_min(Edje_Part_Description_Common *desc,
1616 Edje_Calc_Params *params,
1618 Edje_Internal_Aspect aspect)
1624 w = params->w ? params->w : 99999;
1625 h = params->h ? params->h : 99999;
1629 case EDJE_ASPECT_PREFER_NONE:
1632 case EDJE_ASPECT_PREFER_VERTICAL:
1633 tmp = minh * params->w / h;
1640 case EDJE_ASPECT_PREFER_HORIZONTAL:
1641 tmp = minw * params->h / w;
1648 case EDJE_ASPECT_PREFER_SOURCE:
1649 case EDJE_ASPECT_PREFER_BOTH:
1650 tmp = minh * params->w / h;
1657 tmp = minw * params->h / w;
1667 _edje_part_recalc_single_min_length(desc->align.x, ¶ms->x, ¶ms->w, minw);
1668 _edje_part_recalc_single_min_length(desc->align.y, ¶ms->y, ¶ms->h, minh);
1672 _edje_part_recalc_single_max_length(FLOAT_T align, int *start, int *length, int max)
1678 *start += TO_INT(SCALE(align, (*length - max)));
1685 _edje_part_recalc_single_max(Edje_Part_Description_Common *desc,
1686 Edje_Calc_Params *params,
1688 Edje_Internal_Aspect aspect)
1694 w = params->w ? params->w : 99999;
1695 h = params->h ? params->h : 99999;
1699 case EDJE_ASPECT_PREFER_NONE:
1702 case EDJE_ASPECT_PREFER_VERTICAL:
1703 tmp = maxh * params->w / h;
1710 case EDJE_ASPECT_PREFER_HORIZONTAL:
1711 tmp = maxw * params->h / w;
1718 case EDJE_ASPECT_PREFER_SOURCE:
1719 case EDJE_ASPECT_PREFER_BOTH:
1720 tmp = maxh * params->w / h;
1727 tmp = maxw * params->h / w;
1737 _edje_part_recalc_single_max_length(desc->align.x, ¶ms->x, ¶ms->w, maxw);
1738 _edje_part_recalc_single_max_length(desc->align.y, ¶ms->y, ¶ms->h, maxh);
1742 _edje_part_recalc_single_drag(Edje_Real_Part *ep,
1743 Edje_Real_Part *confine_to,
1744 Edje_Calc_Params *params,
1755 /* complex dragable params */
1756 v = SCALE(ep->drag->size.x, confine_to->w);
1758 if ((minw > 0) && (TO_INT(v) < minw)) params->w = minw;
1759 else if ((maxw >= 0) && (TO_INT(v) > maxw))
1761 else params->w = TO_INT(v);
1763 offset = TO_INT(SCALE(ep->drag->x, (confine_to->w - params->w)))
1765 if (ep->part->dragable.step_x > 0)
1767 params->x = confine_to->x +
1768 ((offset / ep->part->dragable.step_x) * ep->part->dragable.step_x);
1770 else if (ep->part->dragable.count_x > 0)
1772 step = (confine_to->w - params->w) / ep->part->dragable.count_x;
1773 if (step < 1) step = 1;
1774 params->x = confine_to->x +
1775 ((offset / step) * step);
1777 params->req_drag.x = params->x;
1778 params->req_drag.w = params->w;
1780 v = SCALE(ep->drag->size.y, confine_to->h);
1782 if ((minh > 0) && (TO_INT(v) < minh)) params->h = minh;
1783 else if ((maxh >= 0) && (TO_INT(v) > maxh))
1785 else params->h = TO_INT(v);
1787 offset = TO_INT(SCALE(ep->drag->y, (confine_to->h - params->h)))
1789 if (ep->part->dragable.step_y > 0)
1791 params->y = confine_to->y +
1792 ((offset / ep->part->dragable.step_y) * ep->part->dragable.step_y);
1794 else if (ep->part->dragable.count_y > 0)
1796 step = (confine_to->h - params->h) / ep->part->dragable.count_y;
1797 if (step < 1) step = 1;
1798 params->y = confine_to->y +
1799 ((offset / step) * step);
1801 params->req_drag.y = params->y;
1802 params->req_drag.h = params->h;
1804 /* limit to confine */
1805 if (params->x < confine_to->x)
1807 params->x = confine_to->x;
1809 if ((params->x + params->w) > (confine_to->x + confine_to->w))
1811 params->x = confine_to->x + confine_to->w - params->w;
1813 if (params->y < confine_to->y)
1815 params->y = confine_to->y;
1817 if ((params->y + params->h) > (confine_to->y + confine_to->h))
1819 params->y = confine_to->y + confine_to->h - params->h;
1824 /* simple dragable params */
1825 params->x += TO_INT(ep->drag->x) + ep->drag->tmp.x;
1826 params->req_drag.x = params->x;
1827 params->req_drag.w = params->w;
1829 params->y += TO_INT(ep->drag->y) + ep->drag->tmp.y;
1830 params->req_drag.y = params->y;
1831 params->req_drag.h = params->h;
1836 _edje_part_recalc_single_fill(Edje_Real_Part *ep,
1837 Edje_Part_Description_Spec_Fill *fill,
1838 Edje_Calc_Params *params)
1843 params->smooth = fill->smooth;
1845 if (fill->type == EDJE_FILL_TYPE_TILE)
1846 evas_object_image_size_get(ep->object, &fw, NULL);
1850 params->type.common.fill.x = fill->pos_abs_x
1851 + TO_INT(SCALE(fill->pos_rel_x, fw));
1852 params->type.common.fill.w = fill->abs_x
1853 + TO_INT(SCALE(fill->rel_x, fw));
1855 if (fill->type == EDJE_FILL_TYPE_TILE)
1856 evas_object_image_size_get(ep->object, NULL, &fh);
1860 params->type.common.fill.y = fill->pos_abs_y
1861 + TO_INT(SCALE(fill->pos_rel_y, fh));
1862 params->type.common.fill.h = fill->abs_y
1863 + TO_INT(SCALE(fill->rel_y, fh));
1865 params->type.common.fill.angle = fill->angle;
1866 params->type.common.fill.spread = fill->spread;
1870 _edje_part_recalc_single_min_max(FLOAT_T sc,
1872 Edje_Part_Description_Common *desc,
1873 int *minw, int *minh,
1874 int *maxw, int *maxh)
1876 *minw = desc->min.w;
1877 if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw));
1878 if (ep->swallow_params.min.w > desc->min.w)
1879 *minw = ep->swallow_params.min.w;
1881 if (ep->edje->calc_only)
1883 if (desc->minmul.have)
1885 FLOAT_T mmw = desc->minmul.w;
1886 if (mmw != FROM_INT(1)) *minw = TO_INT(SCALE(mmw, *minw));
1890 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */
1891 if ((ep->swallow_params.max.w <= 0) ||
1892 (ep->swallow_params.max.w == EDJE_INF_MAX_W))
1894 *maxw = desc->max.w;
1897 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1898 if (*maxw < 1) *maxw = 1;
1903 if (desc->max.w <= 0)
1904 *maxw = ep->swallow_params.max.w;
1907 *maxw = desc->max.w;
1910 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1911 if (*maxw < 1) *maxw = 1;
1913 if (ep->swallow_params.max.w < *maxw)
1914 *maxw = ep->swallow_params.max.w;
1917 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1918 (desc->minmul.w != FROM_INT(1))) *maxw = *minw;
1921 if (*maxw < *minw) *maxw = *minw;
1924 *minh = desc->min.h;
1925 if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh));
1926 if (ep->swallow_params.min.h > desc->min.h)
1927 *minh = ep->swallow_params.min.h;
1929 if (ep->edje->calc_only)
1931 if (desc->minmul.have)
1933 FLOAT_T mmh = desc->minmul.h;
1934 if (mmh != FROM_INT(1)) *minh = TO_INT(SCALE(mmh, *minh));
1938 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
1939 if ((ep->swallow_params.max.h <= 0) ||
1940 (ep->swallow_params.max.h == EDJE_INF_MAX_H))
1942 *maxh = desc->max.h;
1945 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1946 if (*maxh < 1) *maxh = 1;
1951 if (desc->max.h <= 0)
1952 *maxh = ep->swallow_params.max.h;
1955 *maxh = desc->max.h;
1958 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1959 if (*maxh < 1) *maxh = 1;
1961 if (ep->swallow_params.max.h < *maxh)
1962 *maxh = ep->swallow_params.max.h;
1965 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1966 (desc->minmul.h != FROM_INT(1))) *maxh = *minh;
1969 if (*maxh < *minh) *maxh = *minh;
1974 _edje_part_recalc_single_map(Edje *ed,
1975 Edje_Real_Part *ep __UNUSED__,
1976 Edje_Real_Part *center,
1977 Edje_Real_Part *light,
1978 Edje_Real_Part *persp,
1979 Edje_Part_Description_Common *desc,
1980 Edje_Part_Description_Common *chosen_desc,
1981 Edje_Calc_Params *params)
1983 params->mapped = chosen_desc->map.on;
1984 params->lighted = params->mapped ? !!light : 0;
1985 params->persp_on = params->mapped ? !!persp : 0;
1987 if (!params->mapped) return;
1991 params->map.center.x = ed->x + center->x + (center->w / 2);
1992 params->map.center.y = ed->y + center->y + (center->h / 2);
1996 params->map.center.x = ed->x + params->x + (params->w / 2);
1997 params->map.center.y = ed->y + params->y + (params->h / 2);
1999 params->map.center.z = 0;
2001 params->map.rotation.x = desc->map.rot.x;
2002 params->map.rotation.y = desc->map.rot.y;
2003 params->map.rotation.z = desc->map.rot.z;
2007 Edje_Part_Description_Common *light_desc2;
2010 params->map.light.x = ed->x + light->x + (light->w / 2);
2011 params->map.light.y = ed->y + light->y + (light->h / 2);
2013 pos = light->description_pos;
2014 pos2 = (pos < ZERO) ? ZERO : ((pos > FROM_INT(1)) ? FROM_INT(1) : pos);
2016 light_desc2 = light->param2 ? light->param2->description : NULL;
2018 /* take into account CURRENT state also */
2019 if (pos != ZERO && light_desc2)
2021 params->map.light.z = light->param1.description->persp.zplane +
2022 TO_INT(SCALE(pos, light_desc2->persp.zplane - light->param1.description->persp.zplane));
2023 params->map.light.r = light->param1.description->color.r +
2024 TO_INT(SCALE(pos2, light_desc2->color.r - light->param1.description->color.r));
2025 params->map.light.g = light->param1.description->color.g +
2026 TO_INT(SCALE(pos2, light_desc2->color.g - light->param1.description->color.g));
2027 params->map.light.b = light->param1.description->color.b +
2028 TO_INT(SCALE(pos2, light_desc2->color.b - light->param1.description->color.b));
2029 params->map.light.ar = light->param1.description->color2.r +
2030 TO_INT(SCALE(pos2, light_desc2->color2.r - light->param1.description->color2.r));
2031 params->map.light.ag = light->param1.description->color2.g +
2032 TO_INT(SCALE(pos2, light_desc2->color2.g - light->param1.description->color2.g));
2033 params->map.light.ab = light->param1.description->color2.b +
2034 TO_INT(SCALE(pos2, light_desc2->color2.b - light->param1.description->color2.b));
2038 params->map.light.z = light->param1.description->persp.zplane;
2039 params->map.light.r = light->param1.description->color.r;
2040 params->map.light.g = light->param1.description->color.g;
2041 params->map.light.b = light->param1.description->color.b;
2042 params->map.light.ar = light->param1.description->color2.r;
2043 params->map.light.ag = light->param1.description->color2.g;
2044 params->map.light.ab = light->param1.description->color2.b;
2052 params->map.persp.x = ed->x + persp->x + (persp->w / 2);
2053 params->map.persp.y = ed->y + persp->y + (persp->h / 2);
2055 pos = persp->description_pos;
2057 if (pos != 0 && persp->param2)
2059 params->map.persp.z = persp->param1.description->persp.zplane +
2060 TO_INT(SCALE(pos, persp->param2->description->persp.zplane -
2061 persp->param1.description->persp.zplane));
2062 params->map.persp.focal = persp->param1.description->persp.focal +
2063 TO_INT(SCALE(pos, persp->param2->description->persp.focal -
2064 persp->param1.description->persp.focal));
2068 params->map.persp.z = persp->param1.description->persp.zplane;
2069 params->map.persp.focal = persp->param1.description->persp.focal;
2075 _edje_part_recalc_single(Edje *ed,
2077 Edje_Part_Description_Common *desc,
2078 Edje_Part_Description_Common *chosen_desc,
2079 Edje_Real_Part *center,
2080 Edje_Real_Part *light,
2081 Edje_Real_Part *persp,
2082 Edje_Real_Part *rel1_to_x,
2083 Edje_Real_Part *rel1_to_y,
2084 Edje_Real_Part *rel2_to_x,
2085 Edje_Real_Part *rel2_to_y,
2086 Edje_Real_Part *confine_to,
2087 Edje_Calc_Params *params,
2090 Edje_Color_Class *cc = NULL;
2091 Edje_Internal_Aspect apref;
2092 int minw = 0, minh = 0, maxw = 0, maxh = 0;
2096 if (sc == ZERO) sc = _edje_scale;
2097 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh);
2099 /* relative coords of top left & bottom right */
2100 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params);
2103 apref = _edje_part_recalc_single_aspect(ed, ep, desc, params, &minw, &minh, &maxw, &maxh, pos);
2106 _edje_part_recalc_single_step(desc, params);
2108 /* if we have text that wants to make the min size the text size... */
2109 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2110 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
2111 else if (ep->part->type == EDJE_PART_TYPE_TEXT)
2112 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text *)desc, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
2114 if ((ep->part->type == EDJE_PART_TYPE_TABLE) &&
2115 (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) ||
2116 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v))))
2118 Evas_Coord lminw = 0, lminh = 0;
2120 evas_object_smart_need_recalculate_set(ep->object, 1);
2121 evas_object_smart_calculate(ep->object);
2122 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2123 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h)
2125 if (lminw > minw) minw = lminw;
2127 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)
2129 if (lminh > minh) minh = lminh;
2132 else if ((ep->part->type == EDJE_PART_TYPE_BOX) &&
2133 ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) ||
2134 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)))
2136 Evas_Coord lminw = 0, lminh = 0;
2138 evas_object_smart_need_recalculate_set(ep->object, 1);
2139 evas_object_smart_calculate(ep->object);
2140 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2141 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h)
2143 if (lminw > minw) minw = lminw;
2145 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)
2147 if (lminh > minh) minh = lminh;
2150 else if ((ep->part->type == EDJE_PART_TYPE_IMAGE) &&
2151 (chosen_desc->min.limit || chosen_desc->max.limit))
2155 /* We only need pos to find the right image that would be displayed */
2156 /* Yes, if someone set aspect preference to SOURCE and also max,min
2157 to SOURCE, it will be under efficient, but who cares at the
2159 _edje_real_part_image_set(ed, ep, pos);
2160 evas_object_image_size_get(ep->object, &w, &h);
2162 if (chosen_desc->min.limit)
2164 if (w > minw) minw = w;
2165 if (h > minh) minh = h;
2167 if (chosen_desc->max.limit)
2169 if ((maxw <= 0) || (w < maxw)) maxw = w;
2170 if ((maxh <= 0) || (h < maxh)) maxh = h;
2174 /* remember what our size is BEFORE we go limit it */
2175 params->req.x = params->x;
2176 params->req.y = params->y;
2177 params->req.w = params->w;
2178 params->req.h = params->h;
2180 /* adjust for min size */
2181 _edje_part_recalc_single_min(desc, params, minw, minh, apref);
2183 /* adjust for max size */
2184 _edje_part_recalc_single_max(desc, params, maxw, maxh, apref);
2186 /* take care of dragable part */
2188 _edje_part_recalc_single_drag(ep, confine_to, params, minw, minh, maxw, maxh);
2191 if (ep->part->type == EDJE_PART_TYPE_IMAGE)
2192 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params);
2193 else if (ep->part->type == EDJE_PART_TYPE_PROXY)
2194 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params);
2196 if (ep->part->type != EDJE_PART_TYPE_SPACER)
2199 if ((desc->color_class) && (*desc->color_class))
2200 cc = _edje_color_class_find(ed, desc->color_class);
2204 params->color.r = (((int)cc->r + 1) * desc->color.r) >> 8;
2205 params->color.g = (((int)cc->g + 1) * desc->color.g) >> 8;
2206 params->color.b = (((int)cc->b + 1) * desc->color.b) >> 8;
2207 params->color.a = (((int)cc->a + 1) * desc->color.a) >> 8;
2211 params->color.r = desc->color.r;
2212 params->color.g = desc->color.g;
2213 params->color.b = desc->color.b;
2214 params->color.a = desc->color.a;
2219 params->visible = desc->visible;
2221 switch (ep->part->type)
2223 case EDJE_PART_TYPE_IMAGE:
2225 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image *)desc;
2228 params->type.common.spec.image.l = img_desc->image.border.l;
2229 params->type.common.spec.image.r = img_desc->image.border.r;
2231 params->type.common.spec.image.t = img_desc->image.border.t;
2232 params->type.common.spec.image.b = img_desc->image.border.b;
2234 params->type.common.spec.image.border_scale_by = img_desc->image.border.scale_by;
2238 case EDJE_PART_TYPE_TEXT:
2239 case EDJE_PART_TYPE_TEXTBLOCK:
2241 Edje_Part_Description_Text *text_desc = (Edje_Part_Description_Text *)desc;
2244 params->type.text.align.x = text_desc->text.align.x;
2245 params->type.text.align.y = text_desc->text.align.y;
2246 params->type.text.elipsis = text_desc->text.elipsis;
2251 params->type.text.color2.r = (((int)cc->r2 + 1) * text_desc->common.color2.r) >> 8;
2252 params->type.text.color2.g = (((int)cc->g2 + 1) * text_desc->common.color2.g) >> 8;
2253 params->type.text.color2.b = (((int)cc->b2 + 1) * text_desc->common.color2.b) >> 8;
2254 params->type.text.color2.a = (((int)cc->a2 + 1) * text_desc->common.color2.a) >> 8;
2255 params->type.text.color3.r = (((int)cc->r3 + 1) * text_desc->text.color3.r) >> 8;
2256 params->type.text.color3.g = (((int)cc->g3 + 1) * text_desc->text.color3.g) >> 8;
2257 params->type.text.color3.b = (((int)cc->b3 + 1) * text_desc->text.color3.b) >> 8;
2258 params->type.text.color3.a = (((int)cc->a3 + 1) * text_desc->text.color3.a) >> 8;
2262 params->type.text.color2.r = text_desc->common.color2.r;
2263 params->type.text.color2.g = text_desc->common.color2.g;
2264 params->type.text.color2.b = text_desc->common.color2.b;
2265 params->type.text.color2.a = text_desc->common.color2.a;
2266 params->type.text.color3.r = text_desc->text.color3.r;
2267 params->type.text.color3.g = text_desc->text.color3.g;
2268 params->type.text.color3.b = text_desc->text.color3.b;
2269 params->type.text.color3.a = text_desc->text.color3.a;
2275 case EDJE_PART_TYPE_SPACER:
2276 case EDJE_PART_TYPE_RECTANGLE:
2277 case EDJE_PART_TYPE_BOX:
2278 case EDJE_PART_TYPE_TABLE:
2279 case EDJE_PART_TYPE_SWALLOW:
2280 case EDJE_PART_TYPE_GROUP:
2281 case EDJE_PART_TYPE_PROXY:
2284 case EDJE_PART_TYPE_GRADIENT:
2285 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2292 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
2296 _edje_table_recalc_apply(Edje *ed __UNUSED__,
2298 Edje_Calc_Params *p3 __UNUSED__,
2299 Edje_Part_Description_Table *chosen_desc)
2301 evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous);
2302 evas_object_table_align_set(ep->object, TO_DOUBLE(chosen_desc->table.align.x), TO_DOUBLE(chosen_desc->table.align.y));
2303 evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y);
2304 if (evas_object_smart_need_recalculate_get(ep->object))
2306 evas_object_smart_need_recalculate_set(ep->object, 0);
2307 evas_object_smart_calculate(ep->object);
2312 _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos)
2317 if (pos >= FROM_DOUBLE(0.5))
2318 part_id = ((Edje_Part_Description_Proxy *)ep->param2->description)->proxy.id;
2320 part_id = chosen_desc->proxy.id;
2322 if ((p3->type.common.fill.w == 0) || (p3->type.common.fill.h == 0) ||
2325 evas_object_image_source_set(ep->object, NULL);
2328 pp = ed->table_parts[part_id % ed->table_parts_size];
2330 switch (pp->part->type)
2332 case EDJE_PART_TYPE_IMAGE:
2333 case EDJE_PART_TYPE_TEXT:
2334 case EDJE_PART_TYPE_TEXTBLOCK:
2335 case EDJE_PART_TYPE_RECTANGLE:
2336 case EDJE_PART_TYPE_BOX:
2337 case EDJE_PART_TYPE_TABLE:
2338 case EDJE_PART_TYPE_PROXY:
2339 evas_object_image_source_set(ep->object, pp->object);
2342 case EDJE_PART_TYPE_GRADIENT:
2343 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2346 case EDJE_PART_TYPE_GROUP:
2347 case EDJE_PART_TYPE_SWALLOW:
2348 case EDJE_PART_TYPE_EXTERNAL:
2349 evas_object_image_source_set(ep->object, pp->swallowed_object);
2352 case EDJE_PART_TYPE_SPACER:
2353 /* FIXME: detect that at compile time and prevent it */
2357 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2358 p3->type.common.fill.w, p3->type.common.fill.h);
2359 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2363 _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos)
2368 if (sc == 0.0) sc = _edje_scale;
2369 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2370 p3->type.common.fill.w, p3->type.common.fill.h);
2371 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2372 if (chosen_desc->image.border.scale)
2374 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2376 FLOAT_T sc2 = MUL(sc, p3->type.common.spec.image.border_scale_by);
2377 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc2));
2380 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc));
2384 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2385 evas_object_image_border_scale_set
2386 (ep->object, TO_DOUBLE(p3->type.common.spec.image.border_scale_by));
2388 evas_object_image_border_scale_set(ep->object, 1.0);
2390 evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r,
2391 p3->type.common.spec.image.t, p3->type.common.spec.image.b);
2392 if (chosen_desc->image.border.no_fill == 0)
2393 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_DEFAULT);
2394 else if (chosen_desc->image.border.no_fill == 1)
2395 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE);
2396 else if (chosen_desc->image.border.no_fill == 2)
2397 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID);
2399 _edje_real_part_image_set(ed, ep, pos);
2402 static Edje_Real_Part *
2403 _edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state)
2405 Edje_Real_Part *result = NULL;
2407 if (id >= 0 && id != ep->part->id)
2409 result = ed->table_parts[id % ed->table_parts_size];
2412 if (!result->calculated) _edje_part_recalc(ed, result, flags, NULL);
2413 #ifdef EDJE_CALC_CACHE
2414 if (state) *state = result->state;
2424 _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
2426 #ifdef EDJE_CALC_CACHE
2427 Eina_Bool proxy_invalidate = EINA_FALSE;
2432 Edje_Calc_Params lp1, lp2;
2440 Edje_Real_Part *center[2] = { NULL, NULL };
2441 Edje_Real_Part *light[2] = { NULL, NULL };
2442 Edje_Real_Part *persp[2] = { NULL, NULL };
2443 Edje_Calc_Params *p1, *pf;
2444 Edje_Part_Description_Common *chosen_desc;
2445 Edje_Real_Part *confine_to = NULL;
2446 FLOAT_T pos = ZERO, pos2;
2447 Edje_Calc_Params lp3;
2449 /* GRADIENT ARE GONE, WE MUST IGNORE IT FROM OLD FILE. */
2450 if (ep->part->type == EDJE_PART_TYPE_GRADIENT)
2452 ERR("GRADIENT spotted during recalc ! That should never happen ! Send your edje file to devel ml.");
2456 if ((ep->calculated & FLAG_XY) == FLAG_XY && !state)
2460 if (ep->calculating & flags)
2463 const char *axes = "NONE", *faxes = "NONE";
2465 if ((ep->calculating & FLAG_X) &&
2466 (ep->calculating & FLAG_Y))
2468 else if ((ep->calculating & FLAG_X))
2470 else if ((ep->calculating & FLAG_Y))
2473 if ((flags & FLAG_X) &&
2476 else if ((flags & FLAG_X))
2478 else if ((flags & FLAG_Y))
2480 ERR("Circular dependency when calculating part \"%s\". "
2481 "Already calculating %s [%02x] axes. "
2482 "Need to calculate %s [%02x] axes",
2484 axes, ep->calculating,
2490 if (ep->part->scale &&
2491 ep->part->type == EDJE_PART_TYPE_GROUP &&
2492 ep->swallowed_object)
2494 edje_object_scale_set(ep->swallowed_object, TO_DOUBLE(ed->scale));
2496 if (ep->description_pos > FROM_DOUBLE(0.5) && ep->param2)
2498 edje_object_update_hints_set(ep->swallowed_object, ep->param2->description->min.limit);
2502 edje_object_update_hints_set(ep->swallowed_object, ep->param1.description->min.limit);
2504 if (edje_object_update_hints_get(ep->swallowed_object))
2508 ted = _edje_fetch(ep->swallowed_object);
2509 _edje_recalc_do(ted);
2513 #ifdef EDJE_CALC_CACHE
2514 if (ep->state == ed->state && !state)
2520 ep->calculating |= flags & FLAG_X;
2521 if (ep->param1.rel1_to_x)
2523 _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL);
2524 #ifdef EDJE_CALC_CACHE
2525 state1 = ep->param1.rel1_to_x->state;
2528 if (ep->param1.rel2_to_x)
2530 _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL);
2531 #ifdef EDJE_CALC_CACHE
2532 if (state1 < ep->param1.rel2_to_x->state)
2533 state1 = ep->param1.rel2_to_x->state;
2538 if (ep->param2->rel1_to_x)
2540 _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL);
2541 #ifdef EDJE_CALC_CACHE
2542 state2 = ep->param2->rel1_to_x->state;
2545 if (ep->param2->rel2_to_x)
2547 _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL);
2548 #ifdef EDJE_CALC_CACHE
2549 if (state2 < ep->param2->rel2_to_x->state)
2550 state2 = ep->param2->rel2_to_x->state;
2557 ep->calculating |= flags & FLAG_Y;
2558 if (ep->param1.rel1_to_y)
2560 _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL);
2561 #ifdef EDJE_CALC_CACHE
2562 if (state1 < ep->param1.rel1_to_y->state)
2563 state1 = ep->param1.rel1_to_y->state;
2566 if (ep->param1.rel2_to_y)
2568 _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL);
2569 #ifdef EDJE_CALC_CACHE
2570 if (state1 < ep->param1.rel2_to_y->state)
2571 state1 = ep->param1.rel2_to_y->state;
2576 if (ep->param2->rel1_to_y)
2578 _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL);
2579 #ifdef EDJE_CALC_CACHE
2580 if (state2 < ep->param2->rel1_to_y->state)
2581 state2 = ep->param2->rel1_to_y->state;
2584 if (ep->param2->rel2_to_y)
2586 _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL);
2587 #ifdef EDJE_CALC_CACHE
2588 if (state2 < ep->param2->rel2_to_y->state)
2589 state2 = ep->param2->rel2_to_y->state;
2594 if (ep->drag && ep->drag->confine_to)
2596 confine_to = ep->drag->confine_to;
2597 _edje_part_recalc(ed, confine_to, flags, NULL);
2598 #ifdef EDJE_CALC_CACHE
2599 statec = confine_to->state;
2602 // if (ep->text.source) _edje_part_recalc(ed, ep->text.source, flags);
2603 // if (ep->text.text_source) _edje_part_recalc(ed, ep->text.text_source, flags);
2605 /* actually calculate now */
2606 chosen_desc = ep->chosen_description;
2609 ep->calculating = FLAG_NONE;
2610 ep->calculated |= flags;
2614 pos = ep->description_pos;
2616 if (ep->part->type == EDJE_PART_TYPE_PROXY)
2621 if (pos >= FROM_DOUBLE(0.5))
2622 part_id = ((Edje_Part_Description_Proxy *)ep->param2->description)->proxy.id;
2624 part_id = ((Edje_Part_Description_Proxy *)chosen_desc)->proxy.id;
2626 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL);
2627 #ifdef EDJE_CALC_CACHE
2628 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE;
2632 /* Recalc if needed the map center && light source */
2633 if (ep->param1.description->map.on)
2635 center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1);
2636 light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1);
2638 if (chosen_desc->map.persp_on)
2640 persp[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_persp, &statep1);
2644 if (ep->param2 && ep->param2->description->map.on)
2646 center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2);
2647 light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2);
2649 if (chosen_desc->map.persp_on)
2651 persp[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_persp, &statep2);
2655 #ifndef EDJE_CALC_CACHE
2661 if (ep->param1.description)
2663 #ifdef EDJE_CALC_CACHE
2664 if (ed->all_part_change ||
2666 state1 >= ep->param1.state ||
2667 statec >= ep->param1.state ||
2668 statec1 >= ep->param1.state ||
2669 statel1 >= ep->param1.state ||
2670 statep1 >= ep->param1.state ||
2673 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2676 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
2677 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
2681 #ifdef EDJE_CALC_CACHE
2682 if (flags == FLAG_XY)
2683 ep->param1.state = ed->state;
2689 int beginning_pos, part_type;
2690 Edje_Calc_Params *p2, *p3;
2694 /* FIXME: except for text, we don't need in that case to recalc p1 at all*/
2695 memcpy(p1, ep->current, sizeof (Edje_Calc_Params));
2700 #ifndef EDJE_CALC_CACHE
2703 p2 = &ep->param2->p;
2705 if (ed->all_part_change ||
2707 state2 >= ep->param2->state ||
2708 statec >= ep->param2->state ||
2709 statec2 >= ep->param2->state ||
2710 statel2 >= ep->param2->state ||
2711 statep2 >= ep->param2->state ||
2714 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2717 _edje_part_recalc_single(ed, ep, ep->param2->description,
2719 center[1], light[1], persp[1],
2720 ep->param2->rel1_to_x,
2721 ep->param2->rel1_to_y,
2722 ep->param2->rel2_to_x,
2723 ep->param2->rel2_to_y,
2726 #ifdef EDJE_CALC_CACHE
2727 if (flags == FLAG_XY)
2728 ep->param2->state = ed->state;
2733 if (pos2 < ZERO) pos2 = ZERO;
2734 else if (pos2 > FROM_INT(1))
2736 beginning_pos = (pos < FROM_DOUBLE(0.5));
2737 part_type = ep->part->type;
2739 /* visible is special */
2740 if ((p1->visible) && (!p2->visible))
2741 p3->visible = (pos != FROM_INT(1));
2742 else if ((!p1->visible) && (p2->visible))
2743 p3->visible = (pos != ZERO);
2745 p3->visible = p1->visible;
2747 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth;
2749 /* FIXME: do x and y separately base on flag */
2750 #define FINTP(_x1, _x2, _p) \
2753 : ADD(FROM_INT(_x1), \
2754 SCALE((_p), (_x2) - (_x1))))
2756 #define FFP(_x1, _x2, _p) \
2759 : ADD(_x1, MUL(_p, SUB(_x2, _x1))));
2761 #define INTP(_x1, _x2, _p) TO_INT(FINTP(_x1, _x2, _p))
2763 p3->x = INTP(p1->x, p2->x, pos);
2764 p3->y = INTP(p1->y, p2->y, pos);
2765 p3->w = INTP(p1->w, p2->w, pos);
2766 p3->h = INTP(p1->h, p2->h, pos);
2768 p3->req.x = INTP(p1->req.x, p2->req.x, pos);
2769 p3->req.y = INTP(p1->req.y, p2->req.y, pos);
2770 p3->req.w = INTP(p1->req.w, p2->req.w, pos);
2771 p3->req.h = INTP(p1->req.h, p2->req.h, pos);
2773 if (ep->part->dragable.x)
2775 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos);
2776 p3->req_drag.w = INTP(p1->req_drag.w, p2->req_drag.w, pos);
2778 if (ep->part->dragable.y)
2780 p3->req_drag.y = INTP(p1->req_drag.y, p2->req_drag.y, pos);
2781 p3->req_drag.h = INTP(p1->req_drag.h, p2->req_drag.h, pos);
2784 p3->color.r = INTP(p1->color.r, p2->color.r, pos2);
2785 p3->color.g = INTP(p1->color.g, p2->color.g, pos2);
2786 p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
2787 p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
2791 case EDJE_PART_TYPE_IMAGE:
2792 p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos);
2793 p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos);
2794 p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos);
2795 p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos);
2796 p3->type.common.spec.image.border_scale_by = INTP(p1->type.common.spec.image.border_scale_by, p2->type.common.spec.image.border_scale_by, pos);
2798 case EDJE_PART_TYPE_PROXY:
2799 p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos);
2800 p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos);
2801 p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos);
2802 p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos);
2805 case EDJE_PART_TYPE_TEXT:
2806 p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos);
2808 case EDJE_PART_TYPE_TEXTBLOCK:
2809 p3->type.text.color2.r = INTP(p1->type.text.color2.r, p2->type.text.color2.r, pos2);
2810 p3->type.text.color2.g = INTP(p1->type.text.color2.g, p2->type.text.color2.g, pos2);
2811 p3->type.text.color2.b = INTP(p1->type.text.color2.b, p2->type.text.color2.b, pos2);
2812 p3->type.text.color2.a = INTP(p1->type.text.color2.a, p2->type.text.color2.a, pos2);
2814 p3->type.text.color3.r = INTP(p1->type.text.color3.r, p2->type.text.color3.r, pos2);
2815 p3->type.text.color3.g = INTP(p1->type.text.color3.g, p2->type.text.color3.g, pos2);
2816 p3->type.text.color3.b = INTP(p1->type.text.color3.b, p2->type.text.color3.b, pos2);
2817 p3->type.text.color3.a = INTP(p1->type.text.color3.a, p2->type.text.color3.a, pos2);
2819 p3->type.text.align.x = FFP(p1->type.text.align.x, p2->type.text.align.x, pos);
2820 p3->type.text.align.y = FFP(p1->type.text.align.y, p2->type.text.align.y, pos);
2821 p3->type.text.elipsis = TO_DOUBLE(FINTP(p1->type.text.elipsis, p2->type.text.elipsis, pos2));
2825 p3->mapped = p1->mapped;
2826 p3->persp_on = p3->mapped ? p1->persp_on | p2->persp_on : 0;
2827 p3->lighted = p3->mapped ? p1->lighted | p2->lighted : 0;
2830 p3->map.center.x = INTP(p1->map.center.x, p2->map.center.x, pos);
2831 p3->map.center.y = INTP(p1->map.center.y, p2->map.center.y, pos);
2832 p3->map.center.z = INTP(p1->map.center.z, p2->map.center.z, pos);
2833 p3->map.rotation.x = FFP(p1->map.rotation.x, p2->map.rotation.x, pos);
2834 p3->map.rotation.y = FFP(p1->map.rotation.y, p2->map.rotation.y, pos);
2835 p3->map.rotation.z = FFP(p1->map.rotation.z, p2->map.rotation.z, pos);
2837 #define MIX(P1, P2, P3, pos, info) \
2838 P3->info = P1->info + TO_INT(SCALE(pos, P2->info - P1->info));
2840 if (p1->lighted && p2->lighted)
2842 MIX(p1, p2, p3, pos, map.light.x);
2843 MIX(p1, p2, p3, pos, map.light.y);
2844 MIX(p1, p2, p3, pos, map.light.z);
2845 MIX(p1, p2, p3, pos, map.light.r);
2846 MIX(p1, p2, p3, pos, map.light.g);
2847 MIX(p1, p2, p3, pos, map.light.b);
2848 MIX(p1, p2, p3, pos, map.light.ar);
2849 MIX(p1, p2, p3, pos, map.light.ag);
2850 MIX(p1, p2, p3, pos, map.light.ab);
2852 else if (p1->lighted)
2854 memcpy(&p3->map.light, &p1->map.light, sizeof (p1->map.light));
2856 else if (p2->lighted)
2858 memcpy(&p3->map.light, &p2->map.light, sizeof (p2->map.light));
2861 if (p1->persp_on && p2->persp_on)
2863 MIX(p1, p2, p3, pos, map.persp.x);
2864 MIX(p1, p2, p3, pos, map.persp.y);
2865 MIX(p1, p2, p3, pos, map.persp.z);
2866 MIX(p1, p2, p3, pos, map.persp.focal);
2868 else if (p1->persp_on)
2870 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.persp));
2872 else if (p2->persp_on)
2874 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.persp));
2885 if (!pf->persp_on && chosen_desc->map.persp_on)
2889 pf->map.persp.x = ed->persp->px;
2890 pf->map.persp.y = ed->persp->py;
2891 pf->map.persp.z = ed->persp->z0;
2892 pf->map.persp.focal = ed->persp->foc;
2896 const Edje_Perspective *ps;
2898 // fixme: a tad inefficient as this is a has lookup
2899 ps = edje_object_perspective_get(ed->obj);
2901 ps = edje_evas_global_perspective_get(evas_object_evas_get(ed->obj));
2904 pf->map.persp.x = ps->px;
2905 pf->map.persp.y = ps->py;
2906 pf->map.persp.z = ps->z0;
2907 pf->map.persp.focal = ps->foc;
2911 pf->map.persp.x = ed->x + (ed->w / 2);
2912 pf->map.persp.y = ed->y + (ed->h / 2);
2913 pf->map.persp.z = 0;
2914 pf->map.persp.focal = 1000;
2921 memcpy(state, pf, sizeof (Edje_Calc_Params));
2926 if (ep->drag && ep->drag->need_reset)
2932 _edje_part_dragable_calc(ed, ep, &dx, &dy);
2935 ep->drag->tmp.x = 0;
2936 ep->drag->tmp.y = 0;
2937 ep->drag->need_reset = 0;
2943 /* Common move, resize and color_set for all part. */
2944 switch (ep->part->type)
2946 case EDJE_PART_TYPE_IMAGE:
2948 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image *)chosen_desc;
2950 evas_object_image_scale_hint_set(ep->object,
2951 img_desc->image.scale_hint);
2954 case EDJE_PART_TYPE_PROXY:
2955 case EDJE_PART_TYPE_RECTANGLE:
2956 case EDJE_PART_TYPE_TEXTBLOCK:
2957 case EDJE_PART_TYPE_BOX:
2958 case EDJE_PART_TYPE_TABLE:
2959 evas_object_color_set(ep->object,
2960 (pf->color.r * pf->color.a) / 255,
2961 (pf->color.g * pf->color.a) / 255,
2962 (pf->color.b * pf->color.a) / 255,
2966 evas_object_hide(ep->object);
2969 evas_object_show(ep->object);
2971 /* move and resize are needed for all previous object => no break here. */
2972 case EDJE_PART_TYPE_SWALLOW:
2973 case EDJE_PART_TYPE_GROUP:
2974 case EDJE_PART_TYPE_EXTERNAL:
2975 /* visibility and color have no meaning on SWALLOW and GROUP part. */
2976 evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y);
2977 evas_object_resize(ep->object, pf->w, pf->h);
2978 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
2979 _edje_entry_real_part_configure(ep);
2982 case EDJE_PART_TYPE_TEXT:
2983 /* This is correctly handle in _edje_text_recalc_apply at the moment. */
2986 case EDJE_PART_TYPE_GRADIENT:
2987 /* FIXME: definitivly remove this code when we switch to new format. */
2991 case EDJE_PART_TYPE_SPACER:
2992 /* We really should do nothing on SPACER part */
2996 /* Some object need special recalc. */
2997 switch (ep->part->type)
2999 case EDJE_PART_TYPE_TEXT:
3000 _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text *)chosen_desc);
3003 case EDJE_PART_TYPE_PROXY:
3004 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy *)chosen_desc, pos);
3007 case EDJE_PART_TYPE_IMAGE:
3008 _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image *)chosen_desc, pos);
3011 case EDJE_PART_TYPE_BOX:
3012 _edje_box_recalc_apply(ed, ep, pf, (Edje_Part_Description_Box *)chosen_desc);
3015 case EDJE_PART_TYPE_TABLE:
3016 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table *)chosen_desc);
3019 case EDJE_PART_TYPE_TEXTBLOCK:
3020 _edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text *)chosen_desc);
3023 case EDJE_PART_TYPE_EXTERNAL:
3024 case EDJE_PART_TYPE_RECTANGLE:
3025 case EDJE_PART_TYPE_SWALLOW:
3026 case EDJE_PART_TYPE_GROUP:
3027 /* Nothing special to do for this type of object. */
3030 case EDJE_PART_TYPE_GRADIENT:
3031 /* FIXME: definitivly remove this code when we switch to new format. */
3035 case EDJE_PART_TYPE_SPACER:
3036 /* We really should do nothing on SPACER part */
3040 if (ep->swallowed_object)
3042 //// the below really is wrong - swallow color shouldn't affect swallowed object
3043 //// color - the edje color as a WHOLE should though - and that should be
3044 //// done via the clipper anyway. this created bugs when objects had their
3045 //// colro set and were swallowed - then had their color changed.
3046 // evas_object_color_set(ep->swallowed_object,
3047 // (pf->color.r * pf->color.a) / 255,
3048 // (pf->color.g * pf->color.a) / 255,
3049 // (pf->color.b * pf->color.a) / 255,
3053 evas_object_move(ep->swallowed_object, ed->x + pf->x, ed->y + pf->y);
3054 evas_object_resize(ep->swallowed_object, pf->w, pf->h);
3055 evas_object_show(ep->swallowed_object);
3057 else evas_object_hide(ep->swallowed_object);
3058 mo = ep->swallowed_object;
3060 else mo = ep->object;
3061 if (chosen_desc->map.on && ep->part->type != EDJE_PART_TYPE_SPACER)
3063 static Evas_Map *map = NULL;
3065 ed->have_mapped_part = 1;
3066 // create map and populate with part geometry
3067 if (!map) map = evas_map_new(4);
3068 evas_map_util_points_populate_from_object(map, ep->object);
3069 if (ep->part->type == EDJE_PART_TYPE_IMAGE ||
3070 ((ep->part->type == EDJE_PART_TYPE_SWALLOW) &&
3071 (!strcmp(evas_object_type_get(mo), "image") &&
3072 (!evas_object_image_source_get(mo))))
3077 evas_object_image_size_get(mo, &iw, &ih);
3078 evas_map_point_image_uv_set(map, 0, 0.0, 0.0);
3079 evas_map_point_image_uv_set(map, 1, iw, 0.0);
3080 evas_map_point_image_uv_set(map, 2, iw, ih);
3081 evas_map_point_image_uv_set(map, 3, 0.0, ih);
3083 evas_map_util_3d_rotate(map,
3084 TO_DOUBLE(pf->map.rotation.x), TO_DOUBLE(pf->map.rotation.y), TO_DOUBLE(pf->map.rotation.z),
3085 pf->map.center.x, pf->map.center.y, pf->map.center.z);
3087 // calculate light color & position etc. if there is one
3090 evas_map_util_3d_lighting(map,
3091 pf->map.light.x, pf->map.light.y, pf->map.light.z,
3092 pf->map.light.r, pf->map.light.g, pf->map.light.b,
3093 pf->map.light.ar, pf->map.light.ag, pf->map.light.ab);
3096 // calculate perspective point
3097 if (chosen_desc->map.persp_on)
3099 evas_map_util_3d_perspective(map,
3100 pf->map.persp.x, pf->map.persp.y, pf->map.persp.z,
3101 pf->map.persp.focal);
3104 // handle backface culling (object is facing away from view
3105 if (chosen_desc->map.backcull)
3109 if (evas_map_util_clockwise_get(map))
3110 evas_object_show(mo);
3111 else evas_object_hide(mo);
3116 if (chosen_desc->map.smooth) evas_map_smooth_set(map, 1);
3117 else evas_map_smooth_set(map, 0);
3119 if (chosen_desc->map.alpha) evas_map_alpha_set(map, 1);
3120 else evas_map_alpha_set(map, 0);
3122 evas_object_map_set(mo, map);
3123 evas_object_map_enable_set(mo, 1);
3127 evas_object_map_enable_set(mo, 0);
3128 evas_object_map_set(mo, NULL);
3137 ep->calculated |= flags;
3138 ep->calculating = FLAG_NONE;
3140 #ifdef EDJE_CALC_CACHE
3141 if (ep->calculated == FLAG_XY)
3143 ep->state = ed->state;