From 31d667ae526c22c0043dd14c53438cd306d7fc28 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 28 Jan 2015 20:53:01 +0100 Subject: [PATCH] evas: add fill and size definition for a VG scene graph. Change-Id: Ic4a4a7feff25e1c4a5358f01a391dd9f3c00a4fc --- src/lib/evas/canvas/evas_object_vg.c | 38 +++++++++++++++++++++++- src/lib/evas/canvas/evas_vg.eo | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index ccf406a..0ad5c06 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -21,6 +21,10 @@ struct _Evas_VG_Data /* Opening an SVG file (could actually be inside an eet section */ Eina_File *f; const char *key; + + Eina_Rectangle fill; + + unsigned int width, height; }; static void evas_object_vg_render(Evas_Object *eo_obj, @@ -115,6 +119,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) /* root node */ pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); + fprintf(stderr, "creating root node: %p\n", pd->root); eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); @@ -379,8 +384,39 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, } void -_evas_vg_size_get(Eo *obj, Evas_VG_Data *pd, unsigned int *w, unsigned int *h) +_evas_vg_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + unsigned int *w, unsigned int *h) +{ + if (w) *w = pd->width; + if (h) *h = pd->height; +} + +void +_evas_vg_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + unsigned int w, unsigned int h) +{ + pd->width = w; + pd->height = h; +} + +void +_evas_vg_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + pd->fill.x = x; + pd->fill.y = y; + pd->fill.w = w; + pd->fill.h = h; +} + +void +_evas_vg_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { + if (x) *x = pd->fill.x; + if (y) *y = pd->fill.y; + if (w) *w = pd->fill.w; + if (h) *h = pd->fill.h; } #include "evas_vg.eo.c" diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index dcf047b..bf4960e 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -18,6 +18,13 @@ class Evas.VG (Evas.Object, Efl.File) object were added). */ } + set { + /*@ + Set the size defined in the original data + before any scaling (as in the file or when the + object were added). + */ + } values { uint w; uint h; @@ -53,6 +60,56 @@ class Evas.VG (Evas.Object, Efl.File) NULL, otherwise. */ } } + fill { + set { + /*@ + Set how to fill an image object's drawing rectangle given the + (real) image bound to it. + + Note that if @p w or @p h are smaller than the dimensions of + @p obj, the displayed image will be @b tiled around the object's + area. To have only one copy of the bound image drawn, @p x and @p y + must be 0 and @p w and @p h need to be the exact width and height + of the image object itself, respectively. + + See the following image to better understand the effects of this + call. On this diagram, both image object and original image source + have @c a x @c a dimensions and the image itself is a circle, with + empty space around it: + + @image html image-fill.png + @image rtf image-fill.png + @image latex image-fill.eps + + @warning The default values for the fill parameters are @p x = 0, + @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the + evas_object_image_filled_add() helper and want your image + displayed, you'll have to set valid values with this function on + your object. + + @note evas_object_image_filled_set() is a helper function which + will @b override the values set here automatically, for you, in a + given way. */ + } + get { + /*@ + Retrieve how an image object is to fill its drawing rectangle, + given the (real) image bound to it. + + @note Use @c NULL pointers on the fill components you're not + interested in: they'll be ignored by the function. + + See @ref evas_object_image_fill_set() for more details. */ + } + values { + Evas_Coord x; /*@ The x coordinate (from the top left corner of the bound + image) to start drawing from. */ + Evas_Coord y; /*@ The y coordinate (from the top left corner of the bound + image) to start drawing from. */ + Evas_Coord w; /*@ The width the bound image will be displayed at. */ + Evas_Coord h; /*@ The height the bound image will be displayed at. */ + } + } } implements { Eo.Base.constructor; -- 2.7.4