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