1 #include <Elementary.h>
4 static const char _tooltip_key[] = "_elm_tooltip";
6 #define ELM_TOOLTIP_GET_OR_RETURN(tt, obj, ...) \
12 CRITICAL("Null pointer: " #obj); \
15 tt = evas_object_data_get((obj), _tooltip_key); \
18 ERR("Object does not have tooltip: " #obj); \
26 Elm_Tooltip_Content_Cb func;
31 Evas_Object *eventarea, *owner;
32 Evas_Object *tooltip, *content;
34 Ecore_Timer *show_timer;
35 Ecore_Timer *hide_timer;
36 Ecore_Job *reconfigure_job;
38 Evas_Coord x, y, bx, by;
43 double hide_timeout; /* from theme */
44 Eina_Bool visible_lock:1;
45 Eina_Bool changed_style:1;
46 Eina_Bool free_size : 1;
49 static void _elm_tooltip_reconfigure(Elm_Tooltip *tt);
50 static void _elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt);
51 static void _elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt);
52 static void _elm_tooltip_hide_anim_start(Elm_Tooltip *tt);
53 static void _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt);
54 static void _elm_tooltip_show_timer_stop(Elm_Tooltip *tt);
55 static void _elm_tooltip_hide(Elm_Tooltip *tt);
56 static void _elm_tooltip_data_clean(Elm_Tooltip *tt);
59 _elm_tooltip_content_changed_hints_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
61 _elm_tooltip_reconfigure_job_start(data);
65 _elm_tooltip_content_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
67 Elm_Tooltip *tt = data;
69 tt->visible_lock = EINA_FALSE;
70 if (tt->tooltip) _elm_tooltip_hide(tt);
74 _elm_tooltip_obj_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
76 Elm_Tooltip *tt = data;
77 _elm_tooltip_reconfigure_job_start(tt);
81 _elm_tooltip_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
83 Elm_Tooltip *tt = data;
84 _elm_tooltip_reconfigure_job_start(tt);
88 _elm_tooltip_obj_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
90 Elm_Tooltip *tt = data;
91 _elm_tooltip_reconfigure_job_start(tt);
95 _elm_tooltip_show(Elm_Tooltip *tt)
97 _elm_tooltip_show_timer_stop(tt);
98 _elm_tooltip_hide_anim_stop(tt);
102 _elm_tooltip_reconfigure_job_start(tt);
107 tt->tt_win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
108 elm_win_borderless_set(tt->tt_win, EINA_TRUE);
109 elm_win_override_set(tt->tt_win, EINA_TRUE);
110 tt->tt_evas = evas_object_evas_get(tt->tt_win);
111 tt->tooltip = edje_object_add(tt->tt_evas);
112 evas_object_move(tt->tooltip, 0, 0);
113 elm_win_resize_object_add(tt->tt_win, tt->tooltip);
114 #ifdef HAVE_ELEMENTARY_X
115 ecore_x_window_shape_input_rectangle_set(elm_win_xwindow_get(tt->tt_win), 0, 0, 0, 0);
117 evas_object_show(tt->tt_win);
120 tt->tooltip = edje_object_add(tt->evas);
121 if (!tt->tooltip) return;
123 evas_object_layer_set(tt->tt_win ?: tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP);
125 evas_object_event_callback_add
126 (tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
127 evas_object_event_callback_add
128 (tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
129 evas_object_event_callback_add
130 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt);
132 tt->changed_style = EINA_TRUE;
133 _elm_tooltip_reconfigure_job_start(tt);
137 _elm_tooltip_content_del(Elm_Tooltip *tt)
139 if (!tt->content) return;
141 evas_object_event_callback_del_full
142 (tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
143 _elm_tooltip_content_changed_hints_cb, tt);
144 evas_object_event_callback_del_full
145 (tt->content, EVAS_CALLBACK_DEL,
146 _elm_tooltip_content_del_cb, tt);
147 evas_object_hide(tt->content);
148 evas_object_del(tt->content);
154 _elm_tooltip_hide(Elm_Tooltip *tt)
157 _elm_tooltip_show_timer_stop(tt);
158 _elm_tooltip_hide_anim_stop(tt);
159 _elm_tooltip_reconfigure_job_stop(tt);
161 if (!tt->tooltip) return;
162 if (tt->visible_lock) return;
164 _elm_tooltip_content_del(tt);
166 evas_object_event_callback_del_full
167 (tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
168 evas_object_event_callback_del_full
169 (tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
170 evas_object_event_callback_del_full
171 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt);
173 del = tt->tt_win ?: tt->tooltip;
178 evas_object_del(del);
182 _elm_tooltip_reconfigure_job(void *data)
184 Elm_Tooltip *tt = data;
185 tt->reconfigure_job = NULL;
186 _elm_tooltip_reconfigure(data);
190 _elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt)
192 if (!tt->reconfigure_job) return;
193 ecore_job_del(tt->reconfigure_job);
194 tt->reconfigure_job = NULL;
198 _elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt)
200 if (tt->reconfigure_job) ecore_job_del(tt->reconfigure_job);
201 tt->reconfigure_job = ecore_job_add(_elm_tooltip_reconfigure_job, tt);
205 _elm_tooltip_hide_anim_cb(void *data)
207 Elm_Tooltip *tt = data;
208 tt->hide_timer = NULL;
209 _elm_tooltip_hide(tt);
214 _elm_tooltip_hide_anim_start(Elm_Tooltip *tt)
217 if (tt->hide_timer) return;
218 /* hide slightly faster when in window mode to look less stupid */
219 if ((tt->hide_timeout > 0) && tt->tt_win) extra = 0.1;
220 edje_object_signal_emit(tt->tooltip, "elm,action,hide", "elm");
221 tt->hide_timer = ecore_timer_add
222 (tt->hide_timeout - extra, _elm_tooltip_hide_anim_cb, tt);
226 _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt)
228 if (!tt->hide_timer) return;
230 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
231 ecore_timer_del(tt->hide_timer);
232 tt->hide_timer = NULL;
236 _elm_tooltip_reconfigure(Elm_Tooltip *tt)
238 Evas_Coord ox, oy, ow, oh, px, py, tx, ty, tw, th, cw = 0, ch = 0;
239 Evas_Coord eminw, eminh, ominw, ominh;
241 Eina_Bool inside_eventarea;
242 #ifdef HAVE_ELEMENTARY_X
243 Ecore_X_Window xwin = 0;
246 _elm_tooltip_reconfigure_job_stop(tt);
248 if (tt->hide_timer) return;
249 if (!tt->tooltip) return;
250 if (tt->changed_style)
252 const char *style = tt->style ? tt->style : "default";
254 if (!_elm_theme_object_set(tt->tt_win ? NULL : tt->owner, tt->tooltip, "tooltip", "base", style))
256 ERR("Could not apply the theme to the tooltip! style=%s", style);
257 if (tt->tt_win) evas_object_del(tt->tt_win);
258 else evas_object_del(tt->tooltip);
272 tt->hide_timeout = 0.0;
274 str = edje_object_data_get(tt->tooltip, "transparent");
276 { /* FIXME: hardcoded here is bad */
277 if (str && (!strcmp(str, "enabled")))
279 elm_win_alpha_set(tt->tt_win, EINA_TRUE);
280 elm_win_transparent_set(tt->tt_win, EINA_TRUE);
284 elm_win_alpha_set(tt->tt_win, EINA_FALSE);
285 elm_win_transparent_set(tt->tt_win, EINA_FALSE);
289 str = edje_object_data_get(tt->tooltip, "pad_x");
290 if (str) tt->pad.x = atoi(str);
291 str = edje_object_data_get(tt->tooltip, "pad_y");
292 if (str) tt->pad.y = atoi(str);
294 str = edje_object_data_get(tt->tooltip, "pad_border_x");
295 if (str) tt->pad.bx = atoi(str);
296 str = edje_object_data_get(tt->tooltip, "pad_border_y");
297 if (str) tt->pad.by = atoi(str);
299 str = edje_object_data_get(tt->tooltip, "hide_timeout");
302 tt->hide_timeout = atof(str);
303 if (tt->hide_timeout < 0.0) tt->hide_timeout = 0.0;
306 evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
307 tt->changed_style = EINA_FALSE;
309 edje_object_part_swallow(tt->tooltip, "elm.swallow.content",
312 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
317 tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner);
320 WRN("could not create tooltip content!");
321 if (tt->tt_win) evas_object_del(tt->tt_win);
322 else evas_object_del(tt->tooltip);
329 evas_object_show(tt->content);
330 evas_object_layer_set(tt->content, ELM_OBJECT_LAYER_TOOLTIP);
331 evas_object_pass_events_set(tt->content, EINA_TRUE);
332 edje_object_part_swallow
333 (tt->tooltip, "elm.swallow.content", tt->content);
334 evas_object_event_callback_add(tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
335 _elm_tooltip_content_changed_hints_cb, tt);
336 evas_object_event_callback_add(tt->content, EVAS_CALLBACK_DEL,
337 _elm_tooltip_content_del_cb, tt);
341 evas_object_size_hint_min_get(tt->content, &ominw, &ominh);
342 edje_object_size_min_get(tt->tooltip, &eminw, &eminh);
344 if (eminw && (ominw < eminw)) ominw = eminw;
345 if (eminw && (ominh < eminh)) ominh = eminh;
347 if (ominw < 1) ominw = 10; /* at least it is noticeable */
348 if (ominh < 1) ominh = 10; /* at least it is noticeable */
350 edje_object_size_min_restricted_calc(tt->tooltip, &tw, &th, ominw, ominh);
353 elm_win_screen_size_get(elm_object_top_widget_get(tt->owner), &cw, &ch, NULL, NULL);
355 evas_output_size_get(tt->tt_evas ?: tt->evas, &cw, &ch);
357 evas_object_geometry_get(tt->eventarea, &ox, &oy, &ow, &oh);
362 #ifdef HAVE_ELEMENTARY_X
363 ecore_x_pointer_xy_get(xwin, &px, &py);
365 elm_win_screen_position_get(elm_object_top_widget_get(tt->owner), &x, &y);
370 evas_pointer_canvas_xy_get(tt->evas, &px, &py);
372 inside_eventarea = ((px >= ox) && (py >= oy) &&
373 (px <= ox + ow) && (py <= oy + oh));
374 if (inside_eventarea)
381 tx = ox + (ow / 2) - (tw / 2);
382 if (0 > (th - oy - oh)) ty = oy + th;
388 if (abs((tx + 2 * tw) - cw) < abs(tx))
391 else if ((tx > px) && (px > tx))
398 if (abs((ty + 2 * th) - ch) < abs(ty))
401 else if ((ty > py) && (py > ty))
406 if (inside_eventarea)
408 if ((tx == px) && ((tx + tw + tt->pad.x < cw) || (tx + tw > cw))) tx += tt->pad.x;
409 else if ((tx - tt->pad.x > 0) || (tx < 0)) tx -= tt->pad.x;
410 if ((ty == py) && ((ty + th + tt->pad.y < ch) || (ty + th > ch))) ty += tt->pad.y;
411 else if ((ty - tt->pad.y > 0) || (ty < 0)) ty -= tt->pad.y;
413 if (tt->pad.bx * 2 + tw < cw)
415 if (tx < tt->pad.bx) tx = tt->pad.bx;
416 else if ((tx >= tw) && (tx + tt->pad.bx <= cw)) tx += tt->pad.bx;
417 else if (tx - tt->pad.bx >= 0) tx -= tt->pad.bx;
419 else if (tx < 0) tx -= tt->pad.bx;
420 else if (tx > cw) tx += tt->pad.bx;
422 if (tt->pad.by * 2 + th < ch)
424 if (ty < tt->pad.by) ty = tt->pad.by;
425 else if ((ty >= th) && (ty + tt->pad.by <= ch)) ty += tt->pad.by;
426 else if (ty - tt->pad.by >= 0) ty -= tt->pad.by;
428 else if (ty < 0) ty -= tt->pad.by;
429 else if (ty > ch) ty += tt->pad.by;
431 evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty);
432 evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th);
433 evas_object_show(tt->tooltip);
435 if (inside_eventarea)
437 rel_x = (px - tx) / (double)tw;
438 rel_y = (py - ty) / (double)th;
442 rel_x = (ox + (ow / 2) - tx) / (double)tw;
443 rel_y = (oy + (oh / 2) - ty) / (double)th;
446 #define FDIF(a, b) (fabs((a) - (b)) > 0.0001)
447 if ((FDIF(rel_x, tt->rel_pos.x)) || (FDIF(rel_y, tt->rel_pos.y)))
449 Edje_Message_Float_Set *msg;
451 msg = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double));
455 tt->rel_pos.x = rel_x;
456 tt->rel_pos.y = rel_y;
458 edje_object_message_send(tt->tooltip, EDJE_MESSAGE_FLOAT_SET, 1, msg);
464 _elm_tooltip_show_timer_stop(Elm_Tooltip *tt)
466 if (!tt->show_timer) return;
467 ecore_timer_del(tt->show_timer);
468 tt->show_timer = NULL;
472 _elm_tooltip_timer_show_cb(void *data)
474 Elm_Tooltip *tt = data;
475 tt->show_timer = NULL;
476 _elm_tooltip_show(tt);
477 return ECORE_CALLBACK_CANCEL;
481 _elm_tooltip_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
483 Elm_Tooltip *tt = data;
485 _elm_tooltip_hide_anim_stop(tt);
487 if ((tt->show_timer) || (tt->tooltip)) return;
489 tt->show_timer = ecore_timer_add
490 (_elm_config->tooltip_delay, _elm_tooltip_timer_show_cb, tt);
494 _elm_tooltip_obj_mouse_out_cb(Elm_Tooltip *tt, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Out *event __UNUSED__)
496 if (tt->visible_lock) return;
500 _elm_tooltip_show_timer_stop(tt);
503 _elm_tooltip_hide_anim_start(tt);
506 static void _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
509 _elm_tooltip_unset(Elm_Tooltip *tt)
511 tt->visible_lock = EINA_FALSE;
512 _elm_tooltip_hide(tt);
513 _elm_tooltip_data_clean(tt);
517 evas_object_event_callback_del_full
518 (tt->eventarea, EVAS_CALLBACK_MOUSE_IN,
519 _elm_tooltip_obj_mouse_in_cb, tt);
520 evas_object_event_callback_del_full
521 (tt->eventarea, EVAS_CALLBACK_MOUSE_OUT,
522 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
523 evas_object_event_callback_del_full
524 (tt->eventarea, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
526 evas_object_data_del(tt->eventarea, _tooltip_key);
530 evas_object_event_callback_del_full
531 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
532 elm_widget_tooltip_del(tt->owner, tt);
535 eina_stringshare_del(tt->style);
540 _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
542 Elm_Tooltip *tt = data;
543 if (tt->eventarea == obj) tt->eventarea = NULL;
544 if (tt->owner == obj) tt->owner = NULL;
545 _elm_tooltip_unset(tt);
549 _elm_tooltip_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip)
551 Evas_Object *label = elm_label_add(tooltip);
554 elm_object_style_set(label, "tooltip");
555 elm_object_text_set(label, data);
560 _elm_tooltip_trans_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip)
562 Evas_Object *label = elm_label_add(tooltip);
563 const char **text = data;
566 elm_object_style_set(label, "tooltip");
567 elm_object_domain_translatable_text_set(label, text[0], text[1]);
572 _elm_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
574 eina_stringshare_del(data);
578 _elm_tooltip_trans_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
580 const char **text = data;
581 eina_stringshare_del(text[0]);
582 eina_stringshare_del(text[1]);
587 _elm_tooltip_data_clean(Elm_Tooltip *tt)
589 if (tt->del_cb) tt->del_cb((void *)tt->data, tt->owner, NULL);
591 _elm_tooltip_content_del(tt);
598 * Notify tooltip should recalculate its theme.
602 elm_tooltip_theme(Elm_Tooltip *tt)
604 if (!tt->tooltip) return;
605 tt->changed_style = EINA_TRUE;
606 _elm_tooltip_reconfigure_job_start(tt);
611 * Set the content to be shown in the tooltip object for specific event area.
613 * Setup the tooltip to object. The object @a eventarea can have only
614 * one tooltip, so any previous tooltip data is removed. @p func(with
615 * @p data) will be called every time that need show the tooltip and
616 * it should return a valid Evas_Object. This object is then managed
617 * fully by tooltip system and is deleted when the tooltip is gone.
619 * This is an internal function that is used by objects with sub-items
620 * that want to provide different tooltips for each of them. The @a
621 * owner object should be an elm_widget and will be used to track
622 * theme changes and to feed @a func and @a del_cb. The @a eventarea
623 * may be any object and is the one that should be used later on with
624 * elm_object_tooltip apis, such as elm_object_tooltip_hide(),
625 * elm_object_tooltip_show() or elm_object_tooltip_unset().
627 * @param eventarea the object being attached a tooltip.
628 * @param owner the elm_widget that owns this object, will be used to
629 * track theme changes and to be used in @a func or @a del_cb.
630 * @param func the function used to create the tooltip contents. The
631 * @a Evas_Object parameters will receive @a owner as value.
632 * @param data what to provide to @a func as callback data/context.
633 * @param del_cb called when data is not needed anymore, either when
634 * another callback replaces @p func, the tooltip is unset with
635 * elm_object_tooltip_unset() or the owner object @a obj
636 * dies. This callback receives as the first parameter the
637 * given @a data, and @c event_info is NULL.
643 elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
645 Elm_Tooltip *tt = NULL;
646 Eina_Bool just_created;
648 EINA_SAFETY_ON_NULL_GOTO(owner, error);
649 EINA_SAFETY_ON_NULL_GOTO(eventarea, error);
653 elm_object_tooltip_unset(eventarea);
657 tt = evas_object_data_get(eventarea, _tooltip_key);
660 if (tt->owner != owner)
662 if (tt->owner != eventarea)
663 evas_object_event_callback_del_full
664 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
666 elm_widget_tooltip_del(tt->owner, tt);
668 if (owner != eventarea)
669 evas_object_event_callback_add
670 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
672 elm_widget_tooltip_add(tt->owner, tt);
675 if ((tt->func == func) && (tt->data == data) &&
676 (tt->del_cb == del_cb))
678 _elm_tooltip_data_clean(tt);
679 just_created = EINA_FALSE;
683 tt = ELM_NEW(Elm_Tooltip);
687 tt->eventarea = eventarea;
688 tt->evas = evas_object_evas_get(eventarea);
689 evas_object_data_set(eventarea, _tooltip_key, tt);
691 just_created = EINA_TRUE;
693 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_IN,
694 _elm_tooltip_obj_mouse_in_cb, tt);
695 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_OUT,
696 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
697 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_FREE,
698 _elm_tooltip_obj_free_cb, tt);
700 if (owner != eventarea)
701 evas_object_event_callback_add
702 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
704 elm_widget_tooltip_add(tt->owner, tt);
711 if (!just_created) _elm_tooltip_reconfigure_job_start(tt);
715 if (del_cb) del_cb((void *)data, owner, NULL);
719 * Force show tooltip of object
721 * @param obj Target object
723 * Force show the tooltip and disable hide on mouse_out.
724 * If another content is set as tooltip, the visible tooltip will hididen and
725 * showed again with new content.
726 * This can force show more than one tooltip at a time.
731 elm_object_tooltip_show(Evas_Object *obj)
733 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
734 tt->visible_lock = EINA_TRUE;
735 _elm_tooltip_show(tt);
739 * Force hide tooltip of object
741 * @param obj Target object
743 * Force hide the tooltip and (re)enable future mouse interations.
748 elm_object_tooltip_hide(Evas_Object *obj)
750 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
751 tt->visible_lock = EINA_FALSE;
752 _elm_tooltip_hide_anim_start(tt);
756 * Set the text to be shown in the tooltip object
758 * @param obj Target object
759 * @param text The text to set in the content
761 * Setup the text as tooltip to object. The object can have only one tooltip,
762 * so any previous tooltip data is removed.
763 * This method call internaly the elm_tooltip_content_cb_set().
768 elm_object_tooltip_text_set(Evas_Object *obj, const char *text)
770 EINA_SAFETY_ON_NULL_RETURN(obj);
771 EINA_SAFETY_ON_NULL_RETURN(text);
773 text = eina_stringshare_add(text);
774 elm_object_tooltip_content_cb_set
775 (obj, _elm_tooltip_label_create, text, _elm_tooltip_label_del_cb);
781 elm_object_tooltip_domain_translatable_text_set(Evas_Object *obj, const char *domain, const char *text)
784 EINA_SAFETY_ON_NULL_RETURN(obj);
785 EINA_SAFETY_ON_NULL_RETURN(text);
787 data = malloc(2 * sizeof(char *));
789 data[0] = eina_stringshare_add(domain);
790 data[1] = eina_stringshare_add(text);
791 elm_object_tooltip_content_cb_set
792 (obj, _elm_tooltip_trans_label_create, data,
793 _elm_tooltip_trans_label_del_cb);
797 * Set the content to be shown in the tooltip object
799 * Setup the tooltip to object. The object can have only one tooltip,
800 * so any previous tooltip data is removed. @p func(with @p data) will
801 * be called every time that need show the tooltip and it should
802 * return a valid Evas_Object. This object is then managed fully by
803 * tooltip system and is deleted when the tooltip is gone.
805 * @param obj the object being attached a tooltip.
806 * @param func the function used to create the tooltip contents.
807 * @param data what to provide to @a func as callback data/context.
808 * @param del_cb called when data is not needed anymore, either when
809 * another callback replaces @p func, the tooltip is unset with
810 * elm_object_tooltip_unset() or the owner object @a obj
811 * dies. This callback receives as the first parameter the
812 * given @a data, and @c event_info is NULL.
817 elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
819 elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb);
823 * Unset tooltip from object
825 * @param obj Target object
827 * Remove tooltip from object. The callback provided as del_cb to
828 * elm_object_tooltip_content_cb_set() will be called to notify it is
831 * @see elm_object_tooltip_content_cb_set()
836 elm_object_tooltip_unset(Evas_Object *obj)
838 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
839 _elm_tooltip_unset(tt);
843 * Sets a different style for this object tooltip.
845 * @note before you set a style you should define a tooltip with
846 * elm_object_tooltip_content_cb_set() or
847 * elm_object_tooltip_text_set().
849 * @param obj an object with tooltip already set.
850 * @param style the theme style to use (default, transparent, ...)
853 elm_object_tooltip_style_set(Evas_Object *obj, const char *style)
855 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
856 if (!eina_stringshare_replace(&tt->style, style)) return;
857 elm_tooltip_theme(tt);
861 * Get the style for this object tooltip.
863 * @param obj an object with tooltip already set.
864 * @return style the theme style in use, defaults to "default". If the
865 * object does not have a tooltip set, then NULL is returned.
868 elm_object_tooltip_style_get(const Evas_Object *obj)
870 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, NULL);
871 return tt->style ? tt->style : "default";
875 * Get the configured tooltip delay
877 * This gets the globally configured tooltip delay in seconds
879 * @return The tooltip delay
883 elm_tooltip_delay_get(void)
885 return _elm_config->tooltip_delay;
889 * Set the configured tooltip delay
891 * This sets the globally configured delay to tooltip
893 * @param delay The delay to show the tooltip
894 * @return EINA_TRUE if value is valid and setted
898 elm_tooltip_delay_set(double delay)
900 if (delay < 0.0) return EINA_FALSE;
901 _elm_config->tooltip_delay = delay;
906 * @brief Disable size restrictions on an object's tooltip
907 * @param obj The tooltip's anchor object
908 * @param disable If EINA_TRUE, size restrictions are disabled
909 * @return EINA_FALSE on failure, EINA_TRUE on success
911 * This function allows a tooltip to expand beyond its parant window's canvas.
912 * It will instead be limited only by the size of the display.
915 elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable)
917 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
918 return tt->free_size = disable;
922 * @brief Retrieve size restriction state of an object's tooltip
923 * @param obj The tooltip's anchor object
924 * @return If EINA_TRUE, size restrictions are disabled
926 * This function returns whether a tooltip is allowed to expand beyond
927 * its parant window's canvas.
928 * It will instead be limited only by the size of the display.
931 elm_tooltip_size_restrict_disabled_get(const Evas_Object *obj)
933 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
934 return tt->free_size;