evas: remove Evas_Canvas.objects_at_xy_get

also implement Efl_Canvas.objects_at_xy_get

note that any function which returns an iterator cannot be @const since
it's necessary to wref the object to ensure the iterator's lifetime
This commit is contained in:
Mike Blumenkrantz 2018-02-14 21:14:52 -05:00
parent 3789e3e1dc
commit 420ba4691d
5 changed files with 43 additions and 33 deletions

View File

@ -28,7 +28,7 @@ interface Efl.Canvas ()
all smart objects in the canvas.
]]
}
objects_at_xy_get @const {
objects_at_xy_get {
[[Retrieve a list of objects lying over a given position in
a canvas.

View File

@ -2517,7 +2517,7 @@ _efl_ui_win_efl_canvas_smart_objects_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Win_D
}
EOLIAN static Eina_Iterator *
_efl_ui_win_efl_canvas_objects_at_xy_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Position2D pos, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
_efl_ui_win_efl_canvas_objects_at_xy_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Position2D pos, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
{
Eina_List *objs = NULL;
objs = evas_objects_at_xy_get(sd->evas, pos.x, pos.y, include_pass_events_objects, include_hidden_objects);

View File

@ -2292,6 +2292,31 @@ EAPI Eina_Bool evas_object_pointer_coords_inside_get(const Evas_Object *eo_obj,
*/
EAPI Evas *evas_object_evas_get(const Eo *obj);
/**
* @brief Retrieve a list of objects lying over a given position in a canvas.
*
* This function will traverse all the layers of the given canvas, from top to
* bottom, querying for objects with areas covering the given position. The
* user can remove from query objects which are hidden and/or which are set to
* pass events.
*
* @warning This function will skip objects parented by smart objects, acting
* only on the ones at the "top level", with regard to object parenting.
*
* @param[in] obj The object.
* @param[in] x The pixel position.
* @param[in] y The pixel position.
* @param[in] include_pass_events_objects Boolean flag to include or not
* objects which pass events in this calculation.
* @param[in] include_hidden_objects Boolean flag to include or not hidden
* objects in this calculation.
*
* @return The list of objects that are over the given position in @c e.
*
* @ingroup Efl_Canvas
*/
EAPI Eina_List *evas_objects_at_xy_get(Eo *eo_e, int x, int y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects);
/**
* @}
*/

View File

@ -440,35 +440,6 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface,
@in keyname: string @nonull; [[The name of the modifier to disable.]]
}
}
objects_at_xy_get @const {
[[Retrieve a list of Evas objects lying over a given position in
a canvas.
This function will traverse all the layers of the given canvas,
from top to bottom, querying for objects with areas covering the
given position. The user can remove from query objects which are
hidden and/or which are set to pass events.
Warning: This function will skip objects parented by smart
objects, acting only on the ones at the "top level", with
regard to object parenting.
]]
return: list<Efl.Canvas.Object> @warn_unused; [[
The list of Evas objects that are over the given position in $e.
]]
params {
@in x: int; [[The horizontal coordinate of the position.]]
@in y: int; [[The vertical coordinate of the position.]]
@in include_pass_events_objects: bool; [[
Boolean flag to include or not objects which pass events
in this calculation.
]]
@in include_hidden_objects: bool; [[
Boolean flag to include or not hidden objects in this
calculation.
]]
}
}
render_async {
[[Render the given Evas canvas asynchronously.
@ -1113,5 +1084,6 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface,
Efl.Canvas.device { get; }
Efl.Canvas.seat { get; }
Efl.Canvas.image_max_size { get; }
Efl.Canvas.objects_at_xy_get;
}
}

View File

@ -1532,8 +1532,8 @@ _evas_canvas_object_top_in_rectangle_get(const Eo *eo_e EINA_UNUSED, Evas_Public
return NULL;
}
EOLIAN Eina_List*
_evas_canvas_objects_at_xy_get(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, Evas_Coord x, Evas_Coord y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
static Eina_List *
_efl_canvas_evas_canvas_objects_at_xy_get_helper(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int x, int y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
{
Eina_List *in = NULL;
Evas_Layer *lay;
@ -1576,6 +1576,14 @@ _evas_canvas_objects_at_xy_get(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *e,
return in;
}
EOLIAN static Eina_Iterator *
_evas_canvas_efl_canvas_objects_at_xy_get(Eo *eo_e, Evas_Public_Data *e, Eina_Position2D pos, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
{
Eina_List *l = _efl_canvas_evas_canvas_objects_at_xy_get_helper(eo_e, e, pos.x, pos.y, include_pass_events_objects, include_hidden_objects);
if (l) return efl_canvas_iterator_create(eo_e, eina_list_iterator_new(l), l);
return NULL;
}
/**
* Retrieves the objects in the given rectangle region
* @param eo_e The given evas object.
@ -1783,6 +1791,11 @@ evas_pointer_inside_by_device_get(const Evas *obj, Eo *dev)
return efl_canvas_pointer_inside_get(obj, dev);
}
EAPI Eina_List*
evas_objects_at_xy_get(Eo *eo_e, int x, int y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
{
return _efl_canvas_evas_canvas_objects_at_xy_get_helper(eo_e, efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS), x, y, include_pass_events_objects, include_hidden_objects);
}
/* Internal EO APIs */
EWAPI const Efl_Event_Description _EVAS_CANVAS_EVENT_RENDER_FLUSH_PRE =