1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 
6 #define TWEEN_NUM 7
7 #define BTN_NUM (TWEEN_NUM + 1)
8 #define BTN_W 50
9 #define BTN_H 50
10 #define WIN_H (BTN_NUM * BTN_H)
11 #define WIN_W WIN_H
12 #define TRANSIT_DURATION 1.0
13 
14 typedef struct _Custom_Effect Custom_Effect;
15 
16 struct _Custom_Effect
17 {
18    struct _size
19      {
20         Evas_Coord w, h;
21      } from, to;
22 };
23 
24 static void
_transit_revert(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)25 _transit_revert(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
26 {
27    Elm_Transit *trans = (Elm_Transit*)data;
28    elm_transit_revert(trans);
29 }
30 
31 static void
_transit_rev_cb_del(void * data,Elm_Transit * trans EINA_UNUSED)32 _transit_rev_cb_del(void *data, Elm_Transit *trans EINA_UNUSED)
33 {
34    Evas_Object *rev_bt = (Evas_Object*)data;
35    evas_object_smart_callback_del(rev_bt, "clicked", _transit_revert);
36    elm_object_disabled_set(rev_bt, EINA_TRUE);
37 }
38 
39 static void
_custom_op(Elm_Transit_Effect * effect,Elm_Transit * transit,double progress)40 _custom_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
41 {
42    if (!effect) return;
43    Evas_Coord w, h;
44    Evas_Object *obj;
45    const Eina_List *elist;
46 
47    Custom_Effect *custom_effect = effect;
48    const Eina_List *objs = elm_transit_objects_get(transit);
49 
50    if (progress < 0.5)
51      {
52         h = custom_effect->from.h + (custom_effect->to.h * progress * 2);
53         w = custom_effect->from.w;
54      }
55    else
56      {
57         h = custom_effect->from.h + custom_effect->to.h;
58         w = custom_effect->from.w + \
59             (custom_effect->to.w * (progress - 0.5) * 2);
60      }
61 
62    EINA_LIST_FOREACH(objs, elist, obj)
63       evas_object_resize(obj, w, h);
64 }
65 
66 static Elm_Transit_Effect *
_custom_context_new(Evas_Coord from_w,Evas_Coord from_h,Evas_Coord to_w,Evas_Coord to_h)67 _custom_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
68 {
69    Custom_Effect *custom_effect;
70 
71    custom_effect = calloc(1, sizeof(Custom_Effect));
72    if (!custom_effect) return NULL;
73 
74    custom_effect->from.w = from_w;
75    custom_effect->from.h = from_h;
76    custom_effect->to.w = to_w - from_w;
77    custom_effect->to.h = to_h - from_h;
78 
79    return custom_effect;
80 }
81 
82 static void
_custom_context_free(Elm_Transit_Effect * effect,Elm_Transit * transit EINA_UNUSED)83 _custom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
84 {
85    Custom_Effect *custom_effect = effect;
86    free(custom_effect);
87 }
88 
89 static void
_transit_rotation_color(void * data EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)90 _transit_rotation_color(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
91 {
92    Elm_Transit *trans;
93 
94    trans = elm_transit_add();
95    elm_transit_object_add(trans, obj);
96    elm_transit_auto_reverse_set(trans, EINA_TRUE);
97    elm_transit_repeat_times_set(trans, 2);
98 
99    /* Color Effect */
100    elm_transit_effect_color_add(trans, 100, 255, 100, 255, 50, 30, 50, 50);
101 
102    /* Rotation Effect */
103    elm_transit_effect_rotation_add(trans, 0.0, 135.0);
104 
105    elm_transit_duration_set(trans, 5.0);
106    elm_transit_go(trans);
107 }
108 
109 static void
_transit_wipe(void * data EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)110 _transit_wipe(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
111 {
112    Elm_Transit *trans;
113 
114    trans = elm_transit_add();
115    elm_transit_object_add(trans, obj);
116    elm_transit_auto_reverse_set(trans, EINA_TRUE);
117 
118    elm_transit_effect_wipe_add(trans,
119                                ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
120                                ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT);
121 
122    elm_transit_duration_set(trans, 5.0);
123    elm_transit_go(trans);
124 }
125 
126 static void
_transit_del_cb(void * data,Elm_Transit * transit EINA_UNUSED)127 _transit_del_cb(void *data, Elm_Transit *transit EINA_UNUSED)
128 {
129    evas_object_freeze_events_set(data, EINA_FALSE);
130 }
131 
132 static void
_transit_image_animation(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)133 _transit_image_animation(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
134 {
135    Eina_List *images = NULL;
136    char buf[PATH_MAX];
137    Elm_Transit *trans;
138    Evas_Object *ic = data;
139 
140    snprintf(buf, sizeof(buf), "%s/images/icon_19.png", elm_app_data_dir_get());
141    images = eina_list_append(images, eina_stringshare_add(buf));
142 
143    snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
144    images = eina_list_append(images, eina_stringshare_add(buf));
145 
146    snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
147    images = eina_list_append(images, eina_stringshare_add(buf));
148 
149    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
150    images = eina_list_append(images, eina_stringshare_add(buf));
151 
152    trans = elm_transit_add();
153    elm_transit_del_cb_set(trans, _transit_del_cb, obj);
154    elm_transit_object_add(trans, ic);
155    elm_transit_effect_image_animation_add(trans, images);
156    elm_transit_duration_set(trans, 5.0);
157    elm_transit_go(trans);
158 
159    evas_object_freeze_events_set(obj, EINA_TRUE);
160 }
161 
162 static void
_transit_resizing(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)163 _transit_resizing(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
164 {
165    Elm_Transit *trans;
166    Evas_Object *rev_bt = (Evas_Object*)data;
167    elm_object_disabled_set(rev_bt, EINA_FALSE);
168    trans = elm_transit_add();
169    elm_transit_object_add(trans, obj);
170    elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
171 
172    evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
173    elm_transit_effect_resizing_add(trans, 100, 50, 300, 150);
174 
175    elm_transit_duration_set(trans, 5.0);
176    elm_transit_go(trans);
177 }
178 
179 static void
_transit_flip(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)180 _transit_flip(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
181 {
182    Elm_Transit *trans;
183    Evas_Object *obj2 = data;
184    Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
185    elm_object_disabled_set(rev_bt, EINA_FALSE);
186 
187    trans = elm_transit_add();
188    elm_transit_object_add(trans, obj);
189    elm_transit_object_add(trans, obj2);
190    elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
191 
192    evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
193    elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
194 
195    elm_transit_duration_set(trans, 5.0);
196    elm_transit_go(trans);
197 }
198 
199 static void
_transit_zoom(void * data EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)200 _transit_zoom(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
201 {
202    Elm_Transit *trans;
203 
204    trans = elm_transit_add();
205    Evas_Object *rev_bt = (Evas_Object*)data;
206    elm_object_disabled_set(rev_bt, EINA_FALSE);
207    elm_transit_object_add(trans, obj);
208    elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
209 
210    evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
211    elm_transit_effect_zoom_add(trans, 1.0, 3.0);
212 
213    elm_transit_duration_set(trans, 5.0);
214    elm_transit_go(trans);
215 }
216 
217 static void
_transit_blend(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)218 _transit_blend(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
219 {
220    Elm_Transit *trans;
221    Evas_Object *obj2 = data;
222    Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
223    elm_object_disabled_set(rev_bt, EINA_FALSE);
224 
225    trans = elm_transit_add();
226    elm_transit_object_add(trans, obj);
227    elm_transit_object_add(trans, obj2);
228    elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
229 
230    evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
231 
232    elm_transit_effect_blend_add(trans);
233 
234    elm_transit_duration_set(trans, 5.0);
235    elm_transit_go(trans);
236 }
237 
238 static void
_transit_fade(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)239 _transit_fade(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
240 {
241    Elm_Transit *trans;
242    Evas_Object *obj2 = data;
243    Evas_Object *rev_bt = (Evas_Object*)evas_object_data_get(obj, "revert");
244    elm_object_disabled_set(rev_bt, EINA_FALSE);
245 
246    trans = elm_transit_add();
247    elm_transit_object_add(trans, obj);
248    elm_transit_object_add(trans, obj2);
249    elm_transit_del_cb_set(trans, _transit_rev_cb_del, rev_bt);
250 
251    evas_object_smart_callback_add(rev_bt, "clicked", _transit_revert, trans);
252 
253    elm_transit_effect_fade_add(trans);
254 
255    elm_transit_duration_set(trans, 5.0);
256    elm_transit_go(trans);
257 }
258 
259 static void
_transit_resizable_flip(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)260 _transit_resizable_flip(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
261 {
262    Elm_Transit *trans;
263    Evas_Object *obj2 = data;
264 
265    trans = elm_transit_add();
266    elm_transit_object_add(trans, obj);
267    elm_transit_object_add(trans, obj2);
268 
269    elm_transit_effect_resizable_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
270 
271    elm_transit_duration_set(trans, 5.0);
272    elm_transit_go(trans);
273 }
274 
275 static void
_transit_tween_del_cb(void * data,Elm_Transit * trans EINA_UNUSED)276 _transit_tween_del_cb(void *data, Elm_Transit *trans EINA_UNUSED)
277 {
278    Evas_Object *btn = data;
279    int disabled = (int)(uintptr_t)evas_object_data_get(btn, "disabled");
280    if (disabled > 0)
281      evas_object_data_set(btn, "disabled", (void *)(uintptr_t)(--disabled));
282    if (disabled == 0) elm_object_disabled_set(btn, EINA_FALSE);
283 }
284 
285 static void
_transit_tween(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)286 _transit_tween(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
287 {
288    Elm_Transit_Tween_Mode ettm;
289    Elm_Transit *trans;
290    Evas_Coord x;
291    Evas_Object *bt_all = data;
292    int disabled;
293 
294    evas_object_geometry_get(obj, &x, NULL, NULL, NULL);
295    ettm = (Elm_Transit_Tween_Mode) evas_object_data_get(obj, "tween");
296 
297    trans = elm_transit_add();
298    elm_transit_tween_mode_set(trans, ettm);
299    elm_transit_effect_translation_add(trans, 0, 0,
300                                       ((x ? -1 : 1) * (WIN_W - BTN_W)), 0);
301    elm_transit_object_add(trans, obj);
302    elm_transit_duration_set(trans, TRANSIT_DURATION);
303    elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
304    elm_transit_del_cb_set(trans, _transit_tween_del_cb, bt_all);
305    elm_transit_go(trans);
306 
307    disabled = (int)(uintptr_t)evas_object_data_get(bt_all, "disabled");
308    evas_object_data_set(bt_all, "disabled", (void *)(uintptr_t)(++disabled));
309    elm_object_disabled_set(bt_all, EINA_TRUE);
310 }
311 
312 static void
_transit_tween_all(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)313 _transit_tween_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
314 {
315    Evas_Object **bt = data;
316    Elm_Transit *trans;
317    Evas_Coord x;
318    int i;
319 
320    for (i = 0; i < TWEEN_NUM; i++)
321      {
322         evas_object_geometry_get(bt[i], &x, NULL, NULL, NULL);
323 
324         trans = elm_transit_add();
325         elm_transit_tween_mode_set(trans, i);
326         elm_transit_effect_translation_add(trans, 0, 0,
327                                            ((x ? -1 : 1) * (WIN_W - BTN_W)), 0);
328         elm_transit_object_add(trans, bt[i]);
329         elm_transit_duration_set(trans, TRANSIT_DURATION);
330         elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
331         elm_transit_del_cb_set(trans, _transit_tween_del_cb, obj);
332         elm_transit_go(trans);
333      }
334 
335    elm_object_disabled_set(obj, EINA_TRUE);
336 }
337 
338 static void
_win_delete_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)339 _win_delete_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
340 {
341    Evas_Object **bt = data;
342    free(bt);
343 }
344 
345 /* Translation, Rotation, Color, Wipe, ImagemAnimation Effect */
346 void
test_transit(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)347 test_transit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
348 {
349    Evas_Object *win, *bx, *bt, *ic;
350    char buf[PATH_MAX];
351 
352    win = elm_win_util_standard_add("transit", "Transit");
353    elm_win_autodel_set(win, EINA_TRUE);
354 
355    bx = elm_box_add(win);
356    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
357    elm_win_resize_object_add(win, bx);
358    evas_object_show(bx);
359 
360    ic = elm_image_add(win);
361    snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
362    elm_image_file_set(ic, buf, NULL);
363    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
364 
365    bt = elm_button_add(win);
366    elm_object_text_set(bt, "Image Animation");
367    elm_object_part_content_set(bt, "icon", ic);
368    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369    elm_box_pack_end(bx, bt);
370    evas_object_show(bt);
371    evas_object_show(ic);
372    evas_object_smart_callback_add(bt, "clicked", _transit_image_animation, ic);
373 
374    bt = elm_button_add(win);
375    elm_object_text_set(bt, "Rotation + Color");
376    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
377    elm_box_pack_end(bx, bt);
378    evas_object_show(bt);
379    evas_object_smart_callback_add(bt, "clicked",
380                                   _transit_rotation_color, NULL);
381 
382    bt = elm_button_add(win);
383    elm_object_text_set(bt, "Wipe Effect");
384    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
385    elm_box_pack_end(bx, bt);
386    evas_object_show(bt);
387    evas_object_smart_callback_add(bt, "clicked", _transit_wipe, NULL);
388 
389    evas_object_resize(win, 300, 300);
390    evas_object_show(win);
391 }
392 
393 /* Resizing Effect */
394 void
test_transit_resizing(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)395 test_transit_resizing(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
396 {
397    Evas_Object *win, *bt, *rev_bt;
398 
399    win = elm_win_util_standard_add("transit2", "Transit Resizing");
400    elm_win_autodel_set(win, EINA_TRUE);
401 
402    bt = elm_button_add(win);
403    elm_object_text_set(bt, "Resizing Effect");
404    evas_object_show(bt);
405    evas_object_move(bt, 50, 100);
406    evas_object_resize(bt, 100, 50);
407 
408    rev_bt = elm_button_add(win);
409    elm_object_text_set(rev_bt, "Revert");
410    evas_object_resize(rev_bt, 100, 50);
411    evas_object_move(rev_bt, 50, 300);
412    evas_object_show(rev_bt);
413    elm_object_disabled_set(rev_bt, EINA_TRUE);
414 
415    evas_object_smart_callback_add(bt, "clicked", _transit_resizing, rev_bt);
416 
417    evas_object_resize(win, 400, 400);
418    evas_object_show(win);
419 }
420 
421 /* Flip Effect */
422 void
test_transit_flip(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)423 test_transit_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
424 {
425    Evas_Object *win, *bt, *bt2, *rev_bt;
426 
427    win = elm_win_util_standard_add("transit3", "Transit Flip");
428    elm_win_autodel_set(win, EINA_TRUE);
429 
430    bt = elm_button_add(win);
431    elm_object_text_set(bt, "Front Button - Flip Effect");
432    evas_object_show(bt);
433    evas_object_move(bt, 50, 50);
434    evas_object_resize(bt, 200, 200);
435 
436    bt2 = elm_button_add(win);
437    elm_object_text_set(bt2, "Back Button - Flip Effect");
438    evas_object_move(bt2, 50, 50);
439    evas_object_resize(bt2, 200, 200);
440 
441    rev_bt = elm_button_add(win);
442    elm_object_text_set(rev_bt, "Revert");
443    evas_object_resize(rev_bt, 100, 50);
444    evas_object_move(rev_bt, 50, 300);
445    evas_object_show(rev_bt);
446    elm_object_disabled_set(rev_bt, EINA_TRUE);
447    evas_object_data_set(bt, "revert", rev_bt);
448    evas_object_data_set(bt2, "revert", rev_bt);
449 
450    evas_object_resize(win, 400, 400);
451    evas_object_show(win);
452 
453    evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2);
454    evas_object_smart_callback_add(bt2, "clicked", _transit_flip, bt);
455 }
456 
457 /* Zoom Effect */
458 void
test_transit_zoom(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)459 test_transit_zoom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
460 {
461    Evas_Object *win, *bt, *rev_bt;
462 
463    win = elm_win_util_standard_add("transit4", "Transit Zoom");
464    elm_win_autodel_set(win, EINA_TRUE);
465 
466    bt = elm_button_add(win);
467    elm_object_text_set(bt, "Zoom Effect");
468    evas_object_resize(bt, 100, 50);
469    evas_object_move(bt, 100, 125);
470    evas_object_show(bt);
471 
472    rev_bt = elm_button_add(win);
473    elm_object_text_set(rev_bt, "Revert");
474    evas_object_resize(rev_bt, 100, 50);
475    evas_object_move(rev_bt, 100, 250);
476    evas_object_show(rev_bt);
477    elm_object_disabled_set(rev_bt, EINA_TRUE);
478 
479    evas_object_smart_callback_add(bt, "clicked", _transit_zoom, rev_bt);
480 
481    evas_object_resize(win, 300, 300);
482    evas_object_show(win);
483 }
484 
485 /* Blend Effect */
486 void
test_transit_blend(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)487 test_transit_blend(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
488 {
489    Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
490    char buf[PATH_MAX];
491 
492    win = elm_win_util_standard_add("transit5", "Transit Blend");
493    elm_win_autodel_set(win, EINA_TRUE);
494 
495    ic = elm_image_add(win);
496    snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
497    elm_image_file_set(ic, buf, NULL);
498    evas_object_size_hint_max_set(ic, 50, 50);
499 
500    bt = elm_button_add(win);
501    elm_object_part_content_set(bt, "icon", ic);
502    elm_object_text_set(bt, "Before Button - Blend Effect");
503    evas_object_move(bt, 25, 125);
504    evas_object_resize(bt, 250, 50);
505    evas_object_show(bt);
506 
507    ic = elm_image_add(win);
508    snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
509    elm_image_file_set(ic, buf, NULL);
510    evas_object_size_hint_max_set(ic, 50, 50);
511 
512    bt2 = elm_button_add(win);
513    elm_object_part_content_set(bt2, "icon", ic);
514    elm_object_text_set(bt2, "After Button - Blend Effect");
515    evas_object_move(bt2, 25, 125);
516    evas_object_resize(bt2, 250, 50);
517 
518    rev_bt = elm_button_add(win);
519    elm_object_text_set(rev_bt, "Revert");
520    evas_object_resize(rev_bt, 100, 50);
521    evas_object_move(rev_bt, 50, 300);
522    evas_object_show(rev_bt);
523    elm_object_disabled_set(rev_bt, EINA_TRUE);
524    evas_object_data_set(bt, "revert", rev_bt);
525    evas_object_data_set(bt2, "revert", rev_bt);
526 
527    evas_object_resize(win, 300, 400);
528    evas_object_show(win);
529 
530    evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2);
531    evas_object_smart_callback_add(bt2, "clicked", _transit_blend, bt);
532 }
533 
534 /* Fade Effect */
535 void
test_transit_fade(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)536 test_transit_fade(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
537 {
538    Evas_Object *win, *bt, *bt2, *ic, *rev_bt;
539    char buf[PATH_MAX];
540 
541    win = elm_win_util_standard_add("transit6","Transit Fade");
542    elm_win_autodel_set(win, EINA_TRUE);
543 
544    ic = elm_image_add(win);
545    snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
546    elm_image_file_set(ic, buf, NULL);
547    evas_object_size_hint_max_set(ic, 50, 50);
548 
549    bt = elm_button_add(win);
550    elm_object_part_content_set(bt, "icon", ic);
551    elm_object_text_set(bt, "Before Button - Fade Effect");
552    evas_object_move(bt, 25, 125);
553    evas_object_resize(bt, 250, 50);
554    evas_object_show(bt);
555 
556    ic = elm_image_add(win);
557    snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
558    elm_image_file_set(ic, buf, NULL);
559    evas_object_size_hint_max_set(ic, 50, 50);
560 
561    bt2 = elm_button_add(win);
562    elm_object_part_content_set(bt2, "icon", ic);
563    elm_object_text_set(bt2, "After Button - Fade Effect");
564    evas_object_move(bt2, 25, 125);
565    evas_object_resize(bt2, 250, 50);
566 
567    rev_bt = elm_button_add(win);
568    elm_object_text_set(rev_bt, "Revert");
569    evas_object_resize(rev_bt, 100, 50);
570    evas_object_move(rev_bt, 50, 300);
571    evas_object_show(rev_bt);
572    elm_object_disabled_set(rev_bt, EINA_TRUE);
573    evas_object_data_set(bt, "revert", rev_bt);
574    evas_object_data_set(bt2, "revert", rev_bt);
575 
576    evas_object_resize(win, 300, 400);
577    evas_object_show(win);
578 
579    evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2);
580    evas_object_smart_callback_add(bt2, "clicked", _transit_fade, bt);
581 }
582 
583 /* Resizable Flip Effect */
584 void
test_transit_resizable_flip(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)585 test_transit_resizable_flip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
586 {
587    Evas_Object *win, *bt, *bt2;
588 
589    win = elm_win_util_standard_add("transit7", "Transit Resizable Flip");
590    elm_win_autodel_set(win, EINA_TRUE);
591 
592    bt = elm_button_add(win);
593    elm_object_text_set(bt, "Front Button - Resizable Flip Effect");
594    evas_object_show(bt);
595    evas_object_move(bt, 50, 100);
596    evas_object_resize(bt, 250, 30);
597 
598    bt2 = elm_button_add(win);
599    elm_object_text_set(bt2, "Back Button - Resizable Flip Effect");
600    evas_object_move(bt2, 50, 100);
601    evas_object_resize(bt2, 300, 200);
602 
603    evas_object_resize(win, 400, 400);
604    evas_object_show(win);
605 
606    evas_object_smart_callback_add(bt, "clicked", _transit_resizable_flip, bt2);
607    evas_object_smart_callback_add(bt2, "clicked", _transit_resizable_flip, bt);
608 }
609 
610 /* Custom Effect */
611 void
test_transit_custom(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)612 test_transit_custom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
613 {
614    Evas_Object *win, *bt;
615    Elm_Transit *trans;
616    Elm_Transit_Effect *effect_context;
617 
618    win = elm_win_util_standard_add("transit8", "Transit Custom");
619    elm_win_autodel_set(win, EINA_TRUE);
620 
621    bt = elm_button_add(win);
622    elm_object_text_set(bt, "Button - Custom Effect");
623    evas_object_show(bt);
624    evas_object_move(bt, 50, 50);
625    evas_object_resize(bt, 150, 150);
626 
627    /* Adding Transit */
628    trans = elm_transit_add();
629    elm_transit_auto_reverse_set(trans, EINA_TRUE);
630    elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
631    effect_context = _custom_context_new(150, 150, 50, 50);
632    elm_transit_object_add(trans, bt);
633    elm_transit_effect_add(trans,
634                           _custom_op, effect_context,
635                           _custom_context_free);
636    elm_transit_duration_set(trans, 5.0);
637    elm_transit_repeat_times_set(trans, -1);
638    elm_transit_go(trans);
639 
640    bt = elm_button_add(win);
641    elm_object_text_set(bt, "Revert");
642    evas_object_resize(bt, 150, 50);
643    evas_object_move(bt, 50, 250);
644    evas_object_show(bt);
645    evas_object_smart_callback_add(bt, "clicked", _transit_revert, trans);
646 
647    evas_object_resize(win, 400, 400);
648    evas_object_show(win);
649 }
650 
651 /* Chain Transit Effect */
652 void
test_transit_chain(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)653 test_transit_chain(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
654 {
655    Evas_Object *win, *bt, *bt2, *bt3, *bt4;
656    Elm_Transit *trans, *trans2, *trans3, *trans4;
657 
658    win = elm_win_util_standard_add("transit9", "Transit Chain");
659    elm_win_autodel_set(win, EINA_TRUE);
660 
661    bt = elm_button_add(win);
662    elm_object_text_set(bt, "Chain 1");
663    evas_object_resize(bt, 100, 100);
664    evas_object_move(bt, 0, 0);
665    evas_object_show(bt);
666 
667    bt2 = elm_button_add(win);
668    elm_object_text_set(bt2, "Chain 2");
669    evas_object_resize(bt2, 100, 100);
670    evas_object_move(bt2, 300, 0);
671    evas_object_show(bt2);
672 
673    bt3 = elm_button_add(win);
674    elm_object_text_set(bt3, "Chain 3");
675    evas_object_resize(bt3, 100, 100);
676    evas_object_move(bt3, 300, 300);
677    evas_object_show(bt3);
678 
679    bt4 = elm_button_add(win);
680    elm_object_text_set(bt4, "Chain 4");
681    evas_object_resize(bt4, 100, 100);
682    evas_object_move(bt4, 0, 300);
683    evas_object_show(bt4);
684 
685    trans = elm_transit_add();
686    elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
687    elm_transit_effect_translation_add(trans, 0, 0, 300, 0);
688    elm_transit_object_add(trans, bt);
689    elm_transit_duration_set(trans, 1);
690    elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
691    elm_transit_go(trans);
692 
693    trans2 = elm_transit_add();
694    elm_transit_tween_mode_set(trans2, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
695    elm_transit_effect_translation_add(trans2, 0, 0, 0, 300);
696    elm_transit_object_add(trans2, bt2);
697    elm_transit_duration_set(trans2, 1);
698    elm_transit_objects_final_state_keep_set(trans2, EINA_TRUE);
699    elm_transit_chain_transit_add(trans, trans2);
700 
701    trans3 = elm_transit_add();
702    elm_transit_tween_mode_set(trans3, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
703    elm_transit_effect_translation_add(trans3, 0, 0, -300, 0);
704    elm_transit_object_add(trans3, bt3);
705    elm_transit_duration_set(trans3, 1);
706    elm_transit_objects_final_state_keep_set(trans3, EINA_TRUE);
707    elm_transit_chain_transit_add(trans2, trans3);
708 
709    trans4 = elm_transit_add();
710    elm_transit_tween_mode_set(trans4, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
711    elm_transit_effect_translation_add(trans4, 0, 0, 0, -300);
712    elm_transit_object_add(trans4, bt4);
713    elm_transit_duration_set(trans4, 1);
714    elm_transit_objects_final_state_keep_set(trans4, EINA_TRUE);
715    elm_transit_chain_transit_add(trans3, trans4);
716 
717    evas_object_resize(win, 400, 400);
718    evas_object_show(win);
719 }
720 
721 /* Transit Tween Mode */
722 void
test_transit_tween(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)723 test_transit_tween(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
724 {
725    Evas_Object *win, *bg, *label;
726    Evas_Object **bt = malloc(sizeof(Evas_Object *) * BTN_NUM);
727    int i;
728 
729    char *modes[] = {"LINEAR", "SINUSOIDAL", "DECELERATE", "ACCELERATE",
730                     "DIVISOR_INTERP", "BOUNCE", "SPRING"};
731 
732    win = elm_win_add(NULL, "transit10",  ELM_WIN_BASIC);
733    elm_win_title_set(win, "Transit Tween");
734    elm_win_autodel_set(win, EINA_TRUE);
735    evas_object_smart_callback_add(win, "delete,request", _win_delete_cb, bt);
736 
737    bg = elm_bg_add(win);
738    evas_object_size_hint_min_set(bg, WIN_W, WIN_H);
739    elm_win_resize_object_add(win, bg);
740    evas_object_show(bg);
741 
742    bt[TWEEN_NUM] = elm_button_add(win);
743    elm_object_text_set(bt[TWEEN_NUM], "Go All");
744    evas_object_resize(bt[TWEEN_NUM], WIN_W, BTN_H);
745    evas_object_move(bt[TWEEN_NUM], 0, (WIN_H - BTN_H));
746    evas_object_show(bt[TWEEN_NUM]);
747    evas_object_smart_callback_add(bt[TWEEN_NUM], "clicked", _transit_tween_all,
748                                   bt);
749 
750    for (i = 0; i < TWEEN_NUM; i++)
751      {
752         label = elm_label_add(win);
753         elm_object_text_set(label, modes[i]);
754         evas_object_resize(label, WIN_W, BTN_H);
755         evas_object_move(label, 0, (i * BTN_H));
756         evas_object_show(label);
757 
758         bt[i] = elm_button_add(win);
759         evas_object_data_set(bt[i], "tween", (void *)(uintptr_t)i);
760         elm_object_text_set(bt[i], "Go");
761         evas_object_resize(bt[i], BTN_W, BTN_H);
762         evas_object_move(bt[i], 0, (i * BTN_H));
763         evas_object_show(bt[i]);
764         evas_object_smart_callback_add(bt[i], "clicked", _transit_tween,
765                                        bt[TWEEN_NUM]);
766      }
767 
768    evas_object_resize(win, WIN_W, WIN_H);
769    evas_object_show(win);
770 }
771