discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=f1bf1f3c77f20c5ee502d5e280b20c571cb8bee2
commit f1bf1f3c77f20c5ee502d5e280b20c571cb8bee2 Author: Mike Blumenkrantz <zm...@osg.samsung.com> Date: Fri Jun 9 20:16:08 2017 -0400 evas: add some functions for determining if pointer coords are inside an object @feature --- src/lib/evas/canvas/efl_canvas_object.eo | 50 ++++++++++++++++++++++++++++++++ src/lib/evas/canvas/evas_object_main.c | 40 +++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/src/lib/evas/canvas/efl_canvas_object.eo b/src/lib/evas/canvas/efl_canvas_object.eo index 2c8b8c2b6d..a284a43e93 100644 --- a/src/lib/evas/canvas/efl_canvas_object.eo +++ b/src/lib/evas/canvas/efl_canvas_object.eo @@ -606,6 +606,56 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator, enable: bool; [[Enable "no-render" mode.]] } } + @property pointer_inside_by_device { + [[Returns whether the mouse pointer is logically inside the + object. @since 1.20]] + keys { + dev: Efl.Input.Device; [[The pointer device.]] + } + get {} + values { + in: bool; [[$true if the pointer is inside, $false otherwise.]] + } + } + @property pointer_inside { + get { + [[Returns whether the default mouse pointer is logically inside the + object. + + When this function is called it will return a value of either + $false or $true, depending on if event_feed_mouse_in or + event_feed_mouse_out have been called to feed in a mouse + enter event into the object. + + A return value of $true indicates the mouse is logically + inside the object, and $false implies it is logically + outside the object. + + If $e is not a valid object, the return value is undefined. + ]] + return: bool @warn_unused; [[$true if the mouse pointer is inside the object, $false otherwise]] + } + } + pointer_coords_inside_get { + [[Returns whether the coords are logically inside the + object. + + When this function is called it will return a value of either + $false or $true, depending on if the coords are inside the object's + current geometry. + + A return value of $true indicates the position is logically + inside the object, and $false implies it is logically + outside the object. + + If $e is not a valid object, the return value is undefined. + ]] + params { + @in x: int; [[The canvas-relative x coordinate.]] + @in y: int; [[The canvas-relative y coordinate.]] + } + return: bool @warn_unused; [[$true if the coords are inside the object, $false otherwise]] + } } implements { Efl.Object.constructor; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 48b4efe216..da13fb144f 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -2370,6 +2370,46 @@ _efl_canvas_object_precise_is_inside_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Pro return obj->precise_is_inside; } +EOLIAN static Eina_Bool +_efl_canvas_object_pointer_inside_by_device_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Input_Device *dev) +{ + Evas_Pointer_Data *pdata; + Evas_Object_Pointer_Data *obj_pdata; + + if (!obj->layer) return EINA_FALSE; + pdata = _evas_pointer_data_by_device_get(obj->layer->evas, dev); + if (!pdata) return EINA_FALSE; + obj_pdata = _evas_object_pointer_data_get(pdata, obj); + return obj_pdata ? obj_pdata->mouse_in : EINA_FALSE; +} + +EOLIAN static Eina_Bool +_efl_canvas_object_pointer_coords_inside_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y) +{ + Evas_Coord_Rectangle c; + + if (obj->is_smart) + { + Evas_Coord_Rectangle bounding_box = { 0, 0, 0, 0 }; + + evas_object_smart_bounding_box_update(obj); + evas_object_smart_bounding_box_get(obj, &bounding_box, NULL); + c = bounding_box; + } + else + { + if (obj->clip.clipees) return EINA_FALSE; + c = obj->cur->geometry; + } + return RECTS_INTERSECT(x, y, 1, 1, c.x, c.y, c.w, c.h); +} + +EOLIAN static Eina_Bool +_efl_canvas_object_pointer_inside_get(Eo *eo_obj, Evas_Object_Protected_Data *obj) +{ + return _efl_canvas_object_pointer_inside_by_device_get(eo_obj, obj, NULL); +} + static void _is_frame_flag_set(Evas_Object_Protected_Data *obj, Eina_Bool is_frame) { --