1 #include <Elementary.h>
5 * @defgroup Mapbuf Mapbuf
7 * This holds 1 content object and uses an Evas Map to move/resize etc. it.
10 typedef struct _Widget_Data Widget_Data;
15 Eina_Bool enabled : 1;
20 static const char *widtype = NULL;
21 static void _del_hook(Evas_Object *obj);
22 static void _theme_hook(Evas_Object *obj);
23 static void _sizing_eval(Evas_Object *obj);
24 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
25 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
28 _del_hook(Evas_Object *obj)
30 Widget_Data *wd = elm_widget_data_get(obj);
36 _theme_hook(Evas_Object *obj)
38 Widget_Data *wd = elm_widget_data_get(obj);
44 _sizing_eval(Evas_Object *obj)
46 Widget_Data *wd = elm_widget_data_get(obj);
47 Evas_Coord minw = -1, minh = -1;
48 Evas_Coord maxw = -1, maxh = -1;
52 evas_object_size_hint_min_get(wd->content, &minw, &minh);
53 evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
55 evas_object_size_hint_min_set(obj, minw, minh);
56 evas_object_size_hint_max_set(obj, maxw, maxh);
60 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
62 Widget_Data *wd = elm_widget_data_get(data);
68 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
70 Widget_Data *wd = elm_widget_data_get(obj);
71 Evas_Object *sub = event_info;
73 if (sub == wd->content)
75 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
76 _changed_size_hints, obj);
83 _mapbuf(Evas_Object *obj)
85 Widget_Data *wd = elm_widget_data_get(obj);
86 Evas_Coord x, y, w, h;
88 evas_object_geometry_get(obj, &x, &y, &w, &h);
94 evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0);
95 evas_map_smooth_set(m, wd->smooth);
96 evas_map_alpha_set(m, wd->alpha);
97 evas_object_map_set(wd->content, m);
98 evas_object_map_enable_set(wd->content, wd->enabled);
103 evas_object_map_set(wd->content, NULL);
104 evas_object_map_enable_set(wd->content, 0);
105 evas_object_move(wd->content, x, y);
106 evas_object_resize(wd->content, w, h);
111 _configure(Evas_Object *obj)
113 Widget_Data *wd = elm_widget_data_get(obj);
117 Evas_Coord x, y, w, h;
119 evas_object_geometry_get(obj, &x, &y, &w, &h);
120 if (!wd->enabled) evas_object_move(wd->content, x, y);
121 evas_object_resize(wd->content, w, h);
127 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
133 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
139 * Add a new mapbuf to the parent
141 * @param parent The parent object
142 * @return The new object or NULL if it cannot be created
147 elm_mapbuf_add(Evas_Object *parent)
153 wd = ELM_NEW(Widget_Data);
154 e = evas_object_evas_get(parent);
155 obj = elm_widget_add(e);
156 ELM_SET_WIDTYPE(widtype, "mapbuf");
157 elm_widget_type_set(obj, "mapbuf");
158 elm_widget_sub_object_add(parent, obj);
159 elm_widget_data_set(obj, wd);
160 elm_widget_del_hook_set(obj, _del_hook);
161 elm_widget_theme_hook_set(obj, _theme_hook);
163 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
164 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
165 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
176 * Set the mapbuf front content
178 * @param obj The mapbuf object
179 * @param content The content will be filled in this mapbuf object
184 elm_mapbuf_content_set(Evas_Object *obj, Evas_Object *content)
186 ELM_CHECK_WIDTYPE(obj, widtype);
187 Widget_Data *wd = elm_widget_data_get(obj);
189 if (wd->content == content) return;
190 if ((wd->content != content) && (wd->content))
192 elm_widget_sub_object_del(obj, wd->content);
193 evas_object_smart_member_del(wd->content);
195 wd->content = content;
198 elm_widget_sub_object_add(content, obj);
199 evas_object_smart_member_add(content, obj);
200 evas_object_event_callback_add(content,
201 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
202 _changed_size_hints, obj);
209 * Set the mapbuf enabled state
211 * @param obj The mapbuf object
212 * @param enabled The value to set the enabled state to
217 elm_mapbuf_enabled_set(Evas_Object *obj, Eina_Bool enabled)
219 ELM_CHECK_WIDTYPE(obj, widtype);
220 Widget_Data *wd = elm_widget_data_get(obj);
222 if (wd->enabled == enabled) return;
223 wd->enabled = enabled;
228 * Get the mapbuf enabled state
230 * @param obj The mapbuf object
231 * @return The value that the enabled state is set to
236 elm_mapbuf_enabled_get(const Evas_Object *obj)
238 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
239 Widget_Data *wd = elm_widget_data_get(obj);
240 if (!wd) return EINA_FALSE;
245 * Sets the mapbuf smooth state
247 * @param obj The mapbuf object
248 * @param smooth The value of the smooth state of @p obj
253 elm_mapbuf_smooth_set(Evas_Object *obj, Eina_Bool smooth)
255 ELM_CHECK_WIDTYPE(obj, widtype);
256 Widget_Data *wd = elm_widget_data_get(obj);
258 if (wd->smooth == smooth) return;
264 * Gets the mapbuf smooth state
266 * @param obj The mapbuf object
267 * @return The value of the smooth state of @p obj
272 elm_mapbuf_smooth_get(const Evas_Object *obj)
274 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
275 Widget_Data *wd = elm_widget_data_get(obj);
276 if (!wd) return EINA_FALSE;
281 * Enables/disables the mapbuf alpha channel
283 * @param obj The mapbuf object
284 * @param alpha The state of the alpha channel
289 elm_mapbuf_alpha_set(Evas_Object *obj, Eina_Bool alpha)
291 ELM_CHECK_WIDTYPE(obj, widtype);
292 Widget_Data *wd = elm_widget_data_get(obj);
294 if (wd->alpha == alpha) return;
300 * Gets the state of the mapbuf alpha channel
302 * @param obj The mapbuf object
303 * @return The state of the alpha channel
308 elm_mapbuf_alpha_get(const Evas_Object *obj)
310 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
311 Widget_Data *wd = elm_widget_data_get(obj);
312 if (!wd) return EINA_FALSE;