From 0706ae31b14408a941af60d8fd4f268d1961da65 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 29 Jun 2016 10:24:39 +0900 Subject: [PATCH] evas: Add 2 EO examples for maps Those are copy & paste & eo-ified versions of the legacy samples. I did not touch the other legacy APIs, only maps. --- src/examples/evas/.gitignore | 2 + src/examples/evas/Makefile.am | 10 + src/examples/evas/evas-map-aa-eo.c | 362 ++++++++++++++++++++++++++++++++++ src/examples/evas/evas-map-utils-eo.c | 328 ++++++++++++++++++++++++++++++ 4 files changed, 702 insertions(+) create mode 100644 src/examples/evas/evas-map-aa-eo.c create mode 100644 src/examples/evas/evas-map-utils-eo.c diff --git a/src/examples/evas/.gitignore b/src/examples/evas/.gitignore index 9ee533c..e0621bb 100644 --- a/src/examples/evas/.gitignore +++ b/src/examples/evas/.gitignore @@ -16,6 +16,7 @@ /evas_text /evas_aspect_hints /evas_map_utils +/evas_map_utils_eo /evas_table /evas_multi_touch /evas_3d_cube @@ -37,6 +38,7 @@ /saved_Sonic_EET.eet /evas_3d_blending /evas_map_aa +/evas_map_aa_eo /evas_3d_mmap /evas_3d_shadows /evas_3d_parallax_occlusion diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am index e13aefa..e179934 100644 --- a/src/examples/evas/Makefile.am +++ b/src/examples/evas/Makefile.am @@ -194,6 +194,16 @@ evas_map_aa_SOURCES = evas-map-aa.c evas_map_aa_LDADD = $(ECORE_EVAS_COMMON_LDADD) evas_map_aa_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) +EXTRA_PROGRAMS += evas_map_utils-eo +evas_map_utils_eo_SOURCES = evas-map-utils-eo.c +evas_map_utils_eo_LDADD = $(ECORE_EVAS_COMMON_LDADD) +evas_map_utils_eo_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) + +EXTRA_PROGRAMS += evas_map_aa_eo +evas_map_aa_eo_SOURCES = evas-map-aa-eo.c +evas_map_aa_eo_LDADD = $(ECORE_EVAS_COMMON_LDADD) +evas_map_aa_eo_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) + EXTRA_PROGRAMS += evas_table evas_table_SOURCES = evas-table.c evas_table_LDADD = $(ECORE_EVAS_COMMON_LDADD) diff --git a/src/examples/evas/evas-map-aa-eo.c b/src/examples/evas/evas-map-aa-eo.c new file mode 100644 index 0000000..00a5bfd --- /dev/null +++ b/src/examples/evas/evas-map-aa-eo.c @@ -0,0 +1,362 @@ +/** + * Example showing the difference between Evas Map with and without + * anti-aliasing (AA). + * + * @verbatim + * gcc -o evas_map_aa_eo evas-map-aa-eo.c `pkg-config --libs --cflags evas ecore ecore-evas eina` + * @endverbatim + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define PACKAGE_EXAMPLES_DIR "." +#endif + +#ifndef EFL_BETA_API_SUPPORT +# define EFL_BETA_API_SUPPORT +#endif + +#ifndef EFL_EO_API_SUPPORT +# define EFL_EO_API_SUPPORT +#endif + +#include +#include +#include +#include +#include +#include "evas-common.h" + +#define WIDTH (800) +#define HEIGHT (400) + +#define IMAGE_SIZE_W 256 +#define IMAGE_SIZE_H 256 + +struct exemple_data +{ + Ecore_Evas *ee; + Evas *evas; + Evas_Object *bg; + Evas_Object *target1; + Evas_Object *target2; + Evas_Coord px1, py1; + Evas_Coord px2, py2; + Evas_Coord px3, py3; + Evas_Coord px4, py4; + Eina_Bool r1_down; + Eina_Bool r2_down; + Eina_Bool r3_down; + Eina_Bool r4_down; + Eina_Bool image; +}; + +static const char *img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/cube1.png"; + +static struct exemple_data d = +{ NULL, NULL, NULL, NULL, NULL, 62, 62, 262, 62, 262, 262, 62, 262, + EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE }; + +static void +update() +{ + efl_gfx_map_populate(d.target1, 0); + + efl_gfx_map_point_coord_set(d.target1, 0, d.px1, d.py1, 0); + efl_gfx_map_point_coord_set(d.target1, 1, d.px2, d.py2, 0); + efl_gfx_map_point_coord_set(d.target1, 2, d.px3, d.py3, 0); + efl_gfx_map_point_coord_set(d.target1, 3, d.px4, d.py4, 0); + + efl_gfx_map_point_image_uv_set(d.target1, 0, 0, 0); + efl_gfx_map_point_image_uv_set(d.target1, 1, IMAGE_SIZE_W, 0); + efl_gfx_map_point_image_uv_set(d.target1, 2, IMAGE_SIZE_W, IMAGE_SIZE_H); + efl_gfx_map_point_image_uv_set(d.target1, 3, 0, IMAGE_SIZE_H); + + efl_gfx_map_enable_set(d.target1, EINA_TRUE); + + efl_gfx_map_dup(d.target2, d.target1); + + efl_gfx_map_point_coord_set(d.target2, 0, d.px1 + 400, d.py1, 0); + efl_gfx_map_point_coord_set(d.target2, 1, d.px2 + 400, d.py2, 0); + efl_gfx_map_point_coord_set(d.target2, 2, d.px3 + 400, d.py3, 0); + efl_gfx_map_point_coord_set(d.target2, 3, d.px4 + 400, d.py4, 0); + + efl_gfx_map_enable_set(d.target2, EINA_TRUE); +} + +static void +r1_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r1_down = EINA_TRUE; +} + +static void +r1_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r1_down = EINA_FALSE; +} + +static void +r1_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info) +{ + Evas_Coord x, y, w, h; + + if (!d.r1_down) return; + + Evas_Event_Mouse_Move *ev = event_info; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + evas_object_move(obj, ev->cur.canvas.x - (w/2), ev->cur.canvas.y - (h/2)); + + d.px1 = ev->cur.canvas.x; + d.py1 = ev->cur.canvas.y; + + update(); +} + +static void +r2_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r2_down = EINA_TRUE; +} + +static void +r2_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r2_down = EINA_FALSE; +} + +static void +r2_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info) +{ + Evas_Coord x, y, w, h; + + if (!d.r2_down) return; + + Evas_Event_Mouse_Move *ev = event_info; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + evas_object_move(obj, ev->cur.canvas.x - (w/2), ev->cur.canvas.y - (h/2)); + + d.px2 = ev->cur.canvas.x; + d.py2 = ev->cur.canvas.y; + + update(); +} + +static void +r3_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r3_down = EINA_TRUE; +} + +static void +r3_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r3_down = EINA_FALSE; +} + +static void +r3_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info) +{ + Evas_Coord x, y, w, h; + + if (!d.r3_down) return; + + Evas_Event_Mouse_Move *ev = event_info; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + evas_object_move(obj, ev->cur.canvas.x - (w/2), ev->cur.canvas.y - (h/2)); + + d.px3 = ev->cur.canvas.x; + d.py3 = ev->cur.canvas.y; + + update(); +} + +static void +r4_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r4_down = EINA_TRUE; +} + +static void +r4_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + d.r4_down = EINA_FALSE; +} + +static void +r4_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info) +{ + if (!d.r4_down) return; + + Evas_Event_Mouse_Move *ev = event_info; + + Evas_Coord x, y, w, h; + evas_object_geometry_get(obj, &x, &y, &w, &h); + + evas_object_move(obj, ev->cur.canvas.x - (w/2), ev->cur.canvas.y - (h/2)); + + d.px4 = ev->cur.canvas.x; + d.py4 = ev->cur.canvas.y; + + update(); +} + +static void +_on_keydown(void *data EINA_UNUSED, Evas *e, Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + + if (!strcmp(ev->keyname, "i") || !strcmp(ev->keyname, "I")) + { + d.image = !d.image; + + if (d.image) + { + evas_object_del(d.target1); + d.target1 = evas_object_image_filled_add(e); + evas_object_image_file_set(d.target1, img_path, NULL); + evas_object_image_smooth_scale_set(d.target1, 0); + evas_object_resize(d.target1, 200, 200); + evas_object_show(d.target1); + + evas_object_del(d.target2); + d.target2 = evas_object_image_filled_add(e); + evas_object_image_file_set(d.target2, img_path, NULL); + evas_object_image_smooth_scale_set(d.target2, 0); + evas_object_anti_alias_set(d.target2, EINA_TRUE); + evas_object_resize(d.target2, 200, 200); + evas_object_show(d.target2); + } + else + { + evas_object_del(d.target1); + d.target1 = evas_object_rectangle_add(e); + evas_object_color_set(d.target1, 255, 0, 0, 255); + evas_object_resize(d.target1, 200, 200); + evas_object_move(d.target1, 64, 64); + evas_object_show(d.target1); + + evas_object_del(d.target2); + d.target2 = evas_object_rectangle_add(e); + evas_object_anti_alias_set(d.target2, EINA_TRUE); + evas_object_color_set(d.target2, 255, 0, 0, 255); + evas_object_resize(d.target2, 200, 200); + evas_object_move(d.target2, 464, 64); + evas_object_show(d.target2); + } + update(); + } +} + +static void +_on_delete(Ecore_Evas *ee EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +int +main(void) +{ + if (!ecore_evas_init()) + return EXIT_FAILURE; + + d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + if (!d.ee) + goto panic; + + ecore_evas_callback_delete_request_set(d.ee, _on_delete); + ecore_evas_show(d.ee); + + d.evas = ecore_evas_get(d.ee); + + d.bg = evas_object_rectangle_add(d.evas); + evas_object_resize(d.bg, WIDTH, HEIGHT); + evas_object_color_set(d.bg, 255, 255, 255, 255); + evas_object_show(d.bg); + + evas_object_focus_set(d.bg, EINA_TRUE); + evas_object_event_callback_add(d.bg, EVAS_CALLBACK_KEY_DOWN, + _on_keydown, NULL); + + Evas_Object *r1 = evas_object_rectangle_add(d.evas); + evas_object_event_callback_add(r1, EVAS_CALLBACK_MOUSE_DOWN, r1_down_cb, 0); + evas_object_event_callback_add(r1, EVAS_CALLBACK_MOUSE_MOVE, r1_move_cb, 0); + evas_object_event_callback_add(r1, EVAS_CALLBACK_MOUSE_UP, r1_up_cb, 0); + evas_object_layer_set(r1, EVAS_LAYER_MAX); + evas_object_color_set(r1, 125, 0, 125, 125); + evas_object_move(r1, 50, 50); + evas_object_resize(r1, 25, 25); + evas_object_show(r1); + + Evas_Object *r2 = evas_object_rectangle_add(d.evas); + evas_object_event_callback_add(r2, EVAS_CALLBACK_MOUSE_DOWN, r2_down_cb, 0); + evas_object_event_callback_add(r2, EVAS_CALLBACK_MOUSE_MOVE, r2_move_cb, 0); + evas_object_event_callback_add(r2, EVAS_CALLBACK_MOUSE_UP, r2_up_cb, 0); + evas_object_layer_set(r2, EVAS_LAYER_MAX); + evas_object_color_set(r2, 0, 0, 0, 125); + evas_object_move(r2, 250, 50); + evas_object_resize(r2, 25, 25); + evas_object_show(r2); + + Evas_Object *r3 = evas_object_rectangle_add(d.evas); + evas_object_event_callback_add(r3, EVAS_CALLBACK_MOUSE_DOWN, r3_down_cb, 0); + evas_object_event_callback_add(r3, EVAS_CALLBACK_MOUSE_MOVE, r3_move_cb, 0); + evas_object_event_callback_add(r3, EVAS_CALLBACK_MOUSE_UP, r3_up_cb, 0); + evas_object_color_set(r3, 0, 0, 125, 125); + evas_object_layer_set(r3, EVAS_LAYER_MAX); + evas_object_move(r3, 250, 250); + evas_object_resize(r3, 25, 25); + evas_object_show(r3); + + Evas_Object *r4 = evas_object_rectangle_add(d.evas); + evas_object_event_callback_add(r4, EVAS_CALLBACK_MOUSE_DOWN, r4_down_cb, 0); + evas_object_event_callback_add(r4, EVAS_CALLBACK_MOUSE_MOVE, r4_move_cb, 0); + evas_object_event_callback_add(r4, EVAS_CALLBACK_MOUSE_UP, r4_up_cb, 0); + evas_object_color_set(r4, 0, 125, 0, 125); + evas_object_layer_set(r4, EVAS_LAYER_MAX); + evas_object_move(r4, 50, 250); + evas_object_resize(r4, 25, 25); + evas_object_show(r4); + + d.target1 = evas_object_rectangle_add(d.evas); + evas_object_color_set(d.target1, 255, 0, 0, 255); + evas_object_resize(d.target1, 200, 200); + evas_object_move(d.target1, 64, 64); + evas_object_show(d.target1); + + d.target2 = evas_object_rectangle_add(d.evas); + evas_object_anti_alias_set(d.target2, EINA_TRUE); + evas_object_color_set(d.target2, 255, 0, 0, 255); + evas_object_resize(d.target2, 200, 200); + evas_object_move(d.target2, 464, 64); + evas_object_show(d.target2); + + ecore_main_loop_begin(); + ecore_evas_shutdown(); + return 0; + +panic: + fprintf(stderr, "You got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + return -2; +} diff --git a/src/examples/evas/evas-map-utils-eo.c b/src/examples/evas/evas-map-utils-eo.c new file mode 100644 index 0000000..0894518 --- /dev/null +++ b/src/examples/evas/evas-map-utils-eo.c @@ -0,0 +1,328 @@ +/** + * Simple Evas example illustrating basic map utils. + * + * You'll need at least one engine built for it (excluding the buffer + * one). See stdout/stderr for output. + * + * @verbatim + * gcc -o evas_map_utils_eo evas-map-utils-eo.c `pkg-config --cflags --libs evas ecore ecore-evas` + * @endverbatim + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define PACKAGE_EXAMPLES_DIR "." +#endif + +#ifndef EFL_BETA_API_SUPPORT +# define EFL_BETA_API_SUPPORT +#endif + +#ifndef EFL_EO_API_SUPPORT +# define EFL_EO_API_SUPPORT +#endif + +#include +#include + +#include +#include +#include +#include +#include "evas-common.h" + +#define WIDTH 480 +#define HEIGHT 480 + +typedef struct +{ + Ecore_Evas *ee; + Evas *canvas; + struct { + int r, g, b, a; + } colors[6]; + int colors_index; + int frame; + Eina_Bool alpha : 1; + Eina_Bool smooth : 1; + Eina_Bool backface_culling : 1; + Eina_Bool apply_perspective : 1; + Eina_Bool apply_lighting : 1; +} App_Data; + +static const char *img1_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/cube1.png"; +static const char *img2_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/enlightenment.png"; +static const char *img3_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/im1.png"; + +static const char *help_string = + "Valid commands:\n" + "\ta - toggle alpha for maps\n" + "\ts - toggle smooth for maps\n" + "\tc - switch map color\n" + "\tb - toggle backface culling\n" + "\tp - toggle perspective\n" + "\tl - toggle lighting\n" + "\th - prints this help\n"; + +static Eina_Bool +_anim_cb(void *data) +{ + App_Data *ad = data; + Evas_Object *o, *ref; + int r, g, b, a; + int win_w, win_h, img_w, img_h; + Evas_Coord x, y, w, h; + + evas_output_size_get(ad->canvas, &win_w, &win_h); + + r = ad->colors[ad->colors_index].r; + g = ad->colors[ad->colors_index].g; + b = ad->colors[ad->colors_index].b; + a = ad->colors[ad->colors_index].a; + + o = evas_object_name_find(ad->canvas, "obj1"); + evas_object_geometry_get(o, &x, &y, &w, &h); + + efl_gfx_map_populate(o, 0); + efl_gfx_map_rotate(o, 3 * ad->frame, x + (w / 2), y + (h / 2)); + efl_gfx_map_smooth_set(o, ad->smooth); + efl_gfx_map_alpha_set(o, ad->alpha); + efl_gfx_map_color_set(o, -1, r, g, b, a); + efl_gfx_map_enable_set(o, EINA_TRUE); + ref = o; + + o = evas_object_name_find(ad->canvas, "obj2"); + evas_object_geometry_get(o, &x, &y, &w, &h); + evas_object_image_size_get(o, &img_w, &img_h); + + efl_gfx_map_dup(o, ref); + efl_gfx_map_populate(o, 100); + efl_gfx_map_point_image_uv_set(o, 0, 0, 0); + efl_gfx_map_point_image_uv_set(o, 1, img_w, 0); + efl_gfx_map_point_image_uv_set(o, 2, img_w, img_h); + efl_gfx_map_point_image_uv_set(o, 3, 0, img_h); + efl_gfx_map_rotate_3d(o, ad->frame * 6, ad->frame * 6, ad->frame * 6, + x + (w / 3), y + 10, 0); + if (ad->apply_lighting) + efl_gfx_map_lightning_3d(o, win_w / 2, win_h / 2, -100, + 255, 255, 255, 0, 0, 0); + efl_gfx_map_enable_set(o, EINA_TRUE); + + o = evas_object_name_find(ad->canvas, "obj3"); + evas_object_geometry_get(o, &x, &y, &w, &h); + evas_object_image_size_get(o, &img_w, &img_h); + + efl_gfx_map_dup(o, ref); + efl_gfx_map_populate_manual(o, x, y + (h / 2), w, h, -20); + efl_gfx_map_point_image_uv_set(o, 0, 0, 0); + efl_gfx_map_point_image_uv_set(o, 1, img_w, 0); + efl_gfx_map_point_image_uv_set(o, 2, img_w, img_h); + efl_gfx_map_point_image_uv_set(o, 3, 0, img_h); + efl_gfx_map_rotate_3d(o, 20, ad->frame * 6, 0, + x + (w / 2), y + (w / 2), w / 2); + + if (ad->apply_perspective) + efl_gfx_map_perspective_3d(o, x + (w / 2), y + (h / 2), 0, 256); + if (ad->apply_lighting) + { + Evas_Coord mx, my; + evas_pointer_canvas_xy_get(ad->canvas, &mx, &my); + efl_gfx_map_lightning_3d(o, mx, my, -256, 255, 255, 255, 0, 0, 0); + } + if (ad->backface_culling) + { + if (efl_gfx_map_clockwise_get(o)) + evas_object_show(o); + else + evas_object_hide(o); + } + else + evas_object_show(o); + efl_gfx_map_enable_set(o, EINA_TRUE); + + o = evas_object_name_find(ad->canvas, "obj4"); + evas_object_geometry_get(o, &x, &y, &w, &h); + evas_object_image_size_get(evas_object_image_source_get(o), &img_w, &img_h); + + efl_gfx_map_dup(o, ref); + efl_gfx_map_point_coord_set(o, 0, x, y + h, 0); + efl_gfx_map_point_coord_set(o, 1, x + w, y + h, 0); + efl_gfx_map_point_coord_set(o, 2, win_w - 10, win_h - 30, 0); + efl_gfx_map_point_coord_set(o, 3, (win_w / 2) + 10, win_h - 30, 0); + efl_gfx_map_point_image_uv_set(o, 0, 0, img_h); + efl_gfx_map_point_image_uv_set(o, 1, img_w, img_h); + efl_gfx_map_point_image_uv_set(o, 2, img_w, 2 * (img_h / 3)); + efl_gfx_map_point_image_uv_set(o, 3, 0, 2 * (img_h / 3)); + efl_gfx_map_color_set(o, 0, 200, 200, 200, 150); + efl_gfx_map_color_set(o, 1, 200, 200, 200, 150); + efl_gfx_map_color_set(o, 2, 0, 0, 0, 0); + efl_gfx_map_color_set(o, 3, 0, 0, 0, 0); + efl_gfx_map_enable_set(o, EINA_TRUE); + + ad->frame = (ad->frame + 1) % 60; + + return EINA_TRUE; +} + +static void +_on_keydown(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event) +{ + App_Data *ad = data; + Evas_Event_Key_Down *ev = event; + switch (ev->key[0]) + { + case 'a': + ad->alpha = !ad->alpha; + break; + case 's': + ad->smooth = !ad->smooth; + break; + case 'c': + ad->colors_index = (ad->colors_index + 1) % 6; + break; + case 'b': + ad->backface_culling = !ad->backface_culling; + break; + case 'p': + ad->apply_perspective = !ad->apply_perspective; + break; + case 'l': + ad->apply_lighting = !ad->apply_lighting; + break; + case 'h': + puts(help_string); + break; + default: + break; + } +} + +static void +_objs_fit(Evas *e) +{ + Evas_Object *o; + int w, h; + + evas_output_size_get(e, &w, &h); + w /= 2; + h /= 2; + + o = evas_object_name_find(e, "obj1"); + evas_object_move(o, w / 4, h / 4); + evas_object_resize(o, w / 2, h / 2); + + o = evas_object_name_find(e, "obj2"); + evas_object_move(o, 5 * w / 4, h / 4); + evas_object_resize(o, w / 2, h / 2); + + o = evas_object_name_find(e, "obj3"); + evas_object_move(o, w / 4, 5 * h / 4); + evas_object_resize(o, w / 2, h / 2); + + o = evas_object_name_find(e, "obj4_source"); + evas_object_move(o, 5 * w / 4, 5 * h / 4); + evas_object_resize(o, w / 2, h / 2); + + o = evas_object_name_find(e, "obj4"); + evas_object_move(o, 5 * w / 4, 5 * h / 4); + evas_object_resize(o, w / 2, h / 2); +} + +static void +_on_resize(void *data EINA_UNUSED, Evas *e, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) +{ + _objs_fit(e); +} + +static void +_on_free(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +int +main(void) +{ + Evas_Object *bg, *o, *osrc; + static App_Data d = { + .ee = NULL, + .canvas = NULL, + .colors = { + { 255, 255, 255, 255 }, + { 128, 128, 0, 128 }, + { 255, 0, 0, 255 }, + { 64, 128, 255, 255 }, + { 11, 23, 58, 132 }, + { 0, 0, 0, 255 } + }, + .colors_index = 0, + .frame = 0, + .alpha = EINA_FALSE, + .smooth = EINA_FALSE, + .backface_culling = EINA_FALSE, + .apply_perspective = EINA_TRUE, + .apply_lighting = EINA_TRUE + }; + + if (!ecore_evas_init()) + return EXIT_FAILURE; + + d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + if (!d.ee) + goto error; + + d.canvas = ecore_evas_get(d.ee); + + bg = evas_object_image_filled_add(d.canvas); + evas_object_image_file_set(bg, img1_path, NULL); + ecore_evas_object_associate(d.ee, bg, 0); + evas_object_focus_set(bg, EINA_TRUE); + evas_object_move(bg, 0, 0); + evas_object_resize(bg, WIDTH, HEIGHT); + evas_object_show(bg); + + o = evas_object_rectangle_add(d.canvas); + evas_object_name_set(o, "obj1"); + evas_object_color_set(o, 128, 0, 200, 200); + evas_object_show(o); + + o = evas_object_image_filled_add(d.canvas); + evas_object_name_set(o, "obj2"); + evas_object_image_file_set(o, img2_path, NULL); + evas_object_show(o); + + o = evas_object_image_filled_add(d.canvas); + evas_object_name_set(o, "obj3"); + evas_object_image_file_set(o, img2_path, NULL); + evas_object_show(o); + + osrc = evas_object_image_filled_add(d.canvas); + evas_object_image_file_set(osrc, img3_path, NULL); + evas_object_name_set(osrc, "obj4_source"); + evas_object_show(osrc); + + o = evas_object_image_filled_add(d.canvas); + evas_object_image_source_set(o, osrc); + evas_object_name_set(o, "obj4"); + evas_object_show(o); + + _objs_fit(d.canvas); + + evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, &d); + evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _on_resize, NULL); + evas_object_event_callback_add(bg, EVAS_CALLBACK_FREE, _on_free, NULL); + + ecore_animator_add(_anim_cb, &d); + + ecore_main_loop_begin(); + + ecore_evas_shutdown(); + return 0; + +error: + fprintf(stderr, "you got to have at least one evas engine built and linked" + " up to ecore-evas for this example to run properly.\n"); + ecore_evas_shutdown(); + return -1; +} -- 2.7.4