4 #define PACKAGE_EXAMPLES_DIR "."
9 #include <Ecore_Evas.h>
17 _on_delete(Ecore_Evas *ee __UNUSED__)
19 ecore_main_loop_quit();
22 /* mouse over signals */
24 _on_mouse_over(void *data, Evas_Object *edje_obj,
25 const char *emission __UNUSED__, const char *source __UNUSED__)
28 int x, y, mouseX, mouseY;
31 evas_object_geometry_get(edje_obj, &x, &y, NULL, NULL);
33 evas_pointer_output_xy_get(evas, &mouseX, &mouseY);
35 if ((rand() % 2) == 0)
36 x += ((mouseX - x) + (x / 4 + mouseY / 2));
38 x -= ((mouseX - x) + (x / 4 + mouseY / 2));
40 if ((rand() % 2) == 0)
41 y += ((mouseY - y) + (y / 4 + mouseX / 2));
43 y -= ((mouseY - y) + (y / 4 + mouseX / 2));
47 else if (x < 0) x = 0;
51 else if (y < 0) y = 0;
53 fprintf(stdout, "Moving object to - (%d,%d)\n", x, y);
55 evas_object_move(edje_obj, x, y);
59 main(int argc __UNUSED__, char **argv)
61 const char *edje_file = "signalsBubble.edj";
62 char edje_file_path[PATH_MAX];
67 Evas_Object *edje_obj;
69 if (!ecore_evas_init()) return EXIT_FAILURE;
71 if (!edje_init()) goto shutdown_ecore_evas;
73 pfx = eina_prefix_new(argv[0], main, "EDJE_EXAMPLES", "edje/examples",
74 edje_file, PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
75 PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
77 if (!pfx) goto shutdown_edje;
79 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
81 if (!ee) goto eina_prefix_free;
83 ecore_evas_callback_delete_request_set(ee, _on_delete);
84 ecore_evas_title_set(ee, "Edje animations and signals");
86 evas = ecore_evas_get(ee);
88 bg = evas_object_rectangle_add(evas);
89 evas_object_color_set(bg, 255, 255, 255, 255); //White
90 evas_object_move(bg, 0, 0); //orign
91 evas_object_resize(bg, WIDTH, HEIGHT); //cover the window
94 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
95 evas_object_focus_set(bg, EINA_TRUE);
97 edje_obj = edje_object_add(evas);
99 snprintf(edje_file_path, sizeof(edje_file_path), "%s/examples/%s",
100 eina_prefix_data_get(pfx), edje_file);
102 if (!edje_object_file_set(edje_obj, edje_file_path, "image_group"))
104 int err = edje_object_load_error_get(edje_obj);
105 const char *errmsg = edje_load_error_str(err);
106 fprintf(stderr, "Could not load the edje file - reason:%s\n", errmsg);
107 goto eina_prefix_free;
110 edje_object_signal_callback_add(edje_obj, "mouse,move", "part_image",
111 _on_mouse_over, evas);
112 evas_object_resize(edje_obj, 63, 63);
113 evas_object_move(edje_obj, 50, 50);
114 evas_object_show(edje_obj);
118 ecore_main_loop_begin();
120 eina_prefix_free(pfx);
123 ecore_evas_shutdown();
127 eina_prefix_free: eina_prefix_free(pfx);
129 shutdown_edje: edje_shutdown();
131 shutdown_ecore_evas: ecore_evas_shutdown();