1 #include <Elementary.h>
3 #include "elm_widget_mapbuf.h"
5 EAPI const char ELM_MAPBUF_SMART_NAME[] = "elm_mapbuf";
7 EVAS_SMART_SUBCLASS_NEW
8 (ELM_MAPBUF_SMART_NAME, _elm_mapbuf, Elm_Mapbuf_Smart_Class,
9 Elm_Container_Smart_Class, elm_container_smart_class_get, NULL);
12 _sizing_eval(Evas_Object *obj)
14 Evas_Coord minw = -1, minh = -1;
15 Evas_Coord maxw = -1, maxh = -1;
17 ELM_MAPBUF_DATA_GET(obj, sd);
20 evas_object_size_hint_min_get(sd->content, &minw, &minh);
21 evas_object_size_hint_max_get(sd->content, &maxw, &maxh);
23 evas_object_size_hint_min_set(obj, minw, minh);
24 evas_object_size_hint_max_set(obj, maxw, maxh);
28 _elm_mapbuf_smart_theme(Evas_Object *obj)
30 if (!ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->theme(obj)) return EINA_FALSE;
38 _changed_size_hints_cb(void *data,
40 Evas_Object *obj __UNUSED__,
41 void *event_info __UNUSED__)
47 _elm_mapbuf_smart_sub_object_del(Evas_Object *obj,
50 ELM_MAPBUF_DATA_GET(obj, sd);
52 if (!ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->sub_object_del(obj, sobj))
55 if (sobj == sd->content)
57 evas_object_data_del(sobj, "_elm_leaveme");
58 evas_object_smart_member_del(sobj);
59 evas_object_clip_unset(sobj);
60 evas_object_event_callback_del_full
61 (sobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints_cb,
71 _mapbuf(Evas_Object *obj)
73 Evas_Coord x, y, w, h;
75 ELM_MAPBUF_DATA_GET(obj, sd);
77 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->resize_obj, &x, &y, &w, &h);
78 evas_object_resize(sd->content, w, h);
85 evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0);
86 evas_map_smooth_set(m, sd->smooth);
87 evas_map_alpha_set(m, sd->alpha);
88 evas_object_map_set(sd->content, m);
89 evas_object_map_enable_set(sd->content, EINA_TRUE);
94 evas_object_map_set(sd->content, NULL);
95 evas_object_map_enable_set(sd->content, EINA_FALSE);
96 evas_object_move(sd->content, x, y);
101 _configure(Evas_Object *obj, Eina_Bool update_force)
103 ELM_MAPBUF_DATA_GET(obj, sd);
105 if (!sd->content) return;
106 Evas_Coord x, y, w, h, x2, y2, w2, h2;
107 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->resize_obj, &x, &y, &w, &h);
108 evas_object_geometry_get(sd->content, &x2, &y2, &w2, &h2);
109 if ((update_force) || ((x != x2) || (y != y2) || (w != w2) || (h != h2)))
112 evas_object_move(sd->content, x, y);
115 Evas *e = evas_object_evas_get(obj);
116 evas_smart_objects_calculate(e);
117 ELM_WIDGET_CHECK_OR_RETURN(obj);
118 evas_nochange_push(e);
119 evas_object_move(sd->content, x, y);
120 evas_smart_objects_calculate(e);
121 ELM_WIDGET_CHECK_OR_RETURN(obj);
122 evas_nochange_pop(e);
129 _elm_mapbuf_smart_move(Evas_Object *obj,
133 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.move(obj, x, y);
135 _configure(obj, EINA_FALSE);
139 _elm_mapbuf_smart_resize(Evas_Object *obj,
143 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.resize(obj, x, y);
145 _configure(obj, EINA_FALSE);
149 _elm_mapbuf_smart_content_set(Evas_Object *obj,
151 Evas_Object *content)
153 ELM_MAPBUF_DATA_GET(obj, sd);
155 if (part && strcmp(part, "default")) return EINA_FALSE;
156 if (sd->content == content) return EINA_TRUE;
158 if (sd->content) evas_object_del(sd->content);
159 sd->content = content;
163 evas_object_data_set(content, "_elm_leaveme", (void *)1);
164 elm_widget_sub_object_add(obj, content);
165 evas_object_smart_member_add(content, obj);
166 evas_object_clip_set(content, ELM_WIDGET_DATA(sd)->resize_obj);
167 evas_object_color_set
168 (ELM_WIDGET_DATA(sd)->resize_obj, 255, 255, 255, 255);
169 evas_object_event_callback_add
170 (content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
171 _changed_size_hints_cb, obj);
174 evas_object_color_set(ELM_WIDGET_DATA(sd)->resize_obj, 0, 0, 0, 0);
177 _configure(obj, EINA_TRUE);
183 _elm_mapbuf_smart_content_get(const Evas_Object *obj,
186 ELM_MAPBUF_DATA_GET(obj, sd);
188 if (part && strcmp(part, "default")) return NULL;
193 _elm_mapbuf_smart_content_unset(Evas_Object *obj,
196 Evas_Object *content;
198 ELM_MAPBUF_DATA_GET(obj, sd);
200 if (part && strcmp(part, "default")) return NULL;
201 if (!sd->content) return NULL;
203 content = sd->content;
204 elm_widget_sub_object_del(obj, content);
205 evas_object_smart_member_del(content);
206 evas_object_data_del(content, "_elm_leaveme");
207 evas_object_color_set(ELM_WIDGET_DATA(sd)->resize_obj, 0, 0, 0, 0);
212 _elm_mapbuf_smart_add(Evas_Object *obj)
214 EVAS_SMART_DATA_ALLOC(obj, Elm_Mapbuf_Smart_Data);
216 ELM_WIDGET_DATA(priv)->resize_obj =
217 evas_object_rectangle_add(evas_object_evas_get(obj));
219 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.add(obj);
221 evas_object_static_clip_set(ELM_WIDGET_DATA(priv)->resize_obj, EINA_TRUE);
222 evas_object_pass_events_set(ELM_WIDGET_DATA(priv)->resize_obj, EINA_TRUE);
223 evas_object_color_set(ELM_WIDGET_DATA(priv)->resize_obj, 0, 0, 0, 0);
229 elm_widget_can_focus_set(obj, EINA_FALSE);
235 _elm_mapbuf_smart_set_user(Elm_Mapbuf_Smart_Class *sc)
237 ELM_WIDGET_CLASS(sc)->base.add = _elm_mapbuf_smart_add;
238 ELM_WIDGET_CLASS(sc)->base.resize = _elm_mapbuf_smart_resize;
239 ELM_WIDGET_CLASS(sc)->base.move = _elm_mapbuf_smart_move;
241 ELM_WIDGET_CLASS(sc)->theme = _elm_mapbuf_smart_theme;
242 ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_mapbuf_smart_sub_object_del;
244 ELM_CONTAINER_CLASS(sc)->content_set = _elm_mapbuf_smart_content_set;
245 ELM_CONTAINER_CLASS(sc)->content_get = _elm_mapbuf_smart_content_get;
246 ELM_CONTAINER_CLASS(sc)->content_unset = _elm_mapbuf_smart_content_unset;
249 EAPI const Elm_Mapbuf_Smart_Class *
250 elm_mapbuf_smart_class_get(void)
252 static Elm_Mapbuf_Smart_Class _sc =
253 ELM_MAPBUF_SMART_CLASS_INIT_NAME_VERSION(ELM_MAPBUF_SMART_NAME);
254 static const Elm_Mapbuf_Smart_Class *class = NULL;
256 if (class) return class;
258 _elm_mapbuf_smart_set(&_sc);
265 elm_mapbuf_add(Evas_Object *parent)
269 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
271 obj = elm_widget_add(_elm_mapbuf_smart_class_new(), parent);
272 if (!obj) return NULL;
274 if (!elm_widget_sub_object_add(parent, obj))
275 ERR("could not add %p as sub object of %p", obj, parent);
281 elm_mapbuf_enabled_set(Evas_Object *obj,
284 ELM_MAPBUF_CHECK(obj);
285 ELM_MAPBUF_DATA_GET(obj, sd);
287 if (sd->enabled == enabled) return;
288 sd->enabled = enabled;
290 if (sd->content) evas_object_static_clip_set(sd->content, sd->enabled);
291 _configure(obj, EINA_TRUE);
295 elm_mapbuf_enabled_get(const Evas_Object *obj)
297 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
298 ELM_MAPBUF_DATA_GET(obj, sd);
304 elm_mapbuf_smooth_set(Evas_Object *obj,
307 ELM_MAPBUF_CHECK(obj);
308 ELM_MAPBUF_DATA_GET(obj, sd);
310 if (sd->smooth == smooth) return;
312 _configure(obj, EINA_TRUE);
316 elm_mapbuf_smooth_get(const Evas_Object *obj)
318 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
319 ELM_MAPBUF_DATA_GET(obj, sd);
325 elm_mapbuf_alpha_set(Evas_Object *obj,
328 ELM_MAPBUF_CHECK(obj);
329 ELM_MAPBUF_DATA_GET(obj, sd);
331 if (sd->alpha == alpha) return;
333 _configure(obj, EINA_TRUE);
337 elm_mapbuf_alpha_get(const Evas_Object *obj)
339 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
340 ELM_MAPBUF_DATA_GET(obj, sd);