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)
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);
352 #ifdef HAVE_ELEMENTARY_X
355 xwin = elm_win_xwindow_get(elm_object_top_widget_get(tt->owner));
358 xwin = ecore_x_window_root_get(xwin);
359 ecore_x_randr_screen_current_size_get(xwin, &cw, &ch, NULL, NULL);
364 evas_output_size_get(tt->tt_evas ?: tt->evas, &cw, &ch);
366 evas_object_geometry_get(tt->eventarea, &ox, &oy, &ow, &oh);
371 #ifdef HAVE_ELEMENTARY_X
372 ecore_x_pointer_xy_get(xwin, &px, &py);
374 elm_win_screen_position_get(elm_object_top_widget_get(tt->owner), &x, &y);
379 evas_pointer_canvas_xy_get(tt->evas, &px, &py);
381 inside_eventarea = ((px >= ox) && (py >= oy) &&
382 (px <= ox + ow) && (py <= oy + oh));
383 if (inside_eventarea)
390 tx = ox + (ow / 2) - (tw / 2);
391 if (0 > (th - oy - oh)) ty = oy + th;
397 if (abs((tx + 2 * tw) - cw) < abs(tx))
400 else if ((tx > px) && (px > tx))
407 if (abs((ty + 2 * th) - ch) < abs(ty))
410 else if ((ty > py) && (py > ty))
415 if (inside_eventarea)
417 if ((tx == px) && ((tx + tw + tt->pad.x < cw) || (tx + tw > cw))) tx += tt->pad.x;
418 else if ((tx - tt->pad.x > 0) || (tx < 0)) tx -= tt->pad.x;
419 if ((ty == py) && ((ty + th + tt->pad.y < ch) || (ty + th > ch))) ty += tt->pad.y;
420 else if ((ty - tt->pad.y > 0) || (ty < 0)) ty -= tt->pad.y;
422 if (tt->pad.bx * 2 + tw < cw)
424 if (tx < tt->pad.bx) tx = tt->pad.bx;
425 else if ((tx >= tw) && (tx + tt->pad.bx <= cw)) tx += tt->pad.bx;
426 else if (tx - tt->pad.bx >= 0) tx -= tt->pad.bx;
428 else if (tx < 0) tx -= tt->pad.bx;
429 else if (tx > cw) tx += tt->pad.bx;
431 if (tt->pad.by * 2 + th < ch)
433 if (ty < tt->pad.by) ty = tt->pad.by;
434 else if ((ty >= th) && (ty + tt->pad.by <= ch)) ty += tt->pad.by;
435 else if (ty - tt->pad.by >= 0) ty -= tt->pad.by;
437 else if (ty < 0) ty -= tt->pad.by;
438 else if (ty > ch) ty += tt->pad.by;
440 evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty);
441 evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th);
442 evas_object_show(tt->tooltip);
444 if (inside_eventarea)
446 rel_x = (px - tx) / (double)tw;
447 rel_y = (py - ty) / (double)th;
451 rel_x = (ox + (ow / 2) - tx) / (double)tw;
452 rel_y = (oy + (oh / 2) - ty) / (double)th;
455 #define FDIF(a, b) (fabs((a) - (b)) > 0.0001)
456 if ((FDIF(rel_x, tt->rel_pos.x)) || (FDIF(rel_y, tt->rel_pos.y)))
458 Edje_Message_Float_Set *msg;
460 msg = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double));
464 tt->rel_pos.x = rel_x;
465 tt->rel_pos.y = rel_y;
467 edje_object_message_send(tt->tooltip, EDJE_MESSAGE_FLOAT_SET, 1, msg);
473 _elm_tooltip_show_timer_stop(Elm_Tooltip *tt)
475 if (!tt->show_timer) return;
476 ecore_timer_del(tt->show_timer);
477 tt->show_timer = NULL;
481 _elm_tooltip_timer_show_cb(void *data)
483 Elm_Tooltip *tt = data;
484 tt->show_timer = NULL;
485 _elm_tooltip_show(tt);
486 return ECORE_CALLBACK_CANCEL;
490 _elm_tooltip_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
492 Elm_Tooltip *tt = data;
494 _elm_tooltip_hide_anim_stop(tt);
496 if ((tt->show_timer) || (tt->tooltip)) return;
498 tt->show_timer = ecore_timer_add
499 (_elm_config->tooltip_delay, _elm_tooltip_timer_show_cb, tt);
503 _elm_tooltip_obj_mouse_out_cb(Elm_Tooltip *tt, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Out *event __UNUSED__)
505 if (tt->visible_lock) return;
509 _elm_tooltip_show_timer_stop(tt);
512 _elm_tooltip_hide_anim_start(tt);
515 static void _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
518 _elm_tooltip_unset(Elm_Tooltip *tt)
520 tt->visible_lock = EINA_FALSE;
521 _elm_tooltip_hide(tt);
522 _elm_tooltip_data_clean(tt);
526 evas_object_event_callback_del_full
527 (tt->eventarea, EVAS_CALLBACK_MOUSE_IN,
528 _elm_tooltip_obj_mouse_in_cb, tt);
529 evas_object_event_callback_del_full
530 (tt->eventarea, EVAS_CALLBACK_MOUSE_OUT,
531 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
532 evas_object_event_callback_del_full
533 (tt->eventarea, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
535 evas_object_data_del(tt->eventarea, _tooltip_key);
539 evas_object_event_callback_del_full
540 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
541 elm_widget_tooltip_del(tt->owner, tt);
544 eina_stringshare_del(tt->style);
549 _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
551 Elm_Tooltip *tt = data;
552 if (tt->eventarea == obj) tt->eventarea = NULL;
553 if (tt->owner == obj) tt->owner = NULL;
554 _elm_tooltip_unset(tt);
558 _elm_tooltip_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip)
560 Evas_Object *label = elm_label_add(tooltip);
563 elm_object_style_set(label, "tooltip");
564 elm_object_text_set(label, data);
569 _elm_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
571 eina_stringshare_del(data);
575 _elm_tooltip_data_clean(Elm_Tooltip *tt)
577 if (tt->del_cb) tt->del_cb((void *)tt->data, tt->owner, NULL);
579 _elm_tooltip_content_del(tt);
586 * Notify tooltip should recalculate its theme.
590 elm_tooltip_theme(Elm_Tooltip *tt)
592 if (!tt->tooltip) return;
593 tt->changed_style = EINA_TRUE;
594 _elm_tooltip_reconfigure_job_start(tt);
599 * Set the content to be shown in the tooltip object for specific event area.
601 * Setup the tooltip to object. The object @a eventarea can have only
602 * one tooltip, so any previous tooltip data is removed. @p func(with
603 * @p data) will be called every time that need show the tooltip and
604 * it should return a valid Evas_Object. This object is then managed
605 * fully by tooltip system and is deleted when the tooltip is gone.
607 * This is an internal function that is used by objects with sub-items
608 * that want to provide different tooltips for each of them. The @a
609 * owner object should be an elm_widget and will be used to track
610 * theme changes and to feed @a func and @a del_cb. The @a eventarea
611 * may be any object and is the one that should be used later on with
612 * elm_object_tooltip apis, such as elm_object_tooltip_hide(),
613 * elm_object_tooltip_show() or elm_object_tooltip_unset().
615 * @param eventarea the object being attached a tooltip.
616 * @param owner the elm_widget that owns this object, will be used to
617 * track theme changes and to be used in @a func or @a del_cb.
618 * @param func the function used to create the tooltip contents. The
619 * @a Evas_Object parameters will receive @a owner as value.
620 * @param data what to provide to @a func as callback data/context.
621 * @param del_cb called when data is not needed anymore, either when
622 * another callback replaces @p func, the tooltip is unset with
623 * elm_object_tooltip_unset() or the owner object @a obj
624 * dies. This callback receives as the first parameter the
625 * given @a data, and @c event_info is NULL.
631 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)
633 Elm_Tooltip *tt = NULL;
634 Eina_Bool just_created;
636 EINA_SAFETY_ON_NULL_GOTO(owner, error);
637 EINA_SAFETY_ON_NULL_GOTO(eventarea, error);
641 elm_object_tooltip_unset(eventarea);
645 tt = evas_object_data_get(eventarea, _tooltip_key);
648 if (tt->owner != owner)
650 if (tt->owner != eventarea)
651 evas_object_event_callback_del_full
652 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
654 elm_widget_tooltip_del(tt->owner, tt);
656 if (owner != eventarea)
657 evas_object_event_callback_add
658 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
660 elm_widget_tooltip_add(tt->owner, tt);
663 if ((tt->func == func) && (tt->data == data) &&
664 (tt->del_cb == del_cb))
666 _elm_tooltip_data_clean(tt);
667 just_created = EINA_FALSE;
671 tt = ELM_NEW(Elm_Tooltip);
675 tt->eventarea = eventarea;
676 tt->evas = evas_object_evas_get(eventarea);
677 evas_object_data_set(eventarea, _tooltip_key, tt);
679 just_created = EINA_TRUE;
681 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_IN,
682 _elm_tooltip_obj_mouse_in_cb, tt);
683 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_OUT,
684 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
685 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_FREE,
686 _elm_tooltip_obj_free_cb, tt);
688 if (owner != eventarea)
689 evas_object_event_callback_add
690 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
692 elm_widget_tooltip_add(tt->owner, tt);
699 if (!just_created) _elm_tooltip_reconfigure_job_start(tt);
703 if (del_cb) del_cb((void *)data, owner, NULL);
707 * Force show tooltip of object
709 * @param obj Target object
711 * Force show the tooltip and disable hide on mouse_out.
712 * If another content is set as tooltip, the visible tooltip will hididen and
713 * showed again with new content.
714 * This can force show more than one tooltip at a time.
719 elm_object_tooltip_show(Evas_Object *obj)
721 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
722 tt->visible_lock = EINA_TRUE;
723 _elm_tooltip_show(tt);
727 * Force hide tooltip of object
729 * @param obj Target object
731 * Force hide the tooltip and (re)enable future mouse interations.
736 elm_object_tooltip_hide(Evas_Object *obj)
738 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
739 tt->visible_lock = EINA_FALSE;
740 _elm_tooltip_hide_anim_start(tt);
744 * Set the text to be shown in the tooltip object
746 * @param obj Target object
747 * @param text The text to set in the content
749 * Setup the text as tooltip to object. The object can have only one tooltip,
750 * so any previous tooltip data is removed.
751 * This method call internaly the elm_tooltip_content_cb_set().
756 elm_object_tooltip_text_set(Evas_Object *obj, const char *text)
758 EINA_SAFETY_ON_NULL_RETURN(obj);
759 EINA_SAFETY_ON_NULL_RETURN(text);
761 text = eina_stringshare_add(text);
762 elm_object_tooltip_content_cb_set
763 (obj, _elm_tooltip_label_create, text, _elm_tooltip_label_del_cb);
767 * Set the content to be shown in the tooltip object
769 * Setup the tooltip to object. The object can have only one tooltip,
770 * so any previous tooltip data is removed. @p func(with @p data) will
771 * be called every time that need show the tooltip and it should
772 * return a valid Evas_Object. This object is then managed fully by
773 * tooltip system and is deleted when the tooltip is gone.
775 * @param obj the object being attached a tooltip.
776 * @param func the function used to create the tooltip contents.
777 * @param data what to provide to @a func as callback data/context.
778 * @param del_cb called when data is not needed anymore, either when
779 * another callback replaces @p func, the tooltip is unset with
780 * elm_object_tooltip_unset() or the owner object @a obj
781 * dies. This callback receives as the first parameter the
782 * given @a data, and @c event_info is NULL.
787 elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
789 elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb);
793 * Unset tooltip from object
795 * @param obj Target object
797 * Remove tooltip from object. The callback provided as del_cb to
798 * elm_object_tooltip_content_cb_set() will be called to notify it is
801 * @see elm_object_tooltip_content_cb_set()
806 elm_object_tooltip_unset(Evas_Object *obj)
808 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
809 _elm_tooltip_unset(tt);
813 * Sets a different style for this object tooltip.
815 * @note before you set a style you should define a tooltip with
816 * elm_object_tooltip_content_cb_set() or
817 * elm_object_tooltip_text_set().
819 * @param obj an object with tooltip already set.
820 * @param style the theme style to use (default, transparent, ...)
823 elm_object_tooltip_style_set(Evas_Object *obj, const char *style)
825 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
826 if (!eina_stringshare_replace(&tt->style, style)) return;
827 elm_tooltip_theme(tt);
831 * Get the style for this object tooltip.
833 * @param obj an object with tooltip already set.
834 * @return style the theme style in use, defaults to "default". If the
835 * object does not have a tooltip set, then NULL is returned.
838 elm_object_tooltip_style_get(const Evas_Object *obj)
840 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, NULL);
841 return tt->style ? tt->style : "default";
845 * Get the configured tooltip delay
847 * This gets the globally configured tooltip delay in seconds
849 * @return The tooltip delay
853 elm_tooltip_delay_get(void)
855 return _elm_config->tooltip_delay;
859 * Set the configured tooltip delay
861 * This sets the globally configured delay to tooltip
863 * @param delay The delay to show the tooltip
864 * @return EINA_TRUE if value is valid and setted
868 elm_tooltip_delay_set(double delay)
870 if (delay < 0.0) return EINA_FALSE;
871 _elm_config->tooltip_delay = delay;
876 * @brief Disable size restrictions on an object's tooltip
877 * @param obj The tooltip's anchor object
878 * @param disable If EINA_TRUE, size restrictions are disabled
879 * @return EINA_FALSE on failure, EINA_TRUE on success
881 * This function allows a tooltip to expand beyond its parant window's canvas.
882 * It will instead be limited only by the size of the display.
885 elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable)
887 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
888 return tt->free_size = disable;
892 * @brief Retrieve size restriction state of an object's tooltip
893 * @param obj The tooltip's anchor object
894 * @return If EINA_TRUE, size restrictions are disabled
896 * This function returns whether a tooltip is allowed to expand beyond
897 * its parant window's canvas.
898 * It will instead be limited only by the size of the display.
901 elm_tooltip_size_restrict_disabled_get(const Evas_Object *obj)
903 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
904 return tt->free_size;