#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define PACKAGE_EXAMPLES_DIR "."
#endif
#include <Ecore.h>
#include <stdio.h>
#include <errno.h>
#include "evas-common.h"
#define WIDTH (320)
#define HEIGHT (240)
static const char *img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/enlightenment.png";
static const char *commands = \
"commands are:\n"
"\ta - toggle animation timer\n"
"\tc - cycle between focus and key grabs for key input\n"
"\td - delete canvas callbacks\n"
"\tf - freeze input for 3 seconds\n"
"\tp - toggle precise point collision detection on image\n"
"\tControl + o - add an obscured rectangle\n"
"\th - print help\n";
struct test_data
{
Ecore_Evas *ee;
};
static struct test_data d = {0};
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
}
static void
void *event_info)
{
fprintf(stdout, "An object got focused: %s\n",
fprintf(stdout, "Let's recheck it: %s\n",
fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
"OK!" : "Oops, something is bad.");
}
static void
{
fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
}
{
int w, h, cw, ch;
if (w < cw)
else
}
{
fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
}
static void
{
fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
}
static void
{
fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
}
static void
void *einfo)
{
const Evas_Modifier *mods;
fprintf(stdout,
"We've got key input: %s\n", ev->
key);
fprintf(stdout, "It actually came from %s\n", d.focus ?
"focus" : "key grab");
if (strcmp(ev->
key,
"h") == 0)
{
puts(commands);
return;
}
if (strcmp(ev->
key,
"a") == 0)
{
if (d.resize_timer != NULL)
{
fprintf(stdout, "Stopping animation timer\n");
d.resize_timer = NULL;
}
else
{
fprintf(stdout, "Re-issuing animation timer\n");
}
return;
}
if (strcmp(ev->
key,
"c") == 0)
{
fprintf(stdout, "Switching to %s for key input\n", d.focus ?
"key grabs" : "focus");
if (d.focus)
{
fprintf(stdout, "Focused object is now %s\n",
"still valid! Something went wrong." : "none.");
ret = evas_object_key_grab(d.bg,
"a", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"c", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"d", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"f", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"p", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"o", mask, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg,
"h", 0, 0,
EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
}
else
{
evas_object_key_ungrab(d.bg, "a", 0, 0);
evas_object_key_ungrab(d.bg, "c", 0, 0);
evas_object_key_ungrab(d.bg, "d", 0, 0);
evas_object_key_ungrab(d.bg, "f", 0, 0);
evas_object_key_ungrab(d.bg, "p", 0, 0);
evas_object_key_ungrab(d.bg, "o", mask, 0);
evas_object_key_ungrab(d.bg, "h", 0, 0);
}
c_end:
d.focus = !d.focus;
return;
}
if (strcmp(ev->
key,
"d") == 0)
{
fprintf(stdout, "Deleting canvas event callbacks\n");
_render_flush_cb, NULL);
_object_focus_in_cb, NULL);
return;
}
if (strcmp(ev->
key,
"f") == 0)
{
fprintf(stdout, "Freezing input for 3 seconds\n");
return;
}
if (strcmp(ev->
key,
"p") == 0)
{
Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
fprintf(stdout, "Toggling precise point collision detection %s on"
" Enlightenment logo\n", precise ? "off" : "on");
evas_object_precise_is_inside_set(d.img, !precise);
return;
}
(strcmp(ev->
key,
"o") == 0))
{
fprintf(stdout, "Toggling obscured rectangle on canvas\n");
if (!d.obscured)
{
int w, h;
}
else
{
int w, h;
{
fprintf(stdout, "Rectangle (%d, %d, %d, %d) on canvas got a"
" rendering update.\n", rect->
x, rect->
y,
}
}
d.obscured = !d.obscured;
}
}
int
main(void)
{
int err;
return EXIT_FAILURE;
if (!d.ee)
_render_flush_cb, NULL);
{
fprintf(stderr, "ERROR: Callback registering failed! Aborting.\n");
goto panic;
}
_object_focus_in_cb, NULL);
{
fprintf(stderr, "ERROR: Callback registering failed! Aborting.\n");
goto panic;
}
{
fprintf(stderr, "ERROR: Callback registering failed! Aborting.\n");
goto panic;
}
d.img = evas_object_image_filled_add(d.canvas);
evas_object_image_file_set(d.img, img_path, NULL);
err = evas_object_image_load_error_get(d.img);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "ERROR: Image loading failed! Aborting.\n");
goto panic;
}
else
{
d.img, EVAS_CALLBACK_MOUSE_IN, _on_mouse_in, NULL);
}
puts(commands);
return 0;
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");
panic:
return -1;
}