aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib/edje_smart.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/lib/edje_smart.c')
-rw-r--r--libraries/edje/src/lib/edje_smart.c336
1 files changed, 336 insertions, 0 deletions
diff --git a/libraries/edje/src/lib/edje_smart.c b/libraries/edje/src/lib/edje_smart.c
new file mode 100644
index 0000000..59ccc46
--- /dev/null
+++ b/libraries/edje/src/lib/edje_smart.c
@@ -0,0 +1,336 @@
1#include "edje_private.h"
2
3static void _edje_smart_add(Evas_Object * obj);
4static void _edje_smart_del(Evas_Object * obj);
5static void _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
6static void _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
7static void _edje_smart_show(Evas_Object * obj);
8static void _edje_smart_hide(Evas_Object * obj);
9static void _edje_smart_calculate(Evas_Object * obj);
10
11static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group);
12
13static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje");
14static Evas_Smart_Class _edje_smart_parent;
15static Evas_Smart *_edje_smart = NULL;
16
17Eina_List *_edje_edjes = NULL;
18
19/************************** API Routines **************************/
20
21EAPI Evas_Object *
22edje_object_add(Evas *evas)
23{
24 Evas_Object *e;
25
26 _edje_lib_ref();
27
28 if (!_edje_smart)
29 {
30 memset(&_edje_smart_parent, 0, sizeof(_edje_smart_parent));
31 _edje_object_smart_set(&_edje_smart_class);
32 _edje_smart =
33 evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class);
34 }
35
36 e = evas_object_smart_add(evas, _edje_smart);
37
38 return e;
39}
40
41void
42_edje_object_smart_set(Edje_Smart_Api *sc)
43{
44 if (!sc)
45 return;
46
47 evas_object_smart_clipped_smart_set(&sc->base);
48
49 _edje_smart_parent.add = sc->base.add; /* Save parent class */
50 sc->base.add = _edje_smart_add;
51 _edje_smart_parent.del = sc->base.del; /* Save parent class */
52 sc->base.del = _edje_smart_del;
53 /* we'll handle move thank you */
54 sc->base.move = _edje_smart_move;
55 sc->base.resize = _edje_smart_resize;
56 _edje_smart_parent.show = sc->base.show; /* Save parent class */
57 sc->base.show = _edje_smart_show;
58 _edje_smart_parent.hide = sc->base.hide; /* Save parent class */
59 sc->base.hide = _edje_smart_hide;
60 sc->base.calculate = _edje_smart_calculate;
61 //sc->base.member_add = NULL;
62 //sc->base.member_del = NULL;
63 sc->file_set = _edje_smart_file_set;
64}
65
66const Edje_Smart_Api *
67_edje_object_smart_class_get(void)
68{
69 static const Edje_Smart_Api *class = NULL;
70
71 if (class)
72 return class;
73
74 _edje_object_smart_set(&_edje_smart_class);
75 class = &_edje_smart_class;
76
77 return class;
78}
79
80/* Private Routines */
81static void
82_edje_smart_add(Evas_Object *obj)
83{
84 Edje *ed;
85 Evas *tev = evas_object_evas_get(obj);
86
87 evas_event_freeze(tev);
88 ed = evas_object_smart_data_get(obj);
89 if (!ed)
90 {
91 const Evas_Smart *smart;
92 const Evas_Smart_Class *sc;
93
94 ed = calloc(1, sizeof(Edje));
95 if (!ed) goto end_smart_add;
96
97 smart = evas_object_smart_smart_get(obj);
98 sc = evas_smart_class_get(smart);
99 ed->api = (const Edje_Smart_Api *)sc;
100
101 evas_object_smart_data_set(obj, ed);
102 }
103
104 ed->base.evas = evas_object_evas_get(obj);
105 ed->base.clipper = evas_object_rectangle_add(ed->base.evas);
106 evas_object_static_clip_set(ed->base.clipper, 1);
107 evas_object_smart_member_add(ed->base.clipper, obj);
108 evas_object_color_set(ed->base.clipper, 255, 255, 255, 255);
109 evas_object_move(ed->base.clipper, -10000, -10000);
110 evas_object_resize(ed->base.clipper, 20000, 20000);
111 evas_object_pass_events_set(ed->base.clipper, 1);
112 ed->is_rtl = EINA_FALSE;
113 ed->have_objects = 1;
114 ed->references = 1;
115
116 evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
117 ed->obj = obj;
118 _edje_edjes = eina_list_append(_edje_edjes, obj);
119 /*
120 {
121 Eina_List *l;
122 const void *data;
123
124 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
125 EINA_LIST_FOREACH(_edge_edges, l, data)
126 {
127 ed = _edje_fetch(data);
128 printf("EDJE: %80s | %80s\n", ed->path, ed->part);
129 }
130 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
131 }
132 */
133end_smart_add:
134 evas_event_thaw(tev);
135 evas_event_thaw_eval(tev);
136}
137
138static void
139_edje_smart_del(Evas_Object * obj)
140{
141 Edje *ed;
142
143 ed = evas_object_smart_data_get(obj);
144 if (!ed) return;
145 _edje_block_violate(ed);
146 ed->delete_me = 1;
147 _edje_edjes = eina_list_remove(_edje_edjes, obj);
148 evas_object_smart_data_set(obj, NULL);
149 if (_edje_script_only(ed)) _edje_script_only_shutdown(ed);
150 if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
151 if (ed->persp) edje_object_perspective_set(obj, NULL);
152 _edje_file_del(ed);
153 _edje_clean_objects(ed);
154 _edje_unref(ed);
155 _edje_lib_unref();
156}
157
158static void
159_edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
160{
161 Edje *ed;
162
163 ed = evas_object_smart_data_get(obj);
164 if (!ed) return;
165 if ((ed->x == x) && (ed->y == y)) return;
166 ed->x = x;
167 ed->y = y;
168// evas_object_move(ed->clipper, ed->x, ed->y);
169
170 if (_edje_script_only(ed))
171 {
172 _edje_script_only_move(ed);
173 return;
174 }
175 if (_edje_lua_script_only(ed))
176 {
177 _edje_lua_script_only_move(ed);
178 return;
179 }
180
181 if (ed->have_mapped_part)
182 {
183 ed->dirty = 1;
184 _edje_recalc_do(ed);
185 }
186 else
187 {
188 unsigned int i;
189
190 for (i = 0; i < ed->table_parts_size; i++)
191 {
192 Edje_Real_Part *ep;
193 Evas_Coord ox, oy;
194
195 ep = ed->table_parts[i];
196 evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL);
197 evas_object_move(ep->object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
198 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
199 _edje_entry_real_part_configure(ep);
200 if (ep->swallowed_object)
201 {
202 evas_object_geometry_get(ep->swallowed_object, &ox, &oy, NULL, NULL);
203 evas_object_move(ep->swallowed_object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
204 }
205 }
206 }
207// _edje_emit(ed, "move", NULL);
208}
209
210static void
211_edje_limit_emit(Edje *ed, const char *limit_name, Eina_Bool over)
212{
213 char *buffer;
214 unsigned int length;
215
216 if (!limit_name) return ;
217
218 length = strlen(limit_name) + 13;
219 buffer = alloca(length);
220 snprintf(buffer, length, "limit,%s,%s", limit_name, over ? "over" : "below");
221 _edje_emit(ed, buffer, NULL);
222}
223
224static void
225_edje_limit_get(Edje *ed, Edje_Limit **limits, unsigned int length, Evas_Coord size_current, Evas_Coord size_next)
226{
227 unsigned int i;
228
229 if (size_next == size_current) return ;
230
231 for (i = 0; i < length; ++i)
232 {
233 if ((size_current <= limits[i]->value) && (limits[i]->value < size_next))
234 {
235 _edje_limit_emit(ed, limits[i]->name, EINA_TRUE);
236 }
237 else if ((size_next <= limits[i]->value) && (limits[i]->value < size_current))
238 {
239 _edje_limit_emit(ed, limits[i]->name, EINA_FALSE);
240 }
241 }
242}
243
244static void
245_edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
246{
247 Edje *ed;
248
249 ed = evas_object_smart_data_get(obj);
250 if (!ed) return;
251 if ((w == ed->w) && (h == ed->h)) return;
252 if (ed->collection)
253 {
254 _edje_limit_get(ed, ed->collection->limits.horizontal, ed->collection->limits.horizontal_count, ed->w, w);
255 _edje_limit_get(ed, ed->collection->limits.vertical, ed->collection->limits.vertical_count, ed->h, h);
256 }
257 ed->w = w;
258 ed->h = h;
259#ifdef EDJE_CALC_CACHE
260 ed->all_part_change = 1;
261#endif
262 if (_edje_script_only(ed))
263 {
264 _edje_script_only_resize(ed);
265 return;
266 }
267 if (_edje_lua_script_only(ed))
268 {
269 _edje_lua_script_only_resize(ed);
270 return;
271 }
272// evas_object_resize(ed->clipper, ed->w, ed->h);
273 ed->dirty = 1;
274 _edje_recalc_do(ed);
275 _edje_emit(ed, "resize", NULL);
276}
277
278static void
279_edje_smart_show(Evas_Object * obj)
280{
281 Edje *ed;
282
283 _edje_smart_parent.show(obj);
284 ed = evas_object_smart_data_get(obj);
285 if (!ed) return;
286 if (evas_object_visible_get(obj)) return;
287 if (_edje_script_only(ed))
288 {
289 _edje_script_only_show(ed);
290 return;
291 }
292 if (_edje_lua_script_only(ed))
293 {
294 _edje_lua_script_only_show(ed);
295 return;
296 }
297 _edje_emit(ed, "show", NULL);
298}
299
300static void
301_edje_smart_hide(Evas_Object * obj)
302{
303 Edje *ed;
304
305 _edje_smart_parent.hide(obj);
306 ed = evas_object_smart_data_get(obj);
307 if (!ed) return;
308 if (!evas_object_visible_get(obj)) return;
309 if (_edje_script_only(ed))
310 {
311 _edje_script_only_hide(ed);
312 return;
313 }
314 if (_edje_lua_script_only(ed))
315 {
316 _edje_lua_script_only_hide(ed);
317 return;
318 }
319 _edje_emit(ed, "hide", NULL);
320}
321
322static void
323_edje_smart_calculate(Evas_Object *obj)
324{
325 Edje *ed;
326
327 ed = evas_object_smart_data_get(obj);
328 if (!ed) return;
329 _edje_recalc_do(ed);
330}
331
332static Eina_Bool
333_edje_smart_file_set(Evas_Object *obj, const char *file, const char *group)
334{
335 return _edje_object_file_set_internal(obj, file, group, NULL, NULL);
336}