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;
118 ed->dirty = EINA_TRUE;
119 ed->recalc_call = EINA_TRUE;
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 if ((ep->type != EDJE_RP_TYPE_SWALLOW) ||
514 (!ep->typedata.swallow)) return;
516 external = (Edje_Part_Description_External*)state->description;
518 if (state->external_params)
519 _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object, state->external_params);
520 state->external_params = _edje_external_params_parse(ep->typedata.swallow->swallowed_object, external->external_params);
526 _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2)
528 Edje_Part_Description_Common *epd1;
529 Edje_Part_Description_Common *epd2 = NULL;
530 Edje_Part_Description_Common *chosen_desc;
532 Edje_Part_Description_Image *epdi;
534 if (!d1) d1 = "default";
536 epd1 = _edje_part_description_find(ed, ep, d1, v1);
538 epd1 = ep->part->default_desc; /* never NULL */
541 epd2 = _edje_part_description_find(ed, ep, d2, v2);
543 epdi = (Edje_Part_Description_Image*) epd2;
545 /* There is an animation if both description are different or if description is an image with tweens */
546 if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count)))
550 ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp,
551 sizeof(Edje_Real_Part_State));
552 memset(ep->param2, 0, sizeof(Edje_Real_Part_State));
554 else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
556 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
557 (ep->typedata.swallow))
558 _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object,
559 ep->param2->external_params);
561 ep->param2->external_params = NULL;
566 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
568 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
569 (ep->typedata.swallow))
570 _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object,
571 ep->param2->external_params);
574 free(ep->param2->set);
575 eina_mempool_free(_edje_real_part_state_mp, ep->param2);
579 chosen_desc = ep->chosen_description;
580 ep->param1.description = epd1;
581 ep->chosen_description = epd1;
583 _edje_real_part_rel_to_apply(ed, ep, &ep->param1);
587 ep->param2->description = epd2;
589 _edje_real_part_rel_to_apply(ed, ep, ep->param2);
591 if (ep->description_pos > FROM_DOUBLE(0.0))
592 ep->chosen_description = epd2;
595 if (chosen_desc != ep->chosen_description &&
596 ep->part->type == EDJE_PART_TYPE_EXTERNAL)
597 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
599 ed->recalc_hints = EINA_TRUE;
600 ed->dirty = EINA_TRUE;
601 ed->recalc_call = EINA_TRUE;
602 #ifdef EDJE_CALC_CACHE
608 _edje_recalc(Edje *ed)
610 if ((ed->freeze > 0) || (_edje_freeze_val > 0))
612 ed->recalc = EINA_TRUE;
615 if (_edje_freeze_val > 0)
617 if (!ed->freeze_calc)
619 _edje_freeze_calc_count++;
620 _edje_freeze_calc_list = eina_list_append(_edje_freeze_calc_list, ed);
621 ed->freeze_calc = EINA_TRUE;
627 // XXX: dont need this with current smart calc infra. remove me later
628 // if (ed->postponed) return;
629 // if (!ed->calc_only)
630 evas_object_smart_changed(ed->obj);
631 // XXX: dont need this with current smart calc infra. remove me later
632 // ed->postponed = EINA_TRUE;
636 _edje_recalc_do(Edje *ed)
641 // XXX: dont need this with current smart calc infra. remove me later
642 // ed->postponed = EINA_FALSE;
643 need_calc = evas_object_smart_need_recalculate_get(ed->obj);
644 evas_object_smart_need_recalculate_set(ed->obj, 0);
645 if (!ed->dirty) return;
646 ed->have_mapped_part = EINA_FALSE;
647 ed->dirty = EINA_FALSE;
649 for (i = 0; i < ed->table_parts_size; i++)
653 ep = ed->table_parts[i];
654 ep->calculated = FLAG_NONE;
655 ep->calculating = FLAG_NONE;
657 for (i = 0; i < ed->table_parts_size; i++)
661 ep = ed->table_parts[i];
662 if (ep->calculated != FLAG_XY)
663 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
665 if (!ed->calc_only) ed->recalc = EINA_FALSE;
666 #ifdef EDJE_CALC_CACHE
667 ed->all_part_change = EINA_FALSE;
668 ed->text_part_change = EINA_FALSE;
673 evas_object_smart_callback_call(ed->obj, "recalc", NULL);
676 evas_object_smart_need_recalculate_set(ed->obj, need_calc);
677 ed->recalc_call = EINA_FALSE;
679 if (ed->update_hints && ed->recalc_hints && !ed->calc_only)
683 ed->recalc_hints = EINA_FALSE;
685 edje_object_size_min_calc(ed->obj, &w, &h);
686 evas_object_size_hint_min_set(ed->obj, w, h);
689 if (!ed->collection) return ;
691 for (i = 0; i < ed->collection->limits.parts_count; i++)
697 part = ed->collection->limits.parts[i].part;
698 name = ed->collection->parts[part]->name;
699 limit = ed->table_parts[part]->chosen_description->limit;
703 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
704 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
707 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
710 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
716 if ((limit & 1) == 1)
718 if (ed->table_parts[part]->w > 0 &&
719 (ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_OVER))
721 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_OVER;
722 _edje_emit(ed, "limit,width,over", name);
724 else if (ed->table_parts[part]->w < 0 &&
725 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_BELOW)
727 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_BELOW;
728 _edje_emit(ed, "limit,width,below", name);
730 else if (ed->table_parts[part]->w == 0 &&
731 ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_ZERO)
733 ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_ZERO;
734 _edje_emit(ed, "limit,width,zero", name);
737 if ((limit & 2) == 2)
739 if (ed->table_parts[part]->h > 0 &&
740 (ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_OVER))
742 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_OVER;
743 _edje_emit(ed, "limit,height,over", name);
745 else if (ed->table_parts[part]->h < 0 &&
746 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_BELOW)
748 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_BELOW;
749 _edje_emit(ed, "limit,height,below", name);
751 else if (ed->table_parts[part]->h == 0 &&
752 ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_ZERO)
754 ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_ZERO;
755 _edje_emit(ed, "limit,height,zero", name);
762 _edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep)
764 _edje_part_recalc(ed, ep, FLAG_XY, NULL);
768 _edje_part_dragable_calc(Edje *ed __UNUSED__, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y)
772 if (ep->drag->confine_to)
774 FLOAT_T dx, dy, dw, dh;
777 if ((ep->part->dragable.x != 0) &&
778 (ep->part->dragable.y != 0 )) ret = 3;
779 else if (ep->part->dragable.x != 0) ret = 1;
780 else if (ep->part->dragable.y != 0) ret = 2;
782 dx = FROM_INT(ep->x - ep->drag->confine_to->x);
783 dw = FROM_INT(ep->drag->confine_to->w - ep->w);
784 if (dw != ZERO) dx = DIV(dx, dw);
787 dy = FROM_INT(ep->y - ep->drag->confine_to->y);
788 dh = FROM_INT(ep->drag->confine_to->h - ep->h);
789 if (dh != ZERO) dy = DIV(dy, dh);
799 if (x) *x = ADD(FROM_INT(ep->drag->tmp.x), ep->drag->x);
800 if (y) *y = ADD(FROM_INT(ep->drag->tmp.y), ep->drag->y);
810 _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
812 /* check whether this part is dragable at all */
813 if (!ep->drag) return ;
815 /* instead of checking for equality, we really should check that
816 * the difference is greater than foo, but I have no idea what
817 * value we would set foo to, because it would depend on the
818 * size of the dragable...
820 if (ep->drag->x != x || ep->drag->tmp.x)
824 ep->drag->need_reset = 0;
825 ed->dirty = EINA_TRUE;
826 ed->recalc_call = EINA_TRUE;
829 if (ep->drag->y != y || ep->drag->tmp.y)
833 ep->drag->need_reset = 0;
834 ed->dirty = EINA_TRUE;
835 ed->recalc_call = EINA_TRUE;
838 #ifdef EDJE_CALC_CACHE
841 _edje_recalc(ed); /* won't do anything if dirty flag isn't set */
845 _edje_part_recalc_single_rel(Edje *ed,
846 Edje_Real_Part *ep __UNUSED__,
847 Edje_Part_Description_Common *desc,
848 Edje_Real_Part *rel1_to_x,
849 Edje_Real_Part *rel1_to_y,
850 Edje_Real_Part *rel2_to_x,
851 Edje_Real_Part *rel2_to_y,
852 Edje_Calc_Params *params)
858 x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x),
859 SCALE(desc->rel1.relative_x, rel1_to_x->w));
861 x = ADD(FROM_INT(desc->rel1.offset_x),
862 SCALE(desc->rel1.relative_x, ed->w));
863 params->x = TO_INT(x);
866 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x),
867 SCALE(desc->rel2.relative_x, rel2_to_x->w)),
871 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x),
872 SCALE(desc->rel2.relative_x, ed->w)),
875 params->w = TO_INT(w);
878 y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y),
879 SCALE(desc->rel1.relative_y, rel1_to_y->h));
881 y = ADD(FROM_INT(desc->rel1.offset_y),
882 SCALE(desc->rel1.relative_y, ed->h));
883 params->y = TO_INT(y);
886 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y),
887 SCALE(desc->rel2.relative_y, rel2_to_y->h)),
891 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y),
892 SCALE(desc->rel2.relative_y, ed->h)),
895 params->h = TO_INT(h);
898 static Edje_Internal_Aspect
899 _edje_part_recalc_single_aspect(Edje *ed,
901 Edje_Part_Description_Common *desc,
902 Edje_Calc_Params *params,
903 int *minw, int *minh,
904 int *maxw, int *maxh,
907 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE;
908 FLOAT_T aspect, amax, amin;
909 FLOAT_T new_w = ZERO, new_h = ZERO, want_x, want_y, want_w, want_h;
911 if (params->h <= ZERO) aspect = FROM_INT(999999);
912 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h));
913 amax = desc->aspect.max;
914 amin = desc->aspect.min;
915 if (desc->aspect.prefer == EDJE_ASPECT_PREFER_SOURCE &&
916 ep->part->type == EDJE_PART_TYPE_IMAGE)
920 /* We only need pose to find the right image that would be displayed,
921 and the right aspect ratio in that case */
922 _edje_real_part_image_set(ed, ep, pos);
923 evas_object_image_size_get(ep->object, &w, &h);
924 amin = amax = DIV(FROM_INT(w), FROM_INT(h));
926 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
927 (ep->typedata.swallow))
929 if ((ep->typedata.swallow->swallow_params.aspect.w > 0) &&
930 (ep->typedata.swallow->swallow_params.aspect.h > 0))
932 DIV(FROM_INT(ep->typedata.swallow->swallow_params.aspect.w),
933 FROM_INT(ep->typedata.swallow->swallow_params.aspect.h));
935 want_x = FROM_INT(params->x);
936 want_w = new_w = FROM_INT(params->w);
938 want_y = FROM_INT(params->y);
939 want_h = new_h = FROM_INT(params->h);
941 if ((amin > ZERO) && (amax > ZERO))
943 apref = desc->aspect.prefer;
944 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
945 (ep->typedata.swallow))
947 if (ep->typedata.swallow->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE)
949 switch (ep->typedata.swallow->swallow_params.aspect.mode)
951 case EDJE_ASPECT_CONTROL_NEITHER:
952 apref = EDJE_ASPECT_PREFER_NONE;
954 case EDJE_ASPECT_CONTROL_HORIZONTAL:
955 apref = EDJE_ASPECT_PREFER_HORIZONTAL;
957 case EDJE_ASPECT_CONTROL_VERTICAL:
958 apref = EDJE_ASPECT_PREFER_VERTICAL;
960 case EDJE_ASPECT_CONTROL_BOTH:
961 apref = EDJE_ASPECT_PREFER_BOTH;
970 case EDJE_ASPECT_PREFER_NONE:
971 /* keep both dimensions in check */
972 /* adjust for min aspect (width / height) */
973 if ((amin > ZERO) && (aspect < amin))
975 new_h = DIV(FROM_INT(params->w), amin);
976 new_w = SCALE(amin, params->h);
978 /* adjust for max aspect (width / height) */
979 if ((amax > ZERO) && (aspect > amax))
981 new_h = DIV(FROM_INT(params->w), amax);
982 new_w = SCALE(amax, params->h);
984 if ((amax > ZERO) && (new_w < FROM_INT(params->w)))
986 new_w = FROM_INT(params->w);
987 new_h = DIV(FROM_INT(params->w), amax);
989 if ((amax > ZERO) && (new_h < FROM_INT(params->h)))
991 new_w = SCALE(amax, params->h);
992 new_h = FROM_INT(params->h);
995 /* prefer vertical size as determiner */
996 case EDJE_ASPECT_PREFER_VERTICAL:
997 /* keep both dimensions in check */
998 /* adjust for max aspect (width / height) */
999 if ((amax > ZERO) && (aspect > amax))
1000 new_w = SCALE(amax, params->h);
1001 /* adjust for min aspect (width / height) */
1002 if ((amin > ZERO) && (aspect < amin))
1003 new_w = SCALE(amin, params->h);
1005 /* prefer horizontal size as determiner */
1006 case EDJE_ASPECT_PREFER_HORIZONTAL:
1007 /* keep both dimensions in check */
1008 /* adjust for max aspect (width / height) */
1009 if ((amax > ZERO) && (aspect > amax))
1010 new_h = DIV(FROM_INT(params->w), amax);
1011 /* adjust for min aspect (width / height) */
1012 if ((amin > ZERO) && (aspect < amin))
1013 new_h = DIV(FROM_INT(params->w), amin);
1015 case EDJE_ASPECT_PREFER_SOURCE:
1016 case EDJE_ASPECT_PREFER_BOTH:
1017 /* keep both dimensions in check */
1018 /* adjust for max aspect (width / height) */
1019 if ((amax > ZERO) && (aspect > amax))
1021 new_w = SCALE(amax, params->h);
1022 new_h = DIV(FROM_INT(params->w), amax);
1024 /* adjust for min aspect (width / height) */
1025 if ((amin > ZERO) && (aspect < amin))
1027 new_w = SCALE(amin, params->h);
1028 new_h = DIV(FROM_INT(params->w), amin);
1035 if (!((amin > ZERO) && (amax > ZERO) &&
1036 (apref == EDJE_ASPECT_PREFER_NONE)))
1038 if ((*maxw >= 0) && (new_w > FROM_INT(*maxw)))
1039 new_w = FROM_INT(*maxw);
1040 if (new_w < FROM_INT(*minw))
1041 new_w = FROM_INT(*minw);
1043 if ((FROM_INT(*maxh) >= 0) && (new_h > FROM_INT(*maxh)))
1044 new_h = FROM_INT(*maxh);
1045 if (new_h < FROM_INT(*minh))
1046 new_h = FROM_INT(*minh);
1049 /* do real adjustment */
1050 if (apref == EDJE_ASPECT_PREFER_BOTH)
1052 if (amin == ZERO) amin = amax;
1055 /* fix h and vary w */
1056 if (new_w > FROM_INT(params->w))
1058 // params->w = new_w;
1059 // EXCEEDS BOUNDS in W
1060 new_h = DIV(FROM_INT(params->w), amin);
1061 new_w = FROM_INT(params->w);
1062 if (new_h > FROM_INT(params->h))
1064 new_h = FROM_INT(params->h);
1065 new_w = SCALE(amin, params->h);
1068 /* fix w and vary h */
1071 // params->h = new_h;
1072 // EXCEEDS BOUNDS in H
1073 new_h = FROM_INT(params->h);
1074 new_w = SCALE(amin, params->h);
1075 if (new_w > FROM_INT(params->w))
1077 new_h = DIV(FROM_INT(params->w), amin);
1078 new_w = FROM_INT(params->w);
1081 params->w = TO_INT(new_w);
1082 params->h = TO_INT(new_h);
1086 if (apref != EDJE_ASPECT_PREFER_BOTH)
1088 if ((amin > 0.0) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE))
1090 params->w = TO_INT(new_w);
1091 params->h = TO_INT(new_h);
1093 else if ((FROM_INT(params->h) - new_h) > (FROM_INT(params->w) - new_w))
1095 if (params->h < TO_INT(new_h))
1096 params->h = TO_INT(new_h);
1097 else if (params->h > TO_INT(new_h))
1098 params->h = TO_INT(new_h);
1099 if (apref == EDJE_ASPECT_PREFER_VERTICAL)
1100 params->w = TO_INT(new_w);
1104 if (params->w < TO_INT(new_w))
1105 params->w = TO_INT(new_w);
1106 else if (params->w > TO_INT(new_w))
1107 params->w = TO_INT(new_w);
1108 if (apref == EDJE_ASPECT_PREFER_HORIZONTAL)
1109 params->h = TO_INT(new_h);
1112 params->x = TO_INT(ADD(want_x,
1113 MUL(SUB(want_w, FROM_INT(params->w)),
1115 params->y = TO_INT(ADD(want_y,
1116 MUL(SUB(want_h, FROM_INT(params->h)),
1122 _edje_part_recalc_single_step(Edje_Part_Description_Common *desc,
1123 Edje_Calc_Params *params)
1125 if (desc->step.x > 0)
1130 steps = params->w / desc->step.x;
1131 new_w = desc->step.x * steps;
1132 if (params->w > new_w)
1134 params->x += TO_INT(SCALE(desc->align.x, (params->w - new_w)));
1139 if (desc->step.y > 0)
1144 steps = params->h / desc->step.y;
1145 new_h = desc->step.y * steps;
1146 if (params->h > new_h)
1148 params->y += TO_INT(SCALE(desc->align.y, (params->h - new_h)));
1155 _edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text *chosen_desc, double base_scale, double scale)
1157 double size, min, max;
1159 if (chosen_desc->text.size == 0)
1162 min = base_scale * chosen_desc->text.size_range_min;
1163 max = chosen_desc->text.size_range_max * base_scale;
1164 size = chosen_desc->text.size * scale;
1166 if ((size > max) && (max > 0))
1167 scale = max / (double) chosen_desc->text.size;
1168 else if (size < min)
1169 scale = min / (double) chosen_desc->text.size;
1175 _edje_part_recalc_single_textblock(FLOAT_T sc,
1178 Edje_Part_Description_Text *chosen_desc,
1179 Edje_Calc_Params *params,
1180 int *minw, int *minh,
1181 int *maxw, int *maxh)
1183 if ((ep->type != EDJE_RP_TYPE_TEXT) ||
1184 (!ep->typedata.text))
1188 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
1189 const char *text = "";
1190 const char *style = "";
1191 Edje_Style *stl = NULL;
1195 if (chosen_desc->text.id_source >= 0)
1197 ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1199 tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->typedata.text->source->chosen_description)->text.style);
1200 if (tmp) style = tmp;
1204 ep->typedata.text->source = NULL;
1206 tmp = edje_string_get(&chosen_desc->text.style);
1207 if (tmp) style = tmp;
1210 if (chosen_desc->text.id_text_source >= 0)
1212 ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1213 text = edje_string_get(&((Edje_Part_Description_Text*)ep->typedata.text->text_source->chosen_description)->text.text);
1215 if (ep->typedata.text->text_source->typedata.text->text) text = ep->typedata.text->text_source->typedata.text->text;
1219 ep->typedata.text->text_source = NULL;
1220 text = edje_string_get(&chosen_desc->text.text);
1221 if (ep->typedata.text->text) text = ep->typedata.text->text;
1224 EINA_LIST_FOREACH(ed->file->styles, l, stl)
1226 if ((stl->name) && (!strcmp(stl->name, style))) break;
1230 if (ep->part->scale)
1231 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1233 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
1235 double base_s = 1.0;
1239 if (ep->part->scale) s = TO_DOUBLE(sc);
1240 if (ep->part->scale) base_s = TO_DOUBLE(sc);
1241 evas_object_scale_set(ep->object, base_s);
1242 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1245 /* Now make it bigger so calculations will be more accurate
1246 * and less influenced by hinting... */
1248 orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, orig_s * params->w / (double) tw);
1249 evas_object_scale_set(ep->object, orig_s);
1250 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1252 if (chosen_desc->text.fit_x)
1256 s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, orig_s * params->w / tw);
1257 evas_object_scale_set(ep->object, s);
1258 evas_object_textblock_size_native_get(ep->object, NULL, NULL);
1261 if (chosen_desc->text.fit_y)
1265 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, orig_s * params->h / (double) th);
1266 /* If we already have X fit, restrict Y to be no bigger
1267 * than what we got with X. */
1268 if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
1273 evas_object_scale_set(ep->object, s);
1274 evas_object_textblock_size_native_get(ep->object, NULL, NULL);
1278 /* Final tuning, try going down 90% at a time, hoping it'll
1279 * actually end up being correct. */
1281 int i = 5; /* Tries before we give up. */
1283 evas_object_textblock_size_native_get(ep->object, &fw, &fh);
1285 /* If we are still too big, try reducing the size to
1288 ((chosen_desc->text.fit_x && (fw > params->w)) ||
1289 (chosen_desc->text.fit_y && (fh > params->h))))
1291 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
1293 /* Break if we are not making any progress. */
1298 evas_object_scale_set(ep->object, s);
1299 evas_object_textblock_size_native_get(ep->object, &fw, &fh);
1310 if (evas_object_textblock_style_get(ep->object) != stl->style)
1311 evas_object_textblock_style_set(ep->object, stl->style);
1312 // FIXME: need to account for editing
1313 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1315 // do nothing - should be done elsewhere
1319 ptxt = evas_object_textblock_text_markup_get(ep->object);
1320 if (((!ptxt) && (text)) ||
1321 ((ptxt) && (text) && (strcmp(ptxt, text))) ||
1322 ((ptxt) && (!text)))
1323 evas_object_textblock_text_markup_set(ep->object, text);
1325 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
1330 if (!chosen_desc->text.min_x)
1332 evas_object_resize(ep->object, params->w, params->h);
1333 evas_object_textblock_size_formatted_get(ep->object, &tw,
1337 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1338 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1339 &ins_r, &ins_t, &ins_b);
1340 mw = ins_l + tw + ins_r;
1341 mh = ins_t + th + ins_b;
1342 if (minw && chosen_desc->text.min_x)
1344 if (mw > *minw) *minw = mw;
1346 if (minh && chosen_desc->text.min_y)
1348 if (mh > *minh) *minh = mh;
1353 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1358 if (!chosen_desc->text.max_x)
1360 evas_object_resize(ep->object, params->w, params->h);
1361 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
1364 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1365 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
1367 mw = ins_l + tw + ins_r;
1368 mh = ins_t + th + ins_b;
1369 if (maxw && chosen_desc->text.max_x)
1371 if (mw > *maxw) *maxw = mw;
1372 if (minw && (*maxw < *minw)) *maxw = *minw;
1374 if (maxh && chosen_desc->text.max_y)
1376 if (mh > *maxh) *maxh = mh;
1377 if (minh && (*maxh < *minh)) *maxh = *minh;
1381 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
1386 _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
1387 Edje_Calc_Params *params,
1388 Edje_Part_Description_Text *chosen_desc)
1390 /* FIXME: this is just an hack. */
1393 if (sc == ZERO) sc = _edje_scale;
1394 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
1396 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
1397 NULL, NULL, NULL, NULL);
1402 _edje_part_recalc_single_text(FLOAT_T sc __UNUSED__,
1405 Edje_Part_Description_Text *desc,
1406 Edje_Part_Description_Text *chosen_desc,
1407 Edje_Calc_Params *params,
1408 int *minw, int *minh,
1409 int *maxw, int *maxh)
1410 #define RECALC_SINGLE_TEXT_USING_APPLY 1
1411 #if RECALC_SINGLE_TEXT_USING_APPLY
1415 * Original _edje_part_recalc_single_text() was not working as
1416 * expected since it was not doing size fit, range, ellipsis and so
1419 * The purpose of this function compared with
1420 * _edje_text_recalc_apply() is to be faster, not calling Evas update
1421 * functions. However for text this is quite difficult given that to
1422 * fit we need to set the font, size, style, etc. If it was done
1423 * correctly, we'd save some calls to move and some color sets,
1424 * however those shouldn't matter much in the overall picture.
1426 * I've changed this to force applying the value, it should be more
1427 * correct and not so slow. The previous code is kept below for
1428 * reference but should be removed before next release!
1430 * -- Gustavo Barbieri at 20-Aug-2011
1433 int tw, th, mw, mh, l, r, t, b, size;
1436 _edje_text_class_font_get(ed, desc, &size, &sfont);
1438 params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */
1440 _edje_text_recalc_apply(ed, ep, params, chosen_desc);
1442 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1444 if ((!chosen_desc) ||
1445 ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) &&
1446 (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y)))
1449 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1450 evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
1455 if (chosen_desc->text.max_x)
1457 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1459 if (chosen_desc->text.max_y)
1461 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1463 if (chosen_desc->text.min_x)
1465 if (mw > *minw) *minw = mw;
1467 if (chosen_desc->text.min_y)
1469 if (mh > *minh) *minh = mh;
1482 int inlined_font = 0;
1484 /* Update a object_text part */
1486 if (chosen_desc->text.id_source >= 0)
1487 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1489 ep->text.source = NULL;
1491 if (chosen_desc->text.id_text_source >= 0)
1492 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1494 ep->text.text_source = NULL;
1496 if (ep->text.text_source)
1497 text = edje_string_get(&(((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text));
1499 text = edje_string_get(&chosen_desc->text.text);
1501 if (ep->text.source)
1502 font = _edje_text_class_font_get(ed, ((Edje_Part_Description_Text*)ep->text.source->chosen_description), &size, &sfont);
1504 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
1506 if (!font) font = "";
1508 if (ep->text.text_source)
1510 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1514 if (ep->text.text) text = ep->text.text;
1517 if (ep->text.source)
1519 if (ep->text.source->text.font) font = ep->text.source->text.font;
1520 if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
1524 if (ep->text.font) font = ep->text.font;
1525 if (ep->text.size > 0) size = ep->text.size;
1527 if (!text) text = "";
1529 /* check if the font is embedded in the .eet */
1530 if (ed->file->fonts)
1532 Edje_Font_Directory_Entry *fnt;
1534 fnt = eina_hash_find(ed->file->fonts, font);
1540 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
1541 font2 = alloca(len);
1542 sprintf(font2, "edje/fonts/%s", font);
1547 if (ep->part->scale)
1548 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1551 evas_object_text_font_source_set(ep->object, ed->path);
1553 else evas_object_text_font_source_set(ep->object, NULL);
1555 if ((_edje_fontset_append) && (font))
1559 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
1562 strcpy(font2, font);
1564 strcat(font2, _edje_fontset_append);
1565 evas_object_text_font_set(ep->object, font2, size);
1570 evas_object_text_font_set(ep->object, font, size);
1571 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) ||
1572 (chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1575 Evas_Text_Style_Type
1576 style = EVAS_TEXT_STYLE_PLAIN,
1577 shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT;
1578 const Evas_Text_Style_Type styles[] = {
1579 EVAS_TEXT_STYLE_PLAIN,
1580 EVAS_TEXT_STYLE_PLAIN,
1581 EVAS_TEXT_STYLE_OUTLINE,
1582 EVAS_TEXT_STYLE_SOFT_OUTLINE,
1583 EVAS_TEXT_STYLE_SHADOW,
1584 EVAS_TEXT_STYLE_SOFT_SHADOW,
1585 EVAS_TEXT_STYLE_OUTLINE_SHADOW,
1586 EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW,
1587 EVAS_TEXT_STYLE_FAR_SHADOW,
1588 EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
1589 EVAS_TEXT_STYLE_GLOW
1591 const Evas_Text_Style_Type shadows[] = {
1592 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT,
1593 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM,
1594 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT,
1595 EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT,
1596 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT,
1597 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP,
1598 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT,
1599 EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT
1602 if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC)
1603 < EDJE_TEXT_EFFECT_LAST)
1604 style = styles[ep->part->effect];
1606 [(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4];
1607 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow);
1609 evas_object_text_style_set(ep->object, style);
1610 evas_object_text_text_set(ep->object, text);
1611 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1612 if (chosen_desc->text.max_x)
1615 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1617 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1619 if (chosen_desc->text.max_y)
1622 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1624 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1626 if (chosen_desc->text.min_x)
1629 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1631 if (mw > *minw) *minw = mw;
1633 if (chosen_desc->text.min_y)
1636 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1638 if (mh > *minh) *minh = mh;
1641 if (sfont) free(sfont);
1644 /* FIXME: Do we really need to call it twice if chosen_desc ? */
1646 _edje_text_class_font_get(ed, desc, &size, &sfont);
1648 params->type.text.size = size;
1653 _edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min)
1659 *start += TO_INT(SCALE(align, (*length - min)));
1666 _edje_part_recalc_single_min(Edje_Part_Description_Common *desc,
1667 Edje_Calc_Params *params,
1669 Edje_Internal_Aspect aspect)
1675 w = params->w ? params->w : 99999;
1676 h = params->h ? params->h : 99999;
1680 case EDJE_ASPECT_PREFER_NONE:
1682 case EDJE_ASPECT_PREFER_VERTICAL:
1683 tmp = minh * params->w / h;
1689 case EDJE_ASPECT_PREFER_HORIZONTAL:
1690 tmp = minw * params->h / w;
1696 case EDJE_ASPECT_PREFER_SOURCE:
1697 case EDJE_ASPECT_PREFER_BOTH:
1698 tmp = minh * params->w / h;
1705 tmp = minw * params->h / w;
1715 _edje_part_recalc_single_min_length(desc->align.x, ¶ms->x, ¶ms->w, minw);
1716 _edje_part_recalc_single_min_length(desc->align.y, ¶ms->y, ¶ms->h, minh);
1720 _edje_part_recalc_single_max_length(FLOAT_T align, int *start, int *length, int max)
1726 *start += TO_INT(SCALE(align, (*length - max)));
1733 _edje_part_recalc_single_max(Edje_Part_Description_Common *desc,
1734 Edje_Calc_Params *params,
1736 Edje_Internal_Aspect aspect)
1742 w = params->w ? params->w : 99999;
1743 h = params->h ? params->h : 99999;
1747 case EDJE_ASPECT_PREFER_NONE:
1749 case EDJE_ASPECT_PREFER_VERTICAL:
1750 tmp = maxh * params->w / h;
1756 case EDJE_ASPECT_PREFER_HORIZONTAL:
1757 tmp = maxw * params->h / w;
1763 case EDJE_ASPECT_PREFER_SOURCE:
1764 case EDJE_ASPECT_PREFER_BOTH:
1765 tmp = maxh * params->w / h;
1772 tmp = maxw * params->h / w;
1782 _edje_part_recalc_single_max_length(desc->align.x, ¶ms->x, ¶ms->w, maxw);
1783 _edje_part_recalc_single_max_length(desc->align.y, ¶ms->y, ¶ms->h, maxh);
1787 _edje_part_recalc_single_drag(Edje_Real_Part *ep,
1788 Edje_Real_Part *confine_to,
1789 Edje_Calc_Params *params,
1800 /* complex dragable params */
1801 v = SCALE(ep->drag->size.x, confine_to->w);
1803 if ((minw > 0) && (TO_INT(v) < minw)) params->w = minw;
1804 else if ((maxw >= 0) && (TO_INT(v) > maxw)) params->w = maxw;
1805 else params->w = TO_INT(v);
1807 offset = TO_INT(SCALE(ep->drag->x, (confine_to->w - params->w)))
1809 if (ep->part->dragable.step_x > 0)
1811 params->x = confine_to->x +
1812 ((offset / ep->part->dragable.step_x) * ep->part->dragable.step_x);
1814 else if (ep->part->dragable.count_x > 0)
1816 step = (confine_to->w - params->w) / ep->part->dragable.count_x;
1817 if (step < 1) step = 1;
1818 params->x = confine_to->x +
1819 ((offset / step) * step);
1821 params->req_drag.x = params->x;
1822 params->req_drag.w = params->w;
1824 v = SCALE(ep->drag->size.y, confine_to->h);
1826 if ((minh > 0) && (TO_INT(v) < minh)) params->h = minh;
1827 else if ((maxh >= 0) && (TO_INT(v) > maxh)) params->h = maxh;
1828 else params->h = TO_INT(v);
1830 offset = TO_INT(SCALE(ep->drag->y, (confine_to->h - params->h)))
1832 if (ep->part->dragable.step_y > 0)
1834 params->y = confine_to->y +
1835 ((offset / ep->part->dragable.step_y) * ep->part->dragable.step_y);
1837 else if (ep->part->dragable.count_y > 0)
1839 step = (confine_to->h - params->h) / ep->part->dragable.count_y;
1840 if (step < 1) step = 1;
1841 params->y = confine_to->y +
1842 ((offset / step) * step);
1844 params->req_drag.y = params->y;
1845 params->req_drag.h = params->h;
1847 /* limit to confine */
1848 if (params->x < confine_to->x)
1850 params->x = confine_to->x;
1852 if ((params->x + params->w) > (confine_to->x + confine_to->w))
1854 params->x = confine_to->x + confine_to->w - params->w;
1856 if (params->y < confine_to->y)
1858 params->y = confine_to->y;
1860 if ((params->y + params->h) > (confine_to->y + confine_to->h))
1862 params->y = confine_to->y + confine_to->h - params->h;
1867 /* simple dragable params */
1868 params->x += TO_INT(ep->drag->x) + ep->drag->tmp.x;
1869 params->req_drag.x = params->x;
1870 params->req_drag.w = params->w;
1872 params->y += TO_INT(ep->drag->y) + ep->drag->tmp.y;
1873 params->req_drag.y = params->y;
1874 params->req_drag.h = params->h;
1879 _edje_part_recalc_single_fill(Edje_Real_Part *ep,
1880 Edje_Part_Description_Spec_Fill *fill,
1881 Edje_Calc_Params *params)
1886 params->smooth = fill->smooth;
1888 if (fill->type == EDJE_FILL_TYPE_TILE)
1889 evas_object_image_size_get(ep->object, &fw, NULL);
1893 params->type.common.fill.x = fill->pos_abs_x
1894 + TO_INT(SCALE(fill->pos_rel_x, fw));
1895 params->type.common.fill.w = fill->abs_x
1896 + TO_INT(SCALE(fill->rel_x, fw));
1898 if (fill->type == EDJE_FILL_TYPE_TILE)
1899 evas_object_image_size_get(ep->object, NULL, &fh);
1903 params->type.common.fill.y = fill->pos_abs_y
1904 + TO_INT(SCALE(fill->pos_rel_y, fh));
1905 params->type.common.fill.h = fill->abs_y
1906 + TO_INT(SCALE(fill->rel_y, fh));
1908 params->type.common.fill.angle = fill->angle;
1909 params->type.common.fill.spread = fill->spread;
1913 _edje_part_recalc_single_min_max(FLOAT_T sc,
1915 Edje_Part_Description_Common *desc,
1916 int *minw, int *minh,
1917 int *maxw, int *maxh)
1919 *minw = desc->min.w;
1920 if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw));
1921 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
1922 (ep->typedata.swallow))
1924 if (ep->typedata.swallow->swallow_params.min.w > desc->min.w)
1925 *minw = ep->typedata.swallow->swallow_params.min.w;
1928 if (ep->edje->calc_only)
1930 if (desc->minmul.have)
1932 FLOAT_T mmw = desc->minmul.w;
1933 if (mmw != FROM_INT(1)) *minw = TO_INT(SCALE(mmw, *minw));
1937 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
1938 (ep->typedata.swallow))
1940 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */
1941 if ((ep->typedata.swallow->swallow_params.max.w <= 0) ||
1942 (ep->typedata.swallow->swallow_params.max.w == EDJE_INF_MAX_W))
1944 *maxw = desc->max.w;
1947 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1948 if (*maxw < 1) *maxw = 1;
1953 if (desc->max.w <= 0)
1954 *maxw = ep->typedata.swallow->swallow_params.max.w;
1957 *maxw = desc->max.w;
1960 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1961 if (*maxw < 1) *maxw = 1;
1963 if (ep->typedata.swallow->swallow_params.max.w < *maxw)
1964 *maxw = ep->typedata.swallow->swallow_params.max.w;
1970 *maxw = desc->max.w;
1973 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1974 if (*maxw < 1) *maxw = 1;
1977 if ((ep->edje->calc_only) && (desc->minmul.have) &&
1978 (desc->minmul.w != FROM_INT(1))) *maxw = *minw;
1981 if (*maxw < *minw) *maxw = *minw;
1984 *minh = desc->min.h;
1985 if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh));
1986 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
1987 (ep->typedata.swallow))
1989 if (ep->typedata.swallow->swallow_params.min.h > desc->min.h)
1990 *minh = ep->typedata.swallow->swallow_params.min.h;
1993 if (ep->edje->calc_only)
1995 if (desc->minmul.have)
1997 FLOAT_T mmh = desc->minmul.h;
1998 if (mmh != FROM_INT(1)) *minh = TO_INT(SCALE(mmh, *minh));
2002 if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
2003 (ep->typedata.swallow))
2005 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
2006 if ((ep->typedata.swallow->swallow_params.max.h <= 0) ||
2007 (ep->typedata.swallow->swallow_params.max.h == EDJE_INF_MAX_H))
2009 *maxh = desc->max.h;
2012 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
2013 if (*maxh < 1) *maxh = 1;
2018 if (desc->max.h <= 0)
2019 *maxh = ep->typedata.swallow->swallow_params.max.h;
2022 *maxh = desc->max.h;
2025 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
2026 if (*maxh < 1) *maxh = 1;
2028 if (ep->typedata.swallow->swallow_params.max.h < *maxh)
2029 *maxh = ep->typedata.swallow->swallow_params.max.h;
2035 *maxh = desc->max.h;
2038 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
2039 if (*maxh < 1) *maxh = 1;
2042 if ((ep->edje->calc_only) && (desc->minmul.have) &&
2043 (desc->minmul.h != FROM_INT(1))) *maxh = *minh;
2046 if (*maxh < *minh) *maxh = *minh;
2051 _edje_part_recalc_single_map(Edje *ed,
2052 Edje_Real_Part *ep __UNUSED__,
2053 Edje_Real_Part *center,
2054 Edje_Real_Part *light,
2055 Edje_Real_Part *persp,
2056 Edje_Part_Description_Common *desc,
2057 Edje_Part_Description_Common *chosen_desc,
2058 Edje_Calc_Params *params)
2060 params->mapped = chosen_desc->map.on;
2061 params->lighted = params->mapped ? !!light : 0;
2062 params->persp_on = params->mapped ? !!persp : 0;
2064 if (!params->mapped) return ;
2068 params->map.center.x = ed->x + center->x + (center->w / 2);
2069 params->map.center.y = ed->y + center->y + (center->h / 2);
2073 params->map.center.x = ed->x + params->x + (params->w / 2);
2074 params->map.center.y = ed->y + params->y + (params->h / 2);
2076 params->map.center.z = 0;
2078 params->map.rotation.x = desc->map.rot.x;
2079 params->map.rotation.y = desc->map.rot.y;
2080 params->map.rotation.z = desc->map.rot.z;
2084 Edje_Part_Description_Common *light_desc2;
2087 params->map.light.x = ed->x + light->x + (light->w / 2);
2088 params->map.light.y = ed->y + light->y + (light->h / 2);
2090 pos = light->description_pos;
2091 pos2 = (pos < ZERO) ? ZERO : ((pos > FROM_INT(1)) ? FROM_INT(1) : pos);
2093 light_desc2 = light->param2 ? light->param2->description : NULL;
2095 /* take into account CURRENT state also */
2096 if (pos != ZERO && light_desc2)
2098 params->map.light.z = light->param1.description->persp.zplane +
2099 TO_INT(SCALE(pos, light_desc2->persp.zplane - light->param1.description->persp.zplane));
2100 params->map.light.r = light->param1.description->color.r +
2101 TO_INT(SCALE(pos2, light_desc2->color.r - light->param1.description->color.r));
2102 params->map.light.g = light->param1.description->color.g +
2103 TO_INT(SCALE(pos2, light_desc2->color.g - light->param1.description->color.g));
2104 params->map.light.b = light->param1.description->color.b +
2105 TO_INT(SCALE(pos2, light_desc2->color.b - light->param1.description->color.b));
2106 params->map.light.ar = light->param1.description->color2.r +
2107 TO_INT(SCALE(pos2, light_desc2->color2.r - light->param1.description->color2.r));
2108 params->map.light.ag = light->param1.description->color2.g +
2109 TO_INT(SCALE(pos2, light_desc2->color2.g - light->param1.description->color2.g));
2110 params->map.light.ab = light->param1.description->color2.b +
2111 TO_INT(SCALE(pos2, light_desc2->color2.b - light->param1.description->color2.b));
2115 params->map.light.z = light->param1.description->persp.zplane;
2116 params->map.light.r = light->param1.description->color.r;
2117 params->map.light.g = light->param1.description->color.g;
2118 params->map.light.b = light->param1.description->color.b;
2119 params->map.light.ar = light->param1.description->color2.r;
2120 params->map.light.ag = light->param1.description->color2.g;
2121 params->map.light.ab = light->param1.description->color2.b;
2129 params->map.persp.x = ed->x + persp->x + (persp->w / 2);
2130 params->map.persp.y = ed->y + persp->y + (persp->h / 2);
2132 pos = persp->description_pos;
2134 if (pos != 0 && persp->param2)
2136 params->map.persp.z = persp->param1.description->persp.zplane +
2137 TO_INT(SCALE(pos, persp->param2->description->persp.zplane -
2138 persp->param1.description->persp.zplane));
2139 params->map.persp.focal = persp->param1.description->persp.focal +
2140 TO_INT(SCALE(pos, persp->param2->description->persp.focal -
2141 persp->param1.description->persp.focal));
2145 params->map.persp.z = persp->param1.description->persp.zplane;
2146 params->map.persp.focal = persp->param1.description->persp.focal;
2152 _edje_part_recalc_single(Edje *ed,
2154 Edje_Part_Description_Common *desc,
2155 Edje_Part_Description_Common *chosen_desc,
2156 Edje_Real_Part *center,
2157 Edje_Real_Part *light,
2158 Edje_Real_Part *persp,
2159 Edje_Real_Part *rel1_to_x,
2160 Edje_Real_Part *rel1_to_y,
2161 Edje_Real_Part *rel2_to_x,
2162 Edje_Real_Part *rel2_to_y,
2163 Edje_Real_Part *confine_to,
2164 Edje_Calc_Params *params,
2167 Edje_Color_Class *cc = NULL;
2168 Edje_Internal_Aspect apref;
2169 int minw = 0, minh = 0, maxw = 0, maxh = 0;
2173 if (sc == ZERO) sc = _edje_scale;
2174 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh);
2176 /* relative coords of top left & bottom right */
2177 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params);
2180 apref = _edje_part_recalc_single_aspect(ed, ep, desc, params, &minw, &minh, &maxw, &maxh, pos);
2183 _edje_part_recalc_single_step(desc, params);
2185 /* if we have text that wants to make the min size the text size... */
2186 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2187 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
2188 else if (ep->part->type == EDJE_PART_TYPE_TEXT)
2189 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text*) desc, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
2191 if ((ep->part->type == EDJE_PART_TYPE_TABLE) &&
2192 (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) ||
2193 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v))))
2195 Evas_Coord lminw = 0, lminh = 0;
2197 evas_object_smart_need_recalculate_set(ep->object, 1);
2198 evas_object_smart_calculate(ep->object);
2199 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2200 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h)
2202 if (lminw > minw) minw = lminw;
2204 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)
2206 if (lminh > minh) minh = lminh;
2209 else if ((ep->part->type == EDJE_PART_TYPE_BOX) &&
2210 ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) ||
2211 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)))
2213 Evas_Coord lminw = 0, lminh = 0;
2215 evas_object_smart_need_recalculate_set(ep->object, 1);
2216 evas_object_smart_calculate(ep->object);
2217 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
2218 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h)
2220 if (lminw > minw) minw = lminw;
2222 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)
2224 if (lminh > minh) minh = lminh;
2227 else if ((ep->part->type == EDJE_PART_TYPE_IMAGE) &&
2228 (chosen_desc->min.limit || chosen_desc->max.limit))
2232 /* We only need pos to find the right image that would be displayed */
2233 /* Yes, if someone set aspect preference to SOURCE and also max,min
2234 to SOURCE, it will be under efficient, but who cares at the
2236 _edje_real_part_image_set(ed, ep, pos);
2237 evas_object_image_size_get(ep->object, &w, &h);
2239 if (chosen_desc->min.limit)
2241 if (w > minw) minw = w;
2242 if (h > minh) minh = h;
2244 if (chosen_desc->max.limit)
2246 if ((maxw <= 0) || (w < maxw)) maxw = w;
2247 if ((maxh <= 0) || (h < maxh)) maxh = h;
2251 /* remember what our size is BEFORE we go limit it */
2252 params->req.x = params->x;
2253 params->req.y = params->y;
2254 params->req.w = params->w;
2255 params->req.h = params->h;
2257 /* adjust for min size */
2258 _edje_part_recalc_single_min(desc, params, minw, minh, apref);
2260 /* adjust for max size */
2261 _edje_part_recalc_single_max(desc, params, maxw, maxh, apref);
2263 /* take care of dragable part */
2265 _edje_part_recalc_single_drag(ep, confine_to, params, minw, minh, maxw, maxh);
2268 if (ep->part->type == EDJE_PART_TYPE_IMAGE)
2269 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params);
2270 else if (ep->part->type == EDJE_PART_TYPE_PROXY)
2271 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params);
2273 if (ep->part->type != EDJE_PART_TYPE_SPACER)
2276 if ((desc->color_class) && (*desc->color_class))
2277 cc = _edje_color_class_find(ed, desc->color_class);
2281 params->color.r = (((int)cc->r + 1) * desc->color.r) >> 8;
2282 params->color.g = (((int)cc->g + 1) * desc->color.g) >> 8;
2283 params->color.b = (((int)cc->b + 1) * desc->color.b) >> 8;
2284 params->color.a = (((int)cc->a + 1) * desc->color.a) >> 8;
2288 params->color.r = desc->color.r;
2289 params->color.g = desc->color.g;
2290 params->color.b = desc->color.b;
2291 params->color.a = desc->color.a;
2296 params->visible = desc->visible;
2298 switch (ep->part->type)
2300 case EDJE_PART_TYPE_IMAGE:
2302 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) desc;
2305 params->type.common.spec.image.l = img_desc->image.border.l;
2306 params->type.common.spec.image.r = img_desc->image.border.r;
2308 params->type.common.spec.image.t = img_desc->image.border.t;
2309 params->type.common.spec.image.b = img_desc->image.border.b;
2311 params->type.common.spec.image.border_scale_by = img_desc->image.border.scale_by;
2314 case EDJE_PART_TYPE_TEXT:
2315 case EDJE_PART_TYPE_TEXTBLOCK:
2317 Edje_Part_Description_Text *text_desc = (Edje_Part_Description_Text*) desc;
2320 params->type.text.align.x = text_desc->text.align.x;
2321 params->type.text.align.y = text_desc->text.align.y;
2322 params->type.text.elipsis = text_desc->text.elipsis;
2327 params->type.text.color2.r = (((int)cc->r2 + 1) * text_desc->common.color2.r) >> 8;
2328 params->type.text.color2.g = (((int)cc->g2 + 1) * text_desc->common.color2.g) >> 8;
2329 params->type.text.color2.b = (((int)cc->b2 + 1) * text_desc->common.color2.b) >> 8;
2330 params->type.text.color2.a = (((int)cc->a2 + 1) * text_desc->common.color2.a) >> 8;
2331 params->type.text.color3.r = (((int)cc->r3 + 1) * text_desc->text.color3.r) >> 8;
2332 params->type.text.color3.g = (((int)cc->g3 + 1) * text_desc->text.color3.g) >> 8;
2333 params->type.text.color3.b = (((int)cc->b3 + 1) * text_desc->text.color3.b) >> 8;
2334 params->type.text.color3.a = (((int)cc->a3 + 1) * text_desc->text.color3.a) >> 8;
2338 params->type.text.color2.r = text_desc->common.color2.r;
2339 params->type.text.color2.g = text_desc->common.color2.g;
2340 params->type.text.color2.b = text_desc->common.color2.b;
2341 params->type.text.color2.a = text_desc->common.color2.a;
2342 params->type.text.color3.r = text_desc->text.color3.r;
2343 params->type.text.color3.g = text_desc->text.color3.g;
2344 params->type.text.color3.b = text_desc->text.color3.b;
2345 params->type.text.color3.a = text_desc->text.color3.a;
2350 case EDJE_PART_TYPE_SPACER:
2351 case EDJE_PART_TYPE_RECTANGLE:
2352 case EDJE_PART_TYPE_BOX:
2353 case EDJE_PART_TYPE_TABLE:
2354 case EDJE_PART_TYPE_SWALLOW:
2355 case EDJE_PART_TYPE_GROUP:
2356 case EDJE_PART_TYPE_PROXY:
2358 case EDJE_PART_TYPE_GRADIENT:
2359 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2365 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
2369 _edje_table_recalc_apply(Edje *ed __UNUSED__,
2371 Edje_Calc_Params *p3 __UNUSED__,
2372 Edje_Part_Description_Table *chosen_desc)
2374 evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous);
2375 evas_object_table_align_set(ep->object, TO_DOUBLE(chosen_desc->table.align.x), TO_DOUBLE(chosen_desc->table.align.y));
2376 evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y);
2377 if (evas_object_smart_need_recalculate_get(ep->object))
2379 evas_object_smart_need_recalculate_set(ep->object, 0);
2380 evas_object_smart_calculate(ep->object);
2385 _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos)
2390 if (pos >= FROM_DOUBLE(0.5))
2391 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2393 part_id = chosen_desc->proxy.id;
2395 if ((p3->type.common.fill.w == 0) || (p3->type.common.fill.h == 0) ||
2398 evas_object_image_source_set(ep->object, NULL);
2401 pp = ed->table_parts[part_id % ed->table_parts_size];
2403 if (pp->nested_smart) /* using nested_smart for nested parts */
2405 evas_object_image_source_set(ep->object, pp->nested_smart);
2409 switch (pp->part->type)
2411 case EDJE_PART_TYPE_IMAGE:
2412 case EDJE_PART_TYPE_TEXT:
2413 case EDJE_PART_TYPE_TEXTBLOCK:
2414 case EDJE_PART_TYPE_RECTANGLE:
2415 case EDJE_PART_TYPE_BOX:
2416 case EDJE_PART_TYPE_TABLE:
2417 case EDJE_PART_TYPE_PROXY:
2418 evas_object_image_source_set(ep->object, pp->object);
2420 case EDJE_PART_TYPE_GRADIENT:
2421 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
2423 case EDJE_PART_TYPE_GROUP:
2424 case EDJE_PART_TYPE_SWALLOW:
2425 case EDJE_PART_TYPE_EXTERNAL:
2426 if ((pp->type == EDJE_RP_TYPE_SWALLOW) &&
2427 (pp->typedata.swallow))
2429 evas_object_image_source_set(ep->object, pp->typedata.swallow->swallowed_object);
2432 case EDJE_PART_TYPE_SPACER:
2433 /* FIXME: detect that at compile time and prevent it */
2438 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2439 p3->type.common.fill.w, p3->type.common.fill.h);
2440 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2441 evas_object_image_source_visible_set(ep->object, chosen_desc->proxy.source_visible);
2442 evas_object_image_source_clip_set(ep->object, chosen_desc->proxy.source_clip);
2446 _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos)
2451 if (sc == 0.0) sc = _edje_scale;
2452 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
2453 p3->type.common.fill.w, p3->type.common.fill.h);
2454 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
2455 if (chosen_desc->image.border.scale)
2457 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2459 FLOAT_T sc2 = MUL(sc, p3->type.common.spec.image.border_scale_by);
2460 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc2));
2463 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc));
2467 if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
2468 evas_object_image_border_scale_set
2469 (ep->object, TO_DOUBLE(p3->type.common.spec.image.border_scale_by));
2471 evas_object_image_border_scale_set(ep->object, 1.0);
2473 evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r,
2474 p3->type.common.spec.image.t, p3->type.common.spec.image.b);
2475 if (chosen_desc->image.border.no_fill == 0)
2476 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_DEFAULT);
2477 else if (chosen_desc->image.border.no_fill == 1)
2478 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE);
2479 else if (chosen_desc->image.border.no_fill == 2)
2480 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID);
2482 _edje_real_part_image_set(ed, ep, pos);
2485 static Edje_Real_Part *
2486 _edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state)
2488 Edje_Real_Part *result = NULL;
2490 if (id >= 0 && id != ep->part->id)
2492 result = ed->table_parts[id % ed->table_parts_size];
2495 if (!result->calculated) _edje_part_recalc(ed, result, flags, NULL);
2496 #ifdef EDJE_CALC_CACHE
2497 if (state) *state = result->state;
2507 _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
2509 #ifdef EDJE_CALC_CACHE
2510 Eina_Bool proxy_invalidate = EINA_FALSE;
2515 Edje_Calc_Params lp1, lp2;
2523 Edje_Real_Part *center[2] = { NULL, NULL };
2524 Edje_Real_Part *light[2] = { NULL, NULL };
2525 Edje_Real_Part *persp[2] = { NULL, NULL };
2526 Edje_Calc_Params *p1, *pf;
2527 Edje_Part_Description_Common *chosen_desc;
2528 Edje_Real_Part *confine_to = NULL;
2529 FLOAT_T pos = ZERO, pos2;
2530 Edje_Calc_Params lp3;
2532 /* GRADIENT ARE GONE, WE MUST IGNORE IT FROM OLD FILE. */
2533 if (ep->part->type == EDJE_PART_TYPE_GRADIENT)
2535 ERR("GRADIENT spotted during recalc ! That should never happen ! Send your edje file to devel ml.");
2539 if ((ep->calculated & FLAG_XY) == FLAG_XY && !state)
2543 if (ep->calculating & flags)
2546 const char *axes = "NONE", *faxes = "NONE";
2548 if ((ep->calculating & FLAG_X) &&
2549 (ep->calculating & FLAG_Y))
2551 else if ((ep->calculating & FLAG_X))
2553 else if ((ep->calculating & FLAG_Y))
2556 if ((flags & FLAG_X) &&
2559 else if ((flags & FLAG_X))
2561 else if ((flags & FLAG_Y))
2563 ERR("Circular dependency when calculating part \"%s\". "
2564 "Already calculating %s [%02x] axes. "
2565 "Need to calculate %s [%02x] axes",
2567 axes, ep->calculating,
2573 if (ep->part->scale &&
2574 ep->part->type == EDJE_PART_TYPE_GROUP &&
2575 ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
2576 (ep->typedata.swallow)) &&
2577 ep->typedata.swallow->swallowed_object)
2579 edje_object_scale_set(ep->typedata.swallow->swallowed_object, TO_DOUBLE(ed->scale));
2581 if (ep->description_pos > FROM_DOUBLE(0.5) && ep->param2)
2583 edje_object_update_hints_set(ep->typedata.swallow->swallowed_object, ep->param2->description->min.limit);
2587 edje_object_update_hints_set(ep->typedata.swallow->swallowed_object, ep->param1.description->min.limit);
2589 if (edje_object_update_hints_get(ep->typedata.swallow->swallowed_object))
2593 ted = _edje_fetch(ep->typedata.swallow->swallowed_object);
2594 _edje_recalc_do(ted);
2598 #ifdef EDJE_CALC_CACHE
2599 if (ep->state == ed->state && !state)
2605 ep->calculating |= flags & FLAG_X;
2606 if (ep->param1.rel1_to_x)
2608 _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL);
2609 #ifdef EDJE_CALC_CACHE
2610 state1 = ep->param1.rel1_to_x->state;
2613 if (ep->param1.rel2_to_x)
2615 _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL);
2616 #ifdef EDJE_CALC_CACHE
2617 if (state1 < ep->param1.rel2_to_x->state)
2618 state1 = ep->param1.rel2_to_x->state;
2623 if (ep->param2->rel1_to_x)
2625 _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL);
2626 #ifdef EDJE_CALC_CACHE
2627 state2 = ep->param2->rel1_to_x->state;
2630 if (ep->param2->rel2_to_x)
2632 _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL);
2633 #ifdef EDJE_CALC_CACHE
2634 if (state2 < ep->param2->rel2_to_x->state)
2635 state2 = ep->param2->rel2_to_x->state;
2642 ep->calculating |= flags & FLAG_Y;
2643 if (ep->param1.rel1_to_y)
2645 _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL);
2646 #ifdef EDJE_CALC_CACHE
2647 if (state1 < ep->param1.rel1_to_y->state)
2648 state1 = ep->param1.rel1_to_y->state;
2651 if (ep->param1.rel2_to_y)
2653 _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL);
2654 #ifdef EDJE_CALC_CACHE
2655 if (state1 < ep->param1.rel2_to_y->state)
2656 state1 = ep->param1.rel2_to_y->state;
2661 if (ep->param2->rel1_to_y)
2663 _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL);
2664 #ifdef EDJE_CALC_CACHE
2665 if (state2 < ep->param2->rel1_to_y->state)
2666 state2 = ep->param2->rel1_to_y->state;
2669 if (ep->param2->rel2_to_y)
2671 _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL);
2672 #ifdef EDJE_CALC_CACHE
2673 if (state2 < ep->param2->rel2_to_y->state)
2674 state2 = ep->param2->rel2_to_y->state;
2679 if (ep->drag && ep->drag->confine_to)
2681 confine_to = ep->drag->confine_to;
2682 _edje_part_recalc(ed, confine_to, flags, NULL);
2683 #ifdef EDJE_CALC_CACHE
2684 statec = confine_to->state;
2687 // if (ep->text.source) _edje_part_recalc(ed, ep->text.source, flags);
2688 // if (ep->text.text_source) _edje_part_recalc(ed, ep->text.text_source, flags);
2690 /* actually calculate now */
2691 chosen_desc = ep->chosen_description;
2694 ep->calculating = FLAG_NONE;
2695 ep->calculated |= flags;
2699 pos = ep->description_pos;
2701 if (ep->part->type == EDJE_PART_TYPE_PROXY)
2706 if (pos >= FROM_DOUBLE(0.5))
2707 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2709 part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id;
2711 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL);
2712 #ifdef EDJE_CALC_CACHE
2713 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE;
2717 /* Recalc if needed the map center && light source */
2718 if (ep->param1.description->map.on)
2720 center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1);
2721 light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1);
2723 if (chosen_desc->map.persp_on)
2725 persp[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_persp, &statep1);
2729 if (ep->param2 && ep->param2->description->map.on)
2731 center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2);
2732 light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2);
2734 if (chosen_desc->map.persp_on)
2736 persp[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_persp, &statep2);
2740 #ifndef EDJE_CALC_CACHE
2746 if (ep->param1.description)
2748 #ifdef EDJE_CALC_CACHE
2749 if (ed->all_part_change ||
2751 state1 >= ep->param1.state ||
2752 statec >= ep->param1.state ||
2753 statec1 >= ep->param1.state ||
2754 statel1 >= ep->param1.state ||
2755 statep1 >= ep->param1.state ||
2758 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2761 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
2762 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
2765 #ifdef EDJE_CALC_CACHE
2766 if (flags == FLAG_XY)
2767 ep->param1.state = ed->state;
2773 int beginning_pos, part_type;
2774 Edje_Calc_Params *p2, *p3;
2778 /* FIXME: except for text, we don't need in that case to recalc p1 at all*/
2779 memcpy(p1, ep->current, sizeof (Edje_Calc_Params));
2782 p1->map.center.x += ed->x;
2783 p1->map.center.y += ed->y;
2784 p1->map.light.x += ed->x;
2785 p1->map.light.y += ed->y;
2786 p1->map.persp.x += ed->x;
2787 p1->map.persp.y += ed->y;
2792 #ifndef EDJE_CALC_CACHE
2795 p2 = &ep->param2->p;
2797 if (ed->all_part_change ||
2799 state2 >= ep->param2->state ||
2800 statec >= ep->param2->state ||
2801 statec2 >= ep->param2->state ||
2802 statel2 >= ep->param2->state ||
2803 statep2 >= ep->param2->state ||
2806 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2809 _edje_part_recalc_single(ed, ep, ep->param2->description,
2811 center[1], light[1], persp[1],
2812 ep->param2->rel1_to_x,
2813 ep->param2->rel1_to_y,
2814 ep->param2->rel2_to_x,
2815 ep->param2->rel2_to_y,
2818 #ifdef EDJE_CALC_CACHE
2819 if (flags == FLAG_XY)
2820 ep->param2->state = ed->state;
2825 if (pos2 < ZERO) pos2 = ZERO;
2826 else if (pos2 > FROM_INT(1)) pos2 = FROM_INT(1);
2827 beginning_pos = (pos < FROM_DOUBLE(0.5));
2828 part_type = ep->part->type;
2830 /* visible is special */
2831 if ((p1->visible) && (!p2->visible))
2832 p3->visible = (pos != FROM_INT(1));
2833 else if ((!p1->visible) && (p2->visible))
2834 p3->visible = (pos != ZERO);
2836 p3->visible = p1->visible;
2838 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth;
2840 /* FIXME: do x and y separately base on flag */
2841 #define FINTP(_x1, _x2, _p) \
2844 : ADD(FROM_INT(_x1), \
2845 SCALE((_p), (_x2) - (_x1))))
2847 #define FFP(_x1, _x2, _p) \
2850 : ADD(_x1, MUL(_p, SUB(_x2, _x1))));
2852 #define INTP(_x1, _x2, _p) TO_INT(FINTP(_x1, _x2, _p))
2854 p3->x = INTP(p1->x, p2->x, pos);
2855 p3->y = INTP(p1->y, p2->y, pos);
2856 p3->w = INTP(p1->w, p2->w, pos);
2857 p3->h = INTP(p1->h, p2->h, pos);
2859 p3->req.x = INTP(p1->req.x, p2->req.x, pos);
2860 p3->req.y = INTP(p1->req.y, p2->req.y, pos);
2861 p3->req.w = INTP(p1->req.w, p2->req.w, pos);
2862 p3->req.h = INTP(p1->req.h, p2->req.h, pos);
2864 if (ep->part->dragable.x)
2866 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos);
2867 p3->req_drag.w = INTP(p1->req_drag.w, p2->req_drag.w, pos);
2869 if (ep->part->dragable.y)
2871 p3->req_drag.y = INTP(p1->req_drag.y, p2->req_drag.y, pos);
2872 p3->req_drag.h = INTP(p1->req_drag.h, p2->req_drag.h, pos);
2875 p3->color.r = INTP(p1->color.r, p2->color.r, pos2);
2876 p3->color.g = INTP(p1->color.g, p2->color.g, pos2);
2877 p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
2878 p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
2882 case EDJE_PART_TYPE_IMAGE:
2883 p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos);
2884 p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos);
2885 p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos);
2886 p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos);
2887 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);
2888 case EDJE_PART_TYPE_PROXY:
2889 p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos);
2890 p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos);
2891 p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos);
2892 p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos);
2894 case EDJE_PART_TYPE_TEXT:
2895 p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos);
2896 case EDJE_PART_TYPE_TEXTBLOCK:
2897 p3->type.text.color2.r = INTP(p1->type.text.color2.r, p2->type.text.color2.r, pos2);
2898 p3->type.text.color2.g = INTP(p1->type.text.color2.g, p2->type.text.color2.g, pos2);
2899 p3->type.text.color2.b = INTP(p1->type.text.color2.b, p2->type.text.color2.b, pos2);
2900 p3->type.text.color2.a = INTP(p1->type.text.color2.a, p2->type.text.color2.a, pos2);
2902 p3->type.text.color3.r = INTP(p1->type.text.color3.r, p2->type.text.color3.r, pos2);
2903 p3->type.text.color3.g = INTP(p1->type.text.color3.g, p2->type.text.color3.g, pos2);
2904 p3->type.text.color3.b = INTP(p1->type.text.color3.b, p2->type.text.color3.b, pos2);
2905 p3->type.text.color3.a = INTP(p1->type.text.color3.a, p2->type.text.color3.a, pos2);
2907 p3->type.text.align.x = FFP(p1->type.text.align.x, p2->type.text.align.x, pos);
2908 p3->type.text.align.y = FFP(p1->type.text.align.y, p2->type.text.align.y, pos);
2909 p3->type.text.elipsis = TO_DOUBLE(FINTP(p1->type.text.elipsis, p2->type.text.elipsis, pos2));
2913 p3->mapped = p1->mapped;
2914 p3->persp_on = p3->mapped ? p1->persp_on | p2->persp_on : 0;
2915 p3->lighted = p3->mapped ? p1->lighted | p2->lighted : 0;
2918 p3->map.center.x = INTP(p1->map.center.x, p2->map.center.x, pos);
2919 p3->map.center.y = INTP(p1->map.center.y, p2->map.center.y, pos);
2920 p3->map.center.z = INTP(p1->map.center.z, p2->map.center.z, pos);
2921 p3->map.rotation.x = FFP(p1->map.rotation.x, p2->map.rotation.x, pos);
2922 p3->map.rotation.y = FFP(p1->map.rotation.y, p2->map.rotation.y, pos);
2923 p3->map.rotation.z = FFP(p1->map.rotation.z, p2->map.rotation.z, pos);
2925 #define MIX(P1, P2, P3, pos, info) \
2926 P3->info = P1->info + TO_INT(SCALE(pos, P2->info - P1->info));
2928 if (p1->lighted && p2->lighted)
2930 MIX(p1, p2, p3, pos, map.light.x);
2931 MIX(p1, p2, p3, pos, map.light.y);
2932 MIX(p1, p2, p3, pos, map.light.z);
2933 MIX(p1, p2, p3, pos, map.light.r);
2934 MIX(p1, p2, p3, pos, map.light.g);
2935 MIX(p1, p2, p3, pos, map.light.b);
2936 MIX(p1, p2, p3, pos, map.light.ar);
2937 MIX(p1, p2, p3, pos, map.light.ag);
2938 MIX(p1, p2, p3, pos, map.light.ab);
2940 else if (p1->lighted)
2942 memcpy(&p3->map.light, &p1->map.light, sizeof (p1->map.light));
2944 else if (p2->lighted)
2946 memcpy(&p3->map.light, &p2->map.light, sizeof (p2->map.light));
2949 if (p1->persp_on && p2->persp_on)
2951 MIX(p1, p2, p3, pos, map.persp.x);
2952 MIX(p1, p2, p3, pos, map.persp.y);
2953 MIX(p1, p2, p3, pos, map.persp.z);
2954 MIX(p1, p2, p3, pos, map.persp.focal);
2956 else if (p1->persp_on)
2958 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.persp));
2960 else if (p2->persp_on)
2962 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.persp));
2973 if (!pf->persp_on && chosen_desc->map.persp_on)
2977 pf->map.persp.x = ed->persp->px;
2978 pf->map.persp.y = ed->persp->py;
2979 pf->map.persp.z = ed->persp->z0;
2980 pf->map.persp.focal = ed->persp->foc;
2984 const Edje_Perspective *ps;
2986 // fixme: a tad inefficient as this is a has lookup
2987 ps = edje_object_perspective_get(ed->obj);
2989 ps = edje_evas_global_perspective_get(evas_object_evas_get(ed->obj));
2992 pf->map.persp.x = ps->px;
2993 pf->map.persp.y = ps->py;
2994 pf->map.persp.z = ps->z0;
2995 pf->map.persp.focal = ps->foc;
2999 pf->map.persp.x = ed->x + (ed->w / 2);
3000 pf->map.persp.y = ed->y + (ed->h / 2);
3001 pf->map.persp.z = 0;
3002 pf->map.persp.focal = 1000;
3009 memcpy(state, pf, sizeof (Edje_Calc_Params));
3014 if (ep->drag && ep->drag->need_reset)
3020 _edje_part_dragable_calc(ed, ep, &dx, &dy);
3023 ep->drag->tmp.x = 0;
3024 ep->drag->tmp.y = 0;
3025 ep->drag->need_reset = 0;
3031 /* Common move, resize and color_set for all part. */
3032 switch (ep->part->type)
3034 case EDJE_PART_TYPE_IMAGE:
3036 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) chosen_desc;
3038 evas_object_image_scale_hint_set(ep->object,
3039 img_desc->image.scale_hint);
3041 case EDJE_PART_TYPE_PROXY:
3042 case EDJE_PART_TYPE_RECTANGLE:
3043 case EDJE_PART_TYPE_TEXTBLOCK:
3044 case EDJE_PART_TYPE_BOX:
3045 case EDJE_PART_TYPE_TABLE:
3046 evas_object_color_set(ep->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_hide(ep->object);
3056 evas_object_show(ep->object);
3057 /* move and resize are needed for all previous object => no break here. */
3058 case EDJE_PART_TYPE_SWALLOW:
3059 case EDJE_PART_TYPE_GROUP:
3060 case EDJE_PART_TYPE_EXTERNAL:
3061 /* visibility and color have no meaning on SWALLOW and GROUP part. */
3062 evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y);
3063 evas_object_resize(ep->object, pf->w, pf->h);
3065 if (ep->nested_smart)
3066 { /* Move, Resize all nested parts */
3067 /* Not really needed but will improve the bounding box evaluation done by Evas */
3068 evas_object_move(ep->nested_smart,
3069 ed->x + pf->x, ed->y + pf->y);
3070 evas_object_resize(ep->nested_smart, pf->w, pf->h);
3072 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
3073 _edje_entry_real_part_configure(ep);
3075 case EDJE_PART_TYPE_TEXT:
3076 /* This is correctly handle in _edje_text_recalc_apply at the moment. */
3078 case EDJE_PART_TYPE_GRADIENT:
3079 /* FIXME: definitivly remove this code when we switch to new format. */
3082 case EDJE_PART_TYPE_SPACER:
3083 /* We really should do nothing on SPACER part */
3087 /* Some object need special recalc. */
3088 switch (ep->part->type)
3090 case EDJE_PART_TYPE_TEXT:
3091 _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
3093 case EDJE_PART_TYPE_PROXY:
3094 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy*) chosen_desc, pos);
3096 case EDJE_PART_TYPE_IMAGE:
3097 _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image*) chosen_desc, pos);
3099 case EDJE_PART_TYPE_BOX:
3100 _edje_box_recalc_apply(ed, ep, pf, (Edje_Part_Description_Box*) chosen_desc);
3102 case EDJE_PART_TYPE_TABLE:
3103 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table*) chosen_desc);
3105 case EDJE_PART_TYPE_TEXTBLOCK:
3106 _edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
3108 case EDJE_PART_TYPE_EXTERNAL:
3109 case EDJE_PART_TYPE_RECTANGLE:
3110 case EDJE_PART_TYPE_SWALLOW:
3111 case EDJE_PART_TYPE_GROUP:
3112 /* Nothing special to do for this type of object. */
3114 case EDJE_PART_TYPE_GRADIENT:
3115 /* FIXME: definitivly remove this code when we switch to new format. */
3118 case EDJE_PART_TYPE_SPACER:
3119 /* We really should do nothing on SPACER part */
3123 if (((ep->type == EDJE_RP_TYPE_SWALLOW) &&
3124 (ep->typedata.swallow)) &&
3125 (ep->typedata.swallow->swallowed_object))
3127 //// the below really is wrong - swallow color shouldn't affect swallowed object
3128 //// color - the edje color as a WHOLE should though - and that should be
3129 //// done via the clipper anyway. this created bugs when objects had their
3130 //// colro set and were swallowed - then had their color changed.
3131 // evas_object_color_set(ep->typedata.swallow->swallowed_object,
3132 // (pf->color.r * pf->color.a) / 255,
3133 // (pf->color.g * pf->color.a) / 255,
3134 // (pf->color.b * pf->color.a) / 255,
3138 evas_object_move(ep->typedata.swallow->swallowed_object, ed->x + pf->x, ed->y + pf->y);
3139 evas_object_resize(ep->typedata.swallow->swallowed_object, pf->w, pf->h);
3140 evas_object_show(ep->typedata.swallow->swallowed_object);
3142 else evas_object_hide(ep->typedata.swallow->swallowed_object);
3143 mo = ep->typedata.swallow->swallowed_object;
3145 else mo = ep->object;
3146 if (chosen_desc->map.on && ep->part->type != EDJE_PART_TYPE_SPACER)
3148 static Evas_Map *map = NULL;
3150 ed->have_mapped_part = EINA_TRUE;
3151 // create map and populate with part geometry
3152 if (!map) map = evas_map_new(4);
3153 evas_map_util_points_populate_from_object(map, ep->object);
3154 if (ep->part->type == EDJE_PART_TYPE_IMAGE ||
3155 ((ep->part->type == EDJE_PART_TYPE_SWALLOW) &&
3156 (!strcmp(evas_object_type_get(mo), "image")))
3161 evas_object_image_size_get(mo, &iw, &ih);
3162 evas_map_point_image_uv_set(map, 0, 0.0, 0.0);
3163 evas_map_point_image_uv_set(map, 1, iw , 0.0);
3164 evas_map_point_image_uv_set(map, 2, iw , ih );
3165 evas_map_point_image_uv_set(map, 3, 0.0, ih );
3167 evas_map_util_3d_rotate(map,
3168 TO_DOUBLE(pf->map.rotation.x),
3169 TO_DOUBLE(pf->map.rotation.y),
3170 TO_DOUBLE(pf->map.rotation.z),
3171 pf->map.center.x, pf->map.center.y,
3174 // calculate light color & position etc. if there is one
3177 evas_map_util_3d_lighting(map,
3178 pf->map.light.x, pf->map.light.y, pf->map.light.z,
3179 pf->map.light.r, pf->map.light.g, pf->map.light.b,
3180 pf->map.light.ar, pf->map.light.ag, pf->map.light.ab);
3183 // calculate perspective point
3184 if (chosen_desc->map.persp_on)
3186 evas_map_util_3d_perspective(map,
3187 pf->map.persp.x, pf->map.persp.y, pf->map.persp.z,
3188 pf->map.persp.focal);
3191 // handle backface culling (object is facing away from view
3192 if (chosen_desc->map.backcull)
3196 if (evas_map_util_clockwise_get(map))
3197 evas_object_show(mo);
3198 else evas_object_hide(mo);
3203 if (chosen_desc->map.smooth) evas_map_smooth_set(map, 1);
3204 else evas_map_smooth_set(map, 0);
3206 if (chosen_desc->map.alpha) evas_map_alpha_set(map, 1);
3207 else evas_map_alpha_set(map, 0);
3210 if (ep->nested_smart)
3211 { /* Apply map to smart obj holding nested parts */
3212 evas_object_map_set(ep->nested_smart, map);
3213 evas_object_map_enable_set(ep->nested_smart, 1);
3217 evas_object_map_set(mo, map);
3218 evas_object_map_enable_set(mo, 1);
3223 if (ep->nested_smart)
3224 { /* Cancel map of smart obj holding nested parts */
3225 evas_object_map_enable_set(ep->nested_smart, 0);
3226 evas_object_map_set(ep->nested_smart, NULL);
3230 evas_object_map_enable_set(mo, 0);
3231 evas_object_map_set(mo, NULL);
3241 ep->calculated |= flags;
3242 ep->calculating = FLAG_NONE;
3244 #ifdef EDJE_CALC_CACHE
3245 if (ep->calculated == FLAG_XY)
3247 ep->state = ed->state;