1
#include "edje_private.h"
3
#include "../evas/canvas/evas_box_eo.h"
7
typedef struct _Edje_Transition_Animation_Data Edje_Transition_Animation_Data;
8
struct _Edje_Transition_Animation_Data
13
Evas_Coord x, y, w, h;
17
struct _Edje_Part_Box_Animation
21
Evas_Object_Box_Layout layout;
23
void (*free_data)(void *data);
28
Eina_Bool recalculate : 1;
31
double start_progress;
32
int box_start_w, box_start_h;
36
_edje_box_layout_find_all(const char *name, const char *name_alt, Evas_Object_Box_Layout *cb, void **data, void(**free_data) (void *data))
38
if (!_edje_box_layout_find(name, cb, data, free_data))
41
(!_edje_box_layout_find(name_alt, cb, data, free_data)))
43
ERR("box layout '%s' (fallback '%s') not available, using horizontal.",
45
*cb = evas_object_box_layout_horizontal;
53
_edje_box_layout_calculate_coords(Evas_Object *obj, Evas_Object_Box_Data *priv, Edje_Part_Box_Animation *anim)
56
Edje_Transition_Animation_Data *tad;
59
evas_object_geometry_get(obj, &x, &y, &anim->box_start_w, &anim->box_start_h);
60
EINA_LIST_FOREACH(anim->objs, l, tad)
62
evas_object_geometry_get(tad->obj, &tad->start.x, &tad->start.y,
63
&tad->start.w, &tad->start.h);
64
tad->start.x = tad->start.x - x;
65
tad->start.y = tad->start.y - y;
67
evas_object_box_padding_set(obj, anim->end.padding.x, anim->end.padding.y);
68
evas_object_box_align_set(obj, TO_DOUBLE(anim->end.align.x), TO_DOUBLE(anim->end.align.y));
70
anim->end.layout(obj, priv, anim->end.data);
71
else if (anim->start.layout)
72
anim->start.layout(obj, priv, anim->start.data);
74
EINA_LIST_FOREACH(anim->objs, l, tad)
76
evas_object_geometry_get(tad->obj, &tad->end.x, &tad->end.y,
77
&tad->end.w, &tad->end.h);
78
tad->end.x = tad->end.x - x;
79
tad->end.y = tad->end.y - y;
84
_edje_box_layout_exec(Evas_Object *obj, Edje_Part_Box_Animation *anim)
87
Edje_Transition_Animation_Data *tad;
88
Evas_Coord x, y, w, h;
89
Evas_Coord cur_x, cur_y, cur_w, cur_h;
92
evas_object_geometry_get(obj, &x, &y, &w, &h);
93
progress = (anim->progress - anim->start_progress) / (1 - anim->start_progress);
95
EINA_LIST_FOREACH(anim->objs, l, tad)
97
cur_x = x + (tad->start.x + ((tad->end.x - tad->start.x) * progress)) * (w / (double)anim->box_start_w);
98
cur_y = y + (tad->start.y + ((tad->end.y - tad->start.y) * progress)) * (h / (double)anim->box_start_h);
99
cur_w = (w / (double)anim->box_start_w) * (tad->start.w + ((tad->end.w - tad->start.w) * progress));
100
cur_h = (h / (double)anim->box_start_h) * (tad->start.h + ((tad->end.h - tad->start.h) * progress));
101
evas_object_move(tad->obj, cur_x, cur_y);
102
evas_object_resize(tad->obj, cur_w, cur_h);
107
_edje_box_layout(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data)
109
Edje_Part_Box_Animation *anim = data;
111
if (EINA_DBL_EQ(anim->progress, 0.0))
113
if (anim->start.layout)
115
evas_object_box_padding_set(obj, anim->start.padding.x, anim->start.padding.y);
116
evas_object_box_align_set(obj, TO_DOUBLE(anim->start.align.x), TO_DOUBLE(anim->start.align.y));
117
anim->start.layout(obj, priv, anim->start.data);
122
if (anim->recalculate)
124
_edje_box_layout_calculate_coords(obj, priv, anim);
125
anim->start_progress = anim->progress;
126
anim->recalculate = EINA_FALSE;
129
if ((anim->progress > 0) && (anim->start_progress < 1))
130
_edje_box_layout_exec(obj, anim);
134
_edje_box_layout_free_data(void *data)
136
Edje_Transition_Animation_Data *tad;
137
Edje_Part_Box_Animation *anim = data;
138
if (anim->start.free_data && anim->start.data)
139
anim->start.free_data(anim->start.data);
140
if (anim->end.free_data && anim->end.data)
141
anim->end.free_data(anim->end.data);
142
EINA_LIST_FREE(anim->objs, tad)
147
Edje_Part_Box_Animation *
148
_edje_box_layout_anim_new(Evas_Object *box)
150
Edje_Part_Box_Animation *anim = calloc(1, sizeof(Edje_Part_Box_Animation));
155
evas_object_box_layout_set(box, _edje_box_layout, anim, NULL);
161
_edje_box_recalc_apply(Edje *ed EINA_UNUSED, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_UNUSED, Edje_Part_Description_Box *chosen_desc)
163
Evas_Object_Box_Data *priv;
167
if ((ep->type != EDJE_RP_TYPE_CONTAINER) ||
168
(!ep->typedata.container)) return;
170
if ((ep->param2) && (NEQ(ep->description_pos, ZERO)))
172
Edje_Part_Description_Box *param2_desc = (Edje_Part_Description_Box *)ep->param2->description;
173
if (ep->typedata.container->anim->end.layout == NULL)
175
_edje_box_layout_find_all(param2_desc->box.layout, param2_desc->box.alt_layout, &ep->typedata.container->anim->end.layout, &ep->typedata.container->anim->end.data, &ep->typedata.container->anim->end.free_data);
176
ep->typedata.container->anim->end.padding.x = param2_desc->box.padding.x;
177
ep->typedata.container->anim->end.padding.y = param2_desc->box.padding.y;
178
ep->typedata.container->anim->end.align.x = param2_desc->box.align.x;
179
ep->typedata.container->anim->end.align.y = param2_desc->box.align.y;
181
priv = efl_data_scope_get(ep->object, EVAS_BOX_CLASS);
185
evas_object_box_padding_set(ep->object, ep->typedata.container->anim->start.padding.x, ep->typedata.container->anim->start.padding.y);
186
evas_object_box_align_set(ep->object, TO_DOUBLE(ep->typedata.container->anim->start.align.x), TO_DOUBLE(ep->typedata.container->anim->start.align.y));
187
ep->typedata.container->anim->start.layout(ep->object, priv, ep->typedata.container->anim->start.data);
188
_edje_box_layout_calculate_coords(ep->object, priv, ep->typedata.container->anim);
189
ep->typedata.container->anim->start_progress = 0.0;
191
evas_object_smart_changed(ep->object);
195
ep->typedata.container->anim->end.layout = NULL;
198
if (EINA_DBL_EQ(ep->description_pos, 0.0) || !ep->typedata.container->anim->start.layout)
200
_edje_box_layout_find_all(chosen_desc->box.layout, chosen_desc->box.alt_layout, &ep->typedata.container->anim->start.layout, &ep->typedata.container->anim->start.data, &ep->typedata.container->anim->start.free_data);
201
ep->typedata.container->anim->start.padding.x = chosen_desc->box.padding.x;
202
ep->typedata.container->anim->start.padding.y = chosen_desc->box.padding.y;
203
ep->typedata.container->anim->start.align.x = chosen_desc->box.align.x;
204
ep->typedata.container->anim->start.align.y = chosen_desc->box.align.y;
205
evas_object_smart_changed(ep->object);
208
ep->typedata.container->anim->progress = ep->description_pos;
210
if (evas_object_smart_need_recalculate_get(ep->object))
212
evas_object_smart_need_recalculate_set(ep->object, 0);
213
evas_object_smart_calculate(ep->object);
216
evas_object_size_hint_combined_min_get(ep->object, &min_w, &min_h);
217
if (chosen_desc->box.min.h && (p3->w < min_w))
219
if (chosen_desc->box.min.v && (p3->h < min_h))
225
_edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj)
227
Edje_Transition_Animation_Data *tad;
229
if ((rp->type != EDJE_RP_TYPE_CONTAINER) ||
230
(!rp->typedata.container)) return EINA_FALSE;
231
tad = calloc(1, sizeof(Edje_Transition_Animation_Data));
232
if (!tad) return EINA_FALSE;
233
tad->obj = child_obj;
234
rp->typedata.container->anim->objs = eina_list_append(rp->typedata.container->anim->objs, tad);
235
rp->typedata.container->anim->recalculate = EINA_TRUE;
240
_edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj)
243
Edje_Transition_Animation_Data *tad;
245
if ((rp->type != EDJE_RP_TYPE_CONTAINER) ||
246
(!rp->typedata.container)) return;
247
EINA_LIST_FOREACH(rp->typedata.container->anim->objs, l, tad)
249
if (tad->obj == child_obj)
251
free(eina_list_data_get(l));
252
rp->typedata.container->anim->objs = eina_list_remove_list(rp->typedata.container->anim->objs, l);
253
rp->typedata.container->anim->recalculate = EINA_TRUE;
257
rp->typedata.container->anim->recalculate = EINA_TRUE;