1 #include "edje_private.h"
3 static void _edje_smart_add(Evas_Object * obj);
4 static void _edje_smart_del(Evas_Object * obj);
5 static void _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
6 static void _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
7 static void _edje_smart_show(Evas_Object * obj);
8 static void _edje_smart_hide(Evas_Object * obj);
9 static void _edje_smart_calculate(Evas_Object * obj);
11 static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group);
13 static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje");
14 static Evas_Smart_Class _edje_smart_parent;
15 static Evas_Smart *_edje_smart = NULL;
17 Eina_List *_edje_edjes = NULL;
19 /************************** API Routines **************************/
22 edje_object_add(Evas *evas)
30 memset(&_edje_smart_parent, 0, sizeof(_edje_smart_parent));
31 _edje_object_smart_set(&_edje_smart_class);
33 evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class);
36 e = evas_object_smart_add(evas, _edje_smart);
42 _edje_object_smart_set(Edje_Smart_Api *sc)
47 evas_object_smart_clipped_smart_set(&sc->base);
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;
66 const Edje_Smart_Api *
67 _edje_object_smart_class_get(void)
69 static const Edje_Smart_Api *class = NULL;
74 _edje_object_smart_set(&_edje_smart_class);
75 class = &_edje_smart_class;
81 _edje_color_class_free(void *data)
83 Edje_Color_Class *cc = data;
85 if (cc->name) eina_stringshare_del(cc->name);
90 /* Private Routines */
92 _edje_smart_add(Evas_Object *obj)
95 Evas *tev = evas_object_evas_get(obj);
97 evas_event_freeze(tev);
98 ed = evas_object_smart_data_get(obj);
101 const Evas_Smart *smart;
102 const Evas_Smart_Class *sc;
104 ed = calloc(1, sizeof(Edje));
105 if (!ed) goto end_smart_add;
107 smart = evas_object_smart_smart_get(obj);
108 sc = evas_smart_class_get(smart);
109 ed->api = (const Edje_Smart_Api *)sc;
111 evas_object_smart_data_set(obj, ed);
114 ed->base.evas = evas_object_evas_get(obj);
115 ed->base.clipper = evas_object_rectangle_add(ed->base.evas);
116 evas_object_static_clip_set(ed->base.clipper, 1);
117 evas_object_smart_member_add(ed->base.clipper, obj);
118 evas_object_color_set(ed->base.clipper, 255, 255, 255, 255);
119 evas_object_move(ed->base.clipper, -10000, -10000);
120 evas_object_resize(ed->base.clipper, 20000, 20000);
121 evas_object_pass_events_set(ed->base.clipper, 1);
122 ed->is_rtl = EINA_FALSE;
123 ed->have_objects = 1;
125 ed->user_defined = NULL;
126 ed->color_classes = eina_hash_string_small_new(_edje_color_class_free);
128 evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
130 _edje_edjes = eina_list_append(_edje_edjes, obj);
136 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
137 EINA_LIST_FOREACH(_edge_edges, l, data)
139 ed = _edje_fetch(data);
140 printf("EDJE: %80s | %80s\n", ed->path, ed->part);
142 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
146 evas_event_thaw(tev);
147 evas_event_thaw_eval(tev);
151 _edje_smart_del(Evas_Object * obj)
155 ed = evas_object_smart_data_get(obj);
157 _edje_block_violate(ed);
159 _edje_edjes = eina_list_remove(_edje_edjes, obj);
160 evas_object_smart_data_set(obj, NULL);
161 if (_edje_script_only(ed)) _edje_script_only_shutdown(ed);
162 if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
163 if (ed->persp) edje_object_perspective_set(obj, NULL);
165 _edje_clean_objects(ed);
171 _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
175 ed = evas_object_smart_data_get(obj);
177 if ((ed->x == x) && (ed->y == y)) return;
180 // evas_object_move(ed->clipper, ed->x, ed->y);
182 if (_edje_script_only(ed))
184 _edje_script_only_move(ed);
187 if (_edje_lua_script_only(ed))
189 _edje_lua_script_only_move(ed);
193 if (ed->have_mapped_part)
202 for (i = 0; i < ed->table_parts_size; i++)
207 ep = ed->table_parts[i];
208 evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL);
209 evas_object_move(ep->object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
210 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
211 _edje_entry_real_part_configure(ep);
212 if (ep->swallowed_object)
214 evas_object_geometry_get(ep->swallowed_object, &ox, &oy, NULL, NULL);
215 evas_object_move(ep->swallowed_object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
219 // _edje_emit(ed, "move", NULL);
223 _edje_limit_emit(Edje *ed, const char *limit_name, Eina_Bool over)
228 if (!limit_name) return ;
230 length = strlen(limit_name) + 13;
231 buffer = alloca(length);
232 snprintf(buffer, length, "limit,%s,%s", limit_name, over ? "over" : "below");
233 _edje_emit(ed, buffer, NULL);
237 _edje_limit_get(Edje *ed, Edje_Limit **limits, unsigned int length, Evas_Coord size_current, Evas_Coord size_next)
241 if (size_next == size_current) return ;
243 for (i = 0; i < length; ++i)
245 if ((size_current <= limits[i]->value) && (limits[i]->value < size_next))
247 _edje_limit_emit(ed, limits[i]->name, EINA_TRUE);
249 else if ((size_next <= limits[i]->value) && (limits[i]->value < size_current))
251 _edje_limit_emit(ed, limits[i]->name, EINA_FALSE);
257 _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
261 ed = evas_object_smart_data_get(obj);
263 if ((w == ed->w) && (h == ed->h)) return;
266 _edje_limit_get(ed, ed->collection->limits.horizontal, ed->collection->limits.horizontal_count, ed->w, w);
267 _edje_limit_get(ed, ed->collection->limits.vertical, ed->collection->limits.vertical_count, ed->h, h);
271 #ifdef EDJE_CALC_CACHE
272 ed->all_part_change = 1;
274 if (_edje_script_only(ed))
276 _edje_script_only_resize(ed);
279 if (_edje_lua_script_only(ed))
281 _edje_lua_script_only_resize(ed);
284 // evas_object_resize(ed->clipper, ed->w, ed->h);
287 _edje_emit(ed, "resize", NULL);
291 _edje_smart_show(Evas_Object * obj)
295 _edje_smart_parent.show(obj);
296 ed = evas_object_smart_data_get(obj);
298 if (evas_object_visible_get(obj)) return;
299 if (_edje_script_only(ed))
301 _edje_script_only_show(ed);
304 if (_edje_lua_script_only(ed))
306 _edje_lua_script_only_show(ed);
309 _edje_emit(ed, "show", NULL);
313 _edje_smart_hide(Evas_Object * obj)
317 _edje_smart_parent.hide(obj);
318 ed = evas_object_smart_data_get(obj);
320 if (!evas_object_visible_get(obj)) return;
321 if (_edje_script_only(ed))
323 _edje_script_only_hide(ed);
326 if (_edje_lua_script_only(ed))
328 _edje_lua_script_only_hide(ed);
331 _edje_emit(ed, "hide", NULL);
335 _edje_smart_calculate(Evas_Object *obj)
339 ed = evas_object_smart_data_get(obj);
345 _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group)
347 return _edje_object_file_set_internal(obj, file, group, NULL, NULL);