2010-10-19 11:25:22 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2012-03-29 12:27:13 -07:00
|
|
|
#include <Elementary.h>
|
2013-11-04 00:54:31 -08:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
static const char *names[] =
|
|
|
|
{
|
|
|
|
"bub1", "sh1",
|
|
|
|
"bub2", "sh2",
|
|
|
|
"bub3", "sh3",
|
|
|
|
};
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_anim_tick(void *data EINA_UNUSED, const Efl_Event *event)
|
2010-02-01 08:46:26 -08:00
|
|
|
{
|
|
|
|
Evas_Object *bub, *sh;
|
|
|
|
Evas_Coord x, y, w, h, vw, vh;
|
|
|
|
double t, xx, yy, zz, r, fac;
|
|
|
|
double lx, ly;
|
2010-10-19 11:25:22 -07:00
|
|
|
unsigned int i;
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
evas_output_viewport_get(evas_object_evas_get(event->object), 0, 0, &vw, &vh);
|
2010-02-01 08:46:26 -08:00
|
|
|
r = 48;
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2));
|
2016-05-18 08:17:36 -07:00
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(event->object), &x, &y);
|
2010-02-01 08:46:26 -08:00
|
|
|
lx = x;
|
|
|
|
ly = y;
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
bub = evas_object_data_get(event->object, names[i * 2]);
|
|
|
|
sh = evas_object_data_get(event->object, names[(i * 2) + 1]);
|
2010-02-01 08:46:26 -08:00
|
|
|
zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2;
|
|
|
|
xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2;
|
|
|
|
yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2;
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
w = zz;
|
|
|
|
h = zz;
|
|
|
|
x = (vw / 2) + xx - (w / 2);
|
|
|
|
y = (vh / 2) + yy - (h / 2);
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
evas_object_move(bub, x, y);
|
|
|
|
evas_object_resize(bub, w, h);
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
x = x - ((lx - (x + (w / 2))) / 4);
|
|
|
|
y = y - ((ly - (y + (h / 2))) / 4);
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
evas_object_move(sh, x, y);
|
|
|
|
evas_object_resize(sh, w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-08-31 18:18:03 -07:00
|
|
|
test_anim(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-02-01 08:46:26 -08:00
|
|
|
{
|
|
|
|
Evas_Object *win, *bg, *bub, *sh;
|
|
|
|
char buf[PATH_MAX];
|
2010-10-19 11:25:22 -07:00
|
|
|
unsigned int i;
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 18:54:22 -08:00
|
|
|
win = elm_win_add(NULL, "animation", ELM_WIN_BASIC);
|
|
|
|
elm_win_title_set(win, "Animation");
|
2011-07-25 07:22:19 -07:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2010-02-01 08:46:26 -08:00
|
|
|
|
|
|
|
bg = elm_bg_add(win);
|
2011-08-25 03:01:59 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
|
2010-02-01 08:46:26 -08:00
|
|
|
elm_bg_file_set(bg, buf, NULL);
|
|
|
|
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-11-14 02:49:45 -08:00
|
|
|
elm_win_resize_object_add(win, bg);
|
2010-02-01 08:46:26 -08:00
|
|
|
evas_object_show(bg);
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2011-08-25 03:01:59 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", elm_app_data_dir_get());
|
2010-02-01 08:46:26 -08:00
|
|
|
for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
|
|
|
|
{
|
|
|
|
sh = evas_object_image_filled_add(evas_object_evas_get(win));
|
|
|
|
evas_object_image_file_set(sh, buf, NULL);
|
|
|
|
evas_object_resize(sh, 64, 64);
|
|
|
|
evas_object_show(sh);
|
|
|
|
evas_object_data_set(win, names[(i * 2) + 1], sh);
|
|
|
|
}
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2011-08-25 03:01:59 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
|
2010-02-01 08:46:26 -08:00
|
|
|
for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
|
|
|
|
{
|
|
|
|
bub = evas_object_image_filled_add(evas_object_evas_get(win));
|
|
|
|
evas_object_image_file_set(bub, buf, NULL);
|
|
|
|
evas_object_resize(bub, 64, 64);
|
|
|
|
evas_object_show(bub);
|
|
|
|
evas_object_data_set(win, names[(i * 2)], bub);
|
|
|
|
}
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2010-02-01 08:46:26 -08:00
|
|
|
evas_object_resize(win, 480, 800);
|
|
|
|
evas_object_show(win);
|
2011-04-08 07:30:48 -07:00
|
|
|
|
2019-02-21 12:50:35 -08:00
|
|
|
efl_event_callback_add(win, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _anim_tick, NULL);
|
2010-02-01 08:46:26 -08:00
|
|
|
}
|