1 #include <Elementary.h>
4 // FIXME: handle if canvas resizes
6 typedef struct _Widget_Data Widget_Data;
13 Evas_Coord maxminw, maxminh;
19 static const char *widtype = NULL;
20 static void _del_hook(Evas_Object *obj);
21 static Eina_Bool _focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next);
22 static void _sizing_eval(Evas_Object *obj);
23 static void _eval(Evas_Object *obj);
24 static void _changed(Evas_Object *obj);
25 static void _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
26 static void _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
27 static void _child_change(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
28 static void _child_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
29 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
30 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
33 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
34 >>>>>>> remotes/origin/upstream
36 static const char SIG_REALIZE[] = "realize";
37 static const char SIG_UNREALIZE[] = "unrealize";
39 static const Evas_Smart_Cb_Description _signals[] = {
48 _del_hook(Evas_Object *obj)
50 Widget_Data *wd = elm_widget_data_get(obj);
54 Evas_Object *o = wd->content;
56 evas_object_event_callback_del_full(o,
57 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
59 evas_object_event_callback_del_full(o,
65 // printf("FAC-- = %i\n", fac);
71 _focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
73 Widget_Data *wd = elm_widget_data_get(obj);
76 if ((!wd) || (!wd->content)) return EINA_FALSE;
78 return elm_widget_focus_next_get(cur, dir, next);
82 _sizing_eval(Evas_Object *obj)
84 Widget_Data *wd = elm_widget_data_get(obj);
85 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
88 if (!wd->content) return;
89 evas_object_size_hint_min_get(wd->content, &minw, &minh);
90 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
93 if (minw > wd->maxminw) wd->maxminw = minw;
94 if (minh > wd->maxminh) wd->maxminh = minh;
95 evas_object_size_hint_min_set(obj, wd->maxminw, wd->maxminh);
99 evas_object_size_hint_min_set(obj, minw, minh);
101 evas_object_size_hint_max_set(obj, maxw, maxh);
102 // printf("FAC SZ: %i %i | %i %i\n", minw, minh, maxw, maxh);
106 _eval(Evas_Object *obj)
108 Evas_Coord x, y, w, h, cvx, cvy, cvw, cvh;
109 Widget_Data *wd = elm_widget_data_get(obj);
112 evas_event_freeze(evas_object_evas_get(obj));
113 evas_object_geometry_get(obj, &x, &y, &w, &h);
116 evas_output_viewport_get(evas_object_evas_get(obj),
117 &cvx, &cvy, &cvw, &cvh);
118 if ((cvw < 1) || (cvh < 1)) return;
119 // need some fuzz value thats beyond the current viewport
120 // for now just make it the viewport * 3 in size (so 1 vp in each direction)
127 if (ELM_RECTS_INTERSECT(x, y, w, h, cvx, cvy, cvw, cvh))
131 // printf(" + %i %i %ix%i <> %i %i %ix%i\n", x, y, w, h, cvx, cvy, cvw, cvh);
132 evas_object_smart_callback_call(obj, SIG_REALIZE, NULL);
135 if (evas_object_smart_data_get(wd->content))
136 evas_object_smart_calculate(wd->content);
139 //wd->last_calc_count =
140 //evas_smart_objects_calculate_count_get(evas_object_evas_get(obj));
142 wd->last_calc_count =
143 evas_smart_objects_calculate_count_get(evas_object_evas_get(obj));
144 >>>>>>> remotes/origin/upstream
152 //if (wd->last_calc_count !=
153 //evas_smart_objects_calculate_count_get(evas_object_evas_get(obj)))
155 if (wd->last_calc_count !=
156 evas_smart_objects_calculate_count_get(evas_object_evas_get(obj)))
157 >>>>>>> remotes/origin/upstream
158 evas_object_smart_callback_call(obj, SIG_UNREALIZE, NULL);
161 evas_event_thaw(evas_object_evas_get(obj));
162 evas_event_thaw_eval(evas_object_evas_get(obj));
166 _changed(Evas_Object *obj)
168 Widget_Data *wd = elm_widget_data_get(obj);
173 wd->eval = EINA_FALSE;
178 wd->szeval = EINA_FALSE;
183 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
185 Widget_Data *wd = elm_widget_data_get(obj);
187 wd->eval = EINA_TRUE;
188 evas_object_smart_changed(obj);
192 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
194 Widget_Data *wd = elm_widget_data_get(obj);
196 wd->eval = EINA_TRUE;
197 evas_object_smart_changed(obj);
201 _child_change(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
203 Widget_Data *wd = elm_widget_data_get(data);
205 wd->eval = EINA_TRUE;
206 wd->szeval = EINA_TRUE;
207 evas_object_smart_changed(data);
211 _child_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
213 Evas_Object *fobj = data;
214 Widget_Data *wd = elm_widget_data_get(fobj);
216 if (wd->content != obj) return;
217 evas_object_event_callback_del_full(wd->content,
218 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
220 evas_object_event_callback_del_full(wd->content,
225 // printf("FAC-- = %i\n", fac);
231 _content_unset_hook(Evas_Object *obj, const char *part)
233 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
235 Evas_Object *content;
237 if (part && strcmp(part, "default")) return NULL;
238 wd = elm_widget_data_get(obj);
239 if (!wd || !wd->content) return NULL;
241 content = wd->content;
242 evas_object_event_callback_del_full(content,
243 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
245 evas_object_event_callback_del_full(content,
250 // printf("FAC-- = %i\n", fac);
254 >>>>>>> remotes/origin/upstream
256 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
258 ELM_CHECK_WIDTYPE(obj, widtype);
262 Evas_Object *prev_content;
263 >>>>>>> remotes/origin/upstream
265 if (part && strcmp(part, "default")) return;
266 wd = elm_widget_data_get(obj);
268 if (wd->content == content) return;
272 Evas_Object *o = wd->content;
274 evas_object_event_callback_del_full(wd->content,
275 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
277 evas_object_event_callback_del_full(wd->content,
283 // printf("FAC-- = %i\n", fac);
285 wd->content = content;
289 // printf("FAC++ = %i\n", fac);
290 elm_widget_resize_object_set(obj, wd->content);
291 evas_object_event_callback_add(wd->content, EVAS_CALLBACK_DEL,
293 evas_object_event_callback_add(wd->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
295 wd->eval = EINA_TRUE;
296 wd->szeval = EINA_TRUE;
297 evas_object_smart_changed(obj);
301 prev_content = _content_unset_hook(obj, part);
302 if (prev_content) evas_object_del(prev_content);
304 wd->content = content;
305 if (!content) return;
307 elm_widget_resize_object_set(obj, content);
308 evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, _child_del, obj);
309 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
311 wd->eval = EINA_TRUE;
312 wd->szeval = EINA_TRUE;
313 evas_object_smart_changed(obj);
315 >>>>>>> remotes/origin/upstream
319 _content_get_hook(const Evas_Object *obj, const char *part)
321 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
323 if (part && strcmp(part, "default")) return NULL;
324 wd = elm_widget_data_get(obj);
325 if (!wd) return NULL;
330 elm_factory_add(Evas_Object *parent)
336 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
338 ELM_SET_WIDTYPE(widtype, "factory");
339 elm_widget_type_set(obj, "factory");
340 elm_widget_sub_object_add(parent, obj);
341 elm_widget_data_set(obj, wd);
342 elm_widget_del_hook_set(obj, _del_hook);
343 elm_widget_focus_next_hook_set(obj, _focus_next_hook);
344 elm_widget_content_set_hook_set(obj, _content_set_hook);
345 elm_widget_content_get_hook_set(obj, _content_get_hook);
348 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
349 >>>>>>> remotes/origin/upstream
350 elm_widget_can_focus_set(obj, EINA_FALSE);
351 elm_widget_changed_hook_set(obj, _changed);
353 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
354 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
356 evas_object_smart_callbacks_descriptions_set(obj, _signals);
359 wd->last_calc_count = -1;
365 elm_factory_content_set(Evas_Object *obj, Evas_Object *content)
367 _content_set_hook(obj, NULL, content);
371 elm_factory_content_get(const Evas_Object *obj)
373 return _content_get_hook(obj, NULL);
378 >>>>>>> remotes/origin/upstream
379 elm_factory_maxmin_mode_set(Evas_Object *obj, Eina_Bool enabled)
381 ELM_CHECK_WIDTYPE(obj, widtype);
382 Widget_Data *wd = elm_widget_data_get(obj);
384 wd->maxmin = !!enabled;
388 elm_factory_maxmin_mode_get(const Evas_Object *obj)
390 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
391 Widget_Data *wd = elm_widget_data_get(obj);
392 if (!wd) return EINA_FALSE;
397 elm_factory_maxmin_reset_set(Evas_Object *obj)
399 ELM_CHECK_WIDTYPE(obj, widtype);
400 Widget_Data *wd = elm_widget_data_get(obj);
404 wd->eval = EINA_TRUE;
405 wd->szeval = EINA_TRUE;
406 evas_object_smart_changed(obj);