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 Eina_Bool inside_all = EINA_FALSE;
107 Evas_Coord x, y, w, h, x2, y2, w2, h2, vx, vy, vw, vh;
108 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->resize_obj, &x, &y, &w, &h);
109 evas_object_geometry_get(sd->content, &x2, &y2, &w2, &h2);
111 if ((update_force) || ((x != x2) || (y != y2) || (w != w2) || (h != h2)))
113 Evas *e = evas_object_evas_get(obj);
114 evas_output_viewport_get(e, &vx, &vy, &vw, &vh);
116 /* Apply no changes once the content is rendered fully one time. We
117 aren't sure that the content is updated correctly if the content was
118 outside of the viewport, especially it has many child members. Some
119 type of children will do the lazy updated (ie, textblock) on right
120 before the rendering. It means they lose the update time cause
121 of the mapbuf since the mapbuf tries nochange forcefully. */
122 if (!sd->inside_view[0] && ((x >= vx) && (x <= (vx + vw))))
123 sd->inside_view[0] = EINA_TRUE;
124 if (!sd->inside_view[1] && ((y >= vy) && (y <= (vy + vh))))
125 sd->inside_view[1] = EINA_TRUE;
127 if (!sd->inside_view[2] && (((x + w) >= vx) && ((x + w) <= (vx + vw))))
128 sd->inside_view[2] = EINA_TRUE;
130 if (!sd->inside_view[3] && (((y + h) >= vy) && ((y + h) <= (vy + vh))))
131 sd->inside_view[3] = EINA_TRUE;
133 if (sd->inside_view[0] && sd->inside_view[1] && sd->inside_view[2] &&
135 inside_all = EINA_TRUE;
137 if (!sd->enabled || !inside_all)
138 evas_object_move(sd->content, x, y);
141 evas_smart_objects_calculate(e);
142 ELM_WIDGET_CHECK_OR_RETURN(obj);
143 evas_nochange_push(e);
144 evas_object_move(sd->content, x, y);
145 evas_smart_objects_calculate(e);
146 ELM_WIDGET_CHECK_OR_RETURN(obj);
147 evas_nochange_pop(e);
154 _elm_mapbuf_smart_move(Evas_Object *obj,
158 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.move(obj, x, y);
160 _configure(obj, EINA_FALSE);
164 _elm_mapbuf_smart_resize(Evas_Object *obj,
168 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.resize(obj, x, y);
170 _configure(obj, EINA_FALSE);
174 _elm_mapbuf_inside_view_reset(Evas_Object *obj)
176 ELM_MAPBUF_DATA_GET(obj, sd);
178 sd->inside_view[0] = EINA_FALSE;
179 sd->inside_view[1] = EINA_FALSE;
180 sd->inside_view[2] = EINA_FALSE;
181 sd->inside_view[3] = EINA_FALSE;
185 _elm_mapbuf_smart_content_set(Evas_Object *obj,
187 Evas_Object *content)
189 ELM_MAPBUF_DATA_GET(obj, sd);
191 if (part && strcmp(part, "default")) return EINA_FALSE;
192 if (sd->content == content) return EINA_TRUE;
194 if (sd->content) evas_object_del(sd->content);
195 sd->content = content;
199 evas_object_data_set(content, "_elm_leaveme", (void *)1);
200 elm_widget_sub_object_add(obj, content);
201 evas_object_smart_member_add(content, obj);
202 evas_object_clip_set(content, ELM_WIDGET_DATA(sd)->resize_obj);
203 evas_object_color_set
204 (ELM_WIDGET_DATA(sd)->resize_obj, 255, 255, 255, 255);
205 evas_object_event_callback_add
206 (content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
207 _changed_size_hints_cb, obj);
210 evas_object_color_set(ELM_WIDGET_DATA(sd)->resize_obj, 0, 0, 0, 0);
212 _elm_mapbuf_inside_view_reset(obj);
215 _configure(obj, EINA_TRUE);
221 _elm_mapbuf_smart_content_get(const Evas_Object *obj,
224 ELM_MAPBUF_DATA_GET(obj, sd);
226 if (part && strcmp(part, "default")) return NULL;
231 _elm_mapbuf_smart_content_unset(Evas_Object *obj,
234 Evas_Object *content;
236 ELM_MAPBUF_DATA_GET(obj, sd);
238 if (part && strcmp(part, "default")) return NULL;
239 if (!sd->content) return NULL;
241 content = sd->content;
242 elm_widget_sub_object_del(obj, content);
243 evas_object_smart_member_del(content);
244 evas_object_data_del(content, "_elm_leaveme");
245 evas_object_color_set(ELM_WIDGET_DATA(sd)->resize_obj, 0, 0, 0, 0);
250 _elm_mapbuf_smart_add(Evas_Object *obj)
252 EVAS_SMART_DATA_ALLOC(obj, Elm_Mapbuf_Smart_Data);
254 ELM_WIDGET_DATA(priv)->resize_obj =
255 evas_object_rectangle_add(evas_object_evas_get(obj));
257 ELM_WIDGET_CLASS(_elm_mapbuf_parent_sc)->base.add(obj);
259 evas_object_static_clip_set(ELM_WIDGET_DATA(priv)->resize_obj, EINA_TRUE);
260 evas_object_pass_events_set(ELM_WIDGET_DATA(priv)->resize_obj, EINA_TRUE);
261 evas_object_color_set(ELM_WIDGET_DATA(priv)->resize_obj, 0, 0, 0, 0);
267 elm_widget_can_focus_set(obj, EINA_FALSE);
273 _elm_mapbuf_smart_focus_next(const Evas_Object *obj,
274 Elm_Focus_Direction dir,
277 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
278 ELM_MAPBUF_DATA_GET(obj, sd);
281 return elm_widget_focus_next_get(sd->content, dir, next);
287 _elm_mapbuf_smart_access(Evas_Object *obj, Eina_Bool is_access)
289 ELM_MAPBUF_DATA_GET(obj, sd);
292 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next =
293 _elm_mapbuf_smart_focus_next;
295 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next = NULL;
299 _elm_mapbuf_smart_set_user(Elm_Mapbuf_Smart_Class *sc)
301 ELM_WIDGET_CLASS(sc)->base.add = _elm_mapbuf_smart_add;
302 ELM_WIDGET_CLASS(sc)->base.resize = _elm_mapbuf_smart_resize;
303 ELM_WIDGET_CLASS(sc)->base.move = _elm_mapbuf_smart_move;
305 ELM_WIDGET_CLASS(sc)->theme = _elm_mapbuf_smart_theme;
306 ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_mapbuf_smart_sub_object_del;
307 ELM_WIDGET_CLASS(sc)->access = _elm_mapbuf_smart_access;
309 if (_elm_config->access_mode)
310 ELM_WIDGET_CLASS(sc)->focus_next = _elm_mapbuf_smart_focus_next;
312 ELM_CONTAINER_CLASS(sc)->content_set = _elm_mapbuf_smart_content_set;
313 ELM_CONTAINER_CLASS(sc)->content_get = _elm_mapbuf_smart_content_get;
314 ELM_CONTAINER_CLASS(sc)->content_unset = _elm_mapbuf_smart_content_unset;
317 EAPI const Elm_Mapbuf_Smart_Class *
318 elm_mapbuf_smart_class_get(void)
320 static Elm_Mapbuf_Smart_Class _sc =
321 ELM_MAPBUF_SMART_CLASS_INIT_NAME_VERSION(ELM_MAPBUF_SMART_NAME);
322 static const Elm_Mapbuf_Smart_Class *class = NULL;
324 if (class) return class;
326 _elm_mapbuf_smart_set(&_sc);
333 elm_mapbuf_add(Evas_Object *parent)
337 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
339 obj = elm_widget_add(_elm_mapbuf_smart_class_new(), parent);
340 if (!obj) return NULL;
342 if (!elm_widget_sub_object_add(parent, obj))
343 ERR("could not add %p as sub object of %p", obj, parent);
349 elm_mapbuf_enabled_set(Evas_Object *obj,
352 ELM_MAPBUF_CHECK(obj);
353 ELM_MAPBUF_DATA_GET(obj, sd);
355 if (sd->enabled == enabled) return;
356 sd->enabled = enabled;
358 _elm_mapbuf_inside_view_reset(obj);
359 if (sd->content) evas_object_static_clip_set(sd->content, sd->enabled);
360 _configure(obj, EINA_TRUE);
364 elm_mapbuf_enabled_get(const Evas_Object *obj)
366 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
367 ELM_MAPBUF_DATA_GET(obj, sd);
373 elm_mapbuf_smooth_set(Evas_Object *obj,
376 ELM_MAPBUF_CHECK(obj);
377 ELM_MAPBUF_DATA_GET(obj, sd);
379 if (sd->smooth == smooth) return;
381 _configure(obj, EINA_TRUE);
385 elm_mapbuf_smooth_get(const Evas_Object *obj)
387 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
388 ELM_MAPBUF_DATA_GET(obj, sd);
394 elm_mapbuf_alpha_set(Evas_Object *obj,
397 ELM_MAPBUF_CHECK(obj);
398 ELM_MAPBUF_DATA_GET(obj, sd);
400 if (sd->alpha == alpha) return;
402 _configure(obj, EINA_TRUE);
406 elm_mapbuf_alpha_get(const Evas_Object *obj)
408 ELM_MAPBUF_CHECK(obj) EINA_FALSE;
409 ELM_MAPBUF_DATA_GET(obj, sd);