7
#define PACKAGE_EXAMPLES_DIR "."
11
#ifndef PACKAGE_DATA_DIR
12
#define PACKAGE_DATA_DIR "."
16
#include <Ecore_Evas.h>
24
_on_delete(Ecore_Evas *ee EINA_UNUSED)
26
ecore_main_loop_quit();
31
_on_mouse_over(void *data, Evas_Object *edje_obj,
32
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
35
int x, y, mouseX, mouseY;
38
evas_object_geometry_get(edje_obj, &x, &y, NULL, NULL);
40
evas_pointer_output_xy_get(evas, &mouseX, &mouseY);
42
if ((rand() % 2) == 0)
43
x += ((mouseX - x) + (x / 4 + mouseY / 2));
45
x -= ((mouseX - x) + (x / 4 + mouseY / 2));
47
if ((rand() % 2) == 0)
48
y += ((mouseY - y) + (y / 4 + mouseX / 2));
50
y -= ((mouseY - y) + (y / 4 + mouseX / 2));
54
else if (x < 0) x = 0;
58
else if (y < 0) y = 0;
60
printf("Moving object to - (%d,%d)\n", x, y);
62
evas_object_move(edje_obj, x, y);
66
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
68
const char *edje_file = PACKAGE_DATA_DIR"/signalsBubble.edj";
72
Evas_Object *edje_obj;
74
if (!ecore_evas_init()) return EXIT_FAILURE;
76
if (!edje_init()) goto shutdown_ecore_evas;
78
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
80
if (!ee) goto shutdown_edje;
82
ecore_evas_callback_delete_request_set(ee, _on_delete);
83
ecore_evas_title_set(ee, "Edje animations and signals");
85
evas = ecore_evas_get(ee);
87
bg = evas_object_rectangle_add(evas);
88
evas_object_color_set(bg, 255, 255, 255, 255);
89
evas_object_move(bg, 0, 0);
90
evas_object_resize(bg, WIDTH, HEIGHT);
93
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
94
evas_object_focus_set(bg, EINA_TRUE);
96
edje_obj = edje_object_add(evas);
98
if (!edje_object_file_set(edje_obj, edje_file, "image_group"))
100
int err = edje_object_load_error_get(edje_obj);
101
const char *errmsg = edje_load_error_str(err);
102
fprintf(stderr, "Could not load the edje file - reason:%s\n", errmsg);
106
edje_object_signal_callback_add(edje_obj, "mouse,move", "part_image",
107
_on_mouse_over, evas);
108
evas_object_resize(edje_obj, 63, 63);
109
evas_object_move(edje_obj, 50, 50);
110
evas_object_show(edje_obj);
114
ecore_main_loop_begin();
118
ecore_evas_shutdown();
122
shutdown_edje: edje_shutdown();
124
shutdown_ecore_evas: ecore_evas_shutdown();