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),
35 case EDJE_TWEEN_MODE_ACCELERATE:
36 /* npos = 1.0 - sin((PI / 2.0) + (pos * PI / 2.0)); */
37 npos = SUB(FROM_INT(1),
42 case EDJE_TWEEN_MODE_DECELERATE:
43 /* npos = sin(pos * PI / 2.0); */
44 npos = SIN(MUL(fp_pos,
47 case EDJE_TWEEN_MODE_LINEAR:
55 switch (mode & EDJE_TWEEN_MODE_MASK)
57 case EDJE_TWEEN_MODE_SINUSOIDAL:
58 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
59 ECORE_POS_MAP_SINUSOIDAL,
62 case EDJE_TWEEN_MODE_ACCELERATE:
63 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
64 ECORE_POS_MAP_ACCELERATE,
67 case EDJE_TWEEN_MODE_DECELERATE:
68 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
69 ECORE_POS_MAP_DECELERATE,
72 case EDJE_TWEEN_MODE_LINEAR:
74 /* npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
79 case EDJE_TWEEN_MODE_ACCELERATE_FACTOR:
80 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
81 ECORE_POS_MAP_ACCELERATE_FACTOR,
84 case EDJE_TWEEN_MODE_DECELERATE_FACTOR:
85 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
86 ECORE_POS_MAP_DECELERATE_FACTOR,
89 case EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR:
90 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
91 ECORE_POS_MAP_SINUSOIDAL_FACTOR,
94 case EDJE_TWEEN_MODE_DIVISOR_INTERP:
95 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
96 ECORE_POS_MAP_DIVISOR_INTERP,
97 TO_DOUBLE(v1), TO_DOUBLE(v2)));
99 case EDJE_TWEEN_MODE_BOUNCE:
100 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
101 ECORE_POS_MAP_BOUNCE,
102 TO_DOUBLE(v1), TO_DOUBLE(v2)));
104 case EDJE_TWEEN_MODE_SPRING:
105 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
106 ECORE_POS_MAP_SPRING,
107 TO_DOUBLE(v1), TO_DOUBLE(v2)));
114 if (npos == ep->description_pos) return;
116 ep->description_pos = npos;
120 #ifdef EDJE_CALC_CACHE
127 * Returns part description
131 * Converts part description to RTL-desc.
133 * @param desc Pointer to desc buffer.
137 _edje_part_make_rtl(Edje_Part_Description_Common *desc)
145 /* This makes alignment right-oriented */
146 desc->align.x = 1.0 - desc->align.x;
148 /* same as above for relative components */
149 t = desc->rel1.relative_x;
150 desc->rel1.relative_x = 1.0 - desc->rel2.relative_x;
151 desc->rel2.relative_x = 1.0 - t;
153 /* +1 and +1 are because how edje works with right
154 * side borders - nothing is printed beyond that limit
156 * rel2 is now to the left of rel1, and Edje assumes
157 * the opposite so we switch corners on x-axis to define
158 * offset from right to left */
159 i = desc->rel1.offset_x;
160 desc->rel1.offset_x = -(desc->rel2.offset_x + 1);
161 desc->rel2.offset_x = -(i + 1);
164 desc->rel1.id_x = desc->rel2.id_x;
169 * Returns part description
173 * Returns part description according to object orientation.
174 * When object is in RTL-orientation (RTL flag is set)
175 * this returns the RTL-desc of it.
176 * RTL-desc would be allocated if was not created by a previous call.
177 * The dst pointer is updated in case of an allocation.
179 * @param ed Edje object.
180 * @param src The Left To Right (LTR), original desc.
181 * @param dst Pointer to Right To Left (RTL) desc-list.
182 * @param type name of dec type. Example: "default".
184 * @return Edje part description.
187 static Edje_Part_Description_Common *
188 _edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type)
190 Edje_Part_Description_Common *desc_rtl = NULL;
191 Edje_Part_Collection_Directory_Entry *ce;
194 /* RTL flag is not set, return original description */
195 if(!edje_object_mirrored_get(ed->obj))
199 return *dst; /* Was allocated before and we should use it */
201 #define EDIT_ALLOC_POOL_RTL(Short, Type, Name) \
202 case EDJE_PART_TYPE_##Short: \
204 Edje_Part_Description_##Type *Name; \
205 Name = eina_mempool_malloc(ce->mp_rtl.Short, \
206 sizeof (Edje_Part_Description_##Type)); \
207 memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \
208 desc_rtl = &Name->common; \
209 memsize = sizeof(Edje_Part_Description_##Type); \
213 ce = eina_hash_find(ed->file->collection, ed->group);
217 case EDJE_PART_TYPE_RECTANGLE:
218 desc_rtl = eina_mempool_malloc(ce->mp_rtl.RECTANGLE,
219 sizeof (Edje_Part_Description_Common));
220 ce->count.RECTANGLE++;
221 memsize = sizeof(Edje_Part_Description_Common);
223 case EDJE_PART_TYPE_SWALLOW:
224 desc_rtl = eina_mempool_malloc(ce->mp_rtl.SWALLOW,
225 sizeof (Edje_Part_Description_Common));
227 memsize = sizeof(Edje_Part_Description_Common);
229 case EDJE_PART_TYPE_GROUP:
230 desc_rtl = eina_mempool_malloc(ce->mp_rtl.GROUP,
231 sizeof (Edje_Part_Description_Common));
233 memsize = sizeof(Edje_Part_Description_Common);
235 case EDJE_PART_TYPE_SPACER:
236 desc_rtl = eina_mempool_malloc(ce->mp_rtl.SPACER,
237 sizeof (Edje_Part_Description_Common));
239 memsize = sizeof(Edje_Part_Description_Common);
241 EDIT_ALLOC_POOL_RTL(TEXT, Text, text);
242 EDIT_ALLOC_POOL_RTL(TEXTBLOCK, Text, text);
243 EDIT_ALLOC_POOL_RTL(IMAGE, Image, image);
244 EDIT_ALLOC_POOL_RTL(PROXY, Proxy, proxy);
245 EDIT_ALLOC_POOL_RTL(BOX, Box, box);
246 EDIT_ALLOC_POOL_RTL(TABLE, Table, table);
247 EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params);
251 memcpy(desc_rtl, src, memsize);
253 _edje_part_make_rtl(desc_rtl);
259 Edje_Part_Description_Common *
260 _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
263 Edje_Part *ep = rp->part;
264 Edje_Part_Description_Common *ret = NULL;
265 Edje_Part_Description_Common *d;
267 double min_dst = 99999.0;
270 /* RTL flag is set, return RTL description */
271 if(edje_object_mirrored_get(ed->obj))
272 if(!ep->other.desc_rtl)
273 ep->other.desc_rtl = (Edje_Part_Description_Common **)
274 calloc(ep->other.desc_count,
275 sizeof (Edje_Part_Description_Common *));
277 if (!strcmp(name, "default") && val == 0.0)
278 return _edje_get_description_by_orientation(ed,
279 ep->default_desc, &ep->default_desc_rtl, ep->type);
281 if (!strcmp(name, "custom"))
283 _edje_get_description_by_orientation(ed, rp->custom->description,
284 &rp->custom->description_rtl, ep->type) : NULL;
286 if (!strcmp(name, "default"))
288 ret = _edje_get_description_by_orientation(ed, ep->default_desc,
289 &ep->default_desc_rtl,
292 min_dst = ABS(ep->default_desc->state.value - val);
295 for (i = 0; i < ep->other.desc_count; ++i)
297 d = ep->other.desc[i];
299 if (d->state.name && (d->state.name == name ||
300 !strcmp(d->state.name, name)))
304 dst = ABS(d->state.value - val);
307 ret = _edje_get_description_by_orientation(ed, d,
308 &ep->other.desc_rtl[i], ep->type);
318 _edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid)
320 Edje_Image_Directory_Set_Entry *entry;
321 Edje_Image_Directory_Set *set = NULL;
330 if (st && !st->image.set)
333 if (imid && !imid->set)
341 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
345 if ((*eps)->id == id)
349 if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w)
350 if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h)
351 return (*eps)->entry->id;
355 set = ed->file->image_dir->sets + id;
357 EINA_LIST_FOREACH(set->entries, l, entry)
359 if (entry->size.min.w <= w && w <= entry->size.max.w)
360 if (entry->size.min.h <= h && h <= entry->size.max.h)
365 *eps = calloc(1, sizeof (Edje_Real_Part_Set));
369 (*eps)->entry = entry;
382 _edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T pos)
385 int image_count, image_num;
387 image_id = _edje_image_find(ep->object, ed,
389 (Edje_Part_Description_Image*) ep->param1.description,
393 Edje_Image_Directory_Entry *ie;
395 if (!ed->file->image_dir) ie = NULL;
396 else ie = ed->file->image_dir->entries + (-image_id) - 1;
398 (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
401 evas_object_image_file_set(ep->object, ie->entry, NULL);
408 image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count;
409 image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
411 if (image_num > (image_count - 1))
412 image_num = image_count - 1;
415 image_id = _edje_image_find(ep->object, ed,
417 (Edje_Part_Description_Image*) ep->param1.description,
423 if (image_num == (image_count - 1))
425 image_id = _edje_image_find(ep->object, ed,
427 (Edje_Part_Description_Image*) ep->param2->description,
432 Edje_Part_Image_Id *imid;
434 imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1];
435 image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
440 ERR("¨Part \"%s\" description, "
441 "\"%s\" %3.3f with image %i index has a missing image id in a set of %i !!!",
443 ep->param1.description->state.name,
444 ep->param1.description->state.value,
452 /* Replace snprint("edje/images/%i") == memcpy + itoa */
453 #define IMAGES "edje/images/"
454 memcpy(buf, IMAGES, strlen(IMAGES));
455 eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */
457 evas_object_image_file_set(ep->object, ed->file->path, buf);
458 if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
460 ERR("Error loading image collection \"%s\" from "
461 "file \"%s\". Missing EET Evas loader module?",
462 buf, ed->file->path);
463 switch (evas_object_image_load_error_get(ep->object))
465 case EVAS_LOAD_ERROR_GENERIC:
466 ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
468 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
469 ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
471 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
472 ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
474 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
475 ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
477 case EVAS_LOAD_ERROR_CORRUPT_FILE:
478 ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
480 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
481 ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
484 ERR("Error type: ???");
493 _edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state)
495 state->rel1_to_x = state->rel1_to_y = NULL;
496 state->rel2_to_x = state->rel2_to_y = NULL;
498 if (state->description)
500 if (state->description->rel1.id_x >= 0)
501 state->rel1_to_x = ed->table_parts[state->description->rel1.id_x % ed->table_parts_size];
502 if (state->description->rel1.id_y >= 0)
503 state->rel1_to_y = ed->table_parts[state->description->rel1.id_y % ed->table_parts_size];
504 if (state->description->rel2.id_x >= 0)
505 state->rel2_to_x = ed->table_parts[state->description->rel2.id_x % ed->table_parts_size];
506 if (state->description->rel2.id_y >= 0)
507 state->rel2_to_y = ed->table_parts[state->description->rel2.id_y % ed->table_parts_size];
509 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
511 Edje_Part_Description_External *external;
513 external = (Edje_Part_Description_External*) state->description;
515 if (state->external_params)
516 _edje_external_parsed_params_free(ep->swallowed_object, state->external_params);
517 state->external_params = _edje_external_params_parse(ep->swallowed_object, external->external_params);
523 _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2)
525 Edje_Part_Description_Common *epd1;
526 Edje_Part_Description_Common *epd2 = NULL;
527 Edje_Part_Description_Common *chosen_desc;
529 Edje_Part_Description_Image *epdi;
531 if (!d1) d1 = "default";
533 epd1 = _edje_part_description_find(ed, ep, d1, v1);
535 epd1 = ep->part->default_desc; /* never NULL */
538 epd2 = _edje_part_description_find(ed, ep, d2, v2);
540 epdi = (Edje_Part_Description_Image*) epd2;
542 /* There is an animation if both description are different or if description is an image with tweens */
543 if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count)))
547 ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp,
548 sizeof(Edje_Real_Part_State));
549 memset(ep->param2, 0, sizeof(Edje_Real_Part_State));
551 else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
552 _edje_external_parsed_params_free(ep->swallowed_object,
553 ep->param2->external_params);
554 ep->param2->external_params = NULL;
559 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
560 _edje_external_parsed_params_free(ep->swallowed_object,
561 ep->param2->external_params);
563 free(ep->param2->set);
564 eina_mempool_free(_edje_real_part_state_mp, ep->param2);
568 chosen_desc = ep->chosen_description;
569 ep->param1.description = epd1;
570 ep->chosen_description = epd1;
572 _edje_real_part_rel_to_apply(ed, ep, &ep->param1);
576 ep->param2->description = epd2;
578 _edje_real_part_rel_to_apply(ed, ep, ep->param2);
580 if (ep->description_pos > FROM_DOUBLE(0.0))
581 ep->chosen_description = epd2;
584 if (chosen_desc != ep->chosen_description &&
585 ep->part->type == EDJE_PART_TYPE_EXTERNAL)
586 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
588 ed->recalc_hints = 1;
591 #ifdef EDJE_CALC_CACHE
597 _edje_recalc(Edje *ed)
599 if ((ed->freeze > 0) || (_edje_freeze_val > 0))
604 if (_edje_freeze_val > 0)
606 if (!ed->freeze_calc)
608 _edje_freeze_calc_count++;
609 _edje_freeze_calc_list = eina_list_append(_edje_freeze_calc_list, ed);
616 // XXX: dont need this with current smart calc infra. remove me later
617 // if (ed->postponed) return;
618 // if (!ed->calc_only)
619 evas_object_smart_changed(ed->obj);
620 // XXX: dont need this with current smart calc infra. remove me later
621 // ed->postponed = 1;
625 _edje_recalc_do(Edje *ed)
630 // XXX: dont need this with current smart calc infra. remove me later
631 // ed->postponed = 0;
632 need_calc = evas_object_smart_need_recalculate_get(ed->obj);
633 evas_object_smart_need_recalculate_set(ed->obj, 0);
634 if (!ed->dirty) return;
635 ed->have_mapped_part = 0;
638 for (i = 0; i < ed->table_parts_size; i++)
642 ep = ed->table_parts[i];
643 ep->calculated = FLAG_NONE;
644 ep->calculating = FLAG_NONE;
646 for (i = 0; i < ed->table_parts_size; i++)
650 ep = ed->table_parts[i];
651 if (ep->calculated != FLAG_XY)
652 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
654 if (!ed->calc_only) ed->recalc = 0;
655 #ifdef EDJE_CALC_CACHE
656 ed->all_part_change = 0;
657 ed->text_part_change = 0;
662 evas_object_smart_callback_call(ed->obj, "recalc", NULL);
665 evas_object_smart_need_recalculate_set(ed->obj, need_calc);
668 if (ed->update_hints && ed->recalc_hints && !ed->calc_only)
672 ed->recalc_hints = 0;
674 edje_object_size_min_calc(ed->obj, &w, &h);
675 evas_object_size_hint_min_set(ed->obj, w, h);
678 if (!ed->collection) return ;
680 for (i = 0; i < ed->collection->limits.parts_count; i++)
686 part = ed->collection->limits.parts[i].part;
687 name = ed->collection->parts[part]->name;
688 limit = ed->table_parts[part]->chosen_description->limit;
692 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
693 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
696 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
699 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
705 if ((limit & 1) == 1)
707 if (ed->table_parts[part]->w > 0 &&
708 (ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_OVER))
710 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_OVER;
711 _edje_emit(ed, "limit,width,over", name);
713 else if (ed->table_parts[part]->w < 0 &&
714 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_BELOW)
716 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_BELOW;
717 _edje_emit(ed, "limit,width,below", name);
719 else if (ed->table_parts[part]->w == 0 &&
720 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_ZERO)
722 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_ZERO;
723 _edje_emit(ed, "limit,width,zero", name);
726 if ((limit & 2) == 2)
728 if (ed->table_parts[part]->h > 0 &&
729 (ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_OVER))
731 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_OVER;
732 _edje_emit(ed, "limit,height,over", name);
734 else if (ed->table_parts[part]->h < 0 &&
735 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_BELOW)
737 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_BELOW;
738 _edje_emit(ed, "limit,height,below", name);
740 else if (ed->table_parts[part]->h == 0 &&
741 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_ZERO)
743 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_ZERO;
744 _edje_emit(ed, "limit,height,zero", name);
751 _edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep)
753 _edje_part_recalc(ed, ep, FLAG_XY, NULL);
757 _edje_part_dragable_calc(Edje *ed __UNUSED__, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y)
761 if (ep->drag->confine_to)
763 FLOAT_T dx, dy, dw, dh;
766 if ((ep->part->dragable.x != 0) &&
767 (ep->part->dragable.y != 0 )) ret = 3;
768 else if (ep->part->dragable.x != 0) ret = 1;
769 else if (ep->part->dragable.y != 0) ret = 2;
771 dx = FROM_INT(ep->x - ep->drag->confine_to->x);
772 dw = FROM_INT(ep->drag->confine_to->w - ep->w);
773 if (dw != ZERO) dx = DIV(dx, dw);
776 dy = FROM_INT(ep->y - ep->drag->confine_to->y);
777 dh = FROM_INT(ep->drag->confine_to->h - ep->h);
778 if (dh != ZERO) dy = DIV(dy, dh);
788 if (x) *x = ADD(FROM_INT(ep->drag->tmp.x), ep->drag->x);
789 if (y) *y = ADD(FROM_INT(ep->drag->tmp.y), ep->drag->y);
799 _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
801 /* check whether this part is dragable at all */
802 if (!ep->drag) return ;
804 /* instead of checking for equality, we really should check that
805 * the difference is greater than foo, but I have no idea what
806 * value we would set foo to, because it would depend on the
807 * size of the dragable...
809 if (ep->drag->x != x || ep->drag->tmp.x)
813 ep->drag->need_reset = 0;
818 if (ep->drag->y != y || ep->drag->tmp.y)
822 ep->drag->need_reset = 0;
827 #ifdef EDJE_CALC_CACHE
830 _edje_recalc(ed); /* won't do anything if dirty flag isn't set */
834 _edje_part_recalc_single_rel(Edje *ed,
835 Edje_Real_Part *ep __UNUSED__,
836 Edje_Part_Description_Common *desc,
837 Edje_Real_Part *rel1_to_x,
838 Edje_Real_Part *rel1_to_y,
839 Edje_Real_Part *rel2_to_x,
840 Edje_Real_Part *rel2_to_y,
841 Edje_Calc_Params *params)
847 x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x),
848 SCALE(desc->rel1.relative_x, rel1_to_x->w));
850 x = ADD(FROM_INT(desc->rel1.offset_x),
851 SCALE(desc->rel1.relative_x, ed->w));
852 params->x = TO_INT(x);
855 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x),
856 SCALE(desc->rel2.relative_x, rel2_to_x->w)),
860 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x),
861 SCALE(desc->rel2.relative_x, ed->w)),
864 params->w = TO_INT(w);
867 y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y),
868 SCALE(desc->rel1.relative_y, rel1_to_y->h));
870 y = ADD(FROM_INT(desc->rel1.offset_y),
871 SCALE(desc->rel1.relative_y, ed->h));
872 params->y = TO_INT(y);
875 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y),
876 SCALE(desc->rel2.relative_y, rel2_to_y->h)),
880 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y),
881 SCALE(desc->rel2.relative_y, ed->h)),
884 params->h = TO_INT(h);
887 static Edje_Internal_Aspect
888 _edje_part_recalc_single_aspect(Edje *ed,
890 Edje_Part_Description_Common *desc,
891 Edje_Calc_Params *params,
892 int *minw, int *minh,
893 int *maxw, int *maxh,
896 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE;
897 FLOAT_T aspect, amax, amin;
898 FLOAT_T new_w = ZERO, new_h = ZERO, want_x, want_y, want_w, want_h;
900 if (params->h <= ZERO) aspect = FROM_INT(999999);
901 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h));
902 amax = desc->aspect.max;
903 amin = desc->aspect.min;
904 if (desc->aspect.prefer == EDJE_ASPECT_PREFER_SOURCE &&
905 ep->part->type == EDJE_PART_TYPE_IMAGE)
909 /* We only need pose to find the right image that would be displayed,
910 and the right aspect ratio in that case */
911 _edje_real_part_image_set(ed, ep, pos);
912 evas_object_image_size_get(ep->object, &w, &h);
913 amin = amax = DIV(FROM_INT(w), FROM_INT(h));
915 if ((ep->swallow_params.aspect.w > 0) &&
916 (ep->swallow_params.aspect.h > 0))
918 DIV(FROM_INT(ep->swallow_params.aspect.w),
919 FROM_INT(ep->swallow_params.aspect.h));
920 want_x = FROM_INT(params->x);
921 want_w = new_w = FROM_INT(params->w);
923 want_y = FROM_INT(params->y);
924 want_h = new_h = FROM_INT(params->h);
926 if ((amin > ZERO) && (amax > ZERO))
928 apref = desc->aspect.prefer;
929 if (ep->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE)
931 switch (ep->swallow_params.aspect.mode)
933 case EDJE_ASPECT_CONTROL_NEITHER:
934 apref = EDJE_ASPECT_PREFER_NONE;
936 case EDJE_ASPECT_CONTROL_HORIZONTAL:
937 apref = EDJE_ASPECT_PREFER_HORIZONTAL;
939 case EDJE_ASPECT_CONTROL_VERTICAL:
940 apref = EDJE_ASPECT_PREFER_VERTICAL;
942 case EDJE_ASPECT_CONTROL_BOTH:
943 apref = EDJE_ASPECT_PREFER_BOTH;
951 case EDJE_ASPECT_PREFER_NONE:
952 /* keep both dimensions in check */
953 /* adjust for min aspect (width / height) */
954 if ((amin > ZERO) && (aspect < amin))
956 new_h = DIV(FROM_INT(params->w), amin);
957 new_w = SCALE(amin, params->h);
959 /* adjust for max aspect (width / height) */
960 if ((amax > ZERO) && (aspect > amax))
962 new_h = DIV(FROM_INT(params->w), amax);
963 new_w = SCALE(amax, params->h);
965 if ((amax > ZERO) && (new_w < FROM_INT(params->w)))
967 new_w = FROM_INT(params->w);
968 new_h = DIV(FROM_INT(params->w), amax);
970 if ((amax > ZERO) && (new_h < FROM_INT(params->h)))
972 new_w = SCALE(amax, params->h);
973 new_h = FROM_INT(params->h);
976 /* prefer vertical size as determiner */
977 case EDJE_ASPECT_PREFER_VERTICAL:
978 /* keep both dimensions in check */
979 /* adjust for max aspect (width / height) */
980 if ((amax > ZERO) && (aspect > amax))
981 new_w = SCALE(amax, params->h);
982 /* adjust for min aspect (width / height) */
983 if ((amin > ZERO) && (aspect < amin))
984 new_w = SCALE(amin, params->h);
986 /* prefer horizontal size as determiner */
987 case EDJE_ASPECT_PREFER_HORIZONTAL:
988 /* keep both dimensions in check */
989 /* adjust for max aspect (width / height) */
990 if ((amax > ZERO) && (aspect > amax))
991 new_h = DIV(FROM_INT(params->w), amax);
992 /* adjust for min aspect (width / height) */
993 if ((amin > ZERO) && (aspect < amin))
994 new_h = DIV(FROM_INT(params->w), amin);
996 case EDJE_ASPECT_PREFER_SOURCE:
997 case EDJE_ASPECT_PREFER_BOTH:
998 /* keep both dimensions in check */
999 /* adjust for max aspect (width / height) */
1000 if ((amax > ZERO) && (aspect > amax))
1002 new_w = SCALE(amax, params->h);
1003 new_h = DIV(FROM_INT(params->w), amax);
1005 /* adjust for min aspect (width / height) */
1006 if ((amin > ZERO) && (aspect < amin))
1008 new_w = SCALE(amin, params->h);
1009 new_h = DIV(FROM_INT(params->w), amin);
1016 if (!((amin > ZERO) && (amax > ZERO) &&
1017 (apref == EDJE_ASPECT_PREFER_NONE)))
1019 if ((*maxw >= 0) && (new_w > FROM_INT(*maxw)))
1020 new_w = FROM_INT(*maxw);
1021 if (new_w < FROM_INT(*minw))
1022 new_w = FROM_INT(*minw);
1024 if ((FROM_INT(*maxh) >= 0) && (new_h > FROM_INT(*maxh)))
1025 new_h = FROM_INT(*maxh);
1026 if (new_h < FROM_INT(*minh))
1027 new_h = FROM_INT(*minh);
1030 /* do real adjustment */
1031 if (apref == EDJE_ASPECT_PREFER_BOTH)
1033 if (amin == ZERO) amin = amax;
1036 /* fix h and vary w */
1037 if (new_w > FROM_INT(params->w))
1039 // params->w = new_w;
1040 // EXCEEDS BOUNDS in W
1041 new_h = DIV(FROM_INT(params->w), amin);
1042 new_w = FROM_INT(params->w);
1043 if (new_h > FROM_INT(params->h))
1045 new_h = FROM_INT(params->h);
1046 new_w = SCALE(amin, params->h);
1049 /* fix w and vary h */
1052 // params->h = new_h;
1053 // EXCEEDS BOUNDS in H
1054 new_h = FROM_INT(params->h);
1055 new_w = SCALE(amin, params->h);
1056 if (new_w > FROM_INT(params->w))
1058 new_h = DIV(FROM_INT(params->w), amin);
1059 new_w = FROM_INT(params->w);
1062 params->w = TO_INT(new_w);
1063 params->h = TO_INT(new_h);
1067 if (apref != EDJE_ASPECT_PREFER_BOTH)
1069 if ((amin > 0.0) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE))
1071 params->w = TO_INT(new_w);
1072 params->h = TO_INT(new_h);
1074 else if ((FROM_INT(params->h) - new_h) > (FROM_INT(params->w) - new_w))
1076 if (params->h < TO_INT(new_h))
1077 params->h = TO_INT(new_h);
1078 else if (params->h > TO_INT(new_h))
1079 params->h = TO_INT(new_h);
1080 if (apref == EDJE_ASPECT_PREFER_VERTICAL)
1081 params->w = TO_INT(new_w);
1085 if (params->w < TO_INT(new_w))
1086 params->w = TO_INT(new_w);
1087 else if (params->w > TO_INT(new_w))
1088 params->w = TO_INT(new_w);
1089 if (apref == EDJE_ASPECT_PREFER_HORIZONTAL)
1090 params->h = TO_INT(new_h);
1093 params->x = TO_INT(ADD(want_x,
1094 MUL(SUB(want_w, FROM_INT(params->w)),
1096 params->y = TO_INT(ADD(want_y,
1097 MUL(SUB(want_h, FROM_INT(params->h)),
1103 _edje_part_recalc_single_step(Edje_Part_Description_Common *desc,
1104 Edje_Calc_Params *params)
1106 if (desc->step.x > 0)
1111 steps = params->w / desc->step.x;
1112 new_w = desc->step.x * steps;
1113 if (params->w > new_w)
1115 params->x += TO_INT(SCALE(desc->align.x, (params->w - new_w)));
1120 if (desc->step.y > 0)
1125 steps = params->h / desc->step.y;
1126 new_h = desc->step.y * steps;
1127 if (params->h > new_h)
1129 params->y += TO_INT(SCALE(desc->align.y, (params->h - new_h)));
1136 _edje_part_recalc_single_textblock(FLOAT_T sc,
1139 Edje_Part_Description_Text *chosen_desc,
1140 Edje_Calc_Params *params,
1141 int *minw, int *minh,
1142 int *maxw, int *maxh)
1146 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
1147 const char *text = "";
1148 const char *style = "";
1149 Edje_Style *stl = NULL;
1153 if (chosen_desc->text.id_source >= 0)
1155 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1157 tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.style);
1158 if (tmp) style = tmp;
1162 ep->text.source = NULL;
1164 tmp = edje_string_get(&chosen_desc->text.style);
1165 if (tmp) style = tmp;
1168 if (chosen_desc->text.id_text_source >= 0)
1170 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1171 text = edje_string_get(&((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text);
1173 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1177 ep->text.text_source = NULL;
1178 text = edje_string_get(&chosen_desc->text.text);
1179 if (ep->text.text) text = ep->text.text;
1182 EINA_LIST_FOREACH(ed->file->styles, l, stl)
1184 if ((stl->name) && (!strcmp(stl->name, style))) break;
1188 if (ep->part->scale)
1189 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1195 if (evas_object_textblock_style_get(ep->object) != stl->style)
1196 evas_object_textblock_style_set(ep->object, stl->style);
1197 // FIXME: need to account for editing
1198 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1200 // do nothing - should be done elsewhere
1204 ptxt = evas_object_textblock_text_markup_get(ep->object);
1205 if (((!ptxt) && (text)) ||
1206 ((ptxt) && (text) && (strcmp(ptxt, text))) ||
1207 ((ptxt) && (!text)))
1208 evas_object_textblock_text_markup_set(ep->object, text);
1210 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
1215 if (!chosen_desc->text.min_x)
1217 evas_object_resize(ep->object, params->w, params->h);
1218 evas_object_textblock_size_formatted_get(ep->object, &tw,
1222 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1223 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1224 &ins_r, &ins_t, &ins_b);
1225 mw = ins_l + tw + ins_r;
1226 mh = ins_t + th + ins_b;
1227 if (chosen_desc->text.min_x)
1229 if (mw > *minw) *minw = mw;
1231 if (chosen_desc->text.min_y)
1233 if (mh > *minh) *minh = mh;
1237 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1242 if (!chosen_desc->text.max_x)
1244 evas_object_resize(ep->object, params->w, params->h);
1245 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
1248 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1249 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
1251 mw = ins_l + tw + ins_r;
1252 mh = ins_t + th + ins_b;
1253 if (chosen_desc->text.max_x)
1255 if (mw > *maxw) *maxw = mw;
1256 if (*maxw < *minw) *maxw = *minw;
1258 if (chosen_desc->text.max_y)
1260 if (mh > *maxw) *maxh = mh;
1261 if (*maxh < *minh) *maxh = *minh;
1264 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
1268 if (ep->part->scale) s = TO_DOUBLE(sc);
1269 evas_object_scale_set(ep->object, s);
1270 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
1271 if (chosen_desc->text.fit_x)
1273 if ((tw > 0) && (tw > params->w))
1275 s = (s * params->w) / (double)tw;
1276 evas_object_scale_set(ep->object, s);
1277 evas_object_textblock_size_formatted_get(ep->object,
1281 if (chosen_desc->text.fit_y)
1283 if ((th > 0) && (th > params->h))
1285 s = (s * params->h) / (double)th;
1286 evas_object_scale_set(ep->object, s);
1287 evas_object_textblock_size_formatted_get(ep->object,
1292 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
1297 _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
1298 Edje_Calc_Params *params,
1299 Edje_Part_Description_Text *chosen_desc)
1301 /* FIXME: this is just an hack. */
1304 if (sc == ZERO) sc = _edje_scale;
1305 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
1307 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
1308 NULL, NULL, NULL, NULL);
1313 _edje_part_recalc_single_text(FLOAT_T sc __UNUSED__,
1316 Edje_Part_Description_Text *desc,
1317 Edje_Part_Description_Text *chosen_desc,
1318 Edje_Calc_Params *params,
1319 int *minw, int *minh,
1320 int *maxw, int *maxh)
1321 #define RECALC_SINGLE_TEXT_USING_APPLY 1
1322 #if RECALC_SINGLE_TEXT_USING_APPLY
1326 * Original _edje_part_recalc_single_text() was not working as
1327 * expected since it was not doing size fit, range, ellipsis and so
1330 * The purpose of this function compared with
1331 * _edje_text_recalc_apply() is to be faster, not calling Evas update
1332 * functions. However for text this is quite difficult given that to
1333 * fit we need to set the font, size, style, etc. If it was done
1334 * correctly, we'd save some calls to move and some color sets,
1335 * however those shouldn't matter much in the overall picture.
1337 * I've changed this to force applying the value, it should be more
1338 * correct and not so slow. The previous code is kept below for
1339 * reference but should be removed before next release!
1341 * -- Gustavo Barbieri at 20-Aug-2011
1344 int tw, th, mw, mh, l, r, t, b, size;
1347 _edje_text_class_font_get(ed, desc, &size, &sfont);
1349 params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */
1351 _edje_text_recalc_apply(ed, ep, params, chosen_desc);
1353 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1355 if ((!chosen_desc) ||
1356 ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) &&
1357 (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y)))
1360 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1361 evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
1366 if (chosen_desc->text.max_x)
1368 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1370 if (chosen_desc->text.max_y)
1372 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1374 if (chosen_desc->text.min_x)
1376 if (mw > *minw) *minw = mw;
1378 if (chosen_desc->text.min_y)
1380 if (mh > *minh) *minh = mh;
1393 int inlined_font = 0;
1395 /* Update a object_text part */
1397 if (chosen_desc->text.id_source >= 0)
1398 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1400 ep->text.source = NULL;
1402 if (chosen_desc->text.id_text_source >= 0)
1403 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1405 ep->text.text_source = NULL;
1407 if (ep->text.text_source)
1408 text = edje_string_get(&(((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text));
1410 text = edje_string_get(&chosen_desc->text.text);
1412 if (ep->text.source)
1413 font = _edje_text_class_font_get(ed, ((Edje_Part_Description_Text*)ep->text.source->chosen_description), &size, &sfont);
1415 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
1417 if (!font) font = "";
1419 if (ep->text.text_source)
1421 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1425 if (ep->text.text) text = ep->text.text;
1428 if (ep->text.source)
1430 if (ep->text.source->text.font) font = ep->text.source->text.font;
1431 if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
1435 if (ep->text.font) font = ep->text.font;
1436 if (ep->text.size > 0) size = ep->text.size;
1438 if (!text) text = "";
1440 /* check if the font is embedded in the .eet */
1441 if (ed->file->fonts)
1443 Edje_Font_Directory_Entry *fnt;
1445 fnt = eina_hash_find(ed->file->fonts, font);
1451 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
1452 font2 = alloca(len);
1453 sprintf(font2, "edje/fonts/%s", font);
1458 if (ep->part->scale)
1459 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1462 evas_object_text_font_source_set(ep->object, ed->path);
1464 else evas_object_text_font_source_set(ep->object, NULL);
1466 if ((_edje_fontset_append) && (font))
1470 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
1473 strcpy(font2, font);
1475 strcat(font2, _edje_fontset_append);
1476 evas_object_text_font_set(ep->object, font2, size);
1481 evas_object_text_font_set(ep->object, font, size);
1482 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) ||
1483 (chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1486 Evas_Text_Style_Type
1487 style = EVAS_TEXT_STYLE_PLAIN,
1488 shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT;
1489 const Evas_Text_Style_Type styles[] = {
1490 EVAS_TEXT_STYLE_PLAIN,
1491 EVAS_TEXT_STYLE_PLAIN,
1492 EVAS_TEXT_STYLE_OUTLINE,
1493 EVAS_TEXT_STYLE_SOFT_OUTLINE,
1494 EVAS_TEXT_STYLE_SHADOW,
1495 EVAS_TEXT_STYLE_SOFT_SHADOW,
1496 EVAS_TEXT_STYLE_OUTLINE_SHADOW,
1497 EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW,
1498 EVAS_TEXT_STYLE_FAR_SHADOW,
1499 EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
1500 EVAS_TEXT_STYLE_GLOW
1502 const Evas_Text_Style_Type shadows[] = {
1503 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT,
1504 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM,
1505 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT,
1506 EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT,
1507 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT,
1508 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP,
1509 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT,
1510 EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT
1513 if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC)
1514 < EDJE_TEXT_EFFECT_LAST)
1515 style = styles[ep->part->effect];
1517 [(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4];
1518 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow);
1520 evas_object_text_style_set(ep->object, style);
1521 evas_object_text_text_set(ep->object, text);
1522 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1523 if (chosen_desc->text.max_x)
1526 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1528 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1530 if (chosen_desc->text.max_y)
1533 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1535 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1537 if (chosen_desc->text.min_x)
1540 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1542 if (mw > *minw) *minw = mw;
1544 if (chosen_desc->text.min_y)
1547 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1549 if (mh > *minh) *minh = mh;
1552 if (sfont) free(sfont);
1555 /* FIXME: Do we really need to call it twice if chosen_desc ? */
1557 _edje_text_class_font_get(ed, desc, &size, &sfont);
1559 params->type.text.size = size;
1564 _edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min)
1570 *start += TO_INT(SCALE(align, (*length - min)));
1577 _edje_part_recalc_single_min(Edje_Part_Description_Common *desc,
1578 Edje_Calc_Params *params,
1580 Edje_Internal_Aspect aspect)
1586 w = params->w ? params->w : 99999;
1587 h = params->h ? params->h : 99999;
1591 case EDJE_ASPECT_PREFER_NONE:
1593 case EDJE_ASPECT_PREFER_VERTICAL:
1594 tmp = minh * params->w / h;
1600 case EDJE_ASPECT_PREFER_HORIZONTAL:
1601 tmp = minw * params->h / w;
1607 case EDJE_ASPECT_PREFER_SOURCE:
1608 case EDJE_ASPECT_PREFER_BOTH:
1609 tmp = minh * params->w / h;
1616 tmp = minw * params->h / w;
1626 _edje_part_recalc_single_min_length(desc->align.x, ¶ms->x, ¶ms->w, minw);
1627 _edje_part_recalc_single_min_length(desc->align.y, ¶ms->y, ¶ms->h, minh);
1631 _edje_part_recalc_single_max_length(FLOAT_T align, int *start, int *length, int max)
1637 *start += TO_INT(SCALE(align, (*length - max)));
1644 _edje_part_recalc_single_max(Edje_Part_Description_Common *desc,
1645 Edje_Calc_Params *params,
1647 Edje_Internal_Aspect aspect)
1653 w = params->w ? params->w : 99999;
1654 h = params->h ? params->h : 99999;
1658 case EDJE_ASPECT_PREFER_NONE:
1660 case EDJE_ASPECT_PREFER_VERTICAL:
1661 tmp = maxh * params->w / h;
1667 case EDJE_ASPECT_PREFER_HORIZONTAL:
1668 tmp = maxw * params->h / w;
1674 case EDJE_ASPECT_PREFER_SOURCE:
1675 case EDJE_ASPECT_PREFER_BOTH:
1676 tmp = maxh * params->w / h;
1683 tmp = maxw * params->h / w;
1693 _edje_part_recalc_single_max_length(desc->align.x, ¶ms->x, ¶ms->w, maxw);
1694 _edje_part_recalc_single_max_length(desc->align.y, ¶ms->y, ¶ms->h, maxh);
1698 _edje_part_recalc_single_drag(Edje_Real_Part *ep,
1699 Edje_Real_Part *confine_to,
1700 Edje_Calc_Params *params,
1711 /* complex dragable params */
1712 v = SCALE(ep->drag->size.x, confine_to->w);
1714 if ((minw > 0) && (TO_INT(v) < minw)) params->w = minw;
1715 else if ((maxw >= 0) && (TO_INT(v) > maxw)) params->w = maxw;
1716 else params->w = TO_INT(v);
1718 offset = TO_INT(SCALE(ep->drag->x, (confine_to->w - params->w)))
1720 if (ep->part->dragable.step_x > 0)
1722 params->x = confine_to->x +
1723 ((offset / ep->part->dragable.step_x) * ep->part->dragable.step_x);
1725 else if (ep->part->dragable.count_x > 0)
1727 step = (confine_to->w - params->w) / ep->part->dragable.count_x;
1728 if (step < 1) step = 1;
1729 params->x = confine_to->x +
1730 ((offset / step) * step);
1732 params->req_drag.x = params->x;
1733 params->req_drag.w = params->w;
1735 v = SCALE(ep->drag->size.y, confine_to->h);
1737 if ((minh > 0) && (TO_INT(v) < minh)) params->h = minh;
1738 else if ((maxh >= 0) && (TO_INT(v) > maxh)) params->h = maxh;
1739 else params->h = TO_INT(v);
1741 offset = TO_INT(SCALE(ep->drag->y, (confine_to->h - params->h)))
1743 if (ep->part->dragable.step_y > 0)
1745 params->y = confine_to->y +
1746 ((offset / ep->part->dragable.step_y) * ep->part->dragable.step_y);
1748 else if (ep->part->dragable.count_y > 0)
1750 step = (confine_to->h - params->h) / ep->part->dragable.count_y;
1751 if (step < 1) step = 1;
1752 params->y = confine_to->y +
1753 ((offset / step) * step);
1755 params->req_drag.y = params->y;
1756 params->req_drag.h = params->h;
1758 /* limit to confine */
1759 if (params->x < confine_to->x)
1761 params->x = confine_to->x;
1763 if ((params->x + params->w) > (confine_to->x + confine_to->w))
1765 params->x = confine_to->x + confine_to->w - params->w;
1767 if (params->y < confine_to->y)
1769 params->y = confine_to->y;
1771 if ((params->y + params->h) > (confine_to->y + confine_to->h))
1773 params->y = confine_to->y + confine_to->h - params->h;
1778 /* simple dragable params */
1779 params->x += TO_INT(ep->drag->x) + ep->drag->tmp.x;
1780 params->req_drag.x = params->x;
1781 params->req_drag.w = params->w;
1783 params->y += TO_INT(ep->drag->y) + ep->drag->tmp.y;
1784 params->req_drag.y = params->y;
1785 params->req_drag.h = params->h;
1790 _edje_part_recalc_single_fill(Edje_Real_Part *ep,
1791 Edje_Part_Description_Spec_Fill *fill,
1792 Edje_Calc_Params *params)
1797 params->smooth = fill->smooth;
1799 if (fill->type == EDJE_FILL_TYPE_TILE)
1800 evas_object_image_size_get(ep->object, &fw, NULL);
1804 params->type.common.fill.x = fill->pos_abs_x
1805 + TO_INT(SCALE(fill->pos_rel_x, fw));
1806 params->type.common.fill.w = fill->abs_x
1807 + TO_INT(SCALE(fill->rel_x, fw));
1809 if (fill->type == EDJE_FILL_TYPE_TILE)
1810 evas_object_image_size_get(ep->object, NULL, &fh);
1814 params->type.common.fill.y = fill->pos_abs_y
1815 + TO_INT(SCALE(fill->pos_rel_y, fh));
1816 params->type.common.fill.h = fill->abs_y
1817 + TO_INT(SCALE(fill->rel_y, fh));
1819 params->type.common.fill.angle = fill->angle;
1820 params->type.common.fill.spread = fill->spread;
1824 _edje_part_recalc_single_min_max(FLOAT_T sc,
1826 Edje_Part_Description_Common *desc,
1827 int *minw, int *minh,
1828 int *maxw, int *maxh)
1830 *minw = desc->min.w;
1831 if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw));
1832 if (ep->swallow_params.min.w > desc->min.w)
1833 *minw = ep->swallow_params.min.w;
1835 if (ep->edje->calc_only)
1837 if (desc->minmul.have)
1839 FLOAT_T mmw = desc->minmul.w;
1840 if (mmw != FROM_INT(1)) *minw = TO_INT(SCALE(mmw, *minw));
1844 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */
1845 if ((ep->swallow_params.max.w <= 0) ||
1846 (ep->swallow_params.max.w == EDJE_INF_MAX_W))
1848 *maxw = desc->max.w;
1851 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1852 if (*maxw < 1) *maxw = 1;
1857 if (desc->max.w <= 0)
1858 *maxw = ep->swallow_params.max.w;
1861 *maxw = desc->max.w;
1864 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1865 if (*maxw < 1) *maxw = 1;
1867 if (ep->swallow_params.max.w < *maxw)
1868 *maxw = ep->swallow_params.max.w;
1871 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1872 (desc->minmul.w != FROM_INT(1))) *maxw = *minw;
1875 if (*maxw < *minw) *maxw = *minw;
1878 *minh = desc->min.h;
1879 if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh));
1880 if (ep->swallow_params.min.h > desc->min.h)
1881 *minh = ep->swallow_params.min.h;
1883 if (ep->edje->calc_only)
1885 if (desc->minmul.have)
1887 FLOAT_T mmh = desc->minmul.h;
1888 if (mmh != FROM_INT(1)) *minh = TO_INT(SCALE(mmh, *minh));
1892 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
1893 if ((ep->swallow_params.max.h <= 0) ||
1894 (ep->swallow_params.max.h == EDJE_INF_MAX_H))
1896 *maxh = desc->max.h;
1899 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1900 if (*maxh < 1) *maxh = 1;
1905 if (desc->max.h <= 0)
1906 *maxh = ep->swallow_params.max.h;
1909 *maxh = desc->max.h;
1912 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1913 if (*maxh < 1) *maxh = 1;
1915 if (ep->swallow_params.max.h < *maxh)
1916 *maxh = ep->swallow_params.max.h;
1919 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1920 (desc->minmul.h != FROM_INT(1))) *maxh = *minh;
1923 if (*maxh < *minh) *maxh = *minh;
1928 _edje_part_recalc_single_map(Edje *ed,
1929 Edje_Real_Part *ep __UNUSED__,
1930 Edje_Real_Part *center,
1931 Edje_Real_Part *light,
1932 Edje_Real_Part *persp,
1933 Edje_Part_Description_Common *desc,
1934 Edje_Part_Description_Common *chosen_desc,
1935 Edje_Calc_Params *params)
1937 params->mapped = chosen_desc->map.on;
1938 params->lighted = params->mapped ? !!light : 0;
1939 params->persp_on = params->mapped ? !!persp : 0;
1941 if (!params->mapped) return ;
1945 params->map.center.x = ed->x + center->x + (center->w / 2);
1946 params->map.center.y = ed->y + center->y + (center->h / 2);
1950 params->map.center.x = ed->x + params->x + (params->w / 2);
1951 params->map.center.y = ed->y + params->y + (params->h / 2);
1953 params->map.center.z = 0;
1955 params->map.rotation.x = desc->map.rot.x;
1956 params->map.rotation.y = desc->map.rot.y;
1957 params->map.rotation.z = desc->map.rot.z;
1961 Edje_Part_Description_Common *light_desc2;
1964 params->map.light.x = ed->x + light->x + (light->w / 2);
1965 params->map.light.y = ed->y + light->y + (light->h / 2);
1967 pos = light->description_pos;
1968 pos2 = (pos < ZERO) ? ZERO : ((pos > FROM_INT(1)) ? FROM_INT(1) : pos);
1970 light_desc2 = light->param2 ? light->param2->description : NULL;
1972 /* take into account CURRENT state also */
1973 if (pos != ZERO && light_desc2)
1975 params->map.light.z = light->param1.description->persp.zplane +
1976 TO_INT(SCALE(pos, light_desc2->persp.zplane - light->param1.description->persp.zplane));
1977 params->map.light.r = light->param1.description->color.r +
1978 TO_INT(SCALE(pos2, light_desc2->color.r - light->param1.description->color.r));
1979 params->map.light.g = light->param1.description->color.g +
1980 TO_INT(SCALE(pos2, light_desc2->color.g - light->param1.description->color.g));
1981 params->map.light.b = light->param1.description->color.b +
1982 TO_INT(SCALE(pos2, light_desc2->color.b - light->param1.description->color.b));
1983 params->map.light.ar = light->param1.description->color2.r +
1984 TO_INT(SCALE(pos2, light_desc2->color2.r - light->param1.description->color2.r));
1985 params->map.light.ag = light->param1.description->color2.g +
1986 TO_INT(SCALE(pos2, light_desc2->color2.g - light->param1.description->color2.g));
1987 params->map.light.ab = light->param1.description->color2.b +
1988 TO_INT(SCALE(pos2, light_desc2->color2.b - light->param1.description->color2.b));
1992 params->map.light.z = light->param1.description->persp.zplane;
1993 params->map.light.r = light->param1.description->color.r;
1994 params->map.light.g = light->param1.description->color.g;
1995 params->map.light.b = light->param1.description->color.b;
1996 params->map.light.ar = light->param1.description->color2.r;
1997 params->map.light.ag = light->param1.description->color2.g;
1998 params->map.light.ab = light->param1.description->color2.b;
2006 params->map.persp.x = ed->x + persp->x + (persp->w / 2);
2007 params->map.persp.y = ed->y + persp->y + (persp->h / 2);
2009 pos = persp->description_pos;
2011 if (pos != 0 && persp->param2)
2013 params->map.persp.z = persp->param1.description->persp.zplane +
2014 TO_INT(SCALE(pos, persp->param2->description->persp.zplane -
2015 persp->param1.description->persp.zplane));
2016 params->map.persp.focal = persp->param1.description->persp.focal +
2017 TO_INT(SCALE(pos, persp->param2->description->persp.focal -
2018 persp->param1.description->persp.focal));
2022 params->map.persp.z = persp->param1.description->persp.zplane;
2023 params->map.persp.focal = persp->param1.description->persp.focal;
2029 _edje_part_recalc_single(Edje *ed,
2031 Edje_Part_Description_Common *desc,
2032 Edje_Part_Description_Common *chosen_desc,
2033 Edje_Real_Part *center,
2034 Edje_Real_Part *light,
2035 Edje_Real_Part *persp,
2036 Edje_Real_Part *rel1_to_x,
2037 Edje_Real_Part *rel1_to_y,
2038 Edje_Real_Part *rel2_to_x,
2039 Edje_Real_Part *rel2_to_y,
2040 Edje_Real_Part *confine_to,
2041 Edje_Calc_Params *params,
2044 Edje_Color_Class *cc = NULL;
2045 Edje_Internal_Aspect apref;
2046 int minw = 0, minh = 0, maxw = 0, maxh = 0;
2050 if (sc == ZERO) sc = _edje_scale;
2051 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh);
2053 /* relative coords of top left & bottom right */
2054 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params);
2057 apref = _edje_part_recalc_single_aspect(ed, ep, desc, params, &minw, &minh, &maxw, &maxh, pos);
2060 _edje_part_recalc_single_step(desc, params);
2062 /* if we have text that wants to make the min size the text size... */
2063 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2064 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
2065 else if (ep->part->type == EDJE_PART_TYPE_TEXT)
2066 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text*) desc, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
2068 if ((ep->part->type == EDJE_PART_TYPE_TABLE) &&
2069 (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) ||
2070 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v))))
2072 Evas_Coord lminw = 0, lminh = 0;
2074 evas_object_smart_need_recalculate_set(ep->object, 1);
2075 evas_object_smart_calculate(ep->object);
2076 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2077 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h)
2079 if (lminw > minw) minw = lminw;
2081 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)
2083 if (lminh > minh) minh = lminh;
2086 else if ((ep->part->type == EDJE_PART_TYPE_BOX) &&
2087 ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) ||
2088 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)))
2090 Evas_Coord lminw = 0, lminh = 0;
2092 evas_object_smart_need_recalculate_set(ep->object, 1);
2093 evas_object_smart_calculate(ep->object);
2094 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2095 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h)
2097 if (lminw > minw) minw = lminw;
2099 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)
2101 if (lminh > minh) minh = lminh;
2104 else if ((ep->part->type == EDJE_PART_TYPE_IMAGE) &&
2105 (chosen_desc->min.limit || chosen_desc->max.limit))
2109 /* We only need pos to find the right image that would be displayed */
2110 /* Yes, if someone set aspect preference to SOURCE and also max,min
2111 to SOURCE, it will be under efficient, but who cares at the
2113 _edje_real_part_image_set(ed, ep, pos);
2114 evas_object_image_size_get(ep->object, &w, &h);
2116 if (chosen_desc->min.limit)
2118 if (w > minw) minw = w;
2119 if (h > minh) minh = h;
2121 if (chosen_desc->max.limit)
2123 if ((maxw <= 0) || (w < maxw)) maxw = w;
2124 if ((maxh <= 0) || (h < maxh)) maxh = h;
2128 /* remember what our size is BEFORE we go limit it */
2129 params->req.x = params->x;
2130 params->req.y = params->y;
2131 params->req.w = params->w;
2132 params->req.h = params->h;
2134 /* adjust for min size */
2135 _edje_part_recalc_single_min(desc, params, minw, minh, apref);
2137 /* adjust for max size */
2138 _edje_part_recalc_single_max(desc, params, maxw, maxh, apref);
2140 /* take care of dragable part */
2142 _edje_part_recalc_single_drag(ep, confine_to, params, minw, minh, maxw, maxh);
2145 if (ep->part->type == EDJE_PART_TYPE_IMAGE)
2146 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params);
2147 else if (ep->part->type == EDJE_PART_TYPE_PROXY)
2148 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params);
2150 if (ep->part->type != EDJE_PART_TYPE_SPACER)
2153 if ((desc->color_class) && (*desc->color_class))
2154 cc = _edje_color_class_find(ed, desc->color_class);
2158 params->color.r = (((int)cc->r + 1) * desc->color.r) >> 8;
2159 params->color.g = (((int)cc->g + 1) * desc->color.g) >> 8;
2160 params->color.b = (((int)cc->b + 1) * desc->color.b) >> 8;
2161 params->color.a = (((int)cc->a + 1) * desc->color.a) >> 8;
2165 params->color.r = desc->color.r;
2166 params->color.g = desc->color.g;
2167 params->color.b = desc->color.b;
2168 params->color.a = desc->color.a;
2173 params->visible = desc->visible;
2175 switch (ep->part->type)
2177 case EDJE_PART_TYPE_IMAGE:
2179 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) desc;
2182 params->type.common.spec.image.l = img_desc->image.border.l;
2183 params->type.common.spec.image.r = img_desc->image.border.r;
2185 params->type.common.spec.image.t = img_desc->image.border.t;
2186 params->type.common.spec.image.b = img_desc->image.border.b;
2188 params->type.common.spec.image.border_scale_by = img_desc->image.border.scale_by;
2191 case EDJE_PART_TYPE_TEXT:
2192 case EDJE_PART_TYPE_TEXTBLOCK:
2194 Edje_Part_Description_Text *text_desc = (Edje_Part_Description_Text*) desc;
2197 params->type.text.align.x = text_desc->text.align.x;
2198 params->type.text.align.y = text_desc->text.align.y;
2199 params->type.text.elipsis = text_desc->text.elipsis;
2204 params->type.text.color2.r = (((int)cc->r2 + 1) * text_desc->common.color2.r) >> 8;
2205 params->type.text.color2.g = (((int)cc->g2 + 1) * text_desc->common.color2.g) >> 8;
2206 params->type.text.color2.b = (((int)cc->b2 + 1) * text_desc->common.color2.b) >> 8;
2207 params->type.text.color2.a = (((int)cc->a2 + 1) * text_desc->common.color2.a) >> 8;
2208 params->type.text.color3.r = (((int)cc->r3 + 1) * text_desc->text.color3.r) >> 8;
2209 params->type.text.color3.g = (((int)cc->g3 + 1) * text_desc->text.color3.g) >> 8;
2210 params->type.text.color3.b = (((int)cc->b3 + 1) * text_desc->text.color3.b) >> 8;
2211 params->type.text.color3.a = (((int)cc->a3 + 1) * text_desc->text.color3.a) >> 8;
2215 params->type.text.color2.r = text_desc->common.color2.r;
2216 params->type.text.color2.g = text_desc->common.color2.g;
2217 params->type.text.color2.b = text_desc->common.color2.b;
2218 params->type.text.color2.a = text_desc->common.color2.a;
2219 params->type.text.color3.r = text_desc->text.color3.r;
2220 params->type.text.color3.g = text_desc->text.color3.g;
2221 params->type.text.color3.b = text_desc->text.color3.b;
2222 params->type.text.color3.a = text_desc->text.color3.a;
2227 case EDJE_PART_TYPE_SPACER:
2228 case EDJE_PART_TYPE_RECTANGLE:
2229 case EDJE_PART_TYPE_BOX:
2230 case EDJE_PART_TYPE_TABLE:
2231 case EDJE_PART_TYPE_SWALLOW:
2232 case EDJE_PART_TYPE_GROUP:
2233 case EDJE_PART_TYPE_PROXY:
2235 case EDJE_PART_TYPE_GRADIENT:
2236 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2242 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
2246 _edje_table_recalc_apply(Edje *ed __UNUSED__,
2248 Edje_Calc_Params *p3 __UNUSED__,
2249 Edje_Part_Description_Table *chosen_desc)
2251 evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous);
2252 evas_object_table_align_set(ep->object, TO_DOUBLE(chosen_desc->table.align.x), TO_DOUBLE(chosen_desc->table.align.y));
2253 evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y);
2254 if (evas_object_smart_need_recalculate_get(ep->object))
2256 evas_object_smart_need_recalculate_set(ep->object, 0);
2257 evas_object_smart_calculate(ep->object);
2262 _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos)
2267 if (pos >= FROM_DOUBLE(0.5))
2268 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2270 part_id = chosen_desc->proxy.id;
2272 if ((p3->type.common.fill.w == 0) || (p3->type.common.fill.h == 0) ||
2275 evas_object_image_source_set(ep->object, NULL);
2278 pp = ed->table_parts[part_id % ed->table_parts_size];
2280 switch (pp->part->type)
2282 case EDJE_PART_TYPE_IMAGE:
2283 case EDJE_PART_TYPE_TEXT:
2284 case EDJE_PART_TYPE_TEXTBLOCK:
2285 case EDJE_PART_TYPE_RECTANGLE:
2286 case EDJE_PART_TYPE_BOX:
2287 case EDJE_PART_TYPE_TABLE:
2288 case EDJE_PART_TYPE_PROXY:
2289 evas_object_image_source_set(ep->object, pp->object);
2291 case EDJE_PART_TYPE_GRADIENT:
2292 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2294 case EDJE_PART_TYPE_GROUP:
2295 case EDJE_PART_TYPE_SWALLOW:
2296 case EDJE_PART_TYPE_EXTERNAL:
2297 evas_object_image_source_set(ep->object, pp->swallowed_object);
2299 case EDJE_PART_TYPE_SPACER:
2300 /* FIXME: detect that at compile time and prevent it */
2304 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2305 p3->type.common.fill.w, p3->type.common.fill.h);
2306 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2310 _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos)
2315 if (sc == 0.0) sc = _edje_scale;
2316 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2317 p3->type.common.fill.w, p3->type.common.fill.h);
2318 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2319 if (chosen_desc->image.border.scale)
2321 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2323 FLOAT_T sc2 = MUL(sc, p3->type.common.spec.image.border_scale_by);
2324 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc2));
2327 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc));
2331 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2332 evas_object_image_border_scale_set
2333 (ep->object, TO_DOUBLE(p3->type.common.spec.image.border_scale_by));
2335 evas_object_image_border_scale_set(ep->object, 1.0);
2337 evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r,
2338 p3->type.common.spec.image.t, p3->type.common.spec.image.b);
2339 if (chosen_desc->image.border.no_fill == 0)
2340 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_DEFAULT);
2341 else if (chosen_desc->image.border.no_fill == 1)
2342 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE);
2343 else if (chosen_desc->image.border.no_fill == 2)
2344 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID);
2346 _edje_real_part_image_set(ed, ep, pos);
2349 static Edje_Real_Part *
2350 _edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state)
2352 Edje_Real_Part *result = NULL;
2354 if (id >= 0 && id != ep->part->id)
2356 result = ed->table_parts[id % ed->table_parts_size];
2359 if (!result->calculated) _edje_part_recalc(ed, result, flags, NULL);
2360 #ifdef EDJE_CALC_CACHE
2361 if (state) *state = result->state;
2371 _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
2373 #ifdef EDJE_CALC_CACHE
2374 Eina_Bool proxy_invalidate = EINA_FALSE;
2379 Edje_Calc_Params lp1, lp2;
2387 Edje_Real_Part *center[2] = { NULL, NULL };
2388 Edje_Real_Part *light[2] = { NULL, NULL };
2389 Edje_Real_Part *persp[2] = { NULL, NULL };
2390 Edje_Calc_Params *p1, *pf;
2391 Edje_Part_Description_Common *chosen_desc;
2392 Edje_Real_Part *confine_to = NULL;
2393 FLOAT_T pos = ZERO, pos2;
2394 Edje_Calc_Params lp3;
2396 /* GRADIENT ARE GONE, WE MUST IGNORE IT FROM OLD FILE. */
2397 if (ep->part->type == EDJE_PART_TYPE_GRADIENT)
2399 ERR("GRADIENT spotted during recalc ! That should never happen ! Send your edje file to devel ml.");
2403 if ((ep->calculated & FLAG_XY) == FLAG_XY && !state)
2407 if (ep->calculating & flags)
2410 const char *axes = "NONE", *faxes = "NONE";
2412 if ((ep->calculating & FLAG_X) &&
2413 (ep->calculating & FLAG_Y))
2415 else if ((ep->calculating & FLAG_X))
2417 else if ((ep->calculating & FLAG_Y))
2420 if ((flags & FLAG_X) &&
2423 else if ((flags & FLAG_X))
2425 else if ((flags & FLAG_Y))
2427 ERR("Circular dependency when calculating part \"%s\". "
2428 "Already calculating %s [%02x] axes. "
2429 "Need to calculate %s [%02x] axes",
2431 axes, ep->calculating,
2437 if (ep->part->scale &&
2438 ep->part->type == EDJE_PART_TYPE_GROUP &&
2439 ep->swallowed_object)
2441 edje_object_scale_set(ep->swallowed_object, TO_DOUBLE(ed->scale));
2443 if (ep->description_pos > FROM_DOUBLE(0.5) && ep->param2)
2445 edje_object_update_hints_set(ep->swallowed_object, ep->param2->description->min.limit);
2449 edje_object_update_hints_set(ep->swallowed_object, ep->param1.description->min.limit);
2451 if (edje_object_update_hints_get(ep->swallowed_object))
2455 ted = _edje_fetch(ep->swallowed_object);
2456 _edje_recalc_do(ted);
2460 #ifdef EDJE_CALC_CACHE
2461 if (ep->state == ed->state && !state)
2467 ep->calculating |= flags & FLAG_X;
2468 if (ep->param1.rel1_to_x)
2470 _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL);
2471 #ifdef EDJE_CALC_CACHE
2472 state1 = ep->param1.rel1_to_x->state;
2475 if (ep->param1.rel2_to_x)
2477 _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL);
2478 #ifdef EDJE_CALC_CACHE
2479 if (state1 < ep->param1.rel2_to_x->state)
2480 state1 = ep->param1.rel2_to_x->state;
2485 if (ep->param2->rel1_to_x)
2487 _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL);
2488 #ifdef EDJE_CALC_CACHE
2489 state2 = ep->param2->rel1_to_x->state;
2492 if (ep->param2->rel2_to_x)
2494 _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL);
2495 #ifdef EDJE_CALC_CACHE
2496 if (state2 < ep->param2->rel2_to_x->state)
2497 state2 = ep->param2->rel2_to_x->state;
2504 ep->calculating |= flags & FLAG_Y;
2505 if (ep->param1.rel1_to_y)
2507 _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL);
2508 #ifdef EDJE_CALC_CACHE
2509 if (state1 < ep->param1.rel1_to_y->state)
2510 state1 = ep->param1.rel1_to_y->state;
2513 if (ep->param1.rel2_to_y)
2515 _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL);
2516 #ifdef EDJE_CALC_CACHE
2517 if (state1 < ep->param1.rel2_to_y->state)
2518 state1 = ep->param1.rel2_to_y->state;
2523 if (ep->param2->rel1_to_y)
2525 _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL);
2526 #ifdef EDJE_CALC_CACHE
2527 if (state2 < ep->param2->rel1_to_y->state)
2528 state2 = ep->param2->rel1_to_y->state;
2531 if (ep->param2->rel2_to_y)
2533 _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL);
2534 #ifdef EDJE_CALC_CACHE
2535 if (state2 < ep->param2->rel2_to_y->state)
2536 state2 = ep->param2->rel2_to_y->state;
2541 if (ep->drag && ep->drag->confine_to)
2543 confine_to = ep->drag->confine_to;
2544 _edje_part_recalc(ed, confine_to, flags, NULL);
2545 #ifdef EDJE_CALC_CACHE
2546 statec = confine_to->state;
2549 // if (ep->text.source) _edje_part_recalc(ed, ep->text.source, flags);
2550 // if (ep->text.text_source) _edje_part_recalc(ed, ep->text.text_source, flags);
2552 /* actually calculate now */
2553 chosen_desc = ep->chosen_description;
2556 ep->calculating = FLAG_NONE;
2557 ep->calculated |= flags;
2561 pos = ep->description_pos;
2563 if (ep->part->type == EDJE_PART_TYPE_PROXY)
2568 if (pos >= FROM_DOUBLE(0.5))
2569 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2571 part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id;
2573 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL);
2574 #ifdef EDJE_CALC_CACHE
2575 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE;
2579 /* Recalc if needed the map center && light source */
2580 if (ep->param1.description->map.on)
2582 center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1);
2583 light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1);
2585 if (chosen_desc->map.persp_on)
2587 persp[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_persp, &statep1);
2591 if (ep->param2 && ep->param2->description->map.on)
2593 center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2);
2594 light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2);
2596 if (chosen_desc->map.persp_on)
2598 persp[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_persp, &statep2);
2602 #ifndef EDJE_CALC_CACHE
2608 if (ep->param1.description)
2610 #ifdef EDJE_CALC_CACHE
2611 if (ed->all_part_change ||
2613 state1 >= ep->param1.state ||
2614 statec >= ep->param1.state ||
2615 statec1 >= ep->param1.state ||
2616 statel1 >= ep->param1.state ||
2617 statep1 >= ep->param1.state ||
2620 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2623 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
2624 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
2628 #ifdef EDJE_CALC_CACHE
2629 if (flags == FLAG_XY)
2630 ep->param1.state = ed->state;
2636 int beginning_pos, part_type;
2637 Edje_Calc_Params *p2, *p3;
2641 /* FIXME: except for text, we don't need in that case to recalc p1 at all*/
2642 memcpy(p1, ep->current, sizeof (Edje_Calc_Params));
2645 p1->map.center.x += ed->x;
2646 p1->map.center.y += ed->y;
2647 p1->map.light.x += ed->x;
2648 p1->map.light.y += ed->y;
2649 p1->map.persp.x += ed->x;
2650 p1->map.persp.y += ed->y;
2655 #ifndef EDJE_CALC_CACHE
2658 p2 = &ep->param2->p;
2660 if (ed->all_part_change ||
2662 state2 >= ep->param2->state ||
2663 statec >= ep->param2->state ||
2664 statec2 >= ep->param2->state ||
2665 statel2 >= ep->param2->state ||
2666 statep2 >= ep->param2->state ||
2669 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2672 _edje_part_recalc_single(ed, ep, ep->param2->description,
2674 center[1], light[1], persp[1],
2675 ep->param2->rel1_to_x,
2676 ep->param2->rel1_to_y,
2677 ep->param2->rel2_to_x,
2678 ep->param2->rel2_to_y,
2681 #ifdef EDJE_CALC_CACHE
2682 if (flags == FLAG_XY)
2683 ep->param2->state = ed->state;
2688 if (pos2 < ZERO) pos2 = ZERO;
2689 else if (pos2 > FROM_INT(1)) pos2 = FROM_INT(1);
2690 beginning_pos = (pos < FROM_DOUBLE(0.5));
2691 part_type = ep->part->type;
2693 /* visible is special */
2694 if ((p1->visible) && (!p2->visible))
2695 p3->visible = (pos != FROM_INT(1));
2696 else if ((!p1->visible) && (p2->visible))
2697 p3->visible = (pos != ZERO);
2699 p3->visible = p1->visible;
2701 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth;
2703 /* FIXME: do x and y separately base on flag */
2704 #define FINTP(_x1, _x2, _p) \
2707 : ADD(FROM_INT(_x1), \
2708 SCALE((_p), (_x2) - (_x1))))
2710 #define FFP(_x1, _x2, _p) \
2713 : ADD(_x1, MUL(_p, SUB(_x2, _x1))));
2715 #define INTP(_x1, _x2, _p) TO_INT(FINTP(_x1, _x2, _p))
2717 p3->x = INTP(p1->x, p2->x, pos);
2718 p3->y = INTP(p1->y, p2->y, pos);
2719 p3->w = INTP(p1->w, p2->w, pos);
2720 p3->h = INTP(p1->h, p2->h, pos);
2722 p3->req.x = INTP(p1->req.x, p2->req.x, pos);
2723 p3->req.y = INTP(p1->req.y, p2->req.y, pos);
2724 p3->req.w = INTP(p1->req.w, p2->req.w, pos);
2725 p3->req.h = INTP(p1->req.h, p2->req.h, pos);
2727 if (ep->part->dragable.x)
2729 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos);
2730 p3->req_drag.w = INTP(p1->req_drag.w, p2->req_drag.w, pos);
2732 if (ep->part->dragable.y)
2734 p3->req_drag.y = INTP(p1->req_drag.y, p2->req_drag.y, pos);
2735 p3->req_drag.h = INTP(p1->req_drag.h, p2->req_drag.h, pos);
2738 p3->color.r = INTP(p1->color.r, p2->color.r, pos2);
2739 p3->color.g = INTP(p1->color.g, p2->color.g, pos2);
2740 p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
2741 p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
2745 case EDJE_PART_TYPE_IMAGE:
2746 p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos);
2747 p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos);
2748 p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos);
2749 p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos);
2750 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);
2751 case EDJE_PART_TYPE_PROXY:
2752 p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos);
2753 p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos);
2754 p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos);
2755 p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos);
2757 case EDJE_PART_TYPE_TEXT:
2758 p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos);
2759 case EDJE_PART_TYPE_TEXTBLOCK:
2760 p3->type.text.color2.r = INTP(p1->type.text.color2.r, p2->type.text.color2.r, pos2);
2761 p3->type.text.color2.g = INTP(p1->type.text.color2.g, p2->type.text.color2.g, pos2);
2762 p3->type.text.color2.b = INTP(p1->type.text.color2.b, p2->type.text.color2.b, pos2);
2763 p3->type.text.color2.a = INTP(p1->type.text.color2.a, p2->type.text.color2.a, pos2);
2765 p3->type.text.color3.r = INTP(p1->type.text.color3.r, p2->type.text.color3.r, pos2);
2766 p3->type.text.color3.g = INTP(p1->type.text.color3.g, p2->type.text.color3.g, pos2);
2767 p3->type.text.color3.b = INTP(p1->type.text.color3.b, p2->type.text.color3.b, pos2);
2768 p3->type.text.color3.a = INTP(p1->type.text.color3.a, p2->type.text.color3.a, pos2);
2770 p3->type.text.align.x = FFP(p1->type.text.align.x, p2->type.text.align.x, pos);
2771 p3->type.text.align.y = FFP(p1->type.text.align.y, p2->type.text.align.y, pos);
2772 p3->type.text.elipsis = TO_DOUBLE(FINTP(p1->type.text.elipsis, p2->type.text.elipsis, pos2));
2776 p3->mapped = p1->mapped;
2777 p3->persp_on = p3->mapped ? p1->persp_on | p2->persp_on : 0;
2778 p3->lighted = p3->mapped ? p1->lighted | p2->lighted : 0;
2781 p3->map.center.x = INTP(p1->map.center.x, p2->map.center.x, pos);
2782 p3->map.center.y = INTP(p1->map.center.y, p2->map.center.y, pos);
2783 p3->map.center.z = INTP(p1->map.center.z, p2->map.center.z, pos);
2784 p3->map.rotation.x = FFP(p1->map.rotation.x, p2->map.rotation.x, pos);
2785 p3->map.rotation.y = FFP(p1->map.rotation.y, p2->map.rotation.y, pos);
2786 p3->map.rotation.z = FFP(p1->map.rotation.z, p2->map.rotation.z, pos);
2788 #define MIX(P1, P2, P3, pos, info) \
2789 P3->info = P1->info + TO_INT(SCALE(pos, P2->info - P1->info));
2791 if (p1->lighted && p2->lighted)
2793 MIX(p1, p2, p3, pos, map.light.x);
2794 MIX(p1, p2, p3, pos, map.light.y);
2795 MIX(p1, p2, p3, pos, map.light.z);
2796 MIX(p1, p2, p3, pos, map.light.r);
2797 MIX(p1, p2, p3, pos, map.light.g);
2798 MIX(p1, p2, p3, pos, map.light.b);
2799 MIX(p1, p2, p3, pos, map.light.ar);
2800 MIX(p1, p2, p3, pos, map.light.ag);
2801 MIX(p1, p2, p3, pos, map.light.ab);
2803 else if (p1->lighted)
2805 memcpy(&p3->map.light, &p1->map.light, sizeof (p1->map.light));
2807 else if (p2->lighted)
2809 memcpy(&p3->map.light, &p2->map.light, sizeof (p2->map.light));
2812 if (p1->persp_on && p2->persp_on)
2814 MIX(p1, p2, p3, pos, map.persp.x);
2815 MIX(p1, p2, p3, pos, map.persp.y);
2816 MIX(p1, p2, p3, pos, map.persp.z);
2817 MIX(p1, p2, p3, pos, map.persp.focal);
2819 else if (p1->persp_on)
2821 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.persp));
2823 else if (p2->persp_on)
2825 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.persp));
2836 if (!pf->persp_on && chosen_desc->map.persp_on)
2840 pf->map.persp.x = ed->persp->px;
2841 pf->map.persp.y = ed->persp->py;
2842 pf->map.persp.z = ed->persp->z0;
2843 pf->map.persp.focal = ed->persp->foc;
2847 const Edje_Perspective *ps;
2849 // fixme: a tad inefficient as this is a has lookup
2850 ps = edje_object_perspective_get(ed->obj);
2852 ps = edje_evas_global_perspective_get(evas_object_evas_get(ed->obj));
2855 pf->map.persp.x = ps->px;
2856 pf->map.persp.y = ps->py;
2857 pf->map.persp.z = ps->z0;
2858 pf->map.persp.focal = ps->foc;
2862 pf->map.persp.x = ed->x + (ed->w / 2);
2863 pf->map.persp.y = ed->y + (ed->h / 2);
2864 pf->map.persp.z = 0;
2865 pf->map.persp.focal = 1000;
2872 memcpy(state, pf, sizeof (Edje_Calc_Params));
2877 if (ep->drag && ep->drag->need_reset)
2883 _edje_part_dragable_calc(ed, ep, &dx, &dy);
2886 ep->drag->tmp.x = 0;
2887 ep->drag->tmp.y = 0;
2888 ep->drag->need_reset = 0;
2894 /* Common move, resize and color_set for all part. */
2895 switch (ep->part->type)
2897 case EDJE_PART_TYPE_IMAGE:
2899 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) chosen_desc;
2901 evas_object_image_scale_hint_set(ep->object,
2902 img_desc->image.scale_hint);
2904 case EDJE_PART_TYPE_PROXY:
2905 case EDJE_PART_TYPE_RECTANGLE:
2906 case EDJE_PART_TYPE_TEXTBLOCK:
2907 case EDJE_PART_TYPE_BOX:
2908 case EDJE_PART_TYPE_TABLE:
2909 evas_object_color_set(ep->object,
2910 (pf->color.r * pf->color.a) / 255,
2911 (pf->color.g * pf->color.a) / 255,
2912 (pf->color.b * pf->color.a) / 255,
2916 evas_object_hide(ep->object);
2919 evas_object_show(ep->object);
2920 /* move and resize are needed for all previous object => no break here. */
2921 case EDJE_PART_TYPE_SWALLOW:
2922 case EDJE_PART_TYPE_GROUP:
2923 case EDJE_PART_TYPE_EXTERNAL:
2924 /* visibility and color have no meaning on SWALLOW and GROUP part. */
2925 evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y);
2926 evas_object_resize(ep->object, pf->w, pf->h);
2927 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
2928 _edje_entry_real_part_configure(ep);
2930 case EDJE_PART_TYPE_TEXT:
2931 /* This is correctly handle in _edje_text_recalc_apply at the moment. */
2933 case EDJE_PART_TYPE_GRADIENT:
2934 /* FIXME: definitivly remove this code when we switch to new format. */
2937 case EDJE_PART_TYPE_SPACER:
2938 /* We really should do nothing on SPACER part */
2942 /* Some object need special recalc. */
2943 switch (ep->part->type)
2945 case EDJE_PART_TYPE_TEXT:
2946 _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
2948 case EDJE_PART_TYPE_PROXY:
2949 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy*) chosen_desc, pos);
2951 case EDJE_PART_TYPE_IMAGE:
2952 _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image*) chosen_desc, pos);
2954 case EDJE_PART_TYPE_BOX:
2955 _edje_box_recalc_apply(ed, ep, pf, (Edje_Part_Description_Box*) chosen_desc);
2957 case EDJE_PART_TYPE_TABLE:
2958 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table*) chosen_desc);
2960 case EDJE_PART_TYPE_TEXTBLOCK:
2961 _edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
2963 case EDJE_PART_TYPE_EXTERNAL:
2964 case EDJE_PART_TYPE_RECTANGLE:
2965 case EDJE_PART_TYPE_SWALLOW:
2966 case EDJE_PART_TYPE_GROUP:
2967 /* Nothing special to do for this type of object. */
2969 case EDJE_PART_TYPE_GRADIENT:
2970 /* FIXME: definitivly remove this code when we switch to new format. */
2973 case EDJE_PART_TYPE_SPACER:
2974 /* We really should do nothing on SPACER part */
2978 if (ep->swallowed_object)
2980 //// the below really is wrong - swallow color shouldn't affect swallowed object
2981 //// color - the edje color as a WHOLE should though - and that should be
2982 //// done via the clipper anyway. this created bugs when objects had their
2983 //// colro set and were swallowed - then had their color changed.
2984 // evas_object_color_set(ep->swallowed_object,
2985 // (pf->color.r * pf->color.a) / 255,
2986 // (pf->color.g * pf->color.a) / 255,
2987 // (pf->color.b * pf->color.a) / 255,
2991 evas_object_move(ep->swallowed_object, ed->x + pf->x, ed->y + pf->y);
2992 evas_object_resize(ep->swallowed_object, pf->w, pf->h);
2993 evas_object_show(ep->swallowed_object);
2995 else evas_object_hide(ep->swallowed_object);
2996 mo = ep->swallowed_object;
2998 else mo = ep->object;
2999 if (chosen_desc->map.on && ep->part->type != EDJE_PART_TYPE_SPACER)
3001 static Evas_Map *map = NULL;
3003 ed->have_mapped_part = 1;
3004 // create map and populate with part geometry
3005 if (!map) map = evas_map_new(4);
3006 evas_map_util_points_populate_from_object(map, ep->object);
3007 if (ep->part->type == EDJE_PART_TYPE_IMAGE ||
3008 ((ep->part->type == EDJE_PART_TYPE_SWALLOW) &&
3009 (!strcmp(evas_object_type_get(mo), "image") &&
3010 (!evas_object_image_source_get(mo))))
3015 evas_object_image_size_get(mo, &iw, &ih);
3016 evas_map_point_image_uv_set(map, 0, 0.0, 0.0);
3017 evas_map_point_image_uv_set(map, 1, iw , 0.0);
3018 evas_map_point_image_uv_set(map, 2, iw , ih );
3019 evas_map_point_image_uv_set(map, 3, 0.0, ih );
3021 evas_map_util_3d_rotate(map,
3022 TO_DOUBLE(pf->map.rotation.x), TO_DOUBLE(pf->map.rotation.y), TO_DOUBLE(pf->map.rotation.z),
3023 pf->map.center.x, pf->map.center.y, pf->map.center.z);
3025 // calculate light color & position etc. if there is one
3028 evas_map_util_3d_lighting(map,
3029 pf->map.light.x, pf->map.light.y, pf->map.light.z,
3030 pf->map.light.r, pf->map.light.g, pf->map.light.b,
3031 pf->map.light.ar, pf->map.light.ag, pf->map.light.ab);
3034 // calculate perspective point
3035 if (chosen_desc->map.persp_on)
3037 evas_map_util_3d_perspective(map,
3038 pf->map.persp.x, pf->map.persp.y, pf->map.persp.z,
3039 pf->map.persp.focal);
3042 // handle backface culling (object is facing away from view
3043 if (chosen_desc->map.backcull)
3047 if (evas_map_util_clockwise_get(map))
3048 evas_object_show(mo);
3049 else evas_object_hide(mo);
3054 if (chosen_desc->map.smooth) evas_map_smooth_set(map, 1);
3055 else evas_map_smooth_set(map, 0);
3057 if (chosen_desc->map.alpha) evas_map_alpha_set(map, 1);
3058 else evas_map_alpha_set(map, 0);
3060 evas_object_map_set(mo, map);
3061 evas_object_map_enable_set(mo, 1);
3065 evas_object_map_enable_set(mo, 0);
3066 evas_object_map_set(mo, NULL);
3075 ep->calculated |= flags;
3076 ep->calculating = FLAG_NONE;
3078 #ifdef EDJE_CALC_CACHE
3079 if (ep->calculated == FLAG_XY)
3081 ep->state = ed->state;