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_image_animation(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
111 Eina_List *images = NULL;
114 Evas_Object *ic = data;
116 snprintf(buf, sizeof(buf), "%s/images/icon_19.png", elm_app_data_dir_get());
117 images = eina_list_append(images, eina_stringshare_add(buf));
119 snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get());
120 images = eina_list_append(images, eina_stringshare_add(buf));
122 snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
123 images = eina_list_append(images, eina_stringshare_add(buf));
125 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
126 images = eina_list_append(images, eina_stringshare_add(buf));
128 trans = elm_transit_add();
129 elm_transit_object_add(trans, ic);
131 elm_transit_effect_image_animation_add(trans, images);
133 elm_transit_duration_set(trans, 5.0);
134 elm_transit_go(trans);
138 _transit_resizing(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
142 trans = elm_transit_add();
143 elm_transit_object_add(trans, obj);
145 elm_transit_effect_resizing_add(trans, 100, 50, 300, 150);
147 elm_transit_duration_set(trans, 5.0);
148 elm_transit_go(trans);
152 _transit_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
155 Evas_Object *obj2 = data;
157 trans = elm_transit_add();
158 elm_transit_object_add(trans, obj);
159 elm_transit_object_add(trans, obj2);
161 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
163 elm_transit_duration_set(trans, 5.0);
164 elm_transit_go(trans);
168 _transit_zoom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
172 trans = elm_transit_add();
173 elm_transit_object_add(trans, obj);
175 elm_transit_effect_zoom_add(trans, 1.0, 3.0);
177 elm_transit_duration_set(trans, 5.0);
178 elm_transit_go(trans);
182 _transit_blend(void *data, Evas_Object *obj, void *event_info __UNUSED__)
185 Evas_Object *obj2 = data;
187 trans = elm_transit_add();
188 elm_transit_object_add(trans, obj);
189 elm_transit_object_add(trans, obj2);
191 elm_transit_effect_blend_add(trans);
193 elm_transit_duration_set(trans, 5.0);
194 elm_transit_go(trans);
198 _transit_fade(void *data, Evas_Object *obj, void *event_info __UNUSED__)
201 Evas_Object *obj2 = data;
203 trans = elm_transit_add();
204 elm_transit_object_add(trans, obj);
205 elm_transit_object_add(trans, obj2);
207 elm_transit_effect_fade_add(trans);
209 elm_transit_duration_set(trans, 5.0);
210 elm_transit_go(trans);
214 _transit_resizable_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
217 Evas_Object *obj2 = data;
219 trans = elm_transit_add();
220 elm_transit_object_add(trans, obj);
221 elm_transit_object_add(trans, obj2);
223 elm_transit_effect_resizable_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
225 elm_transit_duration_set(trans, 5.0);
226 elm_transit_go(trans);
229 /* Translation, Rotation, Color, Wipe, ImagemAnimation Effect */
231 test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
233 Evas_Object *win, *bg, *bx, *bt, *ic;
236 win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
237 elm_win_title_set(win, "Transit");
238 elm_win_autodel_set(win, EINA_TRUE);
240 bg = elm_bg_add(win);
241 elm_win_resize_object_add(win, bg);
242 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
243 evas_object_show(bg);
245 bx = elm_box_add(win);
246 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
247 elm_win_resize_object_add(win, bx);
248 evas_object_size_hint_min_set(bx, 318, 318);
249 evas_object_show(bx);
251 ic = elm_icon_add(win);
252 snprintf(buf, sizeof(buf), "%s/images/icon_11.png", elm_app_data_dir_get());
253 elm_icon_file_set(ic, buf, NULL);
254 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
256 bt = elm_button_add(win);
257 elm_object_text_set(bt, "ImageAnimation Effect");
258 elm_object_content_set(bt, ic);
259 elm_box_pack_end(bx, bt);
260 evas_object_show(bt);
261 evas_object_show(ic);
262 evas_object_smart_callback_add(bt, "clicked", _transit_image_animation, ic);
264 bt = elm_button_add(win);
265 elm_object_text_set(bt, "Color, Rotation and Translation");
266 elm_box_pack_end(bx, bt);
267 evas_object_show(bt);
268 evas_object_smart_callback_add(bt, "clicked",
269 _transit_rotation_translation_color, NULL);
271 bt = elm_button_add(win);
272 elm_object_text_set(bt, "Wipe Effect");
273 elm_box_pack_end(bx, bt);
274 evas_object_show(bt);
275 evas_object_smart_callback_add(bt, "clicked", _transit_wipe, NULL);
277 evas_object_show(win);
280 /* Resizing Effect */
282 test_transit2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
284 Evas_Object *win, *bg, *bt;
286 win = elm_win_add(NULL, "transit2", ELM_WIN_BASIC);
287 elm_win_title_set(win, "Transit 2");
288 elm_win_autodel_set(win, EINA_TRUE);
290 bg = elm_bg_add(win);
291 elm_win_resize_object_add(win, bg);
292 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
293 evas_object_show(bg);
295 bt = elm_button_add(win);
296 elm_object_text_set(bt, "Resizing Effect");
297 evas_object_show(bt);
298 evas_object_move(bt, 50, 100);
299 evas_object_resize(bt, 100, 50);
300 evas_object_smart_callback_add(bt, "clicked", _transit_resizing, NULL);
302 evas_object_resize(win, 400, 400);
303 evas_object_show(win);
308 test_transit3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
310 Evas_Object *win, *bg, *bt, *bt2;
312 win = elm_win_add(NULL, "transit3", ELM_WIN_BASIC);
313 elm_win_title_set(win, "Transit 3");
314 elm_win_autodel_set(win, EINA_TRUE);
316 bg = elm_bg_add(win);
317 elm_win_resize_object_add(win, bg);
318 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
319 evas_object_show(bg);
321 bt = elm_button_add(win);
322 elm_object_text_set(bt, "Front Button - Flip Effect");
323 evas_object_show(bt);
324 evas_object_move(bt, 50, 50);
325 evas_object_resize(bt, 200, 200);
327 bt2 = elm_button_add(win);
328 elm_object_text_set(bt2, "Back Button - Flip Effect");
329 evas_object_move(bt2, 50, 50);
330 evas_object_resize(bt2, 200, 200);
332 evas_object_resize(win, 300, 300);
333 evas_object_show(win);
335 evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2);
336 evas_object_smart_callback_add(bt2, "clicked", _transit_flip, bt);
341 test_transit4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
343 Evas_Object *win, *bg, *bt;
345 win = elm_win_add(NULL, "transit4", ELM_WIN_BASIC);
346 elm_win_title_set(win, "Transit 4");
347 elm_win_autodel_set(win, EINA_TRUE);
349 bg = elm_bg_add(win);
350 elm_win_resize_object_add(win, bg);
351 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
352 evas_object_show(bg);
354 bt = elm_button_add(win);
355 elm_object_text_set(bt, "Zoom Effect");
356 evas_object_resize(bt, 100, 50);
357 evas_object_move(bt, 100, 125);
358 evas_object_show(bt);
360 evas_object_smart_callback_add(bt, "clicked", _transit_zoom, NULL);
362 evas_object_resize(win, 300, 300);
363 evas_object_show(win);
368 test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
370 Evas_Object *win, *bg, *bt, *bt2, *ic;
373 win = elm_win_add(NULL, "transit5", ELM_WIN_BASIC);
374 elm_win_title_set(win, "Transit 5");
375 elm_win_autodel_set(win, EINA_TRUE);
377 bg = elm_bg_add(win);
378 elm_win_resize_object_add(win, bg);
379 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
380 evas_object_show(bg);
382 ic = elm_icon_add(win);
383 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
384 elm_icon_file_set(ic, buf, NULL);
385 evas_object_size_hint_max_set(ic, 50, 50);
387 bt = elm_button_add(win);
388 elm_object_content_set(bt, ic);
389 elm_object_text_set(bt, "Before Button - Blend Effect");
390 evas_object_move(bt, 25, 125);
391 evas_object_resize(bt, 250, 50);
392 evas_object_show(bt);
394 ic = elm_icon_add(win);
395 snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
396 elm_icon_file_set(ic, buf, NULL);
397 evas_object_size_hint_max_set(ic, 50, 50);
399 bt2 = elm_button_add(win);
400 elm_object_content_set(bt2, ic);
401 elm_object_text_set(bt2, "After Button - Blend Effect");
402 evas_object_move(bt2, 25, 125);
403 evas_object_resize(bt2, 250, 50);
405 evas_object_resize(win, 300, 300);
406 evas_object_show(win);
408 evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2);
409 evas_object_smart_callback_add(bt2, "clicked", _transit_blend, bt);
414 test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
416 Evas_Object *win, *bg, *bt, *bt2, *ic;
419 win = elm_win_add(NULL, "transit6", ELM_WIN_BASIC);
420 elm_win_title_set(win, "Transit 6");
421 elm_win_autodel_set(win, EINA_TRUE);
423 bg = elm_bg_add(win);
424 elm_win_resize_object_add(win, bg);
425 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
426 evas_object_show(bg);
428 ic = elm_icon_add(win);
429 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
430 elm_icon_file_set(ic, buf, NULL);
431 evas_object_size_hint_max_set(ic, 50, 50);
433 bt = elm_button_add(win);
434 elm_object_content_set(bt, ic);
435 elm_object_text_set(bt, "Before Button - Fade Effect");
436 evas_object_move(bt, 25, 125);
437 evas_object_resize(bt, 250, 50);
438 evas_object_show(bt);
440 ic = elm_icon_add(win);
441 snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
442 elm_icon_file_set(ic, buf, NULL);
443 evas_object_size_hint_max_set(ic, 50, 50);
445 bt2 = elm_button_add(win);
446 elm_object_content_set(bt2, ic);
447 elm_object_text_set(bt2, "After Button - Fade Effect");
448 evas_object_move(bt2, 25, 125);
449 evas_object_resize(bt2, 250, 50);
451 evas_object_resize(win, 300, 300);
452 evas_object_show(win);
454 evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2);
455 evas_object_smart_callback_add(bt2, "clicked", _transit_fade, bt);
458 /* Resizable Flip Effect */
460 test_transit7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
462 Evas_Object *win, *bg, *bt, *bt2;
464 win = elm_win_add(NULL, "transit7", ELM_WIN_BASIC);
465 elm_win_title_set(win, "Transit 7");
466 elm_win_autodel_set(win, EINA_TRUE);
467 evas_object_resize(win, 400, 400);
469 bg = elm_bg_add(win);
470 elm_win_resize_object_add(win, bg);
471 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
472 evas_object_show(bg);
474 bt = elm_button_add(win);
475 elm_object_text_set(bt, "Front Button - Resizable Flip Effect");
476 evas_object_show(bt);
477 evas_object_move(bt, 50, 100);
478 evas_object_resize(bt, 250, 30);
480 bt2 = elm_button_add(win);
481 elm_object_text_set(bt2, "Back Button - Resizable Flip Effect");
482 evas_object_move(bt2, 50, 100);
483 evas_object_resize(bt2, 300, 200);
485 evas_object_show(win);
487 evas_object_smart_callback_add(bt, "clicked", _transit_resizable_flip, bt2);
488 evas_object_smart_callback_add(bt2, "clicked", _transit_resizable_flip, bt);
493 test_transit8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
495 Evas_Object *win, *bg, *bt;
497 Elm_Transit_Effect *effect_context;
499 win = elm_win_add(NULL, "transit8", ELM_WIN_BASIC);
500 elm_win_title_set(win, "Transit 8");
501 elm_win_autodel_set(win, EINA_TRUE);
503 bg = elm_bg_add(win);
504 elm_win_resize_object_add(win, bg);
505 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
506 evas_object_show(bg);
508 bt = elm_button_add(win);
509 elm_object_text_set(bt, "Button - Custom Effect");
510 evas_object_show(bt);
511 evas_object_move(bt, 50, 50);
512 evas_object_resize(bt, 150, 150);
515 trans = elm_transit_add();
516 elm_transit_auto_reverse_set(trans, EINA_TRUE);
517 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
518 effect_context = _custom_context_new(150, 150, 50, 50);
519 elm_transit_object_add(trans, bt);
520 elm_transit_effect_add(trans,
521 _custom_op, effect_context,
522 _custom_context_free);
523 elm_transit_duration_set(trans, 5.0);
524 elm_transit_repeat_times_set(trans, -1);
525 elm_transit_go(trans);
527 evas_object_resize(win, 400, 400);
528 evas_object_show(win);
531 /* Chain Transit Effect */
533 test_transit9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
535 Evas_Object *win, *bg, *bt, *bt2, *bt3, *bt4;
536 Elm_Transit *trans, *trans2, *trans3, *trans4;
538 win = elm_win_add(NULL, "transit9", ELM_WIN_BASIC);
539 elm_win_title_set(win, "Transit 9");
540 elm_win_autodel_set(win, EINA_TRUE);
542 bg = elm_bg_add(win);
543 elm_win_resize_object_add(win, bg);
544 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
545 evas_object_show(bg);
547 bt = elm_button_add(win);
548 elm_object_text_set(bt, "Chain 1");
549 evas_object_resize(bt, 100, 100);
550 evas_object_move(bt, 0, 0);
551 evas_object_show(bt);
553 bt2 = elm_button_add(win);
554 elm_object_text_set(bt2, "Chain 2");
555 evas_object_resize(bt2, 100, 100);
556 evas_object_move(bt2, 300, 0);
557 evas_object_show(bt2);
559 bt3 = elm_button_add(win);
560 elm_object_text_set(bt3, "Chain 3");
561 evas_object_resize(bt3, 100, 100);
562 evas_object_move(bt3, 300, 300);
563 evas_object_show(bt3);
565 bt4 = elm_button_add(win);
566 elm_object_text_set(bt4, "Chain 4");
567 evas_object_resize(bt4, 100, 100);
568 evas_object_move(bt4, 0, 300);
569 evas_object_show(bt4);
571 trans = elm_transit_add();
572 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
573 elm_transit_effect_translation_add(trans, 0, 0, 300, 0);
574 elm_transit_object_add(trans, bt);
575 elm_transit_duration_set(trans, 1);
576 elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
577 elm_transit_go(trans);
579 trans2 = elm_transit_add();
580 elm_transit_tween_mode_set(trans2, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
581 elm_transit_effect_translation_add(trans2, 0, 0, 0, 300);
582 elm_transit_object_add(trans2, bt2);
583 elm_transit_duration_set(trans2, 1);
584 elm_transit_objects_final_state_keep_set(trans2, EINA_TRUE);
585 elm_transit_chain_transit_add(trans, trans2);
587 trans3 = elm_transit_add();
588 elm_transit_tween_mode_set(trans3, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
589 elm_transit_effect_translation_add(trans3, 0, 0, -300, 0);
590 elm_transit_object_add(trans3, bt3);
591 elm_transit_duration_set(trans3, 1);
592 elm_transit_objects_final_state_keep_set(trans3, EINA_TRUE);
593 elm_transit_chain_transit_add(trans2, trans3);
595 trans4 = elm_transit_add();
596 elm_transit_tween_mode_set(trans4, ELM_TRANSIT_TWEEN_MODE_ACCELERATE);
597 elm_transit_effect_translation_add(trans4, 0, 0, 0, -300);
598 elm_transit_object_add(trans4, bt4);
599 elm_transit_duration_set(trans4, 1);
600 elm_transit_objects_final_state_keep_set(trans4, EINA_TRUE);
601 elm_transit_chain_transit_add(trans3, trans4);
603 evas_object_resize(win, 400, 400);
604 evas_object_show(win);