Merge branch 'master' of eunmi15.lee@165.213.180.234:/git/slp/pkgs/elementary
[framework/uifw/elementary.git] / src / bin / test_anim.c
1 #include <Elementary.h>
2 #ifndef ELM_LIB_QUICKLAUNCH
3
4 static const char *names[] =
5 {
6      "bub1", "sh1",
7      "bub2", "sh2",
8      "bub3", "sh3",
9 };
10
11 static void
12 _del(void *data, Evas *evas, Evas_Object *obj, void *event_info)
13 {
14    Evas_Object *win = data;
15    Ecore_Animator *ani = evas_object_data_get(win, "animator");
16    
17    ecore_animator_del(ani);
18 }
19
20 static Eina_Bool
21 anim(void *data)
22 {
23    Evas_Object *win = data;
24    Evas_Object *bub, *sh;
25    Evas_Coord x, y, w, h, vw, vh;
26    double t, xx, yy, zz, r, fac;
27    double lx, ly;
28    int i;
29    
30    evas_output_viewport_get(evas_object_evas_get(win), 0, 0, &vw, &vh);
31    r = 48;
32    t = ecore_loop_time_get();
33    fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2));
34    evas_pointer_canvas_xy_get(evas_object_evas_get(win), &x, &y);
35    lx = x;
36    ly = y;
37    
38    for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
39      {
40         bub = evas_object_data_get(win, names[i * 2]);
41         sh = evas_object_data_get(win, names[(i * 2) + 1]);
42         zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2;
43         xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2;
44         yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2;
45         
46         w = zz;
47         h = zz;
48         x = (vw / 2) + xx - (w / 2);
49         y = (vh / 2) + yy - (h / 2);
50         
51         evas_object_move(bub, x, y);
52         evas_object_resize(bub, w, h);
53        
54         x = x - ((lx - (x + (w / 2))) / 4);
55         y = y - ((ly - (y + (h / 2))) / 4);
56         
57         evas_object_move(sh, x, y);
58         evas_object_resize(sh, w, h);
59      }
60    return ECORE_CALLBACK_RENEW;
61 }
62
63 void
64 test_anim(void *data, Evas_Object *obj, void *event_info)
65 {
66    Evas_Object *win, *bg, *bub, *sh;
67    Ecore_Animator *ani;
68    char buf[PATH_MAX];
69    int i;
70    
71    win = elm_win_add(NULL, "animation", ELM_WIN_BASIC);
72    elm_win_title_set(win, "Animation");
73    elm_win_autodel_set(win, 1);
74
75    bg = elm_bg_add(win);
76    snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", PACKAGE_DATA_DIR);
77    elm_bg_file_set(bg, buf, NULL);
78    elm_win_resize_object_add(win, bg);
79    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
80    evas_object_show(bg);
81    
82    snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
83    for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
84      {
85         sh = evas_object_image_filled_add(evas_object_evas_get(win));
86         evas_object_image_file_set(sh, buf, NULL);
87         evas_object_resize(sh, 64, 64);
88         evas_object_show(sh);
89         evas_object_data_set(win, names[(i * 2) + 1], sh);
90      }
91    
92    snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
93     for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
94      {
95         bub = evas_object_image_filled_add(evas_object_evas_get(win));
96         evas_object_image_file_set(bub, buf, NULL);
97         evas_object_resize(bub, 64, 64);
98         evas_object_show(bub);
99         evas_object_data_set(win, names[(i * 2)], bub);
100      }
101    
102    evas_object_resize(win, 480, 800);
103    evas_object_show(win);
104    
105    ani = ecore_animator_add(anim, win);
106    evas_object_data_set(win, "animator", ani);
107    
108    evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _del, win);
109 }
110 #endif