1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 typedef struct _Custom_Effect Custom_Effect;
18 _custom_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
23 const Eina_List *elist;
25 Custom_Effect *custom_effect = effect;
26 const Eina_List *objs = elm_transit_objects_get(transit);
30 h = custom_effect->from.h + (custom_effect->to.h * progress * 2);
31 w = custom_effect->from.w;
35 h = custom_effect->from.h + custom_effect->to.h;
36 w = custom_effect->from.w + \
37 (custom_effect->to.w * (progress - 0.5) * 2);
40 EINA_LIST_FOREACH(objs, elist, obj)
41 evas_object_resize(obj, w, h);
45 static Elm_Transit_Effect *
46 _custom_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
48 Custom_Effect *custom_effect;
50 custom_effect = calloc(1, sizeof(Custom_Effect));
51 if (!custom_effect) return NULL;
53 custom_effect->from.w = from_w;
54 custom_effect->from.h = from_h;
55 custom_effect->to.w = to_w - from_w;
56 custom_effect->to.h = to_h - from_h;
62 _custom_context_free(Elm_Transit_Effect *effect, Elm_Transit *transit __UNUSED__)
64 Custom_Effect *custom_effect = effect;
69 _transit_rotation_translation_color(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
73 trans = elm_transit_add();
74 elm_transit_object_add(trans, obj);
75 elm_transit_auto_reverse_set(trans, EINA_TRUE);
76 elm_transit_repeat_times_set(trans, 2);
78 /* Translation Effect */
79 elm_transit_effect_translation_add(trans, -70.0, -150.0, 70.0, 150.0);
82 elm_transit_effect_color_add(trans, 100, 255, 100, 255, 200, 50, 200, 50);
85 elm_transit_effect_rotation_add(trans, 0.0, 135.0);
87 elm_transit_duration_set(trans, 5.0);
88 elm_transit_go(trans);
92 _transit_wipe(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
96 trans = elm_transit_add();
97 elm_transit_object_add(trans, obj);
98 elm_transit_auto_reverse_set(trans, EINA_TRUE);
100 elm_transit_effect_wipe_add(trans,
101 ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
102 ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT);
104 elm_transit_duration_set(trans, 5.0);
105 elm_transit_go(trans);
109 _transit_del_cb(void *data, Elm_Transit *transit __UNUSED__)
111 evas_object_freeze_events_set(data, EINA_FALSE);
115 _transit_image_animation(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
117 Eina_List *images = NULL;
120 Evas_Object *ic = data;
122 snprintf(buf, sizeof(buf), "%s/images/icon_19.png", elm_app_data_dir_get());
123 images = eina_list_append(images, eina_stringshare_add(buf));
125 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
126 images = eina_list_append(images, eina_stringshare_add(buf));
128 snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
129 images = eina_list_append(images, eina_stringshare_add(buf));
131 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
132 images = eina_list_append(images, eina_stringshare_add(buf));
134 trans = elm_transit_add();
135 elm_transit_del_cb_set(trans, _transit_del_cb, obj);
136 elm_transit_object_add(trans, ic);
137 elm_transit_effect_image_animation_add(trans, images);
138 elm_transit_duration_set(trans, 5.0);
139 elm_transit_go(trans);
141 evas_object_freeze_events_set(obj, EINA_TRUE);
145 _transit_resizing(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
149 trans = elm_transit_add();
150 elm_transit_object_add(trans, obj);
152 elm_transit_effect_resizing_add(trans, 100, 50, 300, 150);
154 elm_transit_duration_set(trans, 5.0);
155 elm_transit_go(trans);
159 _transit_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
162 Evas_Object *obj2 = data;
164 trans = elm_transit_add();
165 elm_transit_object_add(trans, obj);
166 elm_transit_object_add(trans, obj2);
168 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
170 elm_transit_duration_set(trans, 5.0);
171 elm_transit_go(trans);
175 _transit_zoom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
179 trans = elm_transit_add();
180 elm_transit_object_add(trans, obj);
182 elm_transit_effect_zoom_add(trans, 1.0, 3.0);
184 elm_transit_duration_set(trans, 5.0);
185 elm_transit_go(trans);
189 _transit_blend(void *data, Evas_Object *obj, void *event_info __UNUSED__)
192 Evas_Object *obj2 = data;
194 trans = elm_transit_add();
195 elm_transit_object_add(trans, obj);
196 elm_transit_object_add(trans, obj2);
198 elm_transit_effect_blend_add(trans);
200 elm_transit_duration_set(trans, 5.0);
201 elm_transit_go(trans);
205 _transit_fade(void *data, Evas_Object *obj, void *event_info __UNUSED__)
208 Evas_Object *obj2 = data;
210 trans = elm_transit_add();
211 elm_transit_object_add(trans, obj);
212 elm_transit_object_add(trans, obj2);
214 elm_transit_effect_fade_add(trans);
216 elm_transit_duration_set(trans, 5.0);
217 elm_transit_go(trans);
221 _transit_resizable_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
224 Evas_Object *obj2 = data;
226 trans = elm_transit_add();
227 elm_transit_object_add(trans, obj);
228 elm_transit_object_add(trans, obj2);
230 elm_transit_effect_resizable_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
232 elm_transit_duration_set(trans, 5.0);
233 elm_transit_go(trans);
236 /* Translation, Rotation, Color, Wipe, ImagemAnimation Effect */
238 test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
240 Evas_Object *win, *bg, *bx, *bt, *ic;
243 win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
244 elm_win_title_set(win, "Transit");
245 elm_win_autodel_set(win, EINA_TRUE);
247 bg = elm_bg_add(win);
248 elm_win_resize_object_add(win, bg);
249 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
250 evas_object_show(bg);
252 bx = elm_box_add(win);
253 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
254 elm_win_resize_object_add(win, bx);
255 evas_object_size_hint_min_set(bx, 318, 318);
256 evas_object_show(bx);
258 ic = elm_icon_add(win);
259 snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
260 elm_icon_file_set(ic, buf, NULL);
261 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
263 bt = elm_button_add(win);
264 elm_object_text_set(bt, "ImageAnimation Effect");
265 elm_object_part_content_set(bt, "icon", ic);
266 elm_box_pack_end(bx, bt);
267 evas_object_show(bt);
268 evas_object_show(ic);
269 evas_object_smart_callback_add(bt, "clicked", _transit_image_animation, ic);
271 bt = elm_button_add(win);
272 elm_object_text_set(bt, "Color, Rotation and Translation");
273 elm_box_pack_end(bx, bt);
274 evas_object_show(bt);
275 evas_object_smart_callback_add(bt, "clicked",
276 _transit_rotation_translation_color, NULL);
278 bt = elm_button_add(win);
279 elm_object_text_set(bt, "Wipe Effect");
280 elm_box_pack_end(bx, bt);
281 evas_object_show(bt);
282 evas_object_smart_callback_add(bt, "clicked", _transit_wipe, NULL);
284 evas_object_show(win);
287 /* Resizing Effect */
289 test_transit2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
291 Evas_Object *win, *bg, *bt;
293 win = elm_win_add(NULL, "transit2", ELM_WIN_BASIC);
294 elm_win_title_set(win, "Transit 2");
295 elm_win_autodel_set(win, EINA_TRUE);
297 bg = elm_bg_add(win);
298 elm_win_resize_object_add(win, bg);
299 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
300 evas_object_show(bg);
302 bt = elm_button_add(win);
303 elm_object_text_set(bt, "Resizing Effect");
304 evas_object_show(bt);
305 evas_object_move(bt, 50, 100);
306 evas_object_resize(bt, 100, 50);
307 evas_object_smart_callback_add(bt, "clicked", _transit_resizing, NULL);
309 evas_object_resize(win, 400, 400);
310 evas_object_show(win);
315 test_transit3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
317 Evas_Object *win, *bg, *bt, *bt2;
319 win = elm_win_add(NULL, "transit3", ELM_WIN_BASIC);
320 elm_win_title_set(win, "Transit 3");
321 elm_win_autodel_set(win, EINA_TRUE);
323 bg = elm_bg_add(win);
324 elm_win_resize_object_add(win, bg);
325 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
326 evas_object_show(bg);
328 bt = elm_button_add(win);
329 elm_object_text_set(bt, "Front Button - Flip Effect");
330 evas_object_show(bt);
331 evas_object_move(bt, 50, 50);
332 evas_object_resize(bt, 200, 200);
334 bt2 = elm_button_add(win);
335 elm_object_text_set(bt2, "Back Button - Flip Effect");
336 evas_object_move(bt2, 50, 50);
337 evas_object_resize(bt2, 200, 200);
339 evas_object_resize(win, 300, 300);
340 evas_object_show(win);
342 evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2);
343 evas_object_smart_callback_add(bt2, "clicked", _transit_flip, bt);
348 test_transit4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
350 Evas_Object *win, *bg, *bt;
352 win = elm_win_add(NULL, "transit4", ELM_WIN_BASIC);
353 elm_win_title_set(win, "Transit 4");
354 elm_win_autodel_set(win, EINA_TRUE);
356 bg = elm_bg_add(win);
357 elm_win_resize_object_add(win, bg);
358 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359 evas_object_show(bg);
361 bt = elm_button_add(win);
362 elm_object_text_set(bt, "Zoom Effect");
363 evas_object_resize(bt, 100, 50);
364 evas_object_move(bt, 100, 125);
365 evas_object_show(bt);
367 evas_object_smart_callback_add(bt, "clicked", _transit_zoom, NULL);
369 evas_object_resize(win, 300, 300);
370 evas_object_show(win);
375 test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
377 Evas_Object *win, *bg, *bt, *bt2, *ic;
380 win = elm_win_add(NULL, "transit5", ELM_WIN_BASIC);
381 elm_win_title_set(win, "Transit 5");
382 elm_win_autodel_set(win, EINA_TRUE);
384 bg = elm_bg_add(win);
385 elm_win_resize_object_add(win, bg);
386 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
387 evas_object_show(bg);
389 ic = elm_icon_add(win);
390 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
391 elm_icon_file_set(ic, buf, NULL);
392 evas_object_size_hint_max_set(ic, 50, 50);
394 bt = elm_button_add(win);
395 elm_object_part_content_set(bt, "icon", ic);
396 elm_object_text_set(bt, "Before Button - Blend Effect");
397 evas_object_move(bt, 25, 125);
398 evas_object_resize(bt, 250, 50);
399 evas_object_show(bt);
401 ic = elm_icon_add(win);
402 snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
403 elm_icon_file_set(ic, buf, NULL);
404 evas_object_size_hint_max_set(ic, 50, 50);
406 bt2 = elm_button_add(win);
407 elm_object_part_content_set(bt2, "icon", ic);
408 elm_object_text_set(bt2, "After Button - Blend Effect");
409 evas_object_move(bt2, 25, 125);
410 evas_object_resize(bt2, 250, 50);
412 evas_object_resize(win, 300, 300);
413 evas_object_show(win);
415 evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2);
416 evas_object_smart_callback_add(bt2, "clicked", _transit_blend, bt);
421 test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
423 Evas_Object *win, *bg, *bt, *bt2, *ic;
426 win = elm_win_add(NULL, "transit6", ELM_WIN_BASIC);
427 elm_win_title_set(win, "Transit 6");
428 elm_win_autodel_set(win, EINA_TRUE);
430 bg = elm_bg_add(win);
431 elm_win_resize_object_add(win, bg);
432 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
433 evas_object_show(bg);
435 ic = elm_icon_add(win);
436 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
437 elm_icon_file_set(ic, buf, NULL);
438 evas_object_size_hint_max_set(ic, 50, 50);
440 bt = elm_button_add(win);
441 elm_object_part_content_set(bt, "icon", ic);
442 elm_object_text_set(bt, "Before Button - Fade Effect");
443 evas_object_move(bt, 25, 125);
444 evas_object_resize(bt, 250, 50);
445 evas_object_show(bt);
447 ic = elm_icon_add(win);
448 snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
449 elm_icon_file_set(ic, buf, NULL);
450 evas_object_size_hint_max_set(ic, 50, 50);
452 bt2 = elm_button_add(win);
453 elm_object_part_content_set(bt2, "icon", ic);
454 elm_object_text_set(bt2, "After Button - Fade Effect");
455 evas_object_move(bt2, 25, 125);
456 evas_object_resize(bt2, 250, 50);
458 evas_object_resize(win, 300, 300);
459 evas_object_show(win);
461 evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2);
462 evas_object_smart_callback_add(bt2, "clicked", _transit_fade, bt);
465 /* Resizable Flip Effect */
467 test_transit7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
469 Evas_Object *win, *bg, *bt, *bt2;
471 win = elm_win_add(NULL, "transit7", ELM_WIN_BASIC);
472 elm_win_title_set(win, "Transit 7");
473 elm_win_autodel_set(win, EINA_TRUE);
475 bg = elm_bg_add(win);
476 elm_win_resize_object_add(win, bg);
477 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
478 evas_object_show(bg);
480 bt = elm_button_add(win);
481 elm_object_text_set(bt, "Front Button - Resizable Flip Effect");
482 evas_object_show(bt);
483 evas_object_move(bt, 50, 100);
484 evas_object_resize(bt, 250, 30);
486 bt2 = elm_button_add(win);
487 elm_object_text_set(bt2, "Back Button - Resizable Flip Effect");
488 evas_object_move(bt2, 50, 100);
489 evas_object_resize(bt2, 300, 200);
491 evas_object_resize(win, 400, 400);
492 evas_object_show(win);
494 evas_object_smart_callback_add(bt, "clicked", _transit_resizable_flip, bt2);
495 evas_object_smart_callback_add(bt2, "clicked", _transit_resizable_flip, bt);
500 test_transit8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
502 Evas_Object *win, *bg, *bt;
504 Elm_Transit_Effect *effect_context;
506 win = elm_win_add(NULL, "transit8", ELM_WIN_BASIC);
507 elm_win_title_set(win, "Transit 8");
508 elm_win_autodel_set(win, EINA_TRUE);
510 bg = elm_bg_add(win);
511 elm_win_resize_object_add(win, bg);
512 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
513 evas_object_show(bg);
515 bt = elm_button_add(win);
516 elm_object_text_set(bt, "Button - Custom Effect");
517 evas_object_show(bt);
518 evas_object_move(bt, 50, 50);
519 evas_object_resize(bt, 150, 150);
522 trans = elm_transit_add();
523 elm_transit_auto_reverse_set(trans, EINA_TRUE);
524 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
525 effect_context = _custom_context_new(150, 150, 50, 50);
526 elm_transit_object_add(trans, bt);
527 elm_transit_effect_add(trans,
528 _custom_op, effect_context,
529 _custom_context_free);
530 elm_transit_duration_set(trans, 5.0);
531 elm_transit_repeat_times_set(trans, -1);
532 elm_transit_go(trans);
534 evas_object_resize(win, 400, 400);
535 evas_object_show(win);
538 /* Chain Transit Effect */
540 test_transit9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
542 Evas_Object *win, *bg, *bt, *bt2, *bt3, *bt4;
543 Elm_Transit *trans, *trans2, *trans3, *trans4;
545 win = elm_win_add(NULL, "transit9", ELM_WIN_BASIC);
546 elm_win_title_set(win, "Transit 9");
547 elm_win_autodel_set(win, EINA_TRUE);
549 bg = elm_bg_add(win);
550 elm_win_resize_object_add(win, bg);
551 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
552 evas_object_show(bg);
554 bt = elm_button_add(win);
555 elm_object_text_set(bt, "Chain 1");
556 evas_object_resize(bt, 100, 100);
557 evas_object_move(bt, 0, 0);
558 evas_object_show(bt);
560 bt2 = elm_button_add(win);
561 elm_object_text_set(bt2, "Chain 2");
562 evas_object_resize(bt2, 100, 100);
563 evas_object_move(bt2, 300, 0);
564 evas_object_show(bt2);
566 bt3 = elm_button_add(win);
567 elm_object_text_set(bt3, "Chain 3");
568 evas_object_resize(bt3, 100, 100);
569 evas_object_move(bt3, 300, 300);
570 evas_object_show(bt3);
572 bt4 = elm_button_add(win);
573 elm_object_text_set(bt4, "Chain 4");
574 evas_object_resize(bt4, 100, 100);
575 evas_object_move(bt4, 0, 300);
576 evas_object_show(bt4);
578 trans = elm_transit_add();
579 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
580 elm_transit_effect_translation_add(trans, 0, 0, 300, 0);
581 elm_transit_object_add(trans, bt);
582 elm_transit_duration_set(trans, 1);
583 elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
584 elm_transit_go(trans);
586 trans2 = elm_transit_add();
587 elm_transit_tween_mode_set(trans2, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
588 elm_transit_effect_translation_add(trans2, 0, 0, 0, 300);
589 elm_transit_object_add(trans2, bt2);
590 elm_transit_duration_set(trans2, 1);
591 elm_transit_objects_final_state_keep_set(trans2, EINA_TRUE);
592 elm_transit_chain_transit_add(trans, trans2);
594 trans3 = elm_transit_add();
595 elm_transit_tween_mode_set(trans3, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
596 elm_transit_effect_translation_add(trans3, 0, 0, -300, 0);
597 elm_transit_object_add(trans3, bt3);
598 elm_transit_duration_set(trans3, 1);
599 elm_transit_objects_final_state_keep_set(trans3, EINA_TRUE);
600 elm_transit_chain_transit_add(trans2, trans3);
602 trans4 = elm_transit_add();
603 elm_transit_tween_mode_set(trans4, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
604 elm_transit_effect_translation_add(trans4, 0, 0, 0, -300);
605 elm_transit_object_add(trans4, bt4);
606 elm_transit_duration_set(trans4, 1);
607 elm_transit_objects_final_state_keep_set(trans4, EINA_TRUE);
608 elm_transit_chain_transit_add(trans3, trans4);
610 evas_object_resize(win, 400, 400);
611 evas_object_show(win);