#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 *border_img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/red.png";
static const char *valid_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/enlightenment.png";
static const char *bogus_path = "/tmp/non-existent-220986.png";
static const char *commands = \
"commands are:\n"
"\tx - change image's x fill coordinate\n"
"\ty - change image's y fill coordinate\n"
"\tw - change image's w fill size\n"
"\te - change image's h fill size\n"
"\tf - toggle image filled property (overrides fill)\n"
"\ta - toggle image's alpha channel usage\n"
"\tm - toggle border's smooth scaling\n"
"\tt - change border's thickness\n"
"\tb - change border's center region aspect\n"
"\tc - change border's scaling factor\n"
"\ts - print image's fill property status\n"
"\th - print help\n";
struct test_data
{
Ecore_Evas *ee;
};
static struct test_data d = {0};
static void
{
}
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
}
static const char *
{
switch (mode)
{
return "none";
return "default";
return "solid";
default:
return "invalid";
}
}
static void
void *einfo)
{
if (strcmp(ev->
key,
"h") == 0)
{
puts(commands);
return;
}
if (strcmp(ev->
key,
"m") == 0)
{
printf("Image's border is now %s smooth scaling\n",
smooth_scale ? "without" : "with");
return;
}
if (strcmp(ev->
key,
"t") == 0)
{
int l, r, t, b;
l = (l + 3) % 9;
r = (r + 3) % 9;
t = (t + 3) % 9;
b = (b + 3) % 9;
printf("Image's border thickness is now %d\n", l);
return;
}
if (strcmp(ev->
key,
"c") == 0)
{
scale *= 2;
if (scale > 4.0) scale = 1.0;
printf("Image's border scaling factor is now %f\n", scale);
return;
}
if (strcmp(ev->
key,
"b") == 0)
{
evas_object_image_border_center_fill_get(d.border);
fill = (fill + 1) % 3;
printf("Image's border center region aspect is now \"%s\"\n",
_border_fill_mode_to_str(fill));
return;
}
if (strcmp(ev->
key,
"a") == 0)
{
printf("Image's alpha channel is now %s\n",
alpha ? "off" : "on");
return;
}
if (strcmp(ev->
key,
"f") == 0)
{
printf("Image's x filled property is now %s\n",
filled ? "off" : "on");
return;
}
if (strcmp(ev->
key,
"x") == 0)
{
x = (x + 20) % (WIDTH / 2);
printf("Image's x fill coordinate changed to %d\n", x);
return;
}
if (strcmp(ev->
key,
"y") == 0)
{
y = (y + 20) % (HEIGHT / 2);
printf("Image's y fill coordinate changed to %d\n", y);
return;
}
if (strcmp(ev->
key,
"w") == 0)
{
if (w == (WIDTH / 4)) w = (WIDTH / 2);
else if (w == WIDTH / 2) w = WIDTH;
else w = (WIDTH / 4);
printf("Image's w fill size changed to %d\n", w);
return;
}
if (strcmp(ev->
key,
"e") == 0)
{
if (h == (HEIGHT / 4)) h = (HEIGHT / 2);
else if (h == HEIGHT / 2) h = HEIGHT;
else h = (HEIGHT / 4);
printf("Image's h fill size changed to %d\n", h);
return;
}
if (strcmp(ev->
key,
"s") == 0)
{
printf("Image has fill properties set to: %d, %d, %d, %d\n",
x, y, w, h);
return;
}
}
int
main(void)
{
int err;
return EXIT_FAILURE;
if (!d.ee)
goto error;
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
}
else
{
printf("loaded image '%s' with succes! error string is \"%s\"\n",
}
{
fprintf(stderr, "could not load image '%s': error string is \"%s\"\n",
}
else
{
}
puts(commands);
return 0;
error:
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
" to ecore-evas for this example to run properly.\n");
return -1;
}
int Evas_Coord
Type used for coordinates (in pixels, int).
Definition: Evas_Common.h:116
@ EVAS_CALLBACK_KEY_DOWN
Key Press Event.
Definition: Evas_Common.h:430
EAPI int ecore_evas_init(void)
Inits the Ecore_Evas system.
Definition: ecore_evas.c:602
EAPI void ecore_evas_callback_destroy_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas destroy events.
Definition: ecore_evas.c:1185
EAPI void ecore_evas_show(Ecore_Evas *ee)
Shows an Ecore_Evas' window.
Definition: ecore_evas.c:1480
EAPI Evas * ecore_evas_get(const Ecore_Evas *ee)
Gets an Ecore_Evas's Evas.
Definition: ecore_evas.c:1300
EAPI void ecore_evas_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
Gets the geometry of an Ecore_Evas.
Definition: ecore_evas.c:1362
EAPI Ecore_Evas * ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char *extra_options)
Creates a new Ecore_Evas based on engine name and common parameters.
Definition: ecore_evas.c:1039
EAPI void ecore_evas_callback_resize_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas resize events.
Definition: ecore_evas.c:1140
EAPI int ecore_evas_shutdown(void)
Shuts down the Ecore_Evas system.
Definition: ecore_evas.c:666
EAPI void ecore_evas_free(Ecore_Evas *ee)
Frees an Ecore_Evas.
Definition: ecore_evas.c:1083
void ecore_main_loop_quit(void)
Quits the main loop once all the events currently on the queue have been processed.
Definition: ecore_main.c:1321
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition: ecore_main.c:1311
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
unsigned char Eina_Bool
Type to mimic a boolean.
Definition: eina_types.h:527
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
Eo Evas
An opaque handle to an Evas canvas.
Definition: Evas_Common.h:163
EVAS_API Eina_Bool evas_object_image_alpha_get(const Evas_Object *obj)
Retrieve whether alpha channel data is being used on the given image object.
Definition: evas_image_legacy.c:110
@ EVAS_LOAD_ERROR_NONE
No error on load.
Definition: Evas_Loader.h:141
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1814
EVAS_API void evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
Sets the general/main color of the given Evas object to the given one.
Definition: evas_object_main.c:2024
EVAS_API void evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
Add (register) a callback function to a given Evas object event.
Definition: evas_callbacks.c:478
EVAS_API void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition: evas_object_main.c:1171
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185
EVAS_API void evas_object_focus_set(Efl_Canvas_Object *obj, Eina_Bool focus)
Indicates that this object is the keyboard event receiver on its canvas.
Definition: efl_canvas_object_eo.legacy.c:39
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition: evas_object_main.c:1236
EVAS_API void evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
Dimensions of this image's border, a region that does not scale with the center area.
Definition: evas_image_legacy.c:117
EVAS_API void evas_object_image_fill_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
Set how to fill an image object's drawing rectangle given the (real) image bound to it.
Definition: evas_image_legacy.c:57
EVAS_API Evas_Load_Error evas_object_image_load_error_get(const Evas_Object *obj)
Retrieves a number representing any error that occurred during the last loading of the given image ob...
Definition: evas_image_legacy.c:400
EVAS_API void evas_object_image_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
Dimensions of this image's border, a region that does not scale with the center area.
Definition: evas_image_legacy.c:124
EVAS_API Eina_Bool evas_object_image_filled_get(const Evas_Object *eo_obj)
Retrieve whether the image object's fill property should track the object's size.
Definition: evas_image_legacy.c:74
EVAS_API void evas_object_image_border_scale_set(Evas_Object *obj, double scale)
Scaling factor applied to the image borders.
Definition: evas_image_legacy.c:131
EVAS_API void evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
Specifies how the center part of the object (not the borders) should be drawn when EFL is rendering i...
Definition: evas_image_legacy.c:145
EVAS_API Evas_Object * evas_object_image_add(Evas *eo_e)
Creates a new image object on the given Evas e canvas.
Definition: evas_image_legacy.c:25
Evas_Border_Fill_Mode
How an image's center region (the complement to the border region) should be rendered by Evas.
Definition: Evas_Legacy.h:5720
EVAS_API void evas_object_image_alpha_set(Evas_Object *obj, Eina_Bool alpha)
Enable or disable alpha channel usage on the given image object.
Definition: evas_image_legacy.c:103
EVAS_API void evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
Set the source file from where an image object must fetch the real image data (it may be an Eet file,...
Definition: evas_image_legacy.c:194
EVAS_API void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
Retrieve how an image object is to fill its drawing rectangle, given the (real) image bound to it.
Definition: evas_image_legacy.c:88
EVAS_API void evas_object_image_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth_scale)
Sets whether to use high-quality image scaling algorithm on the given image object.
Definition: evas_image_legacy.c:407
EVAS_API double evas_object_image_border_scale_get(const Evas_Object *obj)
Scaling factor applied to the image borders.
Definition: evas_image_legacy.c:138
EVAS_API void evas_object_image_filled_set(Evas_Object *eo_obj, Eina_Bool value)
Set whether the image object's fill property should track the object's size.
Definition: evas_image_legacy.c:81
EVAS_API Eina_Bool evas_object_image_smooth_scale_get(const Evas_Object *obj)
Retrieves whether the given image object is using high-quality image scaling algorithm.
Definition: evas_image_legacy.c:414
EVAS_API Evas_Object * evas_object_image_filled_add(Evas *eo_e)
Creates a new image object that automatically scales its bound image to the object's area,...
Definition: evas_image_legacy.c:35
@ EVAS_BORDER_FILL_NONE
Image's center region is not to be rendered.
Definition: Evas_Legacy.h:5721
@ EVAS_BORDER_FILL_DEFAULT
Image's center region is to be blended with objects underneath it, if it has transparency.
Definition: Evas_Legacy.h:5722
@ EVAS_BORDER_FILL_SOLID
Image's center region is to be made solid, even if it has transparency on it.
Definition: Evas_Legacy.h:5726
EVAS_API Evas_Object * evas_object_rectangle_add(Evas *e)
Adds a rectangle to the given evas.
Definition: evas_object_rectangle.c:78
EVAS_API const char * evas_load_error_str(Evas_Load_Error error)
Converts the given Evas image load error code into a string describing it in human-readable text.
Definition: evas_main.c:974
Key press event.
Definition: Evas_Legacy.h:314
const char * key
The logical key : (eg shift+1 == exclamation)
Definition: Evas_Legacy.h:320