summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/canvas/evas_layer.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2002-11-08 08:02:15 +0000
committerCarsten Haitzler <raster@rasterman.com>2002-11-08 08:02:15 +0000
commit56b5e15f26e16ec835fdcdc7649347f23fb6abf6 (patch)
tree3f86155cee8ee5cec8ae19fcfba6d2625889bff8 /legacy/evas/src/lib/canvas/evas_layer.c
parent5c822574647037eddc7940c1d29702e215c4c832 (diff)
code move
SVN revision: 6445
Diffstat (limited to 'legacy/evas/src/lib/canvas/evas_layer.c')
-rw-r--r--legacy/evas/src/lib/canvas/evas_layer.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_layer.c b/legacy/evas/src/lib/canvas/evas_layer.c
new file mode 100644
index 0000000..3064b84
--- /dev/null
+++ b/legacy/evas/src/lib/canvas/evas_layer.c
@@ -0,0 +1,151 @@
1#include "evas_common.h"
2#include "evas_private.h"
3#include "Evas.h"
4
5void
6evas_object_inject(Evas_Object *obj, Evas *e)
7{
8 Evas_Layer *lay;
9
10 lay = evas_layer_find(e, obj->cur.layer);
11 if (!lay)
12 {
13 lay = evas_layer_new(e);
14 lay->layer = obj->cur.layer;
15 evas_layer_add(lay);
16 }
17 lay->objects = evas_object_list_append(lay->objects, obj);
18 obj->layer = lay;
19}
20
21void
22evas_object_release(Evas_Object *obj, int clean_layer)
23{
24 obj->layer->objects = evas_object_list_remove(obj->layer->objects, obj);
25 if (clean_layer)
26 {
27 if (!obj->layer->objects)
28 {
29 evas_layer_del(obj->layer);
30 evas_layer_free(obj->layer);
31 }
32 }
33 obj->layer = NULL;
34}
35
36Evas_Layer *
37evas_layer_new(Evas *e)
38{
39 Evas_Layer *lay;
40
41 lay = calloc(1, sizeof(Evas_Layer));
42 if (!lay) return NULL;
43 lay->evas = e;
44 return lay;
45}
46
47void
48evas_layer_free(Evas_Layer *lay)
49{
50 while (lay->objects)
51 {
52 Evas_Object *obj;
53
54 obj = (Evas_Object *)lay->objects;
55 if (obj->smart.smart) evas_object_smart_del(obj);
56 evas_object_free(obj, 0);
57 }
58 free(lay);
59}
60
61Evas_Layer *
62evas_layer_find(Evas *e, int layer_num)
63{
64 Evas_Object_List *list;
65
66 for (list = (Evas_Object_List *)e->layers; list; list = list->next)
67 {
68 Evas_Layer *layer;
69
70 layer = (Evas_Layer *)list;
71 if (layer->layer == layer_num) return layer;
72 }
73 return NULL;
74}
75
76void
77evas_layer_add(Evas_Layer *lay)
78{
79 Evas_Object_List *list;
80
81 for (list = (Evas_Object_List *)lay->evas->layers; list; list = list->next)
82 {
83 Evas_Layer *layer;
84
85 layer = (Evas_Layer *)list;
86 if (layer->layer > lay->layer)
87 {
88 lay->evas->layers = evas_object_list_prepend_relative(lay->evas->layers, lay, layer);
89 return;
90 }
91 }
92 lay->evas->layers = evas_object_list_append(lay->evas->layers, lay);
93}
94
95void
96evas_layer_del(Evas_Layer *lay)
97{
98 Evas_Object_List *ol;
99 Evas *e;
100
101 ol = (Evas_Object_List *)lay;
102 e = lay->evas;
103 e->layers = evas_object_list_remove(e->layers, lay);
104}
105
106/* public functions */
107
108void
109evas_object_layer_set(Evas_Object *obj, int l)
110{
111 Evas *e;
112
113 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
114 return;
115 MAGIC_CHECK_END();
116 if (obj->cur.layer == l)
117 {
118 evas_object_raise(obj);
119 return;
120 }
121 if (obj->smart.smart)
122 {
123 if (obj->smart.smart->func_layer_set)
124 obj->smart.smart->func_layer_set(obj, l);
125 }
126 e = obj->layer->evas;
127 evas_object_release(obj, 1);
128 obj->cur.layer = l;
129 evas_object_inject(obj, e);
130 obj->restack = 1;
131 if (obj->clip.clipees) return;
132 if (!obj->smart.smart)
133 {
134 evas_object_change(obj);
135 if (evas_object_is_in_output_rect(obj,
136 obj->layer->evas->pointer.x,
137 obj->layer->evas->pointer.y, 1, 1) &&
138 obj->cur.visible)
139 if (evas_list_find(obj->layer->evas->pointer.object.in, obj))
140 evas_event_feed_mouse_move(obj->layer->evas, obj->layer->evas->pointer.x, obj->layer->evas->pointer.y);
141 }
142}
143
144int
145evas_object_layer_get(Evas_Object *obj)
146{
147 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
148 return 0;
149 MAGIC_CHECK_END();
150 return obj->cur.layer;
151}