forked from enlightenment/efl
evas event grabber: add function to block stacking updates while visible
@feature
This commit is contained in:
parent
990a9d485d
commit
881f91ef50
|
@ -7763,4 +7763,5 @@ EAPI void evas_object_text_filter_source_set(Evas_Object *obj, const char *name,
|
|||
* @since 1.20
|
||||
*/
|
||||
EAPI Evas_Object *evas_object_event_grabber_add(Evas *e);
|
||||
#include "canvas/efl_canvas_object_event_grabber.eo.legacy.h"
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,8 @@ struct _Efl_Object_Event_Grabber_Data
|
|||
Eina_List *contained;
|
||||
|
||||
Eina_Bool vis : 1;
|
||||
Eina_Bool freeze : 1;
|
||||
Eina_Bool restack : 1;
|
||||
};
|
||||
|
||||
typedef struct Efl_Object_Event_Grabber_Iterator
|
||||
|
@ -128,12 +130,39 @@ _child_insert(Efl_Object_Event_Grabber_Data *pd, Evas_Object_Protected_Data *obj
|
|||
pd->contained = eina_list_prepend(pd->contained, obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_full_restack(Efl_Object_Event_Grabber_Data *pd)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj;
|
||||
Evas_Object_Protected_Data *root = NULL;
|
||||
Eina_List *list = NULL;
|
||||
EINA_LIST_FREE(pd->contained, obj)
|
||||
{
|
||||
if (obj->object == pd->rect)
|
||||
{
|
||||
root = obj;
|
||||
continue;
|
||||
}
|
||||
list = eina_list_append(list, obj);
|
||||
}
|
||||
|
||||
pd->contained = eina_list_append(pd->contained, root);
|
||||
EINA_LIST_FREE(list, obj)
|
||||
_child_insert(pd, obj);
|
||||
pd->restack = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_canvas_object_event_grabber_child_restack(void *data, const Efl_Event *event)
|
||||
{
|
||||
Efl_Object_Event_Grabber_Data *pd = data;
|
||||
Evas_Object_Protected_Data *obj = efl_data_scope_get(event->object, EFL_CANVAS_OBJECT_CLASS);
|
||||
|
||||
if (pd->vis && pd->freeze)
|
||||
{
|
||||
pd->restack = 1;
|
||||
return;
|
||||
}
|
||||
pd->contained = eina_list_remove(pd->contained, obj);
|
||||
_child_insert(pd, obj);
|
||||
}
|
||||
|
@ -261,6 +290,8 @@ _efl_canvas_object_event_grabber_efl_gfx_visible_set(Eo *eo_obj EINA_UNUSED, Efl
|
|||
}
|
||||
pd->vis = !!set;
|
||||
efl_gfx_visible_set(pd->rect, set);
|
||||
if (pd->restack && pd->freeze && (!set))
|
||||
_full_restack(pd);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -273,27 +304,14 @@ _efl_canvas_object_event_grabber_efl_gfx_stack_layer_set(Eo *eo_obj, Efl_Object_
|
|||
static void
|
||||
_efl_canvas_object_event_grabber_restack(void *data, const Efl_Event *event)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj;
|
||||
Efl_Object_Event_Grabber_Data *pd = data;
|
||||
Evas_Object_Protected_Data *root = NULL;
|
||||
Eina_List *list = NULL;
|
||||
|
||||
evas_object_layer_set(pd->rect, evas_object_layer_get(event->object));
|
||||
evas_object_stack_below(pd->rect, event->object);
|
||||
|
||||
EINA_LIST_FREE(pd->contained, obj)
|
||||
{
|
||||
if (obj->object == pd->rect)
|
||||
{
|
||||
root = obj;
|
||||
continue;
|
||||
}
|
||||
list = eina_list_append(list, obj);
|
||||
}
|
||||
|
||||
pd->contained = eina_list_append(pd->contained, root);
|
||||
EINA_LIST_FREE(list, obj)
|
||||
_child_insert(pd, obj);
|
||||
pd->restack = 1;
|
||||
if (pd->vis && pd->freeze) return;
|
||||
_full_restack(pd);
|
||||
}
|
||||
|
||||
EOLIAN static Eo *
|
||||
|
@ -341,6 +359,22 @@ evas_object_event_grabber_members_list(const Eo *eo_obj)
|
|||
return pd->contained;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_canvas_object_event_grabber_freeze_when_visible_set(Eo *eo_obj EINA_UNUSED, Efl_Object_Event_Grabber_Data *pd, Eina_Bool set)
|
||||
{
|
||||
set = !!set;
|
||||
if (pd->freeze == set) return;
|
||||
pd->freeze = set;
|
||||
if (pd->vis && pd->restack && (!set))
|
||||
_full_restack(pd);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_canvas_object_event_grabber_freeze_when_visible_get(Eo *eo_obj EINA_UNUSED, Efl_Object_Event_Grabber_Data *pd)
|
||||
{
|
||||
return pd->freeze;
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
evas_object_event_grabber_add(Evas *eo_e)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,16 @@ class Efl.Canvas.Object.Event.Grabber (Efl.Canvas.Group)
|
|||
]]
|
||||
data: Efl_Object_Event_Grabber_Data;
|
||||
legacy_prefix: evas_object_event_grabber;
|
||||
methods {
|
||||
@property freeze_when_visible {
|
||||
[[Stops the grabber from updating its internal stacking order while visible]]
|
||||
values {
|
||||
set: bool;
|
||||
}
|
||||
set {}
|
||||
get {}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
class.constructor;
|
||||
Efl.Object.constructor;
|
||||
|
|
Loading…
Reference in New Issue