Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/canvas Modified Files: evas_events.c evas_object_image.c evas_object_main.c Log Message: adrunko's precise event patch =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_events.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -3 -r1.51 -r1.52 --- evas_events.c 30 Apr 2007 04:22:42 -0000 1.51 +++ evas_events.c 23 Jul 2007 14:22:56 -0000 1.52 @@ -57,7 +57,9 @@ } else { - if (evas_object_is_in_output_rect(obj, x, y, 1, 1)) + if (evas_object_is_in_output_rect(obj, x, y, 1, 1) && + ((!obj->precise_is_inside) || + (evas_object_is_inside(obj, x, y)))) { in = evas_list_append(in, obj); if (!obj->repeat_events) @@ -584,7 +586,9 @@ (evas_object_clippers_is_visible(obj)) && (evas_list_find(ins, obj)) && (!evas_event_passes_through(obj)) && - (!obj->clip.clipees)) + (!obj->clip.clipees) && + ((!obj->precise_is_inside) || + (evas_object_is_inside(obj, x, y)))) { if ((px != x) || (py != y)) { @@ -989,7 +993,11 @@ evas_object_smart_member_cache_invalidate(obj); if (evas_object_is_in_output_rect(obj, obj->layer->evas->pointer.x, - obj->layer->evas->pointer.y, 1, 1)) + obj->layer->evas->pointer.y, 1, 1) && + ((!obj->precise_is_inside) || + (evas_object_is_inside(obj, + obj->layer->evas->pointer.x, + obj->layer->evas->pointer.y)))) evas_event_feed_mouse_move(obj->layer->evas, obj->layer->evas->pointer.x, obj->layer->evas->pointer.y, @@ -1036,7 +1044,11 @@ obj->repeat_events = repeat; if (evas_object_is_in_output_rect(obj, obj->layer->evas->pointer.x, - obj->layer->evas->pointer.y, 1, 1)) + obj->layer->evas->pointer.y, 1, 1) && + ((!obj->precise_is_inside) || + (evas_object_is_inside(obj, + obj->layer->evas->pointer.x, + obj->layer->evas->pointer.y)))) evas_event_feed_mouse_move(obj->layer->evas, obj->layer->evas->pointer.x, obj->layer->evas->pointer.y, =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_image.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -3 -r1.55 -r1.56 --- evas_object_image.c 18 Jul 2007 04:42:23 -0000 1.55 +++ evas_object_image.c 23 Jul 2007 14:22:56 -0000 1.56 @@ -16,7 +16,7 @@ Evas_Coord x, y, w, h; } fill; struct { - short w, h; + short w, h, stride; } image; struct { short l, r, t, b; @@ -67,6 +67,7 @@ static int evas_object_image_is_opaque(Evas_Object *obj); static int evas_object_image_was_opaque(Evas_Object *obj); +static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y); static const Evas_Object_Func object_func = { @@ -82,7 +83,7 @@ NULL, evas_object_image_is_opaque, evas_object_image_was_opaque, - NULL, + evas_object_image_is_inside, NULL, NULL }; @@ -241,15 +242,22 @@ if (o->engine_data) { int w, h; + int stride; obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output, o->engine_data, &w, &h); + if (obj->layer->evas->engine.func->image_stride_get) + obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output, + o->engine_data, &stride); + else + stride = w; o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output, o->engine_data); o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output, o->engine_data); o->cur.image.w = w; o->cur.image.h = h; + o->cur.image.stride = stride; } else { @@ -258,6 +266,7 @@ o->cur.cspace = EVAS_COLORSPACE_ARGB8888; o->cur.image.w = 0; o->cur.image.h = 0; + o->cur.image.stride = 0; } o->changed = 1; evas_object_change(obj); @@ -562,6 +571,7 @@ evas_object_image_size_set(Evas_Object *obj, int w, int h) { Evas_Object_Image *o; + int stride; MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return; @@ -586,6 +596,14 @@ o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data (obj->layer->evas->engine.data.output, w, h, NULL, o->cur.has_alpha, o->cur.cspace); + + if (obj->layer->evas->engine.func->image_stride_get) + obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output, + o->engine_data, &stride); + else + stride = w; + o->cur.image.stride = stride; + /* FIXME - in engine call above if (o->engine_data) o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output, @@ -627,6 +645,28 @@ } /** + * Retrieves the row stride, which is the number of units between the start of a row and the start of the next row. + * @param obj The given image object. + * @param stride A pointer to an integer in which to store the stride. Can be + * @c NULL. + * @ingroup Evas_Object_Image_Size + */ +EAPI int +evas_object_image_stride_get(Evas_Object *obj) +{ + Evas_Object_Image *o; + + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); + return 0; + MAGIC_CHECK_END(); + o = (Evas_Object_Image *)(obj->object_data); + MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE); + return 0; + MAGIC_CHECK_END(); + return o->cur.image.stride; +} + +/** * Retrieves a number representing any error that occurred during the last * load for the given image object. * @param obj The given image object. @@ -693,6 +733,7 @@ o->load_error = EVAS_LOAD_ERROR_NONE; o->cur.image.w = 0; o->cur.image.h = 0; + o->cur.image.stride = 0; o->engine_data = NULL; } /* FIXME - in engine call above @@ -1641,6 +1682,7 @@ o->cur.cspace = EVAS_COLORSPACE_ARGB8888; o->cur.image.w = 0; o->cur.image.h = 0; + o->cur.image.stride = 0; } static void @@ -1664,15 +1706,22 @@ if (o->engine_data) { int w, h; + int stride; obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output, o->engine_data, &w, &h); + if (obj->layer->evas->engine.func->image_stride_get) + obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output, + o->engine_data, &stride); + else + stride = w; o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output, o->engine_data); o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output, o->engine_data); o->cur.image.w = w; o->cur.image.h = h; + o->cur.image.stride = stride; } else { @@ -2317,4 +2366,53 @@ if (obj->prev.render_op != EVAS_RENDER_BLEND) return 0; return 1; +} + +static int +evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + Evas_Object_Image *o; + void *data; + int w, h, stride; + int a; + + o = (Evas_Object_Image *)(obj->object_data); + + x -= obj->cur.cache.clip.x; + y -= obj->cur.cache.clip.y; + w = o->cur.image.w; + h = o->cur.image.h; + + if ((x > w) || (y > h)) + return 0; + + if (!o->cur.has_alpha) + return 1; + + stride = o->cur.image.stride; + + o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output, + o->engine_data, + 0, + (DATA32**) &data); + if (!data) + return 0; + + switch (o->cur.cspace) + { + case EVAS_COLORSPACE_ARGB8888: + data = ((DATA32*)(data) + ((y * stride) + x)); + a = (*((DATA32*)(data)) >> 24) & 0xff; + break; + case EVAS_COLORSPACE_RGB565_A5P: + data = ((DATA16*)(data) + (h * stride)); + data = ((DATA8*)(data) + ((y * stride) + x)); + a = (*((DATA8*)(data))) & 0x1f; + break; + default: + return 1; + break; + } + + return (a != 0); } =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_main.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -3 -r1.56 -r1.57 --- evas_object_main.c 21 Feb 2007 21:43:45 -0000 1.56 +++ evas_object_main.c 23 Jul 2007 14:22:56 -0000 1.57 @@ -419,6 +419,23 @@ return 0; } +int +evas_object_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + if (obj->smart.smart) return 0; + if (obj->func->is_inside) + return obj->func->is_inside(obj, x, y); + return 0; +} + +int +evas_object_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + if (obj->smart.smart) return 0; + if (obj->func->was_inside) + return obj->func->was_inside(obj, x, y); + return 0; +} /* routines apps will call */ /** @@ -1220,4 +1237,34 @@ MAGIC_CHECK_END(); if (obj->delete_me) return ""; return obj->type; +} + +/** + * Set whether to use a precise (usually expensive) point collision detection. + * @param obj The given object. + * @param precise wheter to use a precise point collision detection or not + * The default value is false. + * @ingroup Evas_Object_Group + */ +EAPI void +evas_object_precise_is_inside_set(Evas_Object *obj, Evas_Bool precise) +{ + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); + return; + MAGIC_CHECK_END(); + obj->precise_is_inside = precise; +} + +/** + * Determine whether an object is set to use a precise point collision detection. + * @param obj The given object. + * @ingroup Evas_Object_Group + */ +EAPI Evas_Bool +evas_object_precise_is_inside_get(Evas_Object *obj) +{ + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); + return 0; + MAGIC_CHECK_END(); + return obj->precise_is_inside; } ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs