1 #include "evas_common_private.h"
2 #include "evas_image_private.h"
3 #include "evas_private.h"
4 
5 /* BEGIN: events to maintain compatibility with legacy */
6 EWAPI const Efl_Event_Description _EFL_GFX_ENTITY_EVENT_SHOW =
7    EFL_EVENT_DESCRIPTION("show");
8 EWAPI const Efl_Event_Description _EFL_GFX_ENTITY_EVENT_HIDE =
9    EFL_EVENT_DESCRIPTION("hide");
10 EWAPI const Efl_Event_Description _EFL_GFX_ENTITY_EVENT_IMAGE_PRELOAD =
11    EFL_EVENT_DESCRIPTION("preload");
12 EWAPI const Efl_Event_Description _EFL_GFX_ENTITY_EVENT_IMAGE_UNLOAD =
13    EFL_EVENT_DESCRIPTION("unload");
14 /* END: events to maintain compatibility with legacy */
15 
16 /* local calls */
17 
18 void
evas_object_inform_call_show(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)19 evas_object_inform_call_show(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
20 {
21    int event_id = _evas_object_event_new();
22    Eina_Bool vis = EINA_TRUE;
23 
24    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_SHOW, &vis, event_id, EFL_GFX_ENTITY_EVENT_SHOW);
25    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
26 }
27 
28 void
evas_object_inform_call_hide(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)29 evas_object_inform_call_hide(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
30 {
31    int event_id = _evas_object_event_new();
32    Eina_Bool vis = EINA_FALSE;
33 
34    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_HIDE, &vis, event_id, EFL_GFX_ENTITY_EVENT_HIDE);
35    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
36 }
37 
38 void
evas_object_inform_call_move(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)39 evas_object_inform_call_move(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
40 {
41    Eina_Position2D pos;
42    int event_id = _evas_object_event_new();
43 
44    pos = ((Eina_Rect) obj->cur->geometry).pos;
45 
46    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOVE, &pos, event_id, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED);
47    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
48 }
49 
50 void
evas_object_inform_call_resize(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)51 evas_object_inform_call_resize(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
52 {
53    Eina_Size2D size;
54    int event_id = _evas_object_event_new();
55 
56    size = ((Eina_Rect) obj->cur->geometry).size;
57 
58    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_RESIZE, &size, event_id, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED);
59    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
60 }
61 
62 void
evas_object_inform_call_restack(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)63 evas_object_inform_call_restack(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
64 {
65    int event_id = _evas_object_event_new();
66 
67    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_RESTACK, NULL, event_id, EFL_GFX_ENTITY_EVENT_STACKING_CHANGED);
68    if (obj->layer)
69      _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
70 }
71 
72 void
evas_object_inform_call_changed_size_hints(Evas_Object * eo_obj,Evas_Object_Protected_Data * obj)73 evas_object_inform_call_changed_size_hints(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
74 {
75    int event_id = _evas_object_event_new();
76 
77    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, NULL, event_id, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED);
78    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
79 }
80 
81 void
evas_object_inform_call_image_preloaded(Evas_Object * eo_obj)82 evas_object_inform_call_image_preloaded(Evas_Object *eo_obj)
83 {
84    Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
85    int event_id;
86 
87    EINA_SAFETY_ON_NULL_RETURN(obj);
88 
89    unsigned char preload = _evas_object_image_preloading_get(eo_obj);
90 
91    //Even cancelled, obj needs to draw image.
92    _evas_image_load_post_update(eo_obj, obj);
93 
94    if ((preload & EVAS_IMAGE_PRELOADING) ||
95      /* Boom! This cancellation call stack is in the intermediate render sequence. Need better idea.
96           So far, this cancellation is triggered by other non-preload image instances,
97           which doesn't require preloading. So by mechasnim we cancel preload other instances as well.
98           and mimic as it finished preloading done. */
99        (preload & EVAS_IMAGE_PRELOAD_CANCEL))
100      {
101         Eina_Bool val = EINA_TRUE;
102         event_id = _evas_object_event_new();
103         evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_IMAGE_PRELOADED, &val, event_id, EFL_GFX_IMAGE_EVENT_IMAGE_PRELOAD);
104         _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
105      }
106 }
107 
108 void
evas_object_inform_call_image_unloaded(Evas_Object * eo_obj)109 evas_object_inform_call_image_unloaded(Evas_Object *eo_obj)
110 {
111    Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
112    int event_id = _evas_object_event_new();
113    Eina_Bool val = EINA_FALSE;
114 
115    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_IMAGE_UNLOADED, &val, event_id, EFL_GFX_IMAGE_EVENT_IMAGE_UNLOAD);
116    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
117 }
118 
119 void
evas_object_inform_call_image_resize(Evas_Object * eo_obj)120 evas_object_inform_call_image_resize(Evas_Object *eo_obj)
121 {
122    Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
123    int event_id = _evas_object_event_new();
124    Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
125    Eina_Size2D sz = EINA_SIZE2D(o->file_size.w, o->file_size.h);
126 
127    evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_IMAGE_RESIZE, &sz, event_id, EFL_GFX_IMAGE_EVENT_IMAGE_RESIZED);
128    _evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas, event_id);
129 }
130