1 #define EFL_CANVAS_OBJECT_PROTECTED
2 #define EFL_GFX_HINT_PROTECTED
3
4 #include "evas_common_private.h"
5 #include "evas_private.h"
6 #include <Ecore.h>
7
8 EVAS_MEMPOOL(_mp_sh);
9
10 #define MY_CLASS EFL_CANVAS_OBJECT_CLASS
11
12 #define MY_CLASS_NAME "Evas_Object"
13
14 /* evas internal stuff */
15 static const Evas_Object_Proxy_Data default_proxy = {
16 NULL, NULL, 0, 0, NULL, 0, 0, 0, 0
17 };
18 static const Evas_Object_Map_Data default_map = {
19 { NULL, NULL, 0, 0 }, { NULL, NULL, 0, 0 }, NULL, 0, 0, NULL, NULL
20 };
21 static const Evas_Object_Protected_State default_state = {
22 NULL, { 0, 0, 0, 0 },
23 { { 0, 0, 0, 0, 0, 0, 0, 0, EINA_FALSE, EINA_FALSE } },
24 { 255, 255, 255, 255 },
25 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
26 };
27 static const Evas_Object_Mask_Data default_mask = {
28 NULL, 0, 0, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
29 };
30 static const Evas_Object_Events_Data default_events = {
31 NULL, NULL, NULL, NULL
32 };
33
34 Eina_Cow *evas_object_proxy_cow = NULL;
35 Eina_Cow *evas_object_map_cow = NULL;
36 Eina_Cow *evas_object_state_cow = NULL;
37 Eina_Cow *evas_object_mask_cow = NULL;
38 Eina_Cow *evas_object_events_cow = NULL;
39
40 typedef struct _Event_Animation
41 {
42 EINA_INLIST;
43
44 const Efl_Event_Description *desc;
45 Efl_Canvas_Animation *anim;
46 } Event_Animation;
47
48 static Eina_Bool
_init_cow(void)49 _init_cow(void)
50 {
51 if (evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow) return EINA_TRUE;
52
53 evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy, EINA_TRUE);
54 evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map, EINA_TRUE);
55 evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state, EINA_FALSE);
56 evas_object_mask_cow = eina_cow_add("Evas Mask Data", sizeof (Evas_Object_Mask_Data), 8, &default_mask, EINA_TRUE);
57 evas_object_events_cow = eina_cow_add("Evas Events Data", sizeof (Evas_Object_Events_Data), 8, &default_events, EINA_TRUE);
58
59 if (!(evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow &&
60 evas_object_mask_cow && evas_object_events_cow))
61 {
62 eina_cow_del(evas_object_proxy_cow);
63 eina_cow_del(evas_object_map_cow);
64 eina_cow_del(evas_object_state_cow);
65 eina_cow_del(evas_object_mask_cow);
66 eina_cow_del(evas_object_events_cow);
67
68 evas_object_proxy_cow = NULL;
69 evas_object_map_cow = NULL;
70 evas_object_state_cow = NULL;
71 evas_object_mask_cow = NULL;
72 evas_object_events_cow = NULL;
73
74 return EINA_FALSE;
75 }
76
77 return EINA_TRUE;
78 }
79
80 Evas_Object_Pointer_Data *
evas_object_pointer_data_find(Evas_Object_Protected_Data * obj,Efl_Input_Device * pointer)81 evas_object_pointer_data_find(Evas_Object_Protected_Data *obj,
82 Efl_Input_Device *pointer)
83 {
84 Evas_Object_Pointer_Data *pdata;
85
86 EINA_INLIST_FOREACH(obj->events->pointer_grabs, pdata)
87 {
88 if (pdata->evas_pdata->pointer == pointer)
89 return pdata;
90 }
91 return NULL;
92 }
93
94 static void
_evas_object_proxy_grab_del(Evas_Object_Protected_Data * obj,Evas_Object_Pointer_Data * pdata)95 _evas_object_proxy_grab_del(Evas_Object_Protected_Data *obj,
96 Evas_Object_Pointer_Data *pdata)
97 {
98 Evas_Object *eo_src = _evas_object_image_source_get(obj->object);
99 Evas_Object_Protected_Data *src = efl_data_scope_get(eo_src, EFL_CANVAS_OBJECT_CLASS);
100 Eina_List *copy = eina_list_clone(src->proxy->src_event_in);
101 Eina_List *l;
102 Evas_Object *eo_child;
103 EINA_LIST_FOREACH(copy, l, eo_child)
104 {
105 Evas_Object_Protected_Data *child = efl_data_scope_get(eo_child, EFL_CANVAS_OBJECT_CLASS);
106 if (!child) continue;
107 Evas_Object_Pointer_Data *obj_pdata = _evas_object_pointer_data_get(pdata->evas_pdata, child);
108 if (!obj_pdata)
109 continue;
110 if (obj_pdata->mouse_grabbed > 0)
111 {
112 pdata->evas_pdata->seat->mouse_grabbed -= obj_pdata->mouse_grabbed;
113 obj_pdata->mouse_grabbed = 0;
114 EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src->proxy, Evas_Object_Proxy_Data, proxy_write)
115 proxy_write->src_event_in = eina_list_remove(proxy_write->src_event_in, eo_child);
116 EINA_COW_WRITE_END(evas_object_proxy_cow, src->proxy, proxy_write);
117 }
118 }
119 }
120
121 void
evas_object_pointer_grab_del(Evas_Object_Protected_Data * obj,Evas_Object_Pointer_Data * pdata)122 evas_object_pointer_grab_del(Evas_Object_Protected_Data *obj,
123 Evas_Object_Pointer_Data *pdata)
124 {
125 if ((pdata->mouse_grabbed > 0) && (obj->layer) && (obj->layer->evas))
126 pdata->evas_pdata->seat->mouse_grabbed -= pdata->mouse_grabbed;
127 if (((pdata->mouse_in) || (pdata->mouse_grabbed > 0)) &&
128 (obj->layer) && (obj->layer->evas))
129 {
130 pdata->evas_pdata->seat->object.in = eina_list_remove(pdata->evas_pdata->seat->object.in, obj->object);
131 if (obj->proxy->is_proxy && obj->proxy->src_events)
132 _evas_object_proxy_grab_del(obj, pdata);
133 }
134 if (obj->events->pointer_grabs)
135 {
136 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
137 events->pointer_grabs = eina_inlist_remove(events->pointer_grabs, EINA_INLIST_GET(pdata));
138 EINA_COW_WRITE_END(evas_object_events_cow, obj->events, events);
139 }
140
141 free(pdata);
142 }
143
144 static Evas_Object_Pointer_Data *
_evas_object_pointer_data_add(Evas_Pointer_Data * evas_pdata,Evas_Object_Protected_Data * obj)145 _evas_object_pointer_data_add(Evas_Pointer_Data *evas_pdata,
146 Evas_Object_Protected_Data *obj)
147 {
148 Evas_Object_Pointer_Data *pdata;
149
150 pdata = calloc(1, sizeof(Evas_Object_Pointer_Data));
151 EINA_SAFETY_ON_NULL_RETURN_VAL(pdata, NULL);
152 pdata->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB;
153 pdata->evas_pdata = evas_pdata;
154 pdata->obj = obj;
155 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
156 events->pointer_grabs = eina_inlist_append(events->pointer_grabs,
157 EINA_INLIST_GET(pdata));
158 EINA_COW_WRITE_END(evas_object_events_cow, obj->events, events);
159
160 efl_input_device_grab_register(evas_pdata->pointer, obj->object, pdata);
161 return pdata;
162 }
163
164 Evas_Object_Pointer_Data *
_evas_object_pointer_data_get(Evas_Pointer_Data * evas_pdata,Evas_Object_Protected_Data * obj)165 _evas_object_pointer_data_get(Evas_Pointer_Data *evas_pdata,
166 Evas_Object_Protected_Data *obj)
167 {
168 Evas_Object_Pointer_Data *pdata;
169
170 if (!obj) return NULL;
171
172 pdata = evas_object_pointer_data_find(obj, evas_pdata->pointer);
173
174 //The pointer does not exist yet - create one.
175 if (!pdata)
176 return _evas_object_pointer_data_add(evas_pdata, obj);
177 return pdata;
178 }
179
180 EOLIAN static Eo *
_efl_canvas_object_efl_object_constructor(Eo * eo_obj,Evas_Object_Protected_Data * obj)181 _efl_canvas_object_efl_object_constructor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
182 {
183 const char *class_name;
184 Eo *parent = NULL;
185 Evas *evas = NULL;
186
187 class_name = efl_class_name_get(eo_obj);
188
189 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
190 if (!eo_obj) goto on_error;
191 efl_canvas_object_type_set(eo_obj, MY_CLASS_NAME);
192 efl_manual_free_set(eo_obj, EINA_TRUE);
193
194 parent = efl_parent_get(eo_obj);
195 evas = evas_object_evas_get(parent);
196
197 if (!obj || !_init_cow() || !evas) goto on_error;
198
199 obj->is_frame = EINA_FALSE;
200 obj->object = eo_obj;
201 obj->proxy = eina_cow_alloc(evas_object_proxy_cow);
202 obj->map = eina_cow_alloc(evas_object_map_cow);
203 obj->cur = eina_cow_alloc(evas_object_state_cow);
204 obj->prev = eina_cow_alloc(evas_object_state_cow);
205 obj->mask = eina_cow_alloc(evas_object_mask_cow);
206 obj->events = eina_cow_alloc(evas_object_events_cow);
207
208 evas_object_inject(eo_obj, obj, evas);
209
210 return eo_obj;
211
212 on_error:
213 ERR("Failed to create a canvas object (evas: %p) of type '%s'.", evas, class_name);
214 return NULL;
215 }
216
217 EOLIAN static Eo *
_efl_canvas_object_efl_object_finalize(Eo * eo_obj,Evas_Object_Protected_Data * obj)218 _efl_canvas_object_efl_object_finalize(Eo *eo_obj, Evas_Object_Protected_Data *obj)
219 {
220 Evas_Public_Data *e;
221
222 if (!EVAS_OBJECT_DATA_ALIVE(obj)) goto end;
223 if (obj->legacy.ctor) goto end;
224
225 if (!obj->legacy.weight_set)
226 efl_gfx_hint_weight_set(eo_obj, 1.0, 1.0);
227
228 if (obj->legacy.visible_set /* && ... */)
229 {
230 obj->legacy.finalized = EINA_TRUE;
231 goto end;
232 }
233
234 e = obj->layer->evas;
235 e->finalize_objects = eina_list_prepend(e->finalize_objects, eo_obj);
236
237 end:
238 evas_object_callbacks_finalized(eo_obj, obj);
239 return efl_finalize(efl_super(eo_obj, MY_CLASS));
240 }
241
242 void
evas_object_change_reset(Evas_Object_Protected_Data * obj)243 evas_object_change_reset(Evas_Object_Protected_Data *obj)
244 {
245 obj->changed = EINA_FALSE;
246 obj->changed_move = EINA_FALSE;
247 obj->changed_color = EINA_FALSE;
248 obj->changed_pchange = EINA_FALSE;
249 obj->changed_src_visible = EINA_FALSE;
250 obj->need_surface_clear = EINA_FALSE;
251 }
252
253 typedef struct _Map_Same
254 {
255 void *p1, *p2;
256 Eina_Bool b1;
257 } Map_Same;
258
259 void
evas_object_clip_recalc_do(Evas_Object_Protected_Data * obj,Evas_Object_Protected_Data * clipper)260 evas_object_clip_recalc_do(Evas_Object_Protected_Data *obj, Evas_Object_Protected_Data *clipper)
261 {
262 int cx, cy, cw, ch, cr, cg, cb, ca;
263 int nx, ny, nw, nh, nr, ng, nb, na;
264 Eina_Bool cvis, nvis;
265
266 evas_object_coords_recalc(obj->object, obj);
267
268 if (EINA_UNLIKELY((!!obj->map) && (obj->map->cur.map) && (obj->map->cur.usemap)))
269 {
270 cx = obj->map->cur.map->normal_geometry.x;
271 cy = obj->map->cur.map->normal_geometry.y;
272 cw = obj->map->cur.map->normal_geometry.w;
273 ch = obj->map->cur.map->normal_geometry.h;
274 }
275 else
276 {
277 if (obj->is_smart)
278 {
279 Eina_Rectangle bounding_box;
280
281 evas_object_smart_bounding_box_update(obj);
282 evas_object_smart_bounding_box_get(obj, &bounding_box, NULL);
283 cx = bounding_box.x;
284 cy = bounding_box.y;
285 cw = bounding_box.w;
286 ch = bounding_box.h;
287 }
288 else
289 {
290 cx = obj->cur->geometry.x;
291 cy = obj->cur->geometry.y;
292 cw = obj->cur->geometry.w;
293 ch = obj->cur->geometry.h;
294 }
295 }
296
297 if (EINA_UNLIKELY((obj->cur->color.a == 0) &&
298 (obj->cur->render_op == EVAS_RENDER_BLEND)))
299 cvis = EINA_FALSE;
300 else cvis = obj->cur->visible;
301
302 cr = obj->cur->color.r; cg = obj->cur->color.g;
303 cb = obj->cur->color.b; ca = obj->cur->color.a;
304
305 if (EVAS_OBJECT_DATA_VALID(clipper))
306 {
307 // this causes problems... hmmm ?????
308 evas_object_clip_recalc(clipper);
309
310 // I don't know why this test was here in the first place. As I have
311 // no issue showing up due to this, I keep it and move color out of it.
312 // breaks cliping of mapped images!!!
313 if (EINA_LIKELY(!!clipper->map) &&
314 EINA_LIKELY(!!obj->map) &&
315 clipper->map->cur.map_parent == obj->map->cur.map_parent)
316 {
317 nx = clipper->cur->cache.clip.x;
318 ny = clipper->cur->cache.clip.y;
319 nw = clipper->cur->cache.clip.w;
320 nh = clipper->cur->cache.clip.h;
321 RECTS_CLIP_TO_RECT(cx, cy, cw, ch, nx, ny, nw, nh);
322 }
323
324 obj->clip.prev_mask = NULL;
325 if (EINA_UNLIKELY(clipper->mask->is_mask))
326 {
327 // Set complex masks the object being clipped (parent)
328 obj->clip.mask = clipper;
329
330 // Forward any mask from the parents
331 if (EINA_LIKELY(obj->smart.parent != NULL))
332 {
333 Evas_Object_Protected_Data *parent =
334 efl_data_scope_get(obj->smart.parent, EFL_CANVAS_OBJECT_CLASS);
335 evas_object_clip_recalc(parent);
336 if (parent->clip.mask)
337 {
338 if (parent->clip.mask != obj->clip.mask)
339 obj->clip.prev_mask = parent->clip.mask;
340 }
341 }
342 }
343 else if (EINA_UNLIKELY(clipper->clip.mask != NULL))
344 {
345 // Pass complex masks to children
346 obj->clip.mask = clipper->clip.mask;
347 }
348 else obj->clip.mask = NULL;
349
350 nvis = clipper->cur->cache.clip.visible;
351 nr = clipper->cur->cache.clip.r;
352 ng = clipper->cur->cache.clip.g;
353 nb = clipper->cur->cache.clip.b;
354 na = clipper->cur->cache.clip.a;
355 cvis = (cvis & nvis);
356 cr = (cr * (nr + 1)) >> 8;
357 cg = (cg * (ng + 1)) >> 8;
358 cb = (cb * (nb + 1)) >> 8;
359 ca = (ca * (na + 1)) >> 8;
360 }
361 else obj->clip.mask = NULL;
362 if (!EVAS_OBJECT_DATA_VALID(obj->clip.mask))
363 obj->clip.mask = NULL;
364
365 if (((ca == 0) && (obj->cur->render_op == EVAS_RENDER_BLEND)) ||
366 (cw <= 0) || (ch <= 0))
367 cvis = EINA_FALSE;
368
369 if ((obj->cur->cache.clip.dirty == EINA_FALSE) &&
370 (obj->cur->cache.clip.visible == cvis) &&
371 (obj->cur->cache.clip.x == cx) &&
372 (obj->cur->cache.clip.y == cy) &&
373 (obj->cur->cache.clip.w == cw) &&
374 (obj->cur->cache.clip.h == ch) &&
375 (obj->cur->cache.clip.r == cr) &&
376 (obj->cur->cache.clip.g == cg) &&
377 (obj->cur->cache.clip.b == cb) &&
378 (obj->cur->cache.clip.a == ca))
379 return;
380
381 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
382 {
383 state_write->cache.clip.x = cx;
384 state_write->cache.clip.y = cy;
385 state_write->cache.clip.w = cw;
386 state_write->cache.clip.h = ch;
387 state_write->cache.clip.visible = cvis;
388 state_write->cache.clip.r = cr;
389 state_write->cache.clip.g = cg;
390 state_write->cache.clip.b = cb;
391 state_write->cache.clip.a = ca;
392 state_write->cache.clip.dirty = EINA_FALSE;
393 }
394 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
395 }
396
397 static inline Eina_Bool
_map_same(const void * map1,const void * map2)398 _map_same(const void *map1, const void *map2)
399 {
400 const Map_Same *same1 = map1, *same2 = map2;
401 return ((same1->p1 == same2->p1) &&
402 (same1->p2 == same2->p2) &&
403 (same1->b1 == same2->b1));
404 }
405
406 void
evas_object_cur_prev(Evas_Object_Protected_Data * obj)407 evas_object_cur_prev(Evas_Object_Protected_Data *obj)
408 {
409 if (!obj->map->prev.valid_map && obj->map->prev.map)
410 {
411 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
412 {
413 if (map_write->prev.map != map_write->cur.map)
414 evas_map_free(map_write->prev.map);
415 if (map_write->cache_map == map_write->prev.map)
416 map_write->cache_map = NULL;
417 map_write->prev.map = NULL;
418 }
419 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
420 }
421
422 if (obj->map->cur.map != obj->map->prev.map)
423 {
424 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
425 {
426 if (map_write->cache_map) evas_map_free(map_write->cache_map);
427 map_write->cache_map = map_write->prev.map;
428 }
429 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
430 }
431 if (!_map_same(&obj->map->prev, &obj->map->cur))
432 {
433 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
434 map_write->prev = map_write->cur;
435 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
436 }
437 _efl_canvas_object_clipper_prev_reset(obj, EINA_TRUE);
438 eina_cow_memcpy(evas_object_state_cow, (const Eina_Cow_Data **) &obj->prev, obj->cur);
439 }
440
441 void
evas_object_free(Evas_Object_Protected_Data * obj,Eina_Bool clean_layer)442 evas_object_free(Evas_Object_Protected_Data *obj, Eina_Bool clean_layer)
443 {
444 Evas_Object *eo_obj;
445 int was_smart_child = 0;
446
447 if (!obj) return ;
448 eo_obj = obj->object;
449
450 if (efl_isa(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS))
451 _evas_object_image_free(eo_obj);
452 evas_object_map_set(eo_obj, NULL);
453 if (obj->map->prev.map) evas_map_free(obj->map->prev.map);
454 if (obj->map->cache_map) evas_map_free(obj->map->cache_map);
455 if (obj->map->surface)
456 {
457 if (obj->layer)
458 {
459 obj->layer->evas->engine.func->image_free(ENC, obj->map->surface);
460 }
461 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
462 map_write->surface = NULL;
463 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
464 }
465 if (obj->mask->is_mask)
466 {
467 EINA_COW_WRITE_BEGIN(evas_object_mask_cow, obj->mask, Evas_Object_Mask_Data, mask)
468 mask->is_mask = EINA_FALSE;
469 mask->redraw = EINA_FALSE;
470 mask->is_alpha = EINA_FALSE;
471 mask->w = mask->h = 0;
472 if (mask->surface)
473 {
474 if (obj->layer)
475 {
476 obj->layer->evas->engine.func->image_free(ENC, mask->surface);
477 mask->surface = NULL;
478 }
479 }
480 EINA_COW_WRITE_END(evas_object_mask_cow, obj->mask, mask);
481 }
482 if (eo_obj)
483 {
484 evas_object_grabs_cleanup(eo_obj, obj);
485 evas_object_intercept_cleanup(eo_obj);
486 if (obj->smart.parent) was_smart_child = 1;
487 evas_object_smart_cleanup(eo_obj);
488 if (obj->func->free)
489 {
490 obj->func->free(eo_obj, obj, obj->private_data);
491 }
492 }
493 if (!was_smart_child) evas_object_release(eo_obj, obj, !!clean_layer);
494 if (obj->clip.clipees)
495 obj->clip.clipees = eina_list_free(obj->clip.clipees);
496 obj->clip.cache_clipees_answer = eina_list_free(obj->clip.cache_clipees_answer);
497 evas_object_clip_changes_clean(obj);
498 evas_object_event_callback_all_del(eo_obj);
499 evas_object_event_callback_cleanup(eo_obj);
500 if (obj->map->spans)
501 {
502 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
503 {
504 free(map_write->spans);
505 map_write->spans = NULL;
506 }
507 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
508 }
509 if (obj->size_hints)
510 {
511 EVAS_MEMPOOL_FREE(_mp_sh, obj->size_hints);
512 }
513 eina_cow_free(evas_object_proxy_cow, (const Eina_Cow_Data**) &obj->proxy);
514 eina_cow_free(evas_object_map_cow, (const Eina_Cow_Data**) &obj->map);
515 eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->cur);
516 eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->prev);
517 eina_cow_free(evas_object_mask_cow, (const Eina_Cow_Data**) &obj->mask);
518 eina_cow_free(evas_object_events_cow, (const Eina_Cow_Data**) &obj->events);
519
520 efl_data_unref(eo_obj, obj->private_data);
521 obj->private_data = NULL;
522
523 /* Try to manual free, and if it fails, unset it so the next unref will
524 * actually free the object. */
525 if (!efl_manual_free(eo_obj))
526 efl_manual_free_set(eo_obj, EINA_FALSE);
527 }
528
529 void
evas_object_change(Evas_Object * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)530 evas_object_change(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
531 {
532 Eina_List *l;
533 Evas_Object_Protected_Data *obj2;
534 Evas_Object *eo_obj2;
535 Eina_Bool movch = EINA_FALSE;
536
537 if ((!obj->layer) || (!obj->layer->evas)) return;
538 if (obj->layer->evas->nochange) return;
539 obj->layer->evas->changed = EINA_TRUE;
540
541 if (obj->changed_move)
542 {
543 movch = EINA_TRUE;
544 obj->changed_move = EINA_FALSE;
545 }
546 else obj->need_surface_clear = EINA_TRUE;
547
548 if (obj->changed) return;
549
550 evas_render_object_recalc(obj);
551 /* set changed flag on all objects this one clips too */
552 if (!((movch) && (obj->is_static_clip)))
553 {
554 EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
555 {
556 evas_object_change(obj2->object, obj2);
557 }
558 }
559 EINA_LIST_FOREACH(obj->proxy->proxies, l, eo_obj2)
560 {
561 obj2 = efl_data_scope_get(eo_obj2, MY_CLASS);
562
563 if (!obj2) continue;
564 evas_object_change(eo_obj2, obj2);
565 }
566 if (obj->smart.parent)
567 {
568 Evas_Object_Protected_Data *smart_parent = efl_data_scope_get(obj->smart.parent, MY_CLASS);
569 if (!smart_parent) return;
570 evas_object_change(obj->smart.parent, smart_parent);
571 }
572 }
573
574 void
evas_object_content_change(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)575 evas_object_content_change(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
576 {
577 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
578 return;
579 MAGIC_CHECK_END();
580
581 if ((obj->map) && (obj->map->surface))
582 {
583 EINA_COW_WRITE_BEGIN(evas_object_map_cow,
584 obj->map, Evas_Object_Map_Data, map_write)
585 {
586 obj->layer->evas->engine.func->image_free(ENC, map_write->surface);
587 map_write->surface = NULL;
588 }
589 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
590 }
591 }
592
593 void
evas_object_render_pre_visible_change(Eina_Array * rects,Evas_Object * eo_obj,int is_v,int was_v)594 evas_object_render_pre_visible_change(Eina_Array *rects, Evas_Object *eo_obj, int is_v, int was_v)
595 {
596 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
597
598 if (!obj) return;
599 if (obj->is_smart) return;
600 if (is_v == was_v) return;
601 if (is_v)
602 {
603 evas_add_rect(rects,
604 obj->cur->cache.clip.x,
605 obj->cur->cache.clip.y,
606 obj->cur->cache.clip.w,
607 obj->cur->cache.clip.h);
608 }
609 else
610 {
611 evas_add_rect(rects,
612 obj->prev->cache.clip.x,
613 obj->prev->cache.clip.y,
614 obj->prev->cache.clip.w,
615 obj->prev->cache.clip.h);
616 }
617 }
618
619 void
evas_object_render_pre_clipper_change(Eina_Array * rects,Evas_Object * eo_obj)620 evas_object_render_pre_clipper_change(Eina_Array *rects, Evas_Object *eo_obj)
621 {
622 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
623
624 if (!obj) return;
625 if (obj->is_smart) return;
626 if (obj->cur->clipper == obj->prev->clipper) return;
627 if ((obj->cur->clipper) && (obj->prev->clipper))
628 {
629 /* get difference rects between clippers */
630 evas_rects_return_difference_rects(rects,
631 obj->cur->clipper->cur->cache.clip.x,
632 obj->cur->clipper->cur->cache.clip.y,
633 obj->cur->clipper->cur->cache.clip.w,
634 obj->cur->clipper->cur->cache.clip.h,
635 obj->prev->clipper->prev->cache.clip.x,
636 obj->prev->clipper->prev->cache.clip.y,
637 obj->prev->clipper->prev->cache.clip.w,
638 obj->prev->clipper->prev->cache.clip.h);
639 }
640 else if (obj->cur->clipper)
641 {
642 evas_rects_return_difference_rects(rects,
643 obj->cur->geometry.x,
644 obj->cur->geometry.y,
645 obj->cur->geometry.w,
646 obj->cur->geometry.h,
647 //// rl = evas_rects_return_difference_rects(obj->cur->cache.geometry.x,
648 //// obj->cur->cache.geometry.y,
649 //// obj->cur->cache.geometry.w,
650 //// obj->cur->cache.geometry.h,
651 obj->cur->clipper->cur->cache.clip.x,
652 obj->cur->clipper->cur->cache.clip.y,
653 obj->cur->clipper->cur->cache.clip.w,
654 obj->cur->clipper->cur->cache.clip.h);
655 }
656 else if (obj->prev->clipper)
657 {
658 evas_rects_return_difference_rects(rects,
659 obj->prev->geometry.x,
660 obj->prev->geometry.y,
661 obj->prev->geometry.w,
662 obj->prev->geometry.h,
663 //// rl = evas_rects_return_difference_rects(obj->prev->cache.geometry.x,
664 //// obj->prev->cache.geometry.y,
665 //// obj->prev->cache.geometry.w,
666 //// obj->prev->cache.geometry.h,
667 obj->prev->clipper->prev->cache.clip.x,
668 obj->prev->clipper->prev->cache.clip.y,
669 obj->prev->clipper->prev->cache.clip.w,
670 obj->prev->clipper->prev->cache.clip.h);
671 }
672 }
673
674 void
evas_object_render_pre_prev_cur_add(Eina_Array * rects,Evas_Object * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)675 evas_object_render_pre_prev_cur_add(Eina_Array *rects, Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
676 {
677 if (!obj) return;
678
679 evas_add_rect(rects,
680 obj->cur->cache.clip.x,
681 obj->cur->cache.clip.y,
682 obj->cur->cache.clip.w,
683 obj->cur->cache.clip.h);
684 evas_add_rect(rects,
685 obj->prev->cache.clip.x,
686 obj->prev->cache.clip.y,
687 obj->prev->cache.clip.w,
688 obj->prev->cache.clip.h);
689 /*
690 evas_add_rect(rects,
691 obj->cur->geometry.x,
692 obj->cur->geometry.y,
693 obj->cur->geometry.w,
694 obj->cur->geometry.h);
695 //// obj->cur->cache.geometry.x,
696 //// obj->cur->cache.geometry.y,
697 //// obj->cur->cache.geometry.w,
698 //// obj->cur->cache.geometry.h);
699 evas_add_rect(rects,
700 obj->prev->geometry.x,
701 obj->prev->geometry.y,
702 obj->prev->geometry.w,
703 obj->prev->geometry.h);
704 //// obj->prev->cache.geometry.x,
705 //// obj->prev->cache.geometry.y,
706 //// obj->prev->cache.geometry.w,
707 //// obj->prev->cache.geometry.h);
708 */
709 }
710
711 void
evas_object_clip_changes_clean(Evas_Object_Protected_Data * obj)712 evas_object_clip_changes_clean(Evas_Object_Protected_Data *obj)
713 {
714 Eina_Rectangle *r;
715
716 EINA_LIST_FREE(obj->clip.changes, r) eina_rectangle_free(r);
717 }
718
719 void
evas_object_render_pre_effect_updates(Eina_Array * rects,Evas_Object * eo_obj,int is_v,int was_v EINA_UNUSED)720 evas_object_render_pre_effect_updates(Eina_Array *rects, Evas_Object *eo_obj, int is_v, int was_v EINA_UNUSED)
721 {
722 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
723 Eina_Rectangle *r;
724 Eina_List *l;
725 unsigned int i;
726 Eina_Array_Iterator it;
727 int x, y, w, h;
728
729 if (!obj) return;
730 if (!obj->layer) return;
731
732 if (obj->is_smart) goto end;
733
734 if (evas_object_is_on_plane(obj))
735 {
736 /* We need some damage to occur if only planes are being updated,
737 or nothing will provoke a page flip.
738 */
739 obj->layer->evas->engine.func->output_redraws_rect_add(ENC,
740 0, 0, 1, 1);
741 /* Force a pixels get callback for E's benefit :( */
742 evas_object_pixels_get_force(eo_obj, obj);
743 goto end;
744 }
745 /* FIXME: was_v isn't used... why? */
746 if (!obj->clip.clipees)
747 {
748 Evas_Public_Data *e;
749 e = obj->layer->evas;
750 EINA_ARRAY_ITER_NEXT(rects, i, r, it)
751 {
752 /* get updates and clip to current clip */
753 x = r->x;
754 y = r->y;
755 w = r->w;
756 h = r->h;
757 RECTS_CLIP_TO_RECT(x, y, w, h,
758 obj->cur->cache.clip.x,
759 obj->cur->cache.clip.y,
760 obj->cur->cache.clip.w,
761 obj->cur->cache.clip.h);
762 if ((w > 0) && (h > 0))
763 obj->layer->evas->engine.func->output_redraws_rect_add(ENC,
764 x + e->framespace.x,
765 y + e->framespace.y,
766 w, h);
767 /* get updates and clip to previous clip */
768 x = r->x;
769 y = r->y;
770 w = r->w;
771 h = r->h;
772 RECTS_CLIP_TO_RECT(x, y, w, h,
773 obj->prev->cache.clip.x,
774 obj->prev->cache.clip.y,
775 obj->prev->cache.clip.w,
776 obj->prev->cache.clip.h);
777 if ((w > 0) && (h > 0))
778 obj->layer->evas->engine.func->output_redraws_rect_add(ENC,
779 x + e->framespace.x,
780 y + e->framespace.y,
781 w, h);
782 }
783 /* if the object is actually visible, take any parent clip changes */
784 if (is_v)
785 {
786 Evas_Object_Protected_Data *clipper;
787
788 clipper = obj->cur->clipper;
789 while (clipper)
790 {
791 EINA_LIST_FOREACH(clipper->clip.changes, l, r)
792 {
793 /* get updates and clip to current clip */
794 x = r->x; y = r->y; w = r->w; h = r->h;
795 RECTS_CLIP_TO_RECT(x, y, w, h,
796 obj->cur->cache.clip.x,
797 obj->cur->cache.clip.y,
798 obj->cur->cache.clip.w,
799 obj->cur->cache.clip.h);
800 if ((w > 0) && (h > 0))
801 obj->layer->evas->engine.func->output_redraws_rect_add(ENC,
802 x + e->framespace.x,
803 y + e->framespace.y,
804 w, h);
805 /* get updates and clip to previous clip */
806 x = r->x; y = r->y; w = r->w; h = r->h;
807 RECTS_CLIP_TO_RECT(x, y, w, h,
808 obj->prev->cache.clip.x,
809 obj->prev->cache.clip.y,
810 obj->prev->cache.clip.w,
811 obj->prev->cache.clip.h);
812 if ((w > 0) && (h > 0))
813 obj->layer->evas->engine.func->output_redraws_rect_add(ENC,
814 x + e->framespace.x,
815 y + e->framespace.y,
816 w, h);
817 }
818 clipper = clipper->cur->clipper;
819 }
820 }
821 }
822 else
823 {
824 /* This is a clipper object: add regions that changed here,
825 * See above: EINA_LIST_FOREACH(clipper->clip.changes) */
826 evas_object_clip_changes_clean(obj);
827 EINA_ARRAY_ITER_NEXT(rects, i, r, it)
828 obj->clip.changes = eina_list_append(obj->clip.changes, r);
829 eina_array_clean(rects);
830 }
831
832 end:
833 EINA_ARRAY_ITER_NEXT(rects, i, r, it)
834 eina_rectangle_free(r);
835 eina_array_clean(rects);
836 }
837
838 int
evas_object_was_in_output_rect(Evas_Object * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,int x,int y,int w,int h)839 evas_object_was_in_output_rect(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, int x, int y, int w, int h)
840 {
841 if (obj->is_smart && !obj->map->prev.map && !obj->map->prev.usemap) return 0;
842 /* assumes coords have been recalced */
843 if ((RECTS_INTERSECT(x, y, w, h,
844 obj->prev->cache.clip.x,
845 obj->prev->cache.clip.y,
846 obj->prev->cache.clip.w,
847 obj->prev->cache.clip.h)))
848 return 1;
849 return 0;
850 }
851
852 int
evas_object_was_opaque(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)853 evas_object_was_opaque(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
854 {
855 if (obj->is_smart) return 0;
856 if (obj->prev->cache.clip.a == 255)
857 {
858 if (obj->func->was_opaque)
859 return obj->func->was_opaque(eo_obj, obj, obj->private_data);
860 return 1;
861 }
862 return 0;
863 }
864
865 int
evas_object_is_inside(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj,Evas_Coord x,Evas_Coord y)866 evas_object_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y)
867 {
868 if (obj->is_smart) return 0;
869 if (obj->func->is_inside)
870 return obj->func->is_inside(eo_obj, obj, obj->private_data, x, y);
871 return 0;
872 }
873
874 int
evas_object_was_inside(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj,Evas_Coord x,Evas_Coord y)875 evas_object_was_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y)
876 {
877 if (obj->is_smart) return 0;
878 if (obj->func->was_inside)
879 return obj->func->was_inside(eo_obj, obj, obj->private_data, x, y);
880 return 0;
881 }
882 /* routines apps will call */
883
884 EAPI void
evas_object_ref(Evas_Object * eo_obj)885 evas_object_ref(Evas_Object *eo_obj)
886 {
887 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
888 return;
889 MAGIC_CHECK_END();
890
891 efl_ref(eo_obj);
892
893 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
894 if (!obj) return;
895 obj->ref++;
896 }
897
898 EAPI void
evas_object_unref(Evas_Object * eo_obj)899 evas_object_unref(Evas_Object *eo_obj)
900 {
901 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
902 return;
903 MAGIC_CHECK_END();
904
905 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
906 if (!obj) return;
907
908 if (obj->ref == 0) return;
909 obj->ref--;
910 efl_unref(eo_obj);
911 if ((obj->del_ref) && (obj->ref == 0)) evas_object_del(eo_obj);
912
913 }
914
915 EAPI int
evas_object_ref_get(const Evas_Object * eo_obj)916 evas_object_ref_get(const Evas_Object *eo_obj)
917 {
918 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
919 return 0;
920 MAGIC_CHECK_END();
921
922 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
923 if (!obj) return 0;
924 return obj->ref;
925 }
926
927 EAPI void
evas_object_del(Evas_Object * obj)928 evas_object_del(Evas_Object *obj)
929 {
930 Evas_Object_Protected_Data *pd;
931
932 if (!obj) return;
933 if (!efl_isa(obj, MY_CLASS))
934 {
935 ERR("Called %s on a non-evas object: %s@%p",
936 __func__, efl_class_name_get(obj), obj);
937 return;
938 }
939 pd = efl_data_scope_get(obj, MY_CLASS);
940 if (pd->delete_me || pd->efl_del_called) return;
941 if (pd->ref)
942 {
943 pd->del_ref = EINA_TRUE;
944 return;
945 }
946 efl_del(obj);
947 }
948
949 EOLIAN static Eina_Bool
_efl_canvas_object_efl_input_interface_seat_event_filter_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Efl_Input_Device * seat)950 _efl_canvas_object_efl_input_interface_seat_event_filter_get(const Eo *eo_obj EINA_UNUSED,
951 Evas_Object_Protected_Data *obj,
952 Efl_Input_Device *seat)
953 {
954 //It means this object accept events from any seat.
955 if (!obj->events_filter_enabled)
956 return EINA_TRUE;
957 return eina_list_data_find(obj->events->events_whitelist, seat) ?
958 EINA_TRUE : EINA_FALSE;
959 }
960
961 static void
_whitelist_events_device_remove_cb(void * data,const Efl_Event * event)962 _whitelist_events_device_remove_cb(void *data, const Efl_Event *event)
963 {
964 Evas_Object_Protected_Data *obj = data;
965
966 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
967 events->events_whitelist = eina_list_remove(events->events_whitelist,
968 event->object);
969 EINA_COW_WRITE_END(evas_object_events_cow, obj->events, events);
970 }
971
972 EOLIAN static void
_efl_canvas_object_efl_input_interface_seat_event_filter_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Efl_Input_Device * seat,Eina_Bool add)973 _efl_canvas_object_efl_input_interface_seat_event_filter_set(Eo *eo_obj,
974 Evas_Object_Protected_Data *obj,
975 Efl_Input_Device *seat,
976 Eina_Bool add)
977 {
978 EINA_SAFETY_ON_NULL_RETURN(seat);
979
980 if (efl_input_device_type_get(seat) != EFL_INPUT_DEVICE_TYPE_SEAT) return;
981
982 obj->events_filter_enabled = EINA_TRUE;
983 if (add)
984 {
985 if (eina_list_data_find(obj->events->events_whitelist, seat)) return;
986 /* remove all previously focused seats, if any - it may happen
987 since there wasn't a whitelist in place (no restrictions) */
988 if ((!obj->events->events_whitelist) && (obj->layer) && (obj->layer->evas))
989 {
990 const Eina_List *devices, *l;
991 Efl_Input_Device *dev;
992
993 devices = obj->layer->evas->devices;
994 EINA_LIST_FOREACH(devices, l, dev)
995 {
996 if ((efl_input_device_type_get(dev) ==
997 EFL_INPUT_DEVICE_TYPE_SEAT) && (dev != seat))
998 efl_canvas_object_seat_focus_del(eo_obj, dev);
999 }
1000 }
1001 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
1002 events->events_whitelist = eina_list_append(events->events_whitelist, seat);
1003 EINA_COW_WRITE_END(evas_object_events_cow, obj->events, events);
1004
1005 efl_event_callback_add(seat, EFL_EVENT_DEL,
1006 _whitelist_events_device_remove_cb, obj);
1007 }
1008 else
1009 {
1010 efl_canvas_object_seat_focus_del(eo_obj, seat);
1011 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
1012 events->events_whitelist = eina_list_remove(events->events_whitelist, seat);
1013 EINA_COW_WRITE_END(evas_object_events_cow, obj->events, events);
1014
1015 efl_event_callback_del(seat, EFL_EVENT_DEL,
1016 _whitelist_events_device_remove_cb, obj);
1017 }
1018 }
1019
1020 EOLIAN static void
_efl_canvas_object_efl_object_invalidate(Eo * eo_obj,Evas_Object_Protected_Data * obj)1021 _efl_canvas_object_efl_object_invalidate(Eo *eo_obj, Evas_Object_Protected_Data *obj)
1022 {
1023 Efl_Input_Device *dev;
1024 Evas_Object_Pointer_Data *pdata;
1025 Evas_Object *proxy;
1026 Eina_List *l, *l2;
1027 int event_id;
1028
1029 evas_object_async_block(obj);
1030
1031 efl_gfx_entity_visible_set((Eo *) eo_obj, EINA_FALSE);
1032 obj->efl_del_called = EINA_TRUE;
1033
1034 evas_object_hide(eo_obj);
1035
1036 if (obj->events)
1037 {
1038 Eina_Inlist *pointer_grabs;
1039
1040 EINA_COW_WRITE_BEGIN(evas_object_events_cow, obj->events, Evas_Object_Events_Data, events)
1041 {
1042 Evas_Public_Data *edata = NULL;
1043
1044 if (!efl_invalidated_get(evas_object_evas_get(eo_obj)))
1045 edata = efl_data_scope_get(evas_object_evas_get(eo_obj), EVAS_CANVAS_CLASS);
1046
1047 EINA_LIST_FREE (events->focused_by_seats, dev)
1048 {
1049 event_id = _evas_event_counter;
1050 efl_event_callback_del(dev, EFL_EVENT_INVALIDATE,
1051 _evas_focus_device_invalidate_cb, obj);
1052 if (edata) eina_hash_del_by_key(edata->focused_objects, &dev);
1053 _evas_focus_dispatch_event(obj, dev, EINA_FALSE);
1054 if ((obj->layer) && (obj->layer->evas))
1055 _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
1056 }
1057 pointer_grabs = events->pointer_grabs;
1058 events->pointer_grabs = NULL;
1059 EINA_LIST_FREE(events->events_whitelist, dev)
1060 efl_event_callback_del(dev, EFL_EVENT_DEL, _whitelist_events_device_remove_cb, obj);
1061 }
1062 EINA_COW_WRITE_END_NOGC(evas_object_events_cow, obj->events, events);
1063
1064 EINA_INLIST_FREE(pointer_grabs, pdata)
1065 {
1066 pointer_grabs = eina_inlist_remove(pointer_grabs, EINA_INLIST_GET(pdata));
1067 efl_input_device_grab_unregister(pdata->evas_pdata->pointer, eo_obj, pdata);
1068 }
1069 }
1070
1071 event_id = _evas_object_event_new();
1072 evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_DEL, NULL, event_id, NULL);
1073 if ((obj->layer) && (obj->layer->evas))
1074 _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
1075
1076 if (obj->layer)
1077 {
1078 if (obj->layer->evas)
1079 if (obj->layer->evas->pending_default_focus_obj == eo_obj)
1080 obj->layer->evas->pending_default_focus_obj = NULL;
1081 }
1082
1083 evas_object_grabs_cleanup(eo_obj, obj);
1084
1085 /* FIXME: Proxies should listen to source death */
1086 if (obj->proxy)
1087 {
1088 EINA_LIST_FOREACH_SAFE(obj->proxy->proxies, l, l2, proxy)
1089 {
1090 if (efl_isa(proxy, EFL_CANVAS_IMAGE_INTERNAL_CLASS))
1091 evas_object_image_source_unset(proxy);
1092 if (efl_isa(proxy, EFL_GFX_FILTER_INTERFACE))
1093 efl_gfx_filter_source_set(proxy, NULL, eo_obj);
1094 }
1095 }
1096
1097 if (obj->cur)
1098 {
1099 if (obj->cur->clipper)
1100 evas_object_clip_unset(eo_obj);
1101 if (obj->prev)
1102 _efl_canvas_object_clipper_prev_reset(obj, EINA_FALSE);
1103 }
1104
1105 if (obj->map) evas_object_map_set(eo_obj, NULL);
1106
1107 if (obj->is_smart) evas_object_smart_del(eo_obj);
1108 evas_object_change(eo_obj, obj);
1109
1110 efl_invalidate(efl_super(eo_obj, MY_CLASS));
1111 }
1112
1113 EOLIAN static void
_efl_canvas_object_efl_object_destructor(Eo * eo_obj,Evas_Object_Protected_Data * obj)1114 _efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
1115 {
1116 int event_id;
1117
1118 if (obj->clip.clipees)
1119 {
1120 ERR("object %p of type '%s' still has %d clippees after del callback",
1121 eo_obj, efl_class_name_get(eo_obj), eina_list_count(obj->clip.clipees));
1122 /* "while" should be used for null check of obj->clip.clipees,
1123 because evas_objct_clip_unset can set null to obj->clip.clipees */
1124 while (obj->clip.clipees)
1125 {
1126 Evas_Object_Protected_Data *tmp;
1127 tmp = eina_list_data_get(obj->clip.clipees);
1128 evas_object_clip_unset(tmp->object);
1129 }
1130 }
1131
1132 if (obj->name) evas_object_name_set(eo_obj, NULL);
1133 if (!obj->layer)
1134 {
1135 efl_manual_free_set(eo_obj, EINA_FALSE);
1136 goto end;
1137 }
1138
1139 event_id = _evas_object_event_new();
1140 evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_FREE, NULL, event_id, NULL);
1141 if ((obj->layer) && (obj->layer->evas))
1142 _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
1143 evas_object_smart_cleanup(eo_obj);
1144 obj->delete_me = 1;
1145 evas_object_change(eo_obj, obj);
1146 end:
1147 evas_object_event_callback_all_del(eo_obj);
1148 evas_object_event_callback_cleanup(eo_obj);
1149 evas_object_callbacks_shutdown(eo_obj, obj);
1150 efl_destructor(efl_super(eo_obj, MY_CLASS));
1151 }
1152
1153
1154 EOLIAN static void
_efl_canvas_object_efl_gfx_entity_geometry_set(Eo * obj,Evas_Object_Protected_Data * pd EINA_UNUSED,Eina_Rect r)1155 _efl_canvas_object_efl_gfx_entity_geometry_set(Eo *obj, Evas_Object_Protected_Data *pd EINA_UNUSED, Eina_Rect r)
1156 {
1157 efl_gfx_entity_position_set(obj, r.pos);
1158 efl_gfx_entity_size_set(obj, EINA_SIZE2D(r.w, r.h));
1159 }
1160
1161 EAPI void
evas_object_geometry_set(Evas_Object * eo_obj,Evas_Coord x,Evas_Coord y,Evas_Coord w,Evas_Coord h)1162 evas_object_geometry_set(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1163 {
1164 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
1165 return;
1166 MAGIC_CHECK_END();
1167 efl_gfx_entity_geometry_set(eo_obj, EINA_RECT(x, y, w, h));
1168 }
1169
1170 EAPI void
evas_object_move(Evas_Object * obj,Evas_Coord x,Evas_Coord y)1171 evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1172 {
1173 efl_gfx_entity_position_set(obj, EINA_POSITION2D(x, y));
1174 }
1175
1176 EOLIAN static void
_efl_canvas_object_efl_gfx_entity_position_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Position2D pos)1177 _efl_canvas_object_efl_gfx_entity_position_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Position2D pos)
1178 {
1179 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE;
1180 Eina_Bool source_invisible = EINA_FALSE;
1181 Eina_List *was = NULL;
1182 Evas_Map *map;
1183 int x = pos.x;
1184 int y = pos.y;
1185
1186 if (_evas_object_intercept_call_evas(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 1, x, y))
1187 return;
1188
1189 map = obj->map->cur.map;
1190 if (map && map->move_sync.enabled)
1191 {
1192 Evas_Coord diff_x = x - obj->cur->geometry.x;
1193 Evas_Coord diff_y = y - obj->cur->geometry.y;
1194 evas_map_object_move_diff_set(map, diff_x, diff_y);
1195 }
1196
1197 if (!(obj->layer->evas->is_frozen))
1198 {
1199 pass = evas_event_passes_through(eo_obj, obj);
1200 freeze = evas_event_freezes_through(eo_obj, obj);
1201 source_invisible = evas_object_is_source_invisible(eo_obj, obj);
1202 if ((!pass) && (!freeze) && (!source_invisible))
1203 was = _evas_pointer_list_in_rect_get(obj->layer->evas, eo_obj, obj,
1204 1, 1);
1205 }
1206 obj->doing.in_move++;
1207
1208 if (obj->is_smart && obj->smart.smart && obj->smart.smart->smart_class->move)
1209 obj->smart.smart->smart_class->move(eo_obj, x, y);
1210
1211 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
1212 {
1213 state_write->geometry.x = x;
1214 state_write->geometry.y = y;
1215 }
1216 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
1217
1218 evas_object_update_bounding_box(eo_obj, obj, NULL);
1219
1220 //// obj->cur->cache.geometry.validity = 0;
1221 obj->changed_move = EINA_TRUE;
1222 evas_object_change(eo_obj, obj);
1223 evas_object_clip_dirty(eo_obj, obj);
1224 obj->doing.in_move--;
1225 if (!(obj->layer->evas->is_frozen))
1226 {
1227 evas_object_recalc_clippees(obj);
1228 if (!pass && !obj->is_smart && obj->cur->visible)
1229 _evas_canvas_event_pointer_in_list_mouse_move_feed(obj->layer->evas, was, eo_obj, obj, 1, 1, EINA_TRUE, NULL);
1230 }
1231 eina_list_free(was);
1232 evas_object_inform_call_move(eo_obj, obj);
1233 }
1234
1235 EAPI void
evas_object_resize(Evas_Object * obj,Evas_Coord w,Evas_Coord h)1236 evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1237 {
1238 efl_gfx_entity_size_set((Evas_Object *)obj, EINA_SIZE2D(w, h));
1239 }
1240
1241 Eina_Bool
_efl_canvas_object_efl_gfx_entity_size_set_block(Eo * eo_obj,Evas_Object_Protected_Data * obj,Evas_Coord w,Evas_Coord h,Eina_Bool internal)1242 _efl_canvas_object_efl_gfx_entity_size_set_block(Eo *eo_obj, Evas_Object_Protected_Data *obj,
1243 Evas_Coord w, Evas_Coord h, Eina_Bool internal)
1244 {
1245 if (!internal && (obj->doing.in_resize > 0))
1246 {
1247 WRN("evas_object_resize() called on object %p (%s) when in the middle "
1248 "of resizing the same object", eo_obj, efl_class_name_get(eo_obj));
1249 return EINA_TRUE;
1250 }
1251
1252 if (w < 0) w = 0;
1253 if (h < 0) h = 0;
1254
1255 if ((obj->cur->geometry.w == w) && (obj->cur->geometry.h == h))
1256 return EINA_TRUE;
1257
1258 return EINA_FALSE;
1259 }
1260
1261 EOLIAN static void
_efl_canvas_object_efl_gfx_entity_size_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Size2D sz)1262 _efl_canvas_object_efl_gfx_entity_size_set(Eo *eo_obj, Evas_Object_Protected_Data *obj,
1263 Eina_Size2D sz)
1264 {
1265 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE;
1266 Eina_Bool source_invisible = EINA_FALSE;
1267 Eina_List *was = NULL;
1268
1269 if (obj->cur->have_clipees)
1270 {
1271 const Eina_List *l;
1272 Evas_Object_Protected_Data *clipee;
1273
1274 EINA_LIST_FOREACH(obj->clip.clipees, l, clipee)
1275 {
1276 if (clipee->cur->has_fixed_size)
1277 ERR("resizing static clipper! this is a bug!!!!");
1278 }
1279 }
1280
1281 if (sz.w < 0) sz.w = 0;
1282 if (sz.h < 0) sz.h = 0;
1283
1284 if (_evas_object_intercept_call_evas(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 1, sz.w, sz.h))
1285 return;
1286
1287 if (!(obj->layer->evas->is_frozen))
1288 {
1289 pass = evas_event_passes_through(eo_obj, obj);
1290 freeze = evas_event_freezes_through(eo_obj, obj);
1291 source_invisible = evas_object_is_source_invisible(eo_obj, obj);
1292 if ((!pass) && (!freeze) && (!source_invisible))
1293 was = _evas_pointer_list_in_rect_get(obj->layer->evas, eo_obj,
1294 obj, 1, 1);
1295 }
1296 obj->doing.in_resize++;
1297
1298 if (obj->is_smart && obj->smart.smart && obj->smart.smart->smart_class->resize)
1299 obj->smart.smart->smart_class->resize(eo_obj, sz.w, sz.h);
1300
1301 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
1302 {
1303 state_write->geometry.w = sz.w;
1304 state_write->geometry.h = sz.h;
1305 }
1306 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
1307
1308 evas_object_update_bounding_box(eo_obj, obj, NULL);
1309
1310 //// obj->cur->cache.geometry.validity = 0;
1311 evas_object_change(eo_obj, obj);
1312 evas_object_clip_dirty(eo_obj, obj);
1313 obj->doing.in_resize--;
1314 /* NB: evas_object_recalc_clippees was here previously ( < 08/07/2009) */
1315 if (!(obj->layer->evas->is_frozen))
1316 {
1317 /* NB: If this creates glitches on screen then move to above position */
1318 evas_object_recalc_clippees(obj);
1319
1320 // if (obj->func->coords_recalc) obj->func->coords_recalc(eo_obj);
1321 if (!pass && !obj->is_smart && obj->cur->visible)
1322 _evas_canvas_event_pointer_in_list_mouse_move_feed(obj->layer->evas, was, eo_obj, obj, 1, 1, EINA_TRUE, NULL);
1323 }
1324 eina_list_free(was);
1325 evas_object_inform_call_resize(eo_obj, obj);
1326 }
1327
1328 EOLIAN Eina_Rect
_efl_canvas_object_efl_gfx_entity_geometry_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1329 _efl_canvas_object_efl_gfx_entity_geometry_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1330 {
1331 return (Eina_Rect) obj->cur->geometry;
1332 }
1333
1334 EAPI void
evas_object_geometry_get(const Evas_Object * eo_obj,Evas_Coord * x,Evas_Coord * y,Evas_Coord * w,Evas_Coord * h)1335 evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1336 {
1337 Eina_Rect r = efl_gfx_entity_geometry_get(eo_obj);
1338 if (x) *x = r.x;
1339 if (y) *y = r.y;
1340 if (w) *w = r.w;
1341 if (h) *h = r.h;
1342 }
1343
1344 EOLIAN static Eina_Position2D
_efl_canvas_object_efl_gfx_entity_position_get(const Eo * obj EINA_UNUSED,Evas_Object_Protected_Data * pd)1345 _efl_canvas_object_efl_gfx_entity_position_get(const Eo *obj EINA_UNUSED,
1346 Evas_Object_Protected_Data *pd)
1347 {
1348 if ((pd->delete_me) || (!pd->layer))
1349 return EINA_POSITION2D(0, 0);
1350
1351 return ((Eina_Rect) pd->cur->geometry).pos;
1352 }
1353
1354 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_entity_size_get(const Eo * obj EINA_UNUSED,Evas_Object_Protected_Data * pd)1355 _efl_canvas_object_efl_gfx_entity_size_get(const Eo *obj EINA_UNUSED,
1356 Evas_Object_Protected_Data *pd)
1357 {
1358 if (pd->delete_me)
1359 return EINA_SIZE2D(0, 0);
1360
1361 return ((Eina_Rect) pd->cur->geometry).size;
1362 }
1363
1364 static void
_evas_object_size_hint_alloc(Evas_Object * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1365 _evas_object_size_hint_alloc(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1366 {
1367 if (obj->size_hints) return;
1368
1369 EVAS_MEMPOOL_INIT(_mp_sh, "evas_size_hints", Evas_Size_Hints, 32, );
1370 obj->size_hints = EVAS_MEMPOOL_ALLOC(_mp_sh, Evas_Size_Hints);
1371 if (!obj->size_hints) return;
1372 EVAS_MEMPOOL_PREP(_mp_sh, obj->size_hints, Evas_Size_Hints);
1373 obj->size_hints->user_max.w = -1;
1374 obj->size_hints->user_max.h = -1;
1375 obj->size_hints->max.w = -1;
1376 obj->size_hints->max.h = -1;
1377 obj->size_hints->align.x = 0.5;
1378 obj->size_hints->align.y = 0.5;
1379 obj->size_hints->fill.x = 1;
1380 obj->size_hints->fill.y = 1;
1381 obj->size_hints->dispmode = EVAS_DISPLAY_MODE_NONE;
1382 }
1383
1384 /* Legacy only */
1385 EAPI Evas_Display_Mode
evas_object_size_hint_display_mode_get(const Evas_Object * eo_obj)1386 evas_object_size_hint_display_mode_get(const Evas_Object *eo_obj)
1387 {
1388 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
1389 EVAS_OBJECT_DATA_ALIVE_CHECK(obj, EVAS_DISPLAY_MODE_NONE);
1390 if (!obj->size_hints) return EVAS_DISPLAY_MODE_NONE;
1391 return obj->size_hints->dispmode;
1392 }
1393
1394 /* Legacy only */
1395 EAPI void
evas_object_size_hint_display_mode_set(Eo * eo_obj,Evas_Display_Mode dispmode)1396 evas_object_size_hint_display_mode_set(Eo *eo_obj, Evas_Display_Mode dispmode)
1397 {
1398 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
1399
1400 EVAS_OBJECT_DATA_ALIVE_CHECK(obj);
1401 evas_object_async_block(obj);
1402 if (EINA_UNLIKELY(!obj->size_hints))
1403 {
1404 if (dispmode == EVAS_DISPLAY_MODE_NONE) return;
1405 _evas_object_size_hint_alloc(eo_obj, obj);
1406 }
1407 if (obj->size_hints->dispmode == dispmode) return;
1408 obj->size_hints->dispmode = dispmode;
1409
1410 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1411 }
1412
1413 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_max_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1414 _efl_canvas_object_efl_gfx_hint_hint_size_restricted_max_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1415 {
1416 if ((!obj->size_hints) || obj->delete_me)
1417 return EINA_SIZE2D(0, 0);
1418
1419 return obj->size_hints->max;
1420 }
1421
1422 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_max_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Size2D sz)1423 _efl_canvas_object_efl_gfx_hint_hint_size_restricted_max_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Size2D sz)
1424 {
1425 if (obj->delete_me)
1426 return;
1427
1428 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1429 evas_object_async_block(obj);
1430 if (EINA_UNLIKELY(!obj->size_hints))
1431 {
1432 if (!sz.w && !sz.h) return;
1433 _evas_object_size_hint_alloc(eo_obj, obj);
1434 }
1435 if (EINA_SIZE2D_EQ(obj->size_hints->max, sz)) return;
1436 obj->size_hints->max = sz;
1437 if ((obj->size_hints->max.w != -1) && (obj->size_hints->max.w < obj->size_hints->min.w))
1438 ERR("restricted max width hint is now smaller than restricted min width hint! (%d < %d)", obj->size_hints->max.w, obj->size_hints->min.w);
1439 if ((obj->size_hints->max.h != -1) && (obj->size_hints->max.h < obj->size_hints->min.h))
1440 ERR("restricted max height hint is now smaller than restricted min height hint! (%d < %d)", obj->size_hints->max.h, obj->size_hints->min.h);
1441 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1442 }
1443
1444 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_min_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1445 _efl_canvas_object_efl_gfx_hint_hint_size_restricted_min_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1446 {
1447 if ((!obj->size_hints) || obj->delete_me)
1448 return EINA_SIZE2D(0, 0);
1449
1450 return obj->size_hints->min;
1451 }
1452
1453 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_size_restricted_min_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Size2D sz)1454 _efl_canvas_object_efl_gfx_hint_hint_size_restricted_min_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Size2D sz)
1455 {
1456 if (obj->delete_me)
1457 return;
1458
1459 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1460 evas_object_async_block(obj);
1461 if (EINA_UNLIKELY(!obj->size_hints))
1462 {
1463 if (!sz.w && !sz.h) return;
1464 _evas_object_size_hint_alloc(eo_obj, obj);
1465 }
1466 if (EINA_SIZE2D_EQ(obj->size_hints->min, sz)) return;
1467 obj->size_hints->min = sz;
1468 if ((obj->size_hints->max.w != -1) && (obj->size_hints->max.w < obj->size_hints->min.w))
1469 ERR("restricted max width hint is now smaller than restricted min width hint! (%d < %d)", obj->size_hints->max.w, obj->size_hints->min.w);
1470 if ((obj->size_hints->max.h != -1) && (obj->size_hints->max.h < obj->size_hints->min.h))
1471 ERR("restricted max height hint is now smaller than restricted min height hint! (%d < %d)", obj->size_hints->max.h, obj->size_hints->min.h);
1472 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1473 }
1474
1475 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_combined_min_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1476 _efl_canvas_object_efl_gfx_hint_hint_size_combined_min_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1477 {
1478 Eina_Size2D sz = { 0, 0 };
1479
1480 if ((!obj->size_hints) || obj->delete_me)
1481 return sz;
1482
1483 sz.w = obj->size_hints->user_min.w;
1484 if (obj->size_hints->max.w != -1)
1485 sz.w = obj->size_hints->max.w;
1486 sz.h = obj->size_hints->user_min.h;
1487 if (obj->size_hints->max.h != -1)
1488 sz.h = obj->size_hints->max.h;
1489
1490 /* clamp user min to restricted max here */
1491 sz.w = MAX(obj->size_hints->min.w, MIN(sz.w, obj->size_hints->user_min.w));
1492 sz.h = MAX(obj->size_hints->min.h, MIN(sz.h, obj->size_hints->user_min.h));
1493 return sz;
1494 }
1495
1496 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_combined_max_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1497 _efl_canvas_object_efl_gfx_hint_hint_size_combined_max_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1498 {
1499 Eina_Size2D sz = { -1, -1 };
1500
1501 if ((!obj->size_hints) || obj->delete_me)
1502 return sz;
1503
1504 sz.w = obj->size_hints->user_max.w;
1505 sz.h = obj->size_hints->user_max.h;
1506
1507 /* clamp user max to restricted max here */
1508 if (obj->size_hints->max.w != -1)
1509 {
1510 if (sz.w == -1)
1511 sz.w = obj->size_hints->max.w;
1512 else
1513 sz.w = MIN(obj->size_hints->max.w, sz.w);
1514 }
1515 if (obj->size_hints->max.h != -1)
1516 {
1517 if (sz.h == -1)
1518 sz.h = obj->size_hints->max.h;
1519 else
1520 sz.h = MIN(obj->size_hints->max.h, sz.h);
1521 }
1522 /* then clamp to restricted min */
1523 if ((sz.w != -1) && obj->size_hints->min.w > 0)
1524 sz.w = MAX(sz.w, obj->size_hints->min.w);
1525 if ((sz.h != -1) && obj->size_hints->min.h > 0)
1526 sz.h = MAX(sz.h, obj->size_hints->min.h);
1527 return sz;
1528 }
1529
1530 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_max_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1531 _efl_canvas_object_efl_gfx_hint_hint_size_max_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1532 {
1533 if ((!obj->size_hints) || obj->delete_me)
1534 return EINA_SIZE2D(-1, -1);
1535
1536 return obj->size_hints->user_max;
1537 }
1538
1539 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_size_max_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Size2D sz)1540 _efl_canvas_object_efl_gfx_hint_hint_size_max_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Size2D sz)
1541 {
1542 if (obj->delete_me)
1543 return;
1544
1545 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1546 evas_object_async_block(obj);
1547 if (EINA_UNLIKELY(!obj->size_hints))
1548 {
1549 if ((sz.w == -1) && (sz.h == -1)) return;
1550 _evas_object_size_hint_alloc(eo_obj, obj);
1551 }
1552 if (EINA_SIZE2D_EQ(obj->size_hints->user_max, sz)) return;
1553 obj->size_hints->user_max.w = sz.w;
1554 obj->size_hints->user_max.h = sz.h;
1555
1556 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1557 }
1558
1559 EAPI void
evas_object_size_hint_request_get(const Eo * eo_obj,Evas_Coord * w,Evas_Coord * h)1560 evas_object_size_hint_request_get(const Eo *eo_obj, Evas_Coord *w, Evas_Coord *h)
1561 {
1562 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
1563 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1564
1565 if ((!obj->size_hints) || obj->delete_me)
1566 {
1567 if (w) *w = 0;
1568 if (h) *h = 0;
1569 return;
1570 }
1571 if (w) *w = obj->size_hints->request.w;
1572 if (h) *h = obj->size_hints->request.h;
1573 }
1574
1575 EAPI void
evas_object_size_hint_request_set(Eo * eo_obj,Evas_Coord w,Evas_Coord h)1576 evas_object_size_hint_request_set(Eo *eo_obj, Evas_Coord w, Evas_Coord h)
1577 {
1578 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
1579 EVAS_OBJECT_DATA_ALIVE_CHECK(obj);
1580
1581 evas_object_async_block(obj);
1582 if (EINA_UNLIKELY(!obj->size_hints))
1583 {
1584 if (!w && !h) return;
1585 _evas_object_size_hint_alloc(eo_obj, obj);
1586 }
1587 if ((obj->size_hints->request.w == w) && (obj->size_hints->request.h == h)) return;
1588 obj->size_hints->request.w = w;
1589 obj->size_hints->request.h = h;
1590
1591 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1592 }
1593
1594 EOLIAN static Eina_Size2D
_efl_canvas_object_efl_gfx_hint_hint_size_min_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)1595 _efl_canvas_object_efl_gfx_hint_hint_size_min_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
1596 {
1597 if ((!obj->size_hints) || obj->delete_me)
1598 return EINA_SIZE2D(0, 0);
1599
1600 return obj->size_hints->user_min;
1601 }
1602
1603 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_size_min_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Size2D sz)1604 _efl_canvas_object_efl_gfx_hint_hint_size_min_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Size2D sz)
1605 {
1606 if (obj->delete_me)
1607 return;
1608
1609 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1610 evas_object_async_block(obj);
1611 if (EINA_UNLIKELY(!obj->size_hints))
1612 {
1613 if (!sz.w && !sz.h) return;
1614 _evas_object_size_hint_alloc(eo_obj, obj);
1615 }
1616 if (EINA_SIZE2D_EQ(obj->size_hints->user_min, sz)) return;
1617 obj->size_hints->user_min = sz;
1618 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1619 }
1620
1621 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_aspect_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Efl_Gfx_Hint_Aspect * aspect,Eina_Size2D * sz)1622 _efl_canvas_object_efl_gfx_hint_hint_aspect_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Gfx_Hint_Aspect *aspect, Eina_Size2D *sz)
1623 {
1624 if ((!obj->size_hints) || obj->delete_me)
1625 {
1626 if (aspect) *aspect = EFL_GFX_HINT_ASPECT_NONE;
1627 if (sz) *sz = EINA_SIZE2D(0, 0);
1628 return;
1629 }
1630 if (aspect) *aspect = (Efl_Gfx_Hint_Aspect)obj->size_hints->aspect.mode;
1631 if (sz)
1632 {
1633 sz->w = obj->size_hints->aspect.size.w;
1634 sz->h = obj->size_hints->aspect.size.h;
1635 }
1636 }
1637
1638 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_aspect_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Efl_Gfx_Hint_Aspect aspect,Eina_Size2D sz)1639 _efl_canvas_object_efl_gfx_hint_hint_aspect_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Hint_Aspect aspect, Eina_Size2D sz)
1640 {
1641 if (obj->delete_me)
1642 return;
1643
1644 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1645 evas_object_async_block(obj);
1646 if (EINA_UNLIKELY(!obj->size_hints))
1647 {
1648 if (!sz.w && !sz.h) return;
1649 _evas_object_size_hint_alloc(eo_obj, obj);
1650 }
1651 if ((obj->size_hints->aspect.mode == (Evas_Aspect_Control)aspect) &&
1652 (obj->size_hints->aspect.size.w == sz.w) &&
1653 (obj->size_hints->aspect.size.h == sz.h)) return;
1654 obj->size_hints->aspect.mode = (Evas_Aspect_Control)aspect;
1655 obj->size_hints->aspect.size = sz;
1656
1657 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1658 }
1659
1660 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_align_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,double * x,double * y)1661 _efl_canvas_object_efl_gfx_hint_hint_align_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, double *x, double *y)
1662 {
1663 if ((!obj->size_hints) || obj->delete_me)
1664 {
1665 if (x) *x = 0.5;
1666 if (y) *y = 0.5;
1667 return;
1668 }
1669 if (x) *x = obj->size_hints->align.x;
1670 if (y) *y = obj->size_hints->align.y;
1671 }
1672
1673 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_align_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,double x,double y)1674 _efl_canvas_object_efl_gfx_hint_hint_align_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, double x, double y)
1675 {
1676 if (obj->delete_me)
1677 return;
1678
1679 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1680 evas_object_async_block(obj);
1681 if (EINA_UNLIKELY(!obj->size_hints))
1682 {
1683 if (EINA_DBL_EQ(x, 0.5) && EINA_DBL_EQ(y, 0.5)) return;
1684 _evas_object_size_hint_alloc(eo_obj, obj);
1685 }
1686 if ((EINA_DBL_EQ(obj->size_hints->align.x, x)) &&
1687 (EINA_DBL_EQ(obj->size_hints->align.y, y)))
1688 return;
1689 obj->size_hints->align.x = x;
1690 obj->size_hints->align.y = y;
1691
1692 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1693 }
1694
1695 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_weight_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,double * x,double * y)1696 _efl_canvas_object_efl_gfx_hint_hint_weight_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, double *x, double *y)
1697 {
1698 if ((!obj->size_hints) || obj->delete_me)
1699 {
1700 if (x) *x = 0.0;
1701 if (y) *y = 0.0;
1702 return;
1703 }
1704 if (x) *x = obj->size_hints->weight.x;
1705 if (y) *y = obj->size_hints->weight.y;
1706 }
1707
1708 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_weight_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,double x,double y)1709 _efl_canvas_object_efl_gfx_hint_hint_weight_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, double x, double y)
1710 {
1711 if (obj->delete_me)
1712 return;
1713
1714 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1715 evas_object_async_block(obj);
1716 if (!obj->legacy.weight_set) obj->legacy.weight_set = 1;
1717 if (EINA_UNLIKELY(!obj->size_hints))
1718 {
1719 if (EINA_DBL_EQ(x, 0.0) && EINA_DBL_EQ(y, 0.0)) return;
1720 _evas_object_size_hint_alloc(eo_obj, obj);
1721 }
1722 if ((EINA_DBL_EQ(obj->size_hints->weight.x, x)) &&
1723 (EINA_DBL_EQ(obj->size_hints->weight.y, y)))
1724 return;
1725 obj->size_hints->weight.x = x;
1726 obj->size_hints->weight.y = y;
1727
1728 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1729 }
1730
1731 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_margin_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Evas_Coord * l,Evas_Coord * r,Evas_Coord * t,Evas_Coord * b)1732 _efl_canvas_object_efl_gfx_hint_hint_margin_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Coord *l, Evas_Coord *r, Evas_Coord *t, Evas_Coord *b)
1733 {
1734 if ((!obj->size_hints) || obj->delete_me)
1735 {
1736 if (l) *l = 0;
1737 if (r) *r = 0;
1738 if (t) *t = 0;
1739 if (b) *b = 0;
1740 return;
1741 }
1742 if (l) *l = obj->size_hints->padding.l;
1743 if (r) *r = obj->size_hints->padding.r;
1744 if (t) *t = obj->size_hints->padding.t;
1745 if (b) *b = obj->size_hints->padding.b;
1746 }
1747
1748 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_margin_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Evas_Coord l,Evas_Coord r,Evas_Coord t,Evas_Coord b)1749 _efl_canvas_object_efl_gfx_hint_hint_margin_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord l, Evas_Coord r, Evas_Coord t, Evas_Coord b)
1750 {
1751 if (obj->delete_me)
1752 return;
1753
1754 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1755 evas_object_async_block(obj);
1756 if (EINA_UNLIKELY(!obj->size_hints))
1757 {
1758 if (!l && !r && !t && !b) return;
1759 _evas_object_size_hint_alloc(eo_obj, obj);
1760 }
1761 if ((obj->size_hints->padding.l == l) && (obj->size_hints->padding.r == r) && (obj->size_hints->padding.t == t) && (obj->size_hints->padding.b == b)) return;
1762 obj->size_hints->padding.l = l;
1763 obj->size_hints->padding.r = r;
1764 obj->size_hints->padding.t = t;
1765 obj->size_hints->padding.b = b;
1766
1767 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1768 }
1769
1770 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_fill_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Eina_Bool * x,Eina_Bool * y)1771 _efl_canvas_object_efl_gfx_hint_hint_fill_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Eina_Bool *x, Eina_Bool *y)
1772 {
1773 if ((!obj->size_hints) || obj->delete_me)
1774 {
1775 if (x) *x = EINA_TRUE;
1776 if (y) *y = EINA_TRUE;
1777 return;
1778 }
1779 if (x) *x = obj->size_hints->fill.x;
1780 if (y) *y = obj->size_hints->fill.y;
1781 }
1782
1783 EOLIAN static void
_efl_canvas_object_efl_gfx_hint_hint_fill_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Bool x,Eina_Bool y)1784 _efl_canvas_object_efl_gfx_hint_hint_fill_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool x, Eina_Bool y)
1785 {
1786 if (obj->delete_me)
1787 return;
1788
1789 if (obj->legacy.ctor)
1790 {
1791 ERR("fill_set() not supported. use align_set() with EVAS_HINT_FILL instead.");
1792 return;
1793 }
1794
1795 EVAS_OBJECT_DATA_VALID_CHECK(obj);
1796 evas_object_async_block(obj);
1797
1798 x = !!x;
1799 y = !!y;
1800
1801 if (EINA_UNLIKELY(!obj->size_hints))
1802 {
1803 if (x && y) return;
1804 _evas_object_size_hint_alloc(eo_obj, obj);
1805 }
1806 if ((obj->size_hints->fill.x == x) && (obj->size_hints->fill.y == y)) return;
1807 obj->size_hints->fill.x = x;
1808 obj->size_hints->fill.y = y;
1809
1810 evas_object_inform_call_changed_size_hints(eo_obj, obj);
1811 }
1812
1813 EAPI void
evas_object_show(Evas_Object * eo_obj)1814 evas_object_show(Evas_Object *eo_obj)
1815 {
1816 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
1817 return;
1818 MAGIC_CHECK_END();
1819 efl_gfx_entity_visible_set(eo_obj, EINA_TRUE);
1820 }
1821
1822 EAPI void
evas_object_hide(Evas_Object * eo_obj)1823 evas_object_hide(Evas_Object *eo_obj)
1824 {
1825 if (!eo_obj) return;
1826 efl_gfx_entity_visible_set(eo_obj, EINA_FALSE);
1827 }
1828
1829 EAPI Eina_Bool
evas_object_visible_get(const Evas_Object * obj)1830 evas_object_visible_get(const Evas_Object *obj)
1831 {
1832 return efl_gfx_entity_visible_get((Evas_Object *)obj);
1833 }
1834
1835 static void
_show(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)1836 _show(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
1837 {
1838 if (obj->anim_player)
1839 efl_player_playing_set(obj->anim_player, EINA_FALSE);
1840 if (obj->is_smart && obj->smart.smart && obj->smart.smart->smart_class->show)
1841 {
1842 obj->smart.smart->smart_class->show(eo_obj);
1843 }
1844 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
1845 {
1846 state_write->visible = 1;
1847 }
1848 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
1849
1850 evas_object_change(eo_obj, obj);
1851 evas_object_clip_dirty(eo_obj, obj);
1852 if (!(obj->layer->evas->is_frozen))
1853 {
1854 evas_object_clip_across_clippees_check(eo_obj, obj);
1855 evas_object_recalc_clippees(obj);
1856 if ((!evas_event_passes_through(eo_obj, obj)) &&
1857 (!evas_event_freezes_through(eo_obj, obj)) &&
1858 (!evas_object_is_source_invisible(eo_obj, obj)))
1859 {
1860 if (!obj->is_smart)
1861 {
1862 _evas_canvas_event_pointer_in_rect_mouse_move_feed(obj->layer->evas,
1863 eo_obj,
1864 obj, 1, 1,
1865 EINA_FALSE,
1866 NULL);
1867 }
1868 }
1869 }
1870 evas_object_update_bounding_box(eo_obj, obj, NULL);
1871 evas_object_inform_call_show(eo_obj, obj);
1872 }
1873
1874 static void
_hide(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)1875 _hide(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
1876 {
1877 if (obj->is_smart && obj->smart.smart && obj->smart.smart->smart_class->hide)
1878 {
1879 obj->smart.smart->smart_class->hide(eo_obj);
1880 }
1881 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
1882 {
1883 state_write->visible = 0;
1884 }
1885 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
1886
1887 if (obj->mask->is_mask)
1888 {
1889 if (obj->mask->surface ||
1890 obj->mask->w || obj->mask->h ||
1891 obj->mask->is_alpha || obj->mask->redraw)
1892 {
1893 EINA_COW_WRITE_BEGIN(evas_object_mask_cow, obj->mask,
1894 Evas_Object_Mask_Data, mask)
1895 mask->redraw = EINA_FALSE;
1896 mask->is_alpha = EINA_FALSE;
1897 mask->w = mask->h = 0;
1898 if (mask->surface)
1899 {
1900 obj->layer->evas->engine.func->image_free(ENC, mask->surface);
1901 mask->surface = NULL;
1902 }
1903 EINA_COW_WRITE_END(evas_object_mask_cow, obj->mask, mask);
1904 }
1905 }
1906
1907 evas_object_change(eo_obj, obj);
1908 evas_object_clip_dirty(eo_obj, obj);
1909 if (obj->layer->evas && !(obj->layer->evas->is_frozen))
1910 {
1911 evas_object_clip_across_clippees_check(eo_obj, obj);
1912 evas_object_recalc_clippees(obj);
1913 if ((!evas_event_passes_through(eo_obj, obj)) &&
1914 (!evas_event_freezes_through(eo_obj, obj)) &&
1915 (!evas_object_is_source_invisible(eo_obj, obj)))
1916 {
1917 if ((!obj->is_smart) ||
1918 ((obj->map->cur.map) && (obj->map->cur.usemap)))
1919 {
1920 Evas_Object_Pointer_Data *obj_pdata;
1921 Eina_Bool mouse_grabbed = EINA_FALSE;
1922 EINA_INLIST_FOREACH(obj->events->pointer_grabs, obj_pdata)
1923 {
1924 if (obj_pdata->mouse_grabbed > 0)
1925 {
1926 mouse_grabbed = EINA_TRUE;
1927 break;
1928 }
1929 }
1930 if (!mouse_grabbed)
1931 {
1932 EINA_INLIST_FOREACH(obj->events->pointer_grabs, obj_pdata)
1933 {
1934 if (evas_object_is_in_output_rect(eo_obj, obj, obj_pdata->evas_pdata->seat->x,
1935 obj_pdata->evas_pdata->seat->y,
1936 1, 1))
1937 _evas_canvas_event_pointer_move_event_dispatch(obj->layer->evas, obj_pdata->evas_pdata, NULL);
1938 }
1939 }
1940 /* this is at odds to handling events when an obj is moved out of the mouse
1941 * ore resized out or clipped out. if mouse is grabbed - regardless of
1942 * visibility, mouse move events should keep happening and mouse up.
1943 * for better or worse it's at least consistent.
1944 if (obj->delete_me) return;
1945 if (obj->mouse_grabbed > 0)
1946 obj->layer->evas->pointer.mouse_grabbed -= obj->mouse_grabbed;
1947 if ((obj->mouse_in) || (obj->mouse_grabbed > 0))
1948 obj->layer->evas->pointer.object.in = eina_list_remove(obj->layer->evas->pointer.object.in, eo_obj);
1949 obj->mouse_grabbed = 0;
1950 if (obj->layer->evas->is_frozen)
1951 {
1952 obj->mouse_in = 0;
1953 return;
1954 }
1955 if (obj->mouse_in)
1956 {
1957 Evas_Event_Mouse_Out ev;
1958
1959 _evas_object_event_new();
1960
1961 obj->mouse_in = 0;
1962 ev.buttons = obj->layer->evas->pointer.button;
1963 ev.output.x = obj->layer->evas->pointer.x;
1964 ev.output.y = obj->layer->evas->pointer.y;
1965 ev.canvas.x = obj->layer->evas->pointer.x;
1966 ev.canvas.y = obj->layer->evas->pointer.y;
1967 ev.data = NULL;
1968 ev.modifiers = &(obj->layer->evas->modifiers);
1969 ev.locks = &(obj->layer->evas->locks);
1970 ev.timestamp = obj->layer->evas->last_timestamp;
1971 ev.event_flags = EVAS_EVENT_FLAG_NONE;
1972 event_id = _evas_object_event_new();
1973 evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
1974 _evas_post_event_callback_call(obj->layer->evas, obj->layer->evas, event_id);
1975 }
1976 */
1977 }
1978 }
1979 }
1980 else
1981 {
1982 /*
1983 if (obj->mouse_grabbed > 0)
1984 obj->layer->evas->pointer.mouse_grabbed -= obj->mouse_grabbed;
1985 if ((obj->mouse_in) || (obj->mouse_grabbed > 0))
1986 obj->layer->evas->pointer.object.in = eina_list_remove(obj->layer->evas->pointer.object.in, eo_obj);
1987 obj->mouse_grabbed = 0;
1988 obj->mouse_in = 0;
1989 */
1990 }
1991 evas_object_update_bounding_box(eo_obj, obj, NULL);
1992 evas_object_inform_call_hide(eo_obj, obj);
1993 }
1994
1995 EOLIAN static void
_efl_canvas_object_efl_gfx_entity_visible_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Bool vis)1996 _efl_canvas_object_efl_gfx_entity_visible_set(Eo *eo_obj, Evas_Object_Protected_Data *obj,
1997 Eina_Bool vis)
1998 {
1999 if (!obj->legacy.visible_set)
2000 obj->legacy.visible_set = EINA_TRUE;
2001 if (_evas_object_intercept_call_evas(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 1, vis))
2002 return;
2003
2004 if (vis) _show(eo_obj, obj);
2005 else _hide(eo_obj, obj);
2006 }
2007
2008 EOLIAN static Eina_Bool
_efl_canvas_object_efl_gfx_entity_visible_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2009 _efl_canvas_object_efl_gfx_entity_visible_get(const Eo *eo_obj EINA_UNUSED,
2010 Evas_Object_Protected_Data *obj)
2011 {
2012 if (!EVAS_OBJECT_DATA_ALIVE(obj)) return EINA_FALSE;
2013 #if 0
2014 // Try to return TRUE when an object is an EO object (must be finalized,
2015 // otherwise we can't know for sure if it's legacy or not).
2016 // Note: This was disabled as it used to lead to render bugs.
2017 if (obj->legacy.finalized && !obj->legacy.ctor && !obj->legacy.visible_set)
2018 return EINA_TRUE;
2019 #endif
2020 return obj->cur->visible;
2021 }
2022
2023 EAPI void
evas_object_color_set(Evas_Object * obj,int r,int g,int b,int a)2024 evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
2025 {
2026 efl_gfx_color_set((Evas_Object *)obj, r, g, b, a);
2027 }
2028
2029 EOLIAN static void
_efl_canvas_object_efl_gfx_color_color_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,int r,int g,int b,int a)2030 _efl_canvas_object_efl_gfx_color_color_set(Eo *eo_obj, Evas_Object_Protected_Data *obj,
2031 int r, int g, int b, int a)
2032 {
2033 int prev_a;
2034
2035 if (obj->delete_me) return;
2036
2037 if (EVAS_COLOR_SANITIZE(r, g, b, a))
2038 ERR("Evas only handles premultiplied colors (0 <= R,G,B <= A <= 255)");
2039
2040 if (_evas_object_intercept_call_evas(obj, EVAS_OBJECT_INTERCEPT_CB_COLOR_SET, 1, r, g, b, a)) return;
2041 if ((obj->cur->color.r == r) &&
2042 (obj->cur->color.g == g) &&
2043 (obj->cur->color.b == b) &&
2044 (obj->cur->color.a == a)) return;
2045
2046 prev_a = obj->cur->color.a;
2047 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
2048 {
2049 state_write->color.r = r;
2050 state_write->color.g = g;
2051 state_write->color.b = b;
2052 state_write->color.a = a;
2053 }
2054 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
2055
2056 if (obj->is_smart && obj->smart.smart &&
2057 obj->smart.smart->smart_class &&
2058 obj->smart.smart->smart_class->color_set)
2059 {
2060 obj->smart.smart->smart_class->color_set(eo_obj, r, g, b, a);
2061 }
2062
2063 evas_object_clip_dirty(eo_obj, obj);
2064 if ((prev_a == 0) && (a == 0) && (obj->cur->render_op == EVAS_RENDER_BLEND)) return;
2065
2066 obj->changed_color = EINA_TRUE;
2067 evas_object_change(eo_obj, obj);
2068 }
2069
2070 EAPI void
evas_object_color_get(const Evas_Object * obj,int * r,int * g,int * b,int * a)2071 evas_object_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
2072 {
2073 efl_gfx_color_get((Evas_Object *)obj, r, g, b, a);
2074 }
2075
2076 EOLIAN static void
_efl_canvas_object_efl_gfx_color_color_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,int * r,int * g,int * b,int * a)2077 _efl_canvas_object_efl_gfx_color_color_get(const Eo *eo_obj EINA_UNUSED,
2078 Evas_Object_Protected_Data *obj,
2079 int *r, int *g, int *b, int *a)
2080 {
2081 if (obj->delete_me)
2082 {
2083 if (r) *r = 0;
2084 if (g) *g = 0;
2085 if (b) *b = 0;
2086 if (a) *a = 0;
2087 return;
2088 }
2089 if (r) *r = obj->cur->color.r;
2090 if (g) *g = obj->cur->color.g;
2091 if (b) *b = obj->cur->color.b;
2092 if (a) *a = obj->cur->color.a;
2093 }
2094
2095 EOLIAN static void
_efl_canvas_object_anti_alias_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Bool anti_alias)2096 _efl_canvas_object_anti_alias_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool anti_alias)
2097 {
2098 if (obj->delete_me) return;
2099 anti_alias = !!anti_alias;
2100 if (obj->cur->anti_alias == anti_alias)return;
2101
2102 evas_object_async_block(obj);
2103 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
2104 {
2105 state_write->anti_alias = anti_alias;
2106 }
2107 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
2108
2109 evas_object_change(eo_obj, obj);
2110 }
2111
2112 EOLIAN static Eina_Bool
_efl_canvas_object_anti_alias_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2113 _efl_canvas_object_anti_alias_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2114 {
2115 if (obj->delete_me) return EINA_FALSE;
2116 return obj->cur->anti_alias;
2117 }
2118
2119 EOLIAN static void
_efl_canvas_object_efl_gfx_entity_scale_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,double scale)2120 _efl_canvas_object_efl_gfx_entity_scale_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, double scale)
2121 {
2122 if (obj->delete_me) return;
2123 if (EINA_DBL_EQ(obj->cur->scale, scale)) return;
2124
2125 evas_object_async_block(obj);
2126 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
2127 {
2128 state_write->scale = scale;
2129 }
2130 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
2131 evas_object_change(eo_obj, obj);
2132 }
2133
2134 EOLIAN static double
_efl_canvas_object_efl_gfx_entity_scale_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2135 _efl_canvas_object_efl_gfx_entity_scale_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2136 {
2137 if (obj->delete_me) return 1.0;
2138 return obj->cur->scale;
2139 }
2140
2141 static void
_render_op_set(Evas_Object_Protected_Data * obj,Evas_Render_Op render_op)2142 _render_op_set(Evas_Object_Protected_Data *obj, Evas_Render_Op render_op)
2143 {
2144 if (!obj || obj->delete_me) return;
2145 if (obj->cur->render_op == render_op) return;
2146
2147 evas_object_async_block(obj);
2148 EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
2149 {
2150 state_write->render_op = render_op;
2151 }
2152 EINA_COW_STATE_WRITE_END(obj, state_write, cur);
2153
2154 evas_object_change(obj->object, obj);
2155 }
2156
2157 EOLIAN static void
_efl_canvas_object_render_op_set(Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Efl_Gfx_Render_Op rop)2158 _efl_canvas_object_render_op_set(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Gfx_Render_Op rop)
2159 {
2160 _render_op_set(obj, _gfx_to_evas_render_op(rop));
2161 }
2162
2163 EAPI void
evas_object_render_op_set(Evas_Object * eo_obj,Evas_Render_Op render_op)2164 evas_object_render_op_set(Evas_Object *eo_obj, Evas_Render_Op render_op)
2165 {
2166 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj);
2167 _render_op_set(obj, render_op);
2168 }
2169
2170 EOLIAN static Efl_Gfx_Render_Op
_efl_canvas_object_render_op_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2171 _efl_canvas_object_render_op_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2172 {
2173 return _evas_to_gfx_render_op(obj->cur->render_op);
2174 }
2175
2176 EAPI Evas_Render_Op
evas_object_render_op_get(const Evas_Object * eo_obj)2177 evas_object_render_op_get(const Evas_Object *eo_obj)
2178 {
2179 return _gfx_to_evas_render_op(efl_canvas_object_render_op_get(eo_obj));
2180 }
2181
2182 EOLIAN static void
_efl_canvas_object_efl_object_dbg_info_get(Eo * eo_obj,Evas_Object_Protected_Data * obj EINA_UNUSED,Efl_Dbg_Info * root)2183 _efl_canvas_object_efl_object_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED, Efl_Dbg_Info *root)
2184 {
2185 efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
2186 Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
2187 Efl_Dbg_Info *node;
2188 const char *name;
2189 double dblw, dblh;
2190 double dblx, dbly;
2191 double scale;
2192 unsigned int m;
2193 int r, g, b, a;
2194 //int requestw, requesth;
2195 Eina_Rect geom;
2196 Eina_Size2D max, min;
2197 short layer;
2198 Eina_Bool focus;
2199 Eina_Bool visible;
2200 Eina_Bool pass_event;
2201 Eina_Bool propagate_event;
2202 Eina_Bool repeat_event;
2203 Eina_Bool clipees_has;
2204 Eina_Bool fillx, filly;
2205
2206 visible = efl_gfx_entity_visible_get(eo_obj);
2207 layer = efl_gfx_stack_layer_get(eo_obj);
2208 name = efl_name_get(eo_obj); // evas_object_name_get(eo_obj);
2209 geom = efl_gfx_entity_geometry_get(eo_obj);
2210 scale = efl_gfx_entity_scale_get(eo_obj);
2211 min = efl_gfx_hint_size_restricted_min_get(eo_obj);
2212 max = efl_gfx_hint_size_max_get(eo_obj);
2213 //efl_gfx_hint_request_get(eo_obj, &requestw, &requesth);
2214 efl_gfx_hint_align_get(eo_obj, &dblx, &dbly);
2215 efl_gfx_hint_weight_get(eo_obj, &dblw, &dblh);
2216 efl_gfx_hint_fill_get(eo_obj, &fillx, &filly);
2217 efl_gfx_color_get(eo_obj, &r, &g, &b, &a);
2218 focus = evas_object_focus_get(eo_obj);
2219 m = efl_canvas_object_pointer_mode_get(eo_obj);
2220 pass_event = efl_canvas_object_pass_events_get(eo_obj);
2221 repeat_event = efl_canvas_object_repeat_events_get(eo_obj);
2222 propagate_event = efl_canvas_object_propagate_events_get(eo_obj);
2223 clipees_has = evas_object_clipees_has(eo_obj);
2224
2225 EFL_DBG_INFO_APPEND(group, "Visibility", EINA_VALUE_TYPE_CHAR, visible);
2226
2227 if (name)
2228 EFL_DBG_INFO_APPEND(group, "Name", EINA_VALUE_TYPE_STRING, name);
2229
2230 EFL_DBG_INFO_APPEND(group, "Layer", EINA_VALUE_TYPE_INT, layer);
2231
2232 node = EFL_DBG_INFO_LIST_APPEND(group, "Position");
2233 EFL_DBG_INFO_APPEND(node, "x", EINA_VALUE_TYPE_INT, geom.x);
2234 EFL_DBG_INFO_APPEND(node, "y", EINA_VALUE_TYPE_INT, geom.y);
2235
2236 node = EFL_DBG_INFO_LIST_APPEND(group, "Size");
2237 EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, geom.w);
2238 EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, geom.h);
2239
2240 EFL_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE, scale);
2241
2242 node = EFL_DBG_INFO_LIST_APPEND(group, "Min size");
2243 EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, min.w);
2244 EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, min.h);
2245
2246 node = EFL_DBG_INFO_LIST_APPEND(group, "Max size");
2247 EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, max.w);
2248 EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, max.h);
2249
2250 //node = EFL_DBG_INFO_LIST_APPEND(group, "Request size");
2251 //EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, requestw);
2252 //EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, requesth);
2253
2254 node = EFL_DBG_INFO_LIST_APPEND(group, "Align");
2255 EFL_DBG_INFO_APPEND(node, "x", EINA_VALUE_TYPE_DOUBLE, dblx);
2256 EFL_DBG_INFO_APPEND(node, "y", EINA_VALUE_TYPE_DOUBLE, dbly);
2257
2258 node = EFL_DBG_INFO_LIST_APPEND(group, "Fill");
2259 EFL_DBG_INFO_APPEND(node, "x", EINA_VALUE_TYPE_CHAR, fillx);
2260 EFL_DBG_INFO_APPEND(node, "y", EINA_VALUE_TYPE_CHAR, filly);
2261
2262 node = EFL_DBG_INFO_LIST_APPEND(group, "Weight");
2263 EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_DOUBLE, dblw);
2264 EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_DOUBLE, dblh);
2265
2266 node = EFL_DBG_INFO_LIST_APPEND(group, "Color");
2267 EFL_DBG_INFO_APPEND(node, "r", EINA_VALUE_TYPE_INT, r);
2268 EFL_DBG_INFO_APPEND(node, "g", EINA_VALUE_TYPE_INT, g);
2269 EFL_DBG_INFO_APPEND(node, "b", EINA_VALUE_TYPE_INT, b);
2270 EFL_DBG_INFO_APPEND(node, "a", EINA_VALUE_TYPE_INT, a);
2271
2272 EFL_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR, focus);
2273
2274 {
2275 const char *text = NULL;
2276 switch (m)
2277 {
2278 case EVAS_OBJECT_POINTER_MODE_AUTOGRAB:
2279 text = "EVAS_OBJECT_POINTER_MODE_AUTOGRAB";
2280 break;
2281 case EVAS_OBJECT_POINTER_MODE_NOGRAB:
2282 text = "EVAS_OBJECT_POINTER_MODE_NOGRAB";
2283 break;
2284 case EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN:
2285 text = "EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN";
2286 break;
2287 default:
2288 text = NULL;
2289 break;
2290 }
2291
2292 if (text)
2293 EFL_DBG_INFO_APPEND(group, "Pointer Mode", EINA_VALUE_TYPE_STRING, text);
2294 }
2295
2296 EFL_DBG_INFO_APPEND(group, "Pass Events", EINA_VALUE_TYPE_CHAR, pass_event);
2297 EFL_DBG_INFO_APPEND(group, "Repeat Events", EINA_VALUE_TYPE_CHAR, repeat_event);
2298 EFL_DBG_INFO_APPEND(group, "Propagate Events", EINA_VALUE_TYPE_CHAR, propagate_event);
2299 EFL_DBG_INFO_APPEND(group, "Has clipees", EINA_VALUE_TYPE_CHAR, clipees_has);
2300
2301 Evas_Object *clipper = NULL;
2302 clipper = efl_canvas_object_clipper_get(eo_obj);
2303 EFL_DBG_INFO_APPEND(group, "Clipper", EINA_VALUE_TYPE_UINT64, (uintptr_t) clipper);
2304
2305 const Evas_Map *map = evas_object_map_get(eo_obj);
2306 if (map)
2307 { /* Save map coords count info if object has map */
2308 node = EFL_DBG_INFO_LIST_APPEND(group, "Evas Map");
2309 int points_count = evas_map_count_get(map);
2310 Efl_Dbg_Info *points = EFL_DBG_INFO_LIST_APPEND(node, "Points");
2311 Efl_Dbg_Info *pointsuv = EFL_DBG_INFO_LIST_APPEND(node, "Image UV");
2312 for (int i = 0 ; i < points_count; i++)
2313 {
2314 {
2315 Evas_Coord px, py, pz;
2316 evas_map_point_coord_get(map, i, &px, &py, &pz);
2317 Efl_Dbg_Info *point = EFL_DBG_INFO_LIST_APPEND(points, "Points");
2318 EFL_DBG_INFO_APPEND(point, "x", EINA_VALUE_TYPE_INT, px);
2319 EFL_DBG_INFO_APPEND(point, "y", EINA_VALUE_TYPE_INT, py);
2320 EFL_DBG_INFO_APPEND(point, "z", EINA_VALUE_TYPE_INT, pz);
2321 }
2322
2323 {
2324 double pu, pv;
2325 evas_map_point_image_uv_get(map, i, &pu, &pv);
2326 Efl_Dbg_Info *point = EFL_DBG_INFO_LIST_APPEND(pointsuv, "Image UV");
2327 EFL_DBG_INFO_APPEND(point, "u", EINA_VALUE_TYPE_DOUBLE, pu);
2328 EFL_DBG_INFO_APPEND(point, "v", EINA_VALUE_TYPE_DOUBLE, pv);
2329 }
2330 }
2331 }
2332 }
2333
2334 EOLIAN static Eo *
_efl_canvas_object_efl_object_provider_find(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,const Efl_Class * klass)2335 _efl_canvas_object_efl_object_provider_find(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, const Efl_Class *klass)
2336 {
2337 if (klass == EVAS_CANVAS_CLASS)
2338 {
2339 if ((obj->delete_me) || (!obj->layer)) goto fallback;
2340 return obj->layer->evas->evas;
2341 }
2342 else if (klass == EFL_LOOP_CLASS)
2343 return efl_main_loop_get();
2344 fallback:
2345 return efl_provider_find(efl_super(eo_obj, MY_CLASS), klass);
2346 }
2347
2348 EOLIAN static Efl_Loop *
_efl_canvas_object_efl_loop_consumer_loop_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj EINA_UNUSED)2349 _efl_canvas_object_efl_loop_consumer_loop_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED)
2350 {
2351 return efl_main_loop_get();
2352 }
2353
2354 EOLIAN static void
_efl_canvas_object_type_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,const char * type)2355 _efl_canvas_object_type_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *type)
2356 {
2357 if (efl_finalized_get(eo_obj))
2358 {
2359 ERR("This function is only allowed during construction.");
2360 return;
2361 }
2362 obj->type = type; // Store it as the top type of this class
2363 }
2364
2365 EOLIAN static void
_efl_canvas_object_precise_is_inside_set(Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Eina_Bool precise)2366 _efl_canvas_object_precise_is_inside_set(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Eina_Bool precise)
2367 {
2368 evas_object_async_block(obj);
2369 obj->precise_is_inside = precise;
2370 }
2371
2372 EOLIAN static Eina_Bool
_efl_canvas_object_precise_is_inside_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2373 _efl_canvas_object_precise_is_inside_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2374 {
2375 return obj->precise_is_inside;
2376 }
2377
2378 EOLIAN static Eina_Bool
_efl_canvas_object_coords_inside_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj,Eina_Position2D pos)2379 _efl_canvas_object_coords_inside_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Eina_Position2D pos)
2380 {
2381 Eina_Rectangle c;
2382
2383 if (obj->is_smart)
2384 {
2385 Eina_Rectangle bounding_box = { 0, };
2386
2387 evas_object_smart_bounding_box_update(obj);
2388 evas_object_smart_bounding_box_get(obj, &bounding_box, NULL);
2389 c = bounding_box;
2390 }
2391 else
2392 {
2393 if (obj->clip.clipees) return EINA_FALSE;
2394 c = obj->cur->geometry;
2395 }
2396 return RECTS_INTERSECT(pos.x, pos.y, 1, 1, c.x, c.y, c.w, c.h);
2397 }
2398
2399 EOLIAN static Eina_Bool
_efl_canvas_object_efl_object_event_callback_priority_add(Eo * obj,Evas_Object_Protected_Data * pd,const Efl_Event_Description * desc,Efl_Callback_Priority priority,Efl_Event_Cb func,const void * user_data)2400 _efl_canvas_object_efl_object_event_callback_priority_add(Eo *obj, Evas_Object_Protected_Data *pd,
2401 const Efl_Event_Description *desc,
2402 Efl_Callback_Priority priority,
2403 Efl_Event_Cb func,
2404 const void *user_data)
2405 {
2406 Efl_Callback_Array_Item full[2] = {
2407 {desc, func},
2408 {NULL, NULL}
2409 };
2410
2411 if (efl_event_callback_priority_add(efl_super(obj, MY_CLASS), desc, priority, func, user_data))
2412 {
2413 evas_object_callbacks_event_catcher_add(obj, pd, full);
2414 return EINA_TRUE;
2415 }
2416 return EINA_FALSE;
2417 }
2418
2419 EOLIAN static Eina_Bool
_efl_canvas_object_efl_object_event_callback_del(Eo * obj,Evas_Object_Protected_Data * pd,const Efl_Event_Description * desc,Efl_Event_Cb func,const void * user_data)2420 _efl_canvas_object_efl_object_event_callback_del(Eo *obj, Evas_Object_Protected_Data *pd,
2421 const Efl_Event_Description *desc,
2422 Efl_Event_Cb func,
2423 const void *user_data)
2424 {
2425 Efl_Callback_Array_Item full[2] = {
2426 {desc, func},
2427 {NULL, NULL}
2428 };
2429
2430 if (efl_event_callback_del(efl_super(obj, MY_CLASS), desc, func, user_data))
2431 {
2432 evas_object_callbacks_event_catcher_del(obj, pd, full);
2433 return EINA_TRUE;
2434 }
2435 return EINA_FALSE;
2436 }
2437
2438 EOLIAN static Eina_Bool
_efl_canvas_object_efl_object_event_callback_array_priority_add(Eo * obj,Evas_Object_Protected_Data * pd,const Efl_Callback_Array_Item * array,Efl_Callback_Priority priority,const void * user_data)2439 _efl_canvas_object_efl_object_event_callback_array_priority_add(Eo *obj, Evas_Object_Protected_Data *pd,
2440 const Efl_Callback_Array_Item *array,
2441 Efl_Callback_Priority priority,
2442 const void *user_data)
2443 {
2444
2445 if (efl_event_callback_array_priority_add(efl_super(obj, MY_CLASS), array, priority, user_data))
2446 {
2447 evas_object_callbacks_event_catcher_add(obj, pd, array);
2448 return EINA_TRUE;
2449 }
2450 return EINA_FALSE;
2451 }
2452
2453 EOLIAN static Eina_Bool
_efl_canvas_object_efl_object_event_callback_array_del(Eo * obj,Evas_Object_Protected_Data * pd,const Efl_Callback_Array_Item * array,const void * user_data)2454 _efl_canvas_object_efl_object_event_callback_array_del(Eo *obj, Evas_Object_Protected_Data *pd,
2455 const Efl_Callback_Array_Item *array,
2456 const void *user_data)
2457 {
2458 if (efl_event_callback_array_del(efl_super(obj, MY_CLASS), array, user_data))
2459 {
2460 evas_object_callbacks_event_catcher_del(obj, pd, array);
2461 return EINA_TRUE;
2462 }
2463 return EINA_FALSE;
2464 }
2465
2466 static void
_is_frame_flag_set(Evas_Object_Protected_Data * obj,Eina_Bool is_frame)2467 _is_frame_flag_set(Evas_Object_Protected_Data *obj, Eina_Bool is_frame)
2468 {
2469 const Eina_Inlist *l;
2470 Evas_Object_Protected_Data *child;
2471
2472 /* Small hack here:
2473 * The main frame object (ie. the frame edje object itself) will set
2474 * a value of 2 here (Eina_Bool is an unsigned char). That way we can
2475 * safely propagate the frame flag inside smart_member_add. */
2476 if (is_frame > 1)
2477 {
2478 obj->is_frame_top = EINA_TRUE;
2479 is_frame = EINA_TRUE;
2480 }
2481
2482 obj->is_frame = is_frame;
2483
2484 if (!obj->is_smart) return;
2485 l = evas_object_smart_members_get_direct(obj->object);
2486
2487 EINA_INLIST_FOREACH(l, child)
2488 _is_frame_flag_set(child, is_frame);
2489 }
2490
2491 EOLIAN static void
_efl_canvas_object_is_frame_object_set(Eo * eo_obj,Evas_Object_Protected_Data * obj,Eina_Bool is_frame)2492 _efl_canvas_object_is_frame_object_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool is_frame)
2493 {
2494 Evas_Coord x, y;
2495
2496 evas_object_async_block(obj);
2497 evas_object_geometry_get(eo_obj, &x, &y, NULL, NULL);
2498
2499 _is_frame_flag_set(obj, is_frame);
2500
2501 evas_object_move(eo_obj, x, y);
2502 }
2503
2504 EOLIAN static Eina_Bool
_efl_canvas_object_is_frame_object_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2505 _efl_canvas_object_is_frame_object_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2506 {
2507 return obj->is_frame;
2508 }
2509
2510 EOLIAN static Evas_Object *
_efl_canvas_object_render_parent_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj)2511 _efl_canvas_object_render_parent_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
2512 {
2513 if (!obj) return NULL;
2514 return obj->smart.parent;
2515 }
2516
2517 EOLIAN static void
_efl_canvas_object_paragraph_direction_set(Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj EINA_UNUSED,Efl_Text_Bidirectional_Type dir EINA_UNUSED)2518 _efl_canvas_object_paragraph_direction_set(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED, Efl_Text_Bidirectional_Type dir EINA_UNUSED)
2519 {
2520 return;
2521 }
2522
2523 EOLIAN static Efl_Text_Bidirectional_Type
_efl_canvas_object_paragraph_direction_get(const Eo * eo_obj EINA_UNUSED,Evas_Object_Protected_Data * obj EINA_UNUSED)2524 _efl_canvas_object_paragraph_direction_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED)
2525 {
2526 return (Efl_Text_Bidirectional_Type)EVAS_BIDI_DIRECTION_NEUTRAL;
2527 }
2528
2529 EOLIAN static void
_efl_canvas_object_legacy_ctor(Eo * eo_obj,Evas_Object_Protected_Data * obj)2530 _efl_canvas_object_legacy_ctor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
2531 {
2532 EINA_SAFETY_ON_FALSE_RETURN(!efl_finalized_get(eo_obj));
2533 obj->legacy.ctor = EINA_TRUE;
2534 }
2535
2536 EAPI Eo *
evas_find(const Eo * obj)2537 evas_find(const Eo *obj)
2538 {
2539 if (efl_isa(obj, EVAS_CANVAS_CLASS))
2540 return (Eo*) obj;
2541 if (efl_isa(obj, EFL_CANVAS_OBJECT_CLASS))
2542 return evas_object_evas_get(obj);
2543 return efl_provider_find(obj, EVAS_CANVAS_CLASS);
2544 }
2545
2546 void
_efl_canvas_object_event_animation_cancel(Eo * eo_obj)2547 _efl_canvas_object_event_animation_cancel(Eo *eo_obj)
2548 {
2549 Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
2550
2551 if (obj)
2552 efl_player_playing_set(obj->anim_player, EINA_FALSE);
2553 }
2554
2555 /* legacy */
2556
2557 EAPI const char *
evas_object_type_get(const Evas_Object * eo_obj)2558 evas_object_type_get(const Evas_Object *eo_obj)
2559 {
2560 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, NULL);
2561 if (obj->delete_me) return "";
2562 return obj->type;
2563 }
2564
2565 EAPI void
evas_object_static_clip_set(Evas_Object * eo_obj,Eina_Bool is_static_clip)2566 evas_object_static_clip_set(Evas_Object *eo_obj, Eina_Bool is_static_clip)
2567 {
2568 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj);
2569 evas_object_async_block(obj);
2570 obj->is_static_clip = is_static_clip;
2571 }
2572
2573 EAPI Eina_Bool
evas_object_static_clip_get(const Evas_Object * eo_obj)2574 evas_object_static_clip_get(const Evas_Object *eo_obj)
2575 {
2576 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, EINA_FALSE);
2577 return obj->is_static_clip;
2578 }
2579
2580 EAPI void
evas_object_size_hint_aspect_set(Evas_Object * obj,Evas_Aspect_Control aspect,Evas_Coord w,Evas_Coord h)2581 evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h)
2582 {
2583 efl_gfx_hint_aspect_set(obj, (Efl_Gfx_Hint_Aspect)aspect, EINA_SIZE2D(w, h));
2584 }
2585
2586 EAPI void
evas_object_size_hint_aspect_get(const Evas_Object * obj,Evas_Aspect_Control * aspect,Evas_Coord * w,Evas_Coord * h)2587 evas_object_size_hint_aspect_get(const Evas_Object *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h)
2588 {
2589 Eina_Size2D sz = { 0, 0 };
2590 efl_gfx_hint_aspect_get(obj, (Efl_Gfx_Hint_Aspect *)aspect, &sz);
2591 if (w) *w = sz.w;
2592 if (h) *h = sz.h;
2593 }
2594
2595 EAPI void
evas_object_size_hint_max_set(Evas_Object * obj,Evas_Coord w,Evas_Coord h)2596 evas_object_size_hint_max_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2597 {
2598 efl_gfx_hint_size_max_set(obj, EINA_SIZE2D(w, h));
2599 }
2600
2601 EAPI void
evas_object_size_hint_max_get(const Evas_Object * obj,Evas_Coord * w,Evas_Coord * h)2602 evas_object_size_hint_max_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2603 {
2604 Eina_Size2D sz;
2605 sz = efl_gfx_hint_size_max_get(obj);
2606 if (w) *w = sz.w;
2607 if (h) *h = sz.h;
2608 }
2609
2610 EAPI void
evas_object_size_hint_min_set(Evas_Object * obj,Evas_Coord w,Evas_Coord h)2611 evas_object_size_hint_min_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2612 {
2613 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(w, h));
2614 }
2615
2616 EAPI void
evas_object_size_hint_min_get(const Evas_Object * obj,Evas_Coord * w,Evas_Coord * h)2617 evas_object_size_hint_min_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2618 {
2619 Eina_Size2D sz;
2620 sz = efl_gfx_hint_size_restricted_min_get(obj);
2621 if (w) *w = sz.w;
2622 if (h) *h = sz.h;
2623 }
2624
2625 EAPI void
evas_object_size_hint_padding_set(Evas_Object * obj,Evas_Coord l,Evas_Coord r,Evas_Coord t,Evas_Coord b)2626 evas_object_size_hint_padding_set(Evas_Object *obj, Evas_Coord l, Evas_Coord r, Evas_Coord t, Evas_Coord b)
2627 {
2628 efl_gfx_hint_margin_set(obj, l, r, t, b);
2629 }
2630
2631 EAPI void
evas_object_size_hint_padding_get(const Evas_Object * obj,Evas_Coord * l,Evas_Coord * r,Evas_Coord * t,Evas_Coord * b)2632 evas_object_size_hint_padding_get(const Evas_Object *obj, Evas_Coord *l, Evas_Coord *r, Evas_Coord *t, Evas_Coord *b)
2633 {
2634 efl_gfx_hint_margin_get(obj, l, r, t, b);
2635 }
2636
2637 EAPI void
evas_object_size_hint_weight_set(Evas_Object * obj,double x,double y)2638 evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
2639 {
2640 efl_gfx_hint_weight_set(obj, x, y);
2641 }
2642
2643 EAPI void
evas_object_size_hint_weight_get(const Evas_Object * obj,double * x,double * y)2644 evas_object_size_hint_weight_get(const Evas_Object *obj, double *x, double *y)
2645 {
2646 efl_gfx_hint_weight_get(obj, x, y);
2647 }
2648
2649 EAPI void
evas_object_size_hint_align_set(Evas_Object * obj,double x,double y)2650 evas_object_size_hint_align_set(Evas_Object *obj, double x, double y)
2651 {
2652 efl_gfx_hint_align_set(obj, x, y);
2653 }
2654
2655 EAPI void
evas_object_size_hint_align_get(const Evas_Object * obj,double * x,double * y)2656 evas_object_size_hint_align_get(const Evas_Object *obj, double *x, double *y)
2657 {
2658 efl_gfx_hint_align_get(obj, x, y);
2659 }
2660
2661 EAPI Evas *
evas_object_evas_get(const Eo * eo_obj)2662 evas_object_evas_get(const Eo *eo_obj)
2663 {
2664 if (efl_isa(eo_obj, EFL_CANVAS_OBJECT_CLASS))
2665 {
2666 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, NULL);
2667
2668 if (!obj->layer || !obj->layer->evas) return NULL;
2669 return obj->layer->evas->evas;
2670 }
2671 return efl_provider_find((Eo *) eo_obj, EVAS_CANVAS_CLASS);
2672 }
2673
2674 EAPI void
evas_object_scale_set(Evas_Object * obj,double scale)2675 evas_object_scale_set(Evas_Object *obj, double scale)
2676 {
2677 efl_gfx_entity_scale_set(obj, scale);
2678 }
2679
2680 EAPI double
evas_object_scale_get(const Evas_Object * obj)2681 evas_object_scale_get(const Evas_Object *obj)
2682 {
2683 return efl_gfx_entity_scale_get(obj);
2684 }
2685
2686 EAPI Eina_Bool
evas_object_pointer_inside_by_device_get(const Evas_Object * eo_obj,Efl_Input_Device * dev)2687 evas_object_pointer_inside_by_device_get(const Evas_Object *eo_obj, Efl_Input_Device *dev)
2688 {
2689 Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, EINA_FALSE);
2690
2691 obj->is_pointer_inside_legacy = EINA_TRUE;
2692 return efl_canvas_pointer_inside_get(eo_obj, dev);
2693 }
2694
2695 EAPI Eina_Bool
evas_object_pointer_coords_inside_get(const Evas_Object * eo_obj,int x,int y)2696 evas_object_pointer_coords_inside_get(const Evas_Object *eo_obj, int x, int y)
2697 {
2698 Eina_Position2D pos = EINA_POSITION2D(x, y);
2699
2700 return efl_canvas_object_coords_inside_get(eo_obj, pos);
2701 }
2702
2703 EAPI Eina_Bool
evas_object_pointer_inside_get(const Evas_Object * eo_obj)2704 evas_object_pointer_inside_get(const Evas_Object *eo_obj)
2705 {
2706 return evas_object_pointer_inside_by_device_get(eo_obj, NULL);
2707 }
2708
2709 EAPI void
evas_object_is_frame_object_set(Efl_Canvas_Object * obj,Eina_Bool is_frame)2710 evas_object_is_frame_object_set(Efl_Canvas_Object *obj, Eina_Bool is_frame)
2711 {
2712 efl_canvas_object_is_frame_object_set(obj, is_frame);
2713 }
2714
2715 EAPI Eina_Bool
evas_object_is_frame_object_get(const Efl_Canvas_Object * obj)2716 evas_object_is_frame_object_get(const Efl_Canvas_Object *obj)
2717 {
2718 return efl_canvas_object_is_frame_object_get(obj);
2719 }
2720
2721
2722 /* Internal EO APIs and hidden overrides */
2723
2724 EOAPI EFL_VOID_FUNC_BODYV(efl_canvas_object_is_frame_object_set, EFL_FUNC_CALL(is_frame), Eina_Bool is_frame);
2725 EOAPI EFL_FUNC_BODY_CONST(efl_canvas_object_is_frame_object_get, Eina_Bool, 0);
2726 EOAPI EFL_VOID_FUNC_BODY(efl_canvas_object_legacy_ctor)
2727 EOAPI EFL_VOID_FUNC_BODYV(efl_canvas_object_type_set, EFL_FUNC_CALL(type), const char *type)
2728
2729 #define EFL_CANVAS_OBJECT_EXTRA_OPS \
2730 EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _efl_canvas_object_efl_object_dbg_info_get), \
2731 EFL_OBJECT_OP_FUNC(efl_canvas_object_is_frame_object_set, _efl_canvas_object_is_frame_object_set), \
2732 EFL_OBJECT_OP_FUNC(efl_canvas_object_is_frame_object_get, _efl_canvas_object_is_frame_object_get), \
2733 EFL_OBJECT_OP_FUNC(efl_canvas_object_legacy_ctor, _efl_canvas_object_legacy_ctor), \
2734 EFL_OBJECT_OP_FUNC(efl_canvas_object_type_set, _efl_canvas_object_type_set), \
2735 EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, _efl_canvas_object_efl_object_event_callback_priority_add), \
2736 EFL_OBJECT_OP_FUNC(efl_event_callback_array_priority_add, _efl_canvas_object_efl_object_event_callback_array_priority_add), \
2737 EFL_OBJECT_OP_FUNC(efl_event_callback_del, _efl_canvas_object_efl_object_event_callback_del), \
2738 EFL_OBJECT_OP_FUNC(efl_event_callback_array_del, _efl_canvas_object_efl_object_event_callback_array_del)
2739
2740 #include "canvas/efl_canvas_object.eo.c"
2741 #include "canvas/efl_canvas_object_eo.legacy.c"
2742