2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
2009-06-20 00:17:40 -07:00
|
|
|
static void _evas_layer_free(Evas_Layer *lay);
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
void
|
2013-05-02 00:47:16 -07:00
|
|
|
evas_object_inject(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas *e)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Layer *lay;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2012-11-11 18:22:39 -08:00
|
|
|
if (!obj) return;
|
|
|
|
if (!e) return;
|
2005-10-26 19:44:36 -07:00
|
|
|
if (obj->in_layer) return;
|
2013-03-12 05:58:19 -07:00
|
|
|
lay = evas_layer_find(e, obj->cur->layer);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!lay)
|
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
lay = evas_layer_new(e);
|
2013-03-12 05:58:19 -07:00
|
|
|
lay->layer = obj->cur->layer;
|
2011-06-18 02:16:22 -07:00
|
|
|
evas_layer_add(lay);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2013-05-02 00:47:16 -07:00
|
|
|
eo_data_ref(eo_obj, NULL);
|
2012-10-08 18:58:41 -07:00
|
|
|
lay->objects = (Evas_Object_Protected_Data *)eina_inlist_append(EINA_INLIST_GET(lay->objects), EINA_INLIST_GET(obj));
|
2005-11-08 03:59:21 -08:00
|
|
|
lay->usage++;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->layer = lay;
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->in_layer = 1;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-05-02 00:47:16 -07:00
|
|
|
evas_object_release(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, int clean_layer)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-10-26 19:44:36 -07:00
|
|
|
if (!obj->in_layer) return;
|
2012-10-08 18:58:41 -07:00
|
|
|
obj->layer->objects = (Evas_Object_Protected_Data *)eina_inlist_remove(EINA_INLIST_GET(obj->layer->objects), EINA_INLIST_GET(obj));
|
2013-05-02 00:47:16 -07:00
|
|
|
eo_data_unref(eo_obj, obj);
|
2005-11-08 03:59:21 -08:00
|
|
|
obj->layer->usage--;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (clean_layer)
|
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
if (obj->layer->usage <= 0)
|
|
|
|
{
|
|
|
|
evas_layer_del(obj->layer);
|
|
|
|
_evas_layer_free(obj->layer);
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
obj->layer = NULL;
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->in_layer = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Layer *
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_layer_new(Evas *eo_e)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
Evas_Public_Data *e = eo_data_ref(eo_e, EVAS_CLASS);
|
2002-11-08 00:02:15 -08:00
|
|
|
Evas_Layer *lay;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
lay = calloc(1, sizeof(Evas_Layer));
|
|
|
|
if (!lay) return NULL;
|
|
|
|
lay->evas = e;
|
|
|
|
return lay;
|
|
|
|
}
|
|
|
|
|
2009-06-20 00:17:40 -07:00
|
|
|
static void
|
|
|
|
_evas_layer_free(Evas_Layer *lay)
|
|
|
|
{
|
|
|
|
free(lay);
|
|
|
|
}
|
|
|
|
|
2003-01-09 21:38:47 -08:00
|
|
|
void
|
|
|
|
evas_layer_pre_free(Evas_Layer *lay)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object_Protected_Data *obj;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(lay->objects, obj)
|
2003-01-09 21:38:47 -08:00
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
if ((!obj->smart.parent) && (!obj->delete_me))
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_del(obj->object);
|
2003-01-09 21:38:47 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
void
|
2009-06-20 00:17:40 -07:00
|
|
|
evas_layer_free_objects(Evas_Layer *lay)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
while (lay->objects)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object_Protected_Data *obj;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
obj = (Evas_Object_Protected_Data *)lay->objects;
|
|
|
|
evas_object_free(obj->object, 0);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2009-06-15 07:25:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_layer_clean(Evas *eo_e)
|
2009-06-15 07:25:21 -07:00
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CLASS);
|
2009-06-15 07:25:21 -07:00
|
|
|
Evas_Layer *tmp;
|
|
|
|
|
|
|
|
while (e->layers)
|
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
tmp = e->layers;
|
|
|
|
evas_layer_del(tmp);
|
|
|
|
_evas_layer_free(tmp);
|
2009-06-15 07:25:21 -07:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Layer *
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_layer_find(Evas *eo_e, short layer_num)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CLASS);
|
2008-10-17 04:23:18 -07:00
|
|
|
Evas_Layer *layer;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(e->layers, layer)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
if (layer->layer == layer_num) return layer;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_layer_add(Evas_Layer *lay)
|
|
|
|
{
|
2008-10-17 04:23:18 -07:00
|
|
|
Evas_Layer *layer;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(lay->evas->layers, layer)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-06-18 02:16:22 -07:00
|
|
|
if (layer->layer > lay->layer)
|
|
|
|
{
|
|
|
|
lay->evas->layers = (Evas_Layer *)eina_inlist_prepend_relative(EINA_INLIST_GET(lay->evas->layers),
|
|
|
|
EINA_INLIST_GET(lay),
|
|
|
|
EINA_INLIST_GET(layer));
|
|
|
|
return;
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2008-10-17 04:23:18 -07:00
|
|
|
lay->evas->layers = (Evas_Layer *)eina_inlist_append(EINA_INLIST_GET(lay->evas->layers), EINA_INLIST_GET(lay));
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_layer_del(Evas_Layer *lay)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Public_Data *e;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
e = lay->evas;
|
2008-10-17 04:23:18 -07:00
|
|
|
e->layers = (Evas_Layer *)eina_inlist_remove(EINA_INLIST_GET(e->layers), EINA_INLIST_GET(lay));
|
2013-05-02 00:47:16 -07:00
|
|
|
|
|
|
|
eo_data_unref(e->evas, e);
|
|
|
|
lay->evas = NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2012-07-23 21:59:22 -07:00
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_layer_set_child(Evas_Object *eo_obj, Evas_Object *par, short l)
|
2012-07-23 21:59:22 -07:00
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
|
|
|
|
Evas_Object_Protected_Data *par_obj = eo_data_scope_get(par, EVAS_OBJ_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2012-07-23 21:59:22 -07:00
|
|
|
if (obj->delete_me) return;
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->layer == l) return;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_release(eo_obj, obj, 1);
|
2013-03-12 05:58:19 -07:00
|
|
|
EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
|
|
|
|
{
|
|
|
|
state_write->layer = l;
|
|
|
|
}
|
|
|
|
EINA_COW_STATE_WRITE_END(obj, state_write, cur);
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
obj->layer = par_obj->layer;
|
2012-07-23 21:59:22 -07:00
|
|
|
obj->layer->usage++;
|
2012-10-08 18:58:41 -07:00
|
|
|
if (obj->is_smart)
|
2012-07-23 21:59:22 -07:00
|
|
|
{
|
|
|
|
Eina_Inlist *contained;
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object_Protected_Data *member;
|
2012-08-02 09:05:49 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
contained = (Eina_Inlist *)evas_object_smart_members_get_direct(eo_obj);
|
2012-07-23 21:59:22 -07:00
|
|
|
EINA_INLIST_FOREACH(contained, member)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_layer_set_child(member->object, eo_obj, l);
|
2012-07-23 21:59:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* public functions */
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_layer_set(Evas_Object *eo_obj, short l)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
|
2002-11-08 00:02:15 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_do(eo_obj, evas_obj_layer_set(l));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_layer_set(Eo *eo_obj, void *_obj, va_list *list)
|
|
|
|
{
|
|
|
|
short l = va_arg(*list, int);
|
|
|
|
|
|
|
|
Evas *eo_e;
|
|
|
|
Evas_Object_Protected_Data *obj = _obj;
|
|
|
|
|
2011-06-18 02:08:33 -07:00
|
|
|
if (obj->delete_me) return;
|
2012-10-08 18:58:41 -07:00
|
|
|
if (evas_object_intercept_call_layer_set(eo_obj, l)) return;
|
2005-10-26 19:44:36 -07:00
|
|
|
if (obj->smart.parent) return;
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->layer == l)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_raise(eo_obj);
|
2011-06-18 02:16:22 -07:00
|
|
|
return;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_e = obj->layer->evas->evas;
|
|
|
|
evas_object_release(eo_obj, obj, 1);
|
2013-03-12 05:58:19 -07:00
|
|
|
EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
|
|
|
|
{
|
|
|
|
state_write->layer = l;
|
|
|
|
}
|
|
|
|
EINA_COW_STATE_WRITE_END(obj, state_write, cur);
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inject(eo_obj, obj, eo_e);
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->restack = 1;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2002-12-09 22:45:18 -08:00
|
|
|
if (obj->clip.clipees)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inform_call_restack(eo_obj);
|
2011-06-18 02:16:22 -07:00
|
|
|
return;
|
2002-12-09 22:45:18 -08:00
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
if (!obj->is_smart)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
if (evas_object_is_in_output_rect(eo_obj, obj,
|
2011-06-18 02:16:22 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1) &&
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->visible)
|
2011-06-18 02:16:22 -07:00
|
|
|
if (eina_list_data_find(obj->layer->evas->pointer.object.in, obj))
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas->evas,
|
2011-06-18 02:16:22 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y,
|
|
|
|
obj->layer->evas->last_timestamp,
|
|
|
|
NULL);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2012-07-23 21:59:22 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_Inlist *contained;
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object_Protected_Data *member;
|
|
|
|
|
|
|
|
contained = (Eina_Inlist *)evas_object_smart_members_get_direct(eo_obj);
|
2012-07-23 21:59:22 -07:00
|
|
|
EINA_INLIST_FOREACH(contained, member)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_layer_set_child(member->object, eo_obj, l);
|
2012-07-23 21:59:22 -07:00
|
|
|
}
|
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inform_call_restack(eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2008-04-30 23:18:21 -07:00
|
|
|
EAPI short
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_layer_get(const Evas_Object *eo_obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
|
2002-11-08 00:02:15 -08:00
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
2012-10-08 18:58:41 -07:00
|
|
|
short layer = 0;
|
|
|
|
eo_do((Eo *)eo_obj, evas_obj_layer_get(&layer));
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_layer_get(Eo *eo_obj EINA_UNUSED, void *_obj, va_list *list)
|
|
|
|
{
|
|
|
|
short *layer = va_arg(*list, short *);
|
|
|
|
const Evas_Object_Protected_Data *obj = _obj;
|
2007-12-12 15:52:18 -08:00
|
|
|
if (obj->smart.parent)
|
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
Evas_Object_Protected_Data *smart_parent_obj = eo_data_scope_get(obj->smart.parent, EVAS_OBJ_CLASS);
|
2013-03-12 05:58:19 -07:00
|
|
|
*layer = smart_parent_obj->cur->layer;
|
2007-12-12 15:52:18 -08:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
*layer = obj->cur->layer;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|