1 #include "evas_common.h"
2 #include "evas_private.h"
4 static void _evas_layer_free(Evas_Layer *lay);
7 evas_object_inject(Evas_Object *obj, Evas *e)
11 if (obj->in_layer) return;
12 lay = evas_layer_find(e, obj->cur.layer);
15 lay = evas_layer_new(e);
16 lay->layer = obj->cur.layer;
19 lay->objects = (Evas_Object *)eina_inlist_append(EINA_INLIST_GET(lay->objects), EINA_INLIST_GET(obj));
26 evas_object_release(Evas_Object *obj, int clean_layer)
28 if (!obj->in_layer) return;
29 obj->layer->objects = (Evas_Object *)eina_inlist_remove(EINA_INLIST_GET(obj->layer->objects), EINA_INLIST_GET(obj));
33 if (obj->layer->usage <= 0)
35 evas_layer_del(obj->layer);
36 _evas_layer_free(obj->layer);
44 evas_layer_new(Evas *e)
48 lay = calloc(1, sizeof(Evas_Layer));
49 if (!lay) return NULL;
55 _evas_layer_free(Evas_Layer *lay)
61 evas_layer_pre_free(Evas_Layer *lay)
65 EINA_INLIST_FOREACH(lay->objects, obj)
67 if ((!obj->smart.parent) && (!obj->delete_me))
73 evas_layer_free_objects(Evas_Layer *lay)
79 obj = (Evas_Object *)lay->objects;
80 evas_object_free(obj, 0);
85 evas_layer_clean(Evas *e)
93 _evas_layer_free(tmp);
98 evas_layer_find(Evas *e, short layer_num)
102 EINA_INLIST_FOREACH(e->layers, layer)
104 if (layer->layer == layer_num) return layer;
110 evas_layer_add(Evas_Layer *lay)
114 EINA_INLIST_FOREACH(lay->evas->layers, layer)
116 if (layer->layer > lay->layer)
118 lay->evas->layers = (Evas_Layer *)eina_inlist_prepend_relative(EINA_INLIST_GET(lay->evas->layers),
119 EINA_INLIST_GET(lay),
120 EINA_INLIST_GET(layer));
124 lay->evas->layers = (Evas_Layer *)eina_inlist_append(EINA_INLIST_GET(lay->evas->layers), EINA_INLIST_GET(lay));
128 evas_layer_del(Evas_Layer *lay)
133 e->layers = (Evas_Layer *)eina_inlist_remove(EINA_INLIST_GET(e->layers), EINA_INLIST_GET(lay));
136 /* public functions */
139 * @addtogroup Evas_Object_Group_Basic
144 * Sets the layer of the evas that the given object will be part of.
146 * It is not possible to change the layer of a smart object's child.
148 * @param obj The given evas object.
149 * @param l The number of the layer to place the object on.
150 * Between #EVAS_LAYER_MIN and #EVAS_LAYER_MAX.
153 evas_object_layer_set(Evas_Object *obj, short l)
157 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
160 if (evas_object_intercept_call_layer_set(obj, l)) return;
161 if (obj->smart.parent) return;
162 if (obj->cur.layer == l)
164 evas_object_raise(obj);
167 e = obj->layer->evas;
168 evas_object_release(obj, 1);
170 evas_object_inject(obj, e);
172 evas_object_change(obj);
173 if (obj->clip.clipees)
175 evas_object_inform_call_restack(obj);
178 evas_object_change(obj);
179 if (!obj->smart.smart)
181 if (evas_object_is_in_output_rect(obj,
182 obj->layer->evas->pointer.x,
183 obj->layer->evas->pointer.y, 1, 1) &&
185 if (eina_list_data_find(obj->layer->evas->pointer.object.in, obj))
186 evas_event_feed_mouse_move(obj->layer->evas,
187 obj->layer->evas->pointer.x,
188 obj->layer->evas->pointer.y,
189 obj->layer->evas->last_timestamp,
192 evas_object_inform_call_restack(obj);
196 * Retrieves the layer of the evas that the given object is part of.
198 * Be careful, it doesn't make sense to change the layer of smart object's
199 * child. So the returned value could be wrong in some case. Don't rely on
202 * @param obj The given evas object.
203 * @return Number of the layer.
206 evas_object_layer_get(const Evas_Object *obj)
208 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
211 if (obj->smart.parent)
213 return obj->smart.parent->cur.layer;
215 return obj->cur.layer;