1 #include <Elementary.h>
6 # define STUPID(X) STR(X)
7 # define TTDBG(x...) fprintf(stderr, STUPID(__LINE__)": " x)
12 static const char _tooltip_key[] = "_elm_tooltip";
14 #define ELM_TOOLTIP_GET_OR_RETURN(tt, obj, ...) \
20 CRITICAL("Null pointer: " #obj); \
23 tt = evas_object_data_get((obj), _tooltip_key); \
26 ERR("Object does not have tooltip: " #obj); \
34 Elm_Tooltip_Content_Cb func;
39 Evas_Object *eventarea, *owner;
40 Evas_Object *tooltip, *content;
42 Ecore_Timer *show_timer;
43 Ecore_Timer *hide_timer;
44 Ecore_Job *reconfigure_job;
46 Evas_Coord x, y, bx, by;
51 double hide_timeout; /* from theme */
52 Eina_Bool visible_lock:1;
53 Eina_Bool changed_style:1;
54 Eina_Bool free_size : 1;
57 static void _elm_tooltip_reconfigure(Elm_Tooltip *tt);
58 static void _elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt);
59 static void _elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt);
60 static void _elm_tooltip_hide_anim_start(Elm_Tooltip *tt);
61 static void _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt);
62 static void _elm_tooltip_show_timer_stop(Elm_Tooltip *tt);
63 static void _elm_tooltip_hide(Elm_Tooltip *tt);
64 static void _elm_tooltip_data_clean(Elm_Tooltip *tt);
67 _elm_tooltip_content_changed_hints_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
69 _elm_tooltip_reconfigure_job_start(data);
73 _elm_tooltip_content_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
75 Elm_Tooltip *tt = data;
77 tt->visible_lock = EINA_FALSE;
78 if (tt->tooltip) _elm_tooltip_hide(tt);
82 _elm_tooltip_obj_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84 Elm_Tooltip *tt = data;
85 _elm_tooltip_reconfigure_job_start(tt);
89 _elm_tooltip_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
91 Elm_Tooltip *tt = data;
92 _elm_tooltip_reconfigure_job_start(tt);
96 _elm_tooltip_obj_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
98 Elm_Tooltip *tt = data;
99 _elm_tooltip_reconfigure_job_start(tt);
103 _elm_tooltip_show(Elm_Tooltip *tt)
105 _elm_tooltip_show_timer_stop(tt);
106 _elm_tooltip_hide_anim_stop(tt);
110 _elm_tooltip_reconfigure_job_start(tt);
115 tt->tt_win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
116 elm_win_borderless_set(tt->tt_win, EINA_TRUE);
117 elm_win_override_set(tt->tt_win, EINA_TRUE);
118 tt->tt_evas = evas_object_evas_get(tt->tt_win);
119 tt->tooltip = edje_object_add(tt->tt_evas);
120 evas_object_move(tt->tooltip, 0, 0);
121 elm_win_resize_object_add(tt->tt_win, tt->tooltip);
122 #ifdef HAVE_ELEMENTARY_X
123 ecore_x_window_shape_input_rectangle_set(elm_win_xwindow_get(tt->tt_win), 0, 0, 0, 0);
125 evas_object_show(tt->tt_win);
128 tt->tooltip = edje_object_add(tt->evas);
129 if (!tt->tooltip) return;
131 evas_object_layer_set(tt->tt_win ?: tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP);
133 evas_object_event_callback_add
134 (tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
135 evas_object_event_callback_add
136 (tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
137 evas_object_event_callback_add
138 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt);
140 tt->changed_style = EINA_TRUE;
141 _elm_tooltip_reconfigure_job_start(tt);
145 _elm_tooltip_content_del(Elm_Tooltip *tt)
147 if (!tt->content) return;
149 evas_object_event_callback_del_full
150 (tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
151 _elm_tooltip_content_changed_hints_cb, tt);
152 evas_object_event_callback_del_full
153 (tt->content, EVAS_CALLBACK_DEL,
154 _elm_tooltip_content_del_cb, tt);
155 evas_object_hide(tt->content);
156 evas_object_del(tt->content);
162 _elm_tooltip_hide(Elm_Tooltip *tt)
165 _elm_tooltip_show_timer_stop(tt);
166 _elm_tooltip_hide_anim_stop(tt);
167 _elm_tooltip_reconfigure_job_stop(tt);
169 if (!tt->tooltip) return;
170 if (tt->visible_lock) return;
172 _elm_tooltip_content_del(tt);
174 evas_object_event_callback_del_full
175 (tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
176 evas_object_event_callback_del_full
177 (tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
178 evas_object_event_callback_del_full
179 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt);
181 del = tt->tt_win ?: tt->tooltip;
186 evas_object_del(del);
190 _elm_tooltip_reconfigure_job(void *data)
192 Elm_Tooltip *tt = data;
193 tt->reconfigure_job = NULL;
194 _elm_tooltip_reconfigure(data);
198 _elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt)
200 if (!tt->reconfigure_job) return;
201 ecore_job_del(tt->reconfigure_job);
202 tt->reconfigure_job = NULL;
206 _elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt)
208 if (tt->reconfigure_job) ecore_job_del(tt->reconfigure_job);
209 tt->reconfigure_job = ecore_job_add(_elm_tooltip_reconfigure_job, tt);
213 _elm_tooltip_hide_anim_cb(void *data)
215 Elm_Tooltip *tt = data;
216 tt->hide_timer = NULL;
217 _elm_tooltip_hide(tt);
222 _elm_tooltip_hide_anim_start(Elm_Tooltip *tt)
225 if (tt->hide_timer) return;
226 /* hide slightly faster when in window mode to look less stupid */
227 if ((tt->hide_timeout > 0) && tt->tt_win) extra = 0.1;
228 edje_object_signal_emit(tt->tooltip, "elm,action,hide", "elm");
229 tt->hide_timer = ecore_timer_add
230 (tt->hide_timeout - extra, _elm_tooltip_hide_anim_cb, tt);
234 _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt)
236 if (!tt->hide_timer) return;
238 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
239 ecore_timer_del(tt->hide_timer);
240 tt->hide_timer = NULL;
244 _elm_tooltip_reconfigure(Elm_Tooltip *tt)
246 Evas_Coord ox, oy, ow, oh, px, py, tx, ty, tw, th, cw = 0, ch = 0;
247 Evas_Coord eminw, eminh, ominw, ominh;
249 Eina_Bool inside_eventarea;
251 _elm_tooltip_reconfigure_job_stop(tt);
253 if (tt->hide_timer) return;
254 if (!tt->tooltip) return;
255 if (tt->changed_style)
257 const char *style = tt->style ? tt->style : "default";
259 if (!_elm_theme_object_set(tt->tt_win ? NULL : tt->owner, tt->tooltip, "tooltip", "base", style))
261 ERR("Could not apply the theme to the tooltip! style=%s", style);
262 if (tt->tt_win) evas_object_del(tt->tt_win);
263 else evas_object_del(tt->tooltip);
277 tt->hide_timeout = 0.0;
279 str = edje_object_data_get(tt->tooltip, "transparent");
281 { /* FIXME: hardcoded here is bad */
282 if (str && (!strcmp(str, "enabled")))
284 elm_win_alpha_set(tt->tt_win, EINA_TRUE);
288 elm_win_alpha_set(tt->tt_win, EINA_FALSE);
292 str = edje_object_data_get(tt->tooltip, "pad_x");
293 if (str) tt->pad.x = atoi(str);
294 str = edje_object_data_get(tt->tooltip, "pad_y");
295 if (str) tt->pad.y = atoi(str);
297 str = edje_object_data_get(tt->tooltip, "pad_border_x");
298 if (str) tt->pad.bx = atoi(str);
299 str = edje_object_data_get(tt->tooltip, "pad_border_y");
300 if (str) tt->pad.by = atoi(str);
302 str = edje_object_data_get(tt->tooltip, "hide_timeout");
305 tt->hide_timeout = atof(str);
306 if (tt->hide_timeout < 0.0) tt->hide_timeout = 0.0;
309 evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
310 tt->changed_style = EINA_FALSE;
312 edje_object_part_swallow(tt->tooltip, "elm.swallow.content",
315 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
320 tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner);
323 WRN("could not create tooltip content!");
324 if (tt->tt_win) evas_object_del(tt->tt_win);
325 else evas_object_del(tt->tooltip);
332 evas_object_show(tt->content);
333 evas_object_layer_set(tt->content, ELM_OBJECT_LAYER_TOOLTIP);
334 evas_object_pass_events_set(tt->content, EINA_TRUE);
335 edje_object_part_swallow
336 (tt->tooltip, "elm.swallow.content", tt->content);
337 evas_object_event_callback_add(tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
338 _elm_tooltip_content_changed_hints_cb, tt);
339 evas_object_event_callback_add(tt->content, EVAS_CALLBACK_DEL,
340 _elm_tooltip_content_del_cb, tt);
343 TTDBG("*******RECALC\n");
344 evas_object_size_hint_min_get(tt->content, &ominw, &ominh);
345 edje_object_size_min_get(tt->tooltip, &eminw, &eminh);
347 if (eminw && (ominw < eminw)) ominw = eminw;
348 if (eminw && (ominh < eminh)) ominh = eminh;
350 if (ominw < 1) ominw = 10; /* at least it is noticeable */
351 if (ominh < 1) ominh = 10; /* at least it is noticeable */
353 edje_object_size_min_restricted_calc(tt->tooltip, &tw, &th, ominw, ominh);
354 TTDBG("TTSIZE: tw=%d,th=%d,ominw=%d,ominh=%d\n", tw, th, ominw, ominh);
357 elm_win_screen_size_get(elm_object_top_widget_get(tt->owner), NULL, NULL, &cw, &ch);
359 evas_output_size_get(tt->tt_evas ?: tt->evas, &cw, &ch);
360 TTDBG("SCREEN: cw=%d,ch=%d\n", cw, ch);
362 evas_object_geometry_get(tt->eventarea, &ox, &oy, &ow, &oh);
363 TTDBG("EVENTAREA: ox=%d,oy=%d,ow=%d,oh=%d\n", ox, oy, ow, oh);
368 Evas_Object *win = elm_object_top_widget_get(tt->owner);
369 #ifdef HAVE_ELEMENTARY_X
370 Ecore_X_Window xwin = elm_win_xwindow_get(win);
371 ecore_x_pointer_xy_get(xwin, &px, &py);
373 elm_win_screen_position_get(win, &x, &y);
380 evas_pointer_canvas_xy_get(tt->evas, &px, &py);
381 TTDBG("POINTER: px=%d,py=%d\n", px, py);
382 inside_eventarea = ((px >= ox) && (py >= oy) &&
383 (px <= ox + ow) && (py <= oy + oh));
384 if (inside_eventarea)
386 /* try to position bottom right corner at pointer */
389 TTDBG("INIT (EVENTAREA)\n");
393 /* try centered on middle of eventarea */
394 tx = ox + (ow / 2) - (tw / 2);
395 if (0 > (th - oy - oh)) ty = oy + th;
397 TTDBG("INIT (INTERPRETED)\n");
399 TTDBG("ADJUST (POINTER): tx=%d,ty=%d\n", tx, ty);
402 /* if we're offscreen, try to flip over the Y axis */
403 if (abs((tx + 2 * tw) - cw) < abs(tx))
406 else if ((tx > px) && (px > tw))
413 /* if we're offscreen, try to flip over the X axis */
414 if (abs((ty + 2 * th) - ch) < abs(ty))
417 else if ((ty > py) && (py > th))
422 TTDBG("ADJUST (FLIP): tx=%d,ty=%d\n", tx, ty);
423 if (inside_eventarea)
425 if ((tx == px) && ((tx + tw + tt->pad.x < cw) || (tx + tw > cw))) tx += tt->pad.x;
426 else if ((tx - tt->pad.x > 0) || (tx < 0)) tx -= tt->pad.x;
427 if ((ty == py) && ((ty + th + tt->pad.y < ch) || (ty + th > ch))) ty += tt->pad.y;
428 else if ((ty - tt->pad.y > 0) || (ty < 0)) ty -= tt->pad.y;
430 TTDBG("PAD: tx=%d,ty=%d\n", tx, ty);
431 if (tt->pad.bx * 2 + tw < cw)
433 if (tx < tt->pad.bx) tx = tt->pad.bx;
434 else if ((tx >= tw) && (tx + tt->pad.bx <= cw)) tx += tt->pad.bx;
435 else if (tx - tt->pad.bx >= 0) tx -= tt->pad.bx;
437 else if (tx < 0) tx -= tt->pad.bx;
438 else if (tx > cw) tx += tt->pad.bx;
439 if (tt->pad.by * 2 + th < ch)
441 if (ty < tt->pad.by) ty = tt->pad.by;
442 else if ((ty >= th) && (ty + tt->pad.by <= ch)) ty += tt->pad.by;
443 else if (ty - tt->pad.by >= 0) ty -= tt->pad.by;
445 else if (ty < 0) ty -= tt->pad.by;
446 else if (ty > ch) ty += tt->pad.by;
447 TTDBG("PAD (BORDER): tx=%d,ty=%d\n", tx, ty);
448 if ((tx < 0) || (ty < 0))
450 TTDBG("POSITIONING FAILED! THIS IS A BUG SOMEWHERE!\n");
453 evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty);
454 evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th);
455 evas_object_show(tt->tooltip);
457 if (inside_eventarea)
459 rel_x = (px - tx) / (double)tw;
460 rel_y = (py - ty) / (double)th;
464 rel_x = (ox + (ow / 2) - tx) / (double)tw;
465 rel_y = (oy + (oh / 2) - ty) / (double)th;
468 #define FDIF(a, b) (fabs((a) - (b)) > 0.0001)
469 if ((FDIF(rel_x, tt->rel_pos.x)) || (FDIF(rel_y, tt->rel_pos.y)))
471 Edje_Message_Float_Set *msg;
473 msg = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double));
477 tt->rel_pos.x = rel_x;
478 tt->rel_pos.y = rel_y;
480 edje_object_message_send(tt->tooltip, EDJE_MESSAGE_FLOAT_SET, 1, msg);
486 _elm_tooltip_show_timer_stop(Elm_Tooltip *tt)
488 if (!tt->show_timer) return;
489 ecore_timer_del(tt->show_timer);
490 tt->show_timer = NULL;
494 _elm_tooltip_timer_show_cb(void *data)
496 Elm_Tooltip *tt = data;
497 tt->show_timer = NULL;
498 _elm_tooltip_show(tt);
499 return ECORE_CALLBACK_CANCEL;
503 _elm_tooltip_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
505 Elm_Tooltip *tt = data;
507 _elm_tooltip_hide_anim_stop(tt);
509 if ((tt->show_timer) || (tt->tooltip)) return;
511 tt->show_timer = ecore_timer_add
512 (_elm_config->tooltip_delay, _elm_tooltip_timer_show_cb, tt);
516 _elm_tooltip_obj_mouse_out_cb(Elm_Tooltip *tt, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Out *event __UNUSED__)
518 if (tt->visible_lock) return;
522 _elm_tooltip_show_timer_stop(tt);
525 _elm_tooltip_hide_anim_start(tt);
528 static void _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
531 _elm_tooltip_unset(Elm_Tooltip *tt)
533 tt->visible_lock = EINA_FALSE;
534 _elm_tooltip_hide(tt);
535 _elm_tooltip_data_clean(tt);
539 evas_object_event_callback_del_full
540 (tt->eventarea, EVAS_CALLBACK_MOUSE_IN,
541 _elm_tooltip_obj_mouse_in_cb, tt);
542 evas_object_event_callback_del_full
543 (tt->eventarea, EVAS_CALLBACK_MOUSE_OUT,
544 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
545 evas_object_event_callback_del_full
546 (tt->eventarea, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
548 evas_object_data_del(tt->eventarea, _tooltip_key);
552 evas_object_event_callback_del_full
553 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
554 elm_widget_tooltip_del(tt->owner, tt);
557 eina_stringshare_del(tt->style);
562 _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
564 Elm_Tooltip *tt = data;
565 if (tt->eventarea == obj) tt->eventarea = NULL;
566 if (tt->owner == obj) tt->owner = NULL;
567 _elm_tooltip_unset(tt);
571 _elm_tooltip_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip)
573 Evas_Object *label = elm_label_add(tooltip);
576 elm_object_style_set(label, "tooltip");
577 elm_object_text_set(label, data);
582 _elm_tooltip_trans_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip)
584 Evas_Object *label = elm_label_add(tooltip);
585 const char **text = data;
588 elm_object_style_set(label, "tooltip");
589 elm_object_domain_translatable_text_set(label, text[0], text[1]);
594 _elm_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
596 eina_stringshare_del(data);
600 _elm_tooltip_trans_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
602 const char **text = data;
603 eina_stringshare_del(text[0]);
604 eina_stringshare_del(text[1]);
609 _elm_tooltip_data_clean(Elm_Tooltip *tt)
611 if (tt->del_cb) tt->del_cb((void *)tt->data, tt->owner, NULL);
613 _elm_tooltip_content_del(tt);
620 * Notify tooltip should recalculate its theme.
624 elm_tooltip_theme(Elm_Tooltip *tt)
626 if (!tt->tooltip) return;
627 tt->changed_style = EINA_TRUE;
628 _elm_tooltip_reconfigure_job_start(tt);
633 * Set the content to be shown in the tooltip object for specific event area.
635 * Setup the tooltip to object. The object @a eventarea can have only
636 * one tooltip, so any previous tooltip data is removed. @p func(with
637 * @p data) will be called every time that need show the tooltip and
638 * it should return a valid Evas_Object. This object is then managed
639 * fully by tooltip system and is deleted when the tooltip is gone.
641 * This is an internal function that is used by objects with sub-items
642 * that want to provide different tooltips for each of them. The @a
643 * owner object should be an elm_widget and will be used to track
644 * theme changes and to feed @a func and @a del_cb. The @a eventarea
645 * may be any object and is the one that should be used later on with
646 * elm_object_tooltip apis, such as elm_object_tooltip_hide(),
647 * elm_object_tooltip_show() or elm_object_tooltip_unset().
649 * @param eventarea the object being attached a tooltip.
650 * @param owner the elm_widget that owns this object, will be used to
651 * track theme changes and to be used in @a func or @a del_cb.
652 * @param func the function used to create the tooltip contents. The
653 * @a Evas_Object parameters will receive @a owner as value.
654 * @param data what to provide to @a func as callback data/context.
655 * @param del_cb called when data is not needed anymore, either when
656 * another callback replaces @p func, the tooltip is unset with
657 * elm_object_tooltip_unset() or the owner object @a obj
658 * dies. This callback receives as the first parameter the
659 * given @a data, and @c event_info is NULL.
665 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)
667 Elm_Tooltip *tt = NULL;
668 Eina_Bool just_created;
670 EINA_SAFETY_ON_NULL_GOTO(owner, error);
671 EINA_SAFETY_ON_NULL_GOTO(eventarea, error);
675 elm_object_tooltip_unset(eventarea);
679 tt = evas_object_data_get(eventarea, _tooltip_key);
682 if (tt->owner != owner)
684 if (tt->owner != eventarea)
685 evas_object_event_callback_del_full
686 (tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
688 elm_widget_tooltip_del(tt->owner, tt);
690 if (owner != eventarea)
691 evas_object_event_callback_add
692 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
694 elm_widget_tooltip_add(tt->owner, tt);
697 if ((tt->func == func) && (tt->data == data) &&
698 (tt->del_cb == del_cb))
700 _elm_tooltip_data_clean(tt);
701 just_created = EINA_FALSE;
705 tt = ELM_NEW(Elm_Tooltip);
709 tt->eventarea = eventarea;
710 tt->evas = evas_object_evas_get(eventarea);
711 evas_object_data_set(eventarea, _tooltip_key, tt);
713 just_created = EINA_TRUE;
715 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_IN,
716 _elm_tooltip_obj_mouse_in_cb, tt);
717 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_OUT,
718 (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
719 evas_object_event_callback_add(eventarea, EVAS_CALLBACK_FREE,
720 _elm_tooltip_obj_free_cb, tt);
722 if (owner != eventarea)
723 evas_object_event_callback_add
724 (owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
726 elm_widget_tooltip_add(tt->owner, tt);
733 if (!just_created) _elm_tooltip_reconfigure_job_start(tt);
737 if (del_cb) del_cb((void *)data, owner, NULL);
741 * Force show tooltip of object
743 * @param obj Target object
745 * Force show the tooltip and disable hide on mouse_out.
746 * If another content is set as tooltip, the visible tooltip will hididen and
747 * showed again with new content.
748 * This can force show more than one tooltip at a time.
753 elm_object_tooltip_show(Evas_Object *obj)
755 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
756 tt->visible_lock = EINA_TRUE;
757 _elm_tooltip_show(tt);
761 * Force hide tooltip of object
763 * @param obj Target object
765 * Force hide the tooltip and (re)enable future mouse interations.
770 elm_object_tooltip_hide(Evas_Object *obj)
772 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
773 tt->visible_lock = EINA_FALSE;
774 _elm_tooltip_hide_anim_start(tt);
778 * Set the text to be shown in the tooltip object
780 * @param obj Target object
781 * @param text The text to set in the content
783 * Setup the text as tooltip to object. The object can have only one tooltip,
784 * so any previous tooltip data is removed.
785 * This method call internaly the elm_tooltip_content_cb_set().
790 elm_object_tooltip_text_set(Evas_Object *obj, const char *text)
792 EINA_SAFETY_ON_NULL_RETURN(obj);
793 EINA_SAFETY_ON_NULL_RETURN(text);
795 text = eina_stringshare_add(text);
796 elm_object_tooltip_content_cb_set
797 (obj, _elm_tooltip_label_create, text, _elm_tooltip_label_del_cb);
803 elm_object_tooltip_domain_translatable_text_set(Evas_Object *obj, const char *domain, const char *text)
806 EINA_SAFETY_ON_NULL_RETURN(obj);
807 EINA_SAFETY_ON_NULL_RETURN(text);
809 data = malloc(2 * sizeof(char *));
811 data[0] = eina_stringshare_add(domain);
812 data[1] = eina_stringshare_add(text);
813 elm_object_tooltip_content_cb_set
814 (obj, _elm_tooltip_trans_label_create, data,
815 _elm_tooltip_trans_label_del_cb);
819 * Set the content to be shown in the tooltip object
821 * Setup the tooltip to object. The object can have only one tooltip,
822 * so any previous tooltip data is removed. @p func(with @p data) will
823 * be called every time that need show the tooltip and it should
824 * return a valid Evas_Object. This object is then managed fully by
825 * tooltip system and is deleted when the tooltip is gone.
827 * @param obj the object being attached a tooltip.
828 * @param func the function used to create the tooltip contents.
829 * @param data what to provide to @a func as callback data/context.
830 * @param del_cb called when data is not needed anymore, either when
831 * another callback replaces @p func, the tooltip is unset with
832 * elm_object_tooltip_unset() or the owner object @a obj
833 * dies. This callback receives as the first parameter the
834 * given @a data, and @c event_info is NULL.
839 elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
841 elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb);
845 * Unset tooltip from object
847 * @param obj Target object
849 * Remove tooltip from object. The callback provided as del_cb to
850 * elm_object_tooltip_content_cb_set() will be called to notify it is
853 * @see elm_object_tooltip_content_cb_set()
858 elm_object_tooltip_unset(Evas_Object *obj)
860 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
861 _elm_tooltip_unset(tt);
865 * Sets a different style for this object tooltip.
867 * @note before you set a style you should define a tooltip with
868 * elm_object_tooltip_content_cb_set() or
869 * elm_object_tooltip_text_set().
871 * @param obj an object with tooltip already set.
872 * @param style the theme style to use (default, transparent, ...)
875 elm_object_tooltip_style_set(Evas_Object *obj, const char *style)
877 ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
878 if (!eina_stringshare_replace(&tt->style, style)) return;
879 elm_tooltip_theme(tt);
883 * Get the style for this object tooltip.
885 * @param obj an object with tooltip already set.
886 * @return style the theme style in use, defaults to "default". If the
887 * object does not have a tooltip set, then NULL is returned.
890 elm_object_tooltip_style_get(const Evas_Object *obj)
892 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, NULL);
893 return tt->style ? tt->style : "default";
897 * @brief Disable size restrictions on an object's tooltip
898 * @param obj The tooltip's anchor object
899 * @param disable If EINA_TRUE, size restrictions are disabled
900 * @return EINA_FALSE on failure, EINA_TRUE on success
902 * This function allows a tooltip to expand beyond its parent window's canvas.
903 * It will instead be limited only by the size of the display.
906 elm_object_tooltip_window_mode_set(Evas_Object *obj, Eina_Bool disable)
908 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
909 return tt->free_size = disable;
913 * @brief Retrieve size restriction state of an object's tooltip
914 * @param obj The tooltip's anchor object
915 * @return If EINA_TRUE, size restrictions are disabled
917 * This function returns whether a tooltip is allowed to expand beyond
918 * its parent window's canvas.
919 * It will instead be limited only by the size of the display.
922 elm_object_tooltip_window_mode_get(const Evas_Object *obj)
924 ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
925 return tt->free_size;