ecore_evas_buffer_example_02.c
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define EINA_UNUSED
#define PACKAGE_EXAMPLES_DIR "."
#endif
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <stdio.h>
#define WIDTH (320)
#define HEIGHT (240)
static Ecore_Evas *ee;
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
static void
_on_destroy(Ecore_Evas *ee_ EINA_UNUSED)
{
}
int
main(void)
{
Evas *canvas, *sub_canvas;
Evas_Object *bg, *r0, *r1, *r2, *r3; /* "sub" canvas objects */
Evas_Object *border, *img; /* canvas objects */
Ecore_Evas *sub_ee;
/* this will give you a window with an Evas canvas under the first
* engine available */
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
if (!ee) goto error;
ecore_evas_size_min_set(ee, WIDTH, HEIGHT);
ecore_evas_size_max_set(ee, WIDTH, HEIGHT);
ecore_evas_title_set(ee, "Ecore_Evas buffer (image) example");
canvas = ecore_evas_get(ee);
evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
evas_object_move(bg, 0, 0); /* at origin */
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
/* this is a border around the image containing a scene of another
* canvas */
border = evas_object_image_filled_add(canvas);
evas_object_image_file_set(border, border_img_path, NULL);
evas_object_image_border_set(border, 3, 3, 3, 3);
evas_object_move(border, WIDTH / 6, HEIGHT / 6);
evas_object_resize(border, (2 * WIDTH) / 3, (2 * HEIGHT) / 3);
img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
sub_canvas = ecore_evas_object_evas_get(img);
evas_object_move(img, (WIDTH / 6) + 3, (HEIGHT / 6) + 3);
/* apply the same size on both! */
evas_object_resize(img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
ecore_evas_resize(sub_ee, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
r0 = evas_object_rectangle_add(sub_canvas);
evas_object_color_set(r0, 0, 0, 0, 255); /* 100% opaque black bg */
evas_object_move(r0, 0, 0);
evas_object_resize(r0, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
r1 = evas_object_rectangle_add(sub_canvas);
evas_object_color_set(r1, 255, 0, 0, 255); /* 100% opaque red */
evas_object_move(r1, 10, 10);
evas_object_resize(r1, 100, 100);
r2 = evas_object_rectangle_add(sub_canvas);
evas_object_color_set(r2, 0, 128, 0, 128); /* 50% opaque green */
evas_object_move(r2, 10, 10);
evas_object_resize(r2, 50, 50);
r3 = evas_object_rectangle_add(sub_canvas);
evas_object_color_set(r3, 0, 128, 0, 255); /* 100% opaque dark green */
evas_object_move(r3, 60, 60);
evas_object_resize(r3, 50, 50);
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;
}
Evas wrapper functions.
EAPI void ecore_evas_resize(Ecore_Evas *ee, int w, int h)
Resizes an Ecore_Evas.
Definition: ecore_evas.c:1324
EAPI int ecore_evas_init(void)
Inits the Ecore_Evas system.
Definition: ecore_evas.c:602
EAPI void ecore_evas_title_set(Ecore_Evas *ee, const char *t)
Sets the title of an Ecore_Evas' window.
Definition: ecore_evas.c:1527
EAPI void ecore_evas_callback_delete_request_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas delete request events.
Definition: ecore_evas.c:1176
EAPI Evas * ecore_evas_object_evas_get(Evas_Object *obj)
Retrieve the canvas bound to the internal Ecore_Evas handle of an image object created via ecore_evas...
Definition: ecore_evas.c:1120
EAPI void ecore_evas_show(Ecore_Evas *ee)
Shows an Ecore_Evas' window.
Definition: ecore_evas.c:1480
EAPI void ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h)
Sets the minimum size of a given Ecore_Evas window.
Definition: ecore_evas.c:1560
EAPI Evas * ecore_evas_get(const Ecore_Evas *ee)
Gets an Ecore_Evas's Evas.
Definition: ecore_evas.c:1300
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 int ecore_evas_shutdown(void)
Shuts down the Ecore_Evas system.
Definition: ecore_evas.c:666
EAPI void ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h)
Sets the maximum size of a given Ecore_Evas window.
Definition: ecore_evas.c:1596
EAPI Evas_Object * ecore_evas_object_image_new(Ecore_Evas *ee_target)
Creates an Evas image object with image data bound to an own, internal Ecore_Evas canvas wrapper
Definition: ecore_evas_buffer.c:941
EAPI void ecore_evas_free(Ecore_Evas *ee)
Frees an Ecore_Evas.
Definition: ecore_evas.c:1083
EAPI Ecore_Evas * ecore_evas_object_ecore_evas_get(Evas_Object *obj)
Retrieve the internal Ecore_Evas handle of an image object created via ecore_evas_object_image_new().
Definition: ecore_evas.c:1131
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
#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 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_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_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_size_set(Evas_Object *eo_obj, int w, int h)
Sets the size of the given image object.
Definition: evas_image_legacy.c:847
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 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_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 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_API Evas_Object * evas_object_rectangle_add(Evas *e)
Adds a rectangle to the given evas.
Definition: evas_object_rectangle.c:78