forked from enlightenment/enlightenment
Add code for start of surface smart object.
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
9e420a288e
commit
50f4aeb942
|
@ -0,0 +1,278 @@
|
||||||
|
#include "e.h"
|
||||||
|
//#include "e_comp_wl.h"
|
||||||
|
#include "e_surface.h"
|
||||||
|
|
||||||
|
/* local structures */
|
||||||
|
typedef struct _E_Smart_Data E_Smart_Data;
|
||||||
|
struct _E_Smart_Data
|
||||||
|
{
|
||||||
|
/* canvas */
|
||||||
|
Evas *evas;
|
||||||
|
|
||||||
|
/* object geometry */
|
||||||
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
|
/* input geometry */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
Evas_Coord x, y, w, h;
|
||||||
|
} input;
|
||||||
|
|
||||||
|
/* main image object where we draw pixels to */
|
||||||
|
Evas_Object *o_img;
|
||||||
|
|
||||||
|
/* input rectangle */
|
||||||
|
Evas_Object *o_input;
|
||||||
|
|
||||||
|
/* reference to the surface */
|
||||||
|
/* E_Wayland_Surface *ews; */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* smart function prototypes */
|
||||||
|
static void _e_smart_add(Evas_Object *obj);
|
||||||
|
static void _e_smart_del(Evas_Object *obj);
|
||||||
|
static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||||
|
static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
||||||
|
static void _e_smart_show(Evas_Object *obj);
|
||||||
|
static void _e_smart_hide(Evas_Object *obj);
|
||||||
|
static void _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
|
||||||
|
static void _e_smart_clip_unset(Evas_Object *obj);
|
||||||
|
|
||||||
|
EAPI Evas_Object *
|
||||||
|
e_surface_add(Evas *evas)
|
||||||
|
{
|
||||||
|
/* Evas_Object *obj = NULL; */
|
||||||
|
/* E_Smart_Data *sd = NULL; */
|
||||||
|
|
||||||
|
static Evas_Smart *smart = NULL;
|
||||||
|
static const Evas_Smart_Class sc =
|
||||||
|
{
|
||||||
|
"smart_surface", EVAS_SMART_CLASS_VERSION,
|
||||||
|
_e_smart_add, _e_smart_del, _e_smart_move, _e_smart_resize,
|
||||||
|
_e_smart_show, _e_smart_hide, NULL,
|
||||||
|
_e_smart_clip_set, _e_smart_clip_unset,
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
/* create the smart class */
|
||||||
|
if (!smart)
|
||||||
|
if (!(smart = evas_smart_class_new(&sc)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* create new smart object */
|
||||||
|
/* obj = evas_object_smart_add(evas, smart); */
|
||||||
|
|
||||||
|
/* get the smart data and set reference to the surface */
|
||||||
|
/* if ((sd = evas_object_smart_data_get(obj))) */
|
||||||
|
/* sd->ews = ews; */
|
||||||
|
|
||||||
|
/* return newly created smart object */
|
||||||
|
return evas_object_smart_add(evas, smart);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_surface_input_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
sd->input.x = x;
|
||||||
|
sd->input.y = y;
|
||||||
|
sd->input.w = w;
|
||||||
|
sd->input.h = h;
|
||||||
|
|
||||||
|
/* update input rectangle geometry */
|
||||||
|
if (sd->o_input)
|
||||||
|
{
|
||||||
|
evas_object_move(sd->o_input, x, y);
|
||||||
|
evas_object_resize(sd->o_input, w, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_surface_damage_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* update the image damaged area */
|
||||||
|
if (sd->o_img)
|
||||||
|
evas_object_image_data_update_add(sd->o_img, x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_surface_image_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h, void *pixels)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* update the image damaged area */
|
||||||
|
if (sd->o_img)
|
||||||
|
{
|
||||||
|
evas_object_image_load_size_set(sd->o_img, w, h);
|
||||||
|
evas_object_image_size_set(sd->o_img, w, h);
|
||||||
|
evas_object_image_fill_set(sd->o_img, 0, 0, w, h);
|
||||||
|
evas_object_image_data_copy_set(sd->o_img, pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* smart functions */
|
||||||
|
static void
|
||||||
|
_e_smart_add(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to allocate space for the smart data structure */
|
||||||
|
if (!(sd = E_NEW(E_Smart_Data, 1))) return;
|
||||||
|
|
||||||
|
/* get a reference to the canvas */
|
||||||
|
sd->evas = evas_object_evas_get(obj);
|
||||||
|
|
||||||
|
/* create the image object */
|
||||||
|
sd->o_img = evas_object_image_filled_add(sd->evas);
|
||||||
|
evas_object_image_smooth_scale_set(sd->o_img, EINA_FALSE);
|
||||||
|
evas_object_image_alpha_set(sd->o_img, EINA_TRUE);
|
||||||
|
evas_object_pass_events_set(sd->o_img, EINA_FALSE);
|
||||||
|
evas_object_smart_member_add(sd->o_img, obj);
|
||||||
|
|
||||||
|
/* create the base input rectangle */
|
||||||
|
sd->o_input = evas_object_rectangle_add(sd->evas);
|
||||||
|
evas_object_color_set(sd->o_input, 255, 0, 0, 64);
|
||||||
|
// evas_object_smart_member_add(sd->o_input, obj);
|
||||||
|
|
||||||
|
/* set the objects smart data */
|
||||||
|
evas_object_smart_data_set(obj, sd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_del(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* delete the image object */
|
||||||
|
if (sd->o_img) evas_object_del(sd->o_img);
|
||||||
|
|
||||||
|
/* delete the input rectangle */
|
||||||
|
if (sd->o_input) evas_object_del(sd->o_input);
|
||||||
|
|
||||||
|
/* free the allocated smart data structure */
|
||||||
|
E_FREE(sd);
|
||||||
|
|
||||||
|
/* set the objects smart data */
|
||||||
|
evas_object_smart_data_set(obj, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
// if ((sd->x == x) && (sd->y == y)) return;
|
||||||
|
|
||||||
|
sd->x = x;
|
||||||
|
sd->y = y;
|
||||||
|
|
||||||
|
/* move the input rectangle */
|
||||||
|
if (sd->o_input)
|
||||||
|
evas_object_move(sd->o_input, sd->input.x, sd->input.y);
|
||||||
|
|
||||||
|
/* move the image object */
|
||||||
|
if (sd->o_img) evas_object_move(sd->o_img, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
// if ((sd->w == w) && (sd->h == h)) return;
|
||||||
|
|
||||||
|
sd->w = w;
|
||||||
|
sd->h = h;
|
||||||
|
|
||||||
|
/* resize the input rectangle */
|
||||||
|
if (sd->o_input)
|
||||||
|
evas_object_resize(sd->o_input, sd->input.w, sd->input.h);
|
||||||
|
|
||||||
|
/* resize the image object */
|
||||||
|
if (sd->o_img)
|
||||||
|
{
|
||||||
|
evas_object_image_load_size_set(sd->o_img, w, h);
|
||||||
|
evas_object_image_size_set(sd->o_img, w, h);
|
||||||
|
evas_object_image_fill_set(sd->o_img, 0, 0, w, h);
|
||||||
|
evas_object_resize(sd->o_img, w, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_show(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* show the input rectangle */
|
||||||
|
if (sd->o_input) evas_object_show(sd->o_input);
|
||||||
|
|
||||||
|
/* show the image object */
|
||||||
|
if (sd->o_img) evas_object_show(sd->o_img);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_hide(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* hide the input rectangle */
|
||||||
|
if (sd->o_input) evas_object_hide(sd->o_input);
|
||||||
|
|
||||||
|
/* hide the image object */
|
||||||
|
if (sd->o_img) evas_object_hide(sd->o_img);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* TODO: Hmmm, set clip on the input rectangle ?? */
|
||||||
|
|
||||||
|
/* set the clip on the image object */
|
||||||
|
// if (sd->o_img) evas_object_clip_set(sd->o_img, clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_smart_clip_unset(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd = NULL;
|
||||||
|
|
||||||
|
/* try to get the objects smart data */
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
||||||
|
|
||||||
|
/* TODO: Hmmm, unset clip on the input rectangle ?? */
|
||||||
|
|
||||||
|
/* unset the image object clip */
|
||||||
|
// if (sd->o_img) evas_object_clip_unset(sd->o_img);
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifdef E_TYPEDEFS
|
||||||
|
#else
|
||||||
|
# ifndef E_SURFACE_H
|
||||||
|
# define E_SURFACE_H
|
||||||
|
|
||||||
|
EAPI Evas_Object *e_surface_add(Evas *evas);
|
||||||
|
EAPI void e_surface_input_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
||||||
|
EAPI void e_surface_damage_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
||||||
|
EAPI void e_surface_image_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h, void *pixels);
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
Loading…
Reference in New Issue