1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
9 Evas_Object *content, *icon;
10 const char *label, *info, *corner;
14 >>>>>>> remotes/origin/upstream
17 static const char *widtype = NULL;
18 static void _del_hook(Evas_Object *obj);
19 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
20 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
21 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
22 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
23 static void _theme_hook(Evas_Object *obj);
24 static void _sizing_eval(Evas_Object *obj);
25 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
26 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
28 static const char SIG_CLICKED[] = "clicked";
30 static const Evas_Smart_Cb_Description _signals[] =
38 static const char *corner_string[] =
46 >>>>>>> remotes/origin/upstream
48 _del_hook(Evas_Object *obj)
50 Widget_Data *wd = elm_widget_data_get(obj);
52 if (wd->label) eina_stringshare_del(wd->label);
53 if (wd->info) eina_stringshare_del(wd->info);
54 if (wd->corner) eina_stringshare_del(wd->corner);
59 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
61 Widget_Data *wd = elm_widget_data_get(obj);
63 edje_object_mirrored_set(wd->bbl, rtl);
67 _theme_hook(Evas_Object *obj)
69 Widget_Data *wd = elm_widget_data_get(obj);
71 _elm_widget_mirrored_reload(obj);
72 _mirrored_set(obj, elm_widget_mirrored_get(obj));
74 _elm_theme_object_set(obj, wd->bbl, "bubble", wd->corner,
76 _elm_theme_object_set(obj, wd->bbl, "bubble", corner_string[wd->pos],
77 >>>>>>> remotes/origin/upstream
78 elm_widget_style_get(obj));
79 edje_object_part_text_set(wd->bbl, "elm.text", wd->label);
80 if (wd->label) edje_object_signal_emit(wd->bbl, "elm,state,text,visible", "elm");
81 else edje_object_signal_emit(wd->bbl, "elm,state,text,hidden", "elm");
82 edje_object_part_text_set(wd->bbl, "elm.info", wd->info);
83 if (wd->info) edje_object_signal_emit(wd->bbl, "elm,state,info,visible", "elm");
84 else edje_object_signal_emit(wd->bbl, "elm,state,info,hidden", "elm");
87 edje_object_part_swallow(wd->bbl, "elm.swallow.content", wd->content);
88 edje_object_message_signal_process(wd->bbl);
91 edje_object_signal_emit(wd->bbl, "elm,state,icon,visible", "elm");
93 edje_object_signal_emit(wd->bbl, "elm,state,icon,hidden", "elm");
94 edje_object_scale_set(wd->bbl,
95 elm_widget_scale_get(obj) * _elm_config->scale);
100 _content_set(Evas_Object *obj, Evas_Object *content)
102 Widget_Data *wd = elm_widget_data_get(obj);
105 if (wd->content == content) return;
106 if (wd->content) evas_object_del(wd->content);
107 wd->content = content;
110 elm_widget_sub_object_add(obj, content);
111 evas_object_event_callback_add(content,
112 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
113 _changed_size_hints, obj);
114 edje_object_part_swallow(wd->bbl, "elm.swallow.content", content);
120 _content_unset(Evas_Object *obj)
122 Widget_Data *wd = elm_widget_data_get(obj);
123 Evas_Object *content;
124 if (!wd) return NULL;
125 if (!wd->content) return NULL;
126 content = wd->content;
127 elm_widget_sub_object_del(obj, content);
128 evas_object_event_callback_del_full(content,
129 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
130 _changed_size_hints, obj);
131 edje_object_part_unswallow(wd->bbl, content);
137 _icon_set(Evas_Object *obj, Evas_Object* icon)
139 Widget_Data *wd = elm_widget_data_get(obj);
141 if (wd->icon == icon) return;
142 if (wd->icon) evas_object_del(wd->icon);
146 elm_widget_sub_object_add(obj, icon);
147 edje_object_part_swallow(wd->bbl, "elm.swallow.icon", icon);
148 evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
149 _changed_size_hints, obj);
150 edje_object_signal_emit(wd->bbl, "elm,state,icon,visible", "elm");
151 edje_object_message_signal_process(wd->bbl);
157 _icon_unset(Evas_Object *obj)
159 Widget_Data *wd = elm_widget_data_get(obj);
161 if (!wd) return NULL;
162 if (!wd->icon) return NULL;
164 elm_widget_sub_object_del(obj, icon);
165 evas_object_event_callback_del_full(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
166 _changed_size_hints, obj);
167 edje_object_part_unswallow(wd->bbl, icon);
173 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
175 ELM_CHECK_WIDTYPE(obj, widtype);
176 Widget_Data *wd = elm_widget_data_get(obj);
179 if (!part || !strcmp(part, "default"))
180 _content_set(obj, content);
181 else if(!strcmp(part, "icon"))
182 _icon_set(obj, content);
186 _content_get_hook(const Evas_Object *obj, const char *part)
188 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
189 Widget_Data *wd = elm_widget_data_get(obj);
190 if (!wd) return NULL;
191 if (!part || !strcmp(part, "default"))
193 else if(!strcmp(part, "icon"))
199 _content_unset_hook(Evas_Object *obj, const char *part)
201 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
202 Widget_Data *wd = elm_widget_data_get(obj);
203 if (!wd) return NULL;
204 if (!part || !strcmp(part, "default"))
205 return _content_unset(obj);
206 else if(!strcmp(part, "icon"))
207 return _icon_unset(obj);
212 _elm_bubble_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
214 Widget_Data *wd = elm_widget_data_get(obj);
217 if ((!wd) || (!wd->content))
222 /* Try Focus cycle in subitem */
223 return elm_widget_focus_next_get(cur, dir, next);
227 _sizing_eval(Evas_Object *obj)
229 Widget_Data *wd = elm_widget_data_get(obj);
230 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
232 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
233 edje_object_size_min_restricted_calc(wd->bbl, &minw, &minh, minw, minh);
234 evas_object_size_hint_min_set(obj, minw, minh);
235 evas_object_size_hint_max_set(obj, maxw, maxh);
239 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
241 Widget_Data *wd = elm_widget_data_get(data);
247 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
249 Widget_Data *wd = elm_widget_data_get(obj);
250 Evas_Object *sub = event_info;
252 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
253 _changed_size_hints, obj);
254 if (sub == wd->content) wd->content = NULL;
255 else if (sub == wd->icon)
257 edje_object_signal_emit(wd->bbl, "elm,state,icon,hidden", "elm");
259 edje_object_message_signal_process(wd->bbl);
265 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
267 Evas_Event_Mouse_Up *ev = event_info;
268 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
270 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
274 _elm_bubble_label_set(Evas_Object *obj, const char *item, const char *label)
276 ELM_CHECK_WIDTYPE(obj, widtype);
277 Widget_Data *wd = elm_widget_data_get(obj);
280 if (!item || !strcmp(item, "default"))
282 eina_stringshare_replace(&wd->label, label);
283 edje_object_part_text_set(wd->bbl, "elm.text", label);
284 if (label) edje_object_signal_emit(wd->bbl, "elm,state,text,visible",
286 else edje_object_signal_emit(wd->bbl, "elm,state,text,hidden", "elm");
289 else if (!strcmp(item, "info"))
291 eina_stringshare_replace(&wd->info, label);
292 edje_object_part_text_set(wd->bbl, "elm.info", label);
293 if (label) edje_object_signal_emit(wd->bbl, "elm,state,info,visible",
295 else edje_object_signal_emit(wd->bbl, "elm,state,info,hidden", "elm");
301 _elm_bubble_label_get(const Evas_Object *obj, const char *item)
303 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
304 Widget_Data *wd = elm_widget_data_get(obj);
305 if (!wd) return NULL;
307 if (!item || !strcmp(item, "default"))
311 else if (!strcmp(item, "info"))
320 elm_bubble_add(Evas_Object *parent)
326 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
328 ELM_SET_WIDTYPE(widtype, "bubble");
329 elm_widget_type_set(obj, "bubble");
330 elm_widget_sub_object_add(parent, obj);
331 elm_widget_data_set(obj, wd);
332 elm_widget_del_hook_set(obj, _del_hook);
333 elm_widget_theme_hook_set(obj, _theme_hook);
334 elm_widget_focus_next_hook_set(obj, _elm_bubble_focus_next_hook);
335 elm_widget_can_focus_set(obj, EINA_FALSE);
336 elm_widget_text_set_hook_set(obj, _elm_bubble_label_set);
337 elm_widget_text_get_hook_set(obj, _elm_bubble_label_get);
338 elm_widget_content_set_hook_set(obj, _content_set_hook);
339 elm_widget_content_get_hook_set(obj, _content_get_hook);
340 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
342 wd->corner = eina_stringshare_add("base");
345 wd->pos = ELM_BUBBLE_POS_TOP_LEFT; //default
346 >>>>>>> remotes/origin/upstream
348 wd->bbl = edje_object_add(e);
349 elm_widget_resize_object_set(obj, wd->bbl);
351 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
352 evas_object_event_callback_add(wd->bbl, EVAS_CALLBACK_MOUSE_UP,
355 evas_object_smart_callbacks_descriptions_set(obj, _signals);
356 _mirrored_set(obj, elm_widget_mirrored_get(obj));
357 _elm_theme_object_set(obj, wd->bbl, "bubble", wd->corner,
358 elm_widget_style_get(obj));
365 elm_bubble_label_set(Evas_Object *obj, const char *label)
367 _elm_bubble_label_set(obj, NULL, label);
371 elm_bubble_label_get(const Evas_Object *obj)
373 return _elm_bubble_label_get(obj, NULL);
377 elm_bubble_info_set(Evas_Object *obj, const char *info)
379 _elm_bubble_label_set(obj, "info", info);
383 elm_bubble_info_get(const Evas_Object *obj)
385 return _elm_bubble_label_get(obj, "info");
389 elm_bubble_content_set(Evas_Object *obj, Evas_Object *content)
391 _content_set_hook(obj, NULL, content);
395 elm_bubble_content_get(const Evas_Object *obj)
397 return _content_get_hook(obj, NULL);
401 elm_bubble_content_unset(Evas_Object *obj)
403 return _content_unset_hook(obj, NULL);
407 elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon)
409 _content_set_hook(obj, "icon", icon);
413 elm_bubble_icon_get(const Evas_Object *obj)
415 return _content_get_hook(obj, "icon");
419 elm_bubble_icon_unset(Evas_Object *obj)
421 return _content_unset_hook(obj, "icon");
425 elm_bubble_corner_set(Evas_Object *obj, const char *corner)
427 EINA_DEPRECATED EAPI void
428 elm_bubble_corner_set(Evas_Object *obj, const char *corner)
431 for (i=ELM_BUBBLE_POS_TOP_LEFT; i<=ELM_BUBBLE_POS_BOTTOM_RIGHT; i++)
433 if (!strcmp(corner,corner_string[i]))
434 elm_bubble_pos_set(obj, i);
439 elm_bubble_pos_set(Evas_Object *obj, Elm_Bubble_Pos pos)
440 >>>>>>> remotes/origin/upstream
442 ELM_CHECK_WIDTYPE(obj, widtype);
443 Widget_Data *wd = elm_widget_data_get(obj);
446 EINA_SAFETY_ON_NULL_RETURN(corner);
447 eina_stringshare_replace(&wd->corner, corner);
452 elm_bubble_corner_get(const Evas_Object *obj)
454 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
455 Widget_Data *wd = elm_widget_data_get(obj);
456 if (!wd) return NULL;
459 if(pos<ELM_BUBBLE_POS_TOP_LEFT || pos>ELM_BUBBLE_POS_BOTTOM_RIGHT) return;
464 EINA_DEPRECATED EAPI const char*
465 elm_bubble_corner_get(const Evas_Object *obj)
467 return corner_string[elm_bubble_pos_get(obj)];
471 elm_bubble_pos_get(const Evas_Object *obj)
473 ELM_CHECK_WIDTYPE(obj, widtype) ELM_BUBBLE_POS_INVALID;
474 Widget_Data *wd = elm_widget_data_get(obj);
475 if (!wd) return ELM_BUBBLE_POS_INVALID;
477 >>>>>>> remotes/origin/upstream