From 54f1e32c172769d3cd8a5ad1ea89035b2af246b0 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 26 Jul 2011 09:38:23 +0000 Subject: [PATCH] THE MOST ANTICIPATED COMMIT OF 2011: HUGENORMOUS TOOLTIPS!!!!!! these bad boys are so big and pixelthirsty they can't be constrained by a regular canvas or window, they use OVERRIDE REDIRECT WINDOWS. not only that, they totally exceed the boundaries of what a reasonable function name length could be. 50 character function name limit? puh-leeze. these guys don't care what side of the screen they're even on so long as they get to wade into the thick of the action and block out each and every crappy non-efl application behind them. and that's when they're in good moods. you don't even want to know what happens when you piss these guys off. SVN revision: 61735 --- legacy/elementary/src/bin/test_tooltip.c | 21 ++-- legacy/elementary/src/lib/Elementary.h.in | 71 ++++++++++++- legacy/elementary/src/lib/elm_gengrid.c | 19 +++- legacy/elementary/src/lib/elm_genlist.c | 19 +++- legacy/elementary/src/lib/elm_list.c | 14 +++ legacy/elementary/src/lib/elm_widget.c | 24 ++++- legacy/elementary/src/lib/elm_widget.h | 8 ++ legacy/elementary/src/lib/els_tooltip.c | 121 ++++++++++++++++++---- 8 files changed, 255 insertions(+), 42 deletions(-) diff --git a/legacy/elementary/src/bin/test_tooltip.c b/legacy/elementary/src/bin/test_tooltip.c index 2a941cf5ef..af84c7711d 100644 --- a/legacy/elementary/src/bin/test_tooltip.c +++ b/legacy/elementary/src/bin/test_tooltip.c @@ -108,10 +108,11 @@ gltt_label_get(void *data, static Evas_Object * _tt_item_icon(void *data __UNUSED__, - Evas_Object *obj, + Evas_Object *obj __UNUSED__, + Evas_Object *tt, void *item __UNUSED__) { - Evas_Object *ic = elm_icon_add(obj); + Evas_Object *ic = elm_icon_add(tt); char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); @@ -123,10 +124,11 @@ _tt_item_icon(void *data __UNUSED__, static Evas_Object * _tt_item_icon2(void *data __UNUSED__, - Evas_Object *obj, + Evas_Object *obj __UNUSED__, + Evas_Object *tt, void *item __UNUSED__) { - Evas_Object *ic = elm_icon_add(obj); + Evas_Object *ic = elm_icon_add(tt); char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); @@ -197,9 +199,10 @@ _tt_text_replace_timed(void *data __UNUSED__, static Evas_Object * _tt_icon(void *data __UNUSED__, - Evas_Object *obj) + Evas_Object *obj __UNUSED__, + Evas_Object *tt) { - Evas_Object *ic = elm_icon_add(obj); + Evas_Object *ic = elm_icon_add(tt); char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); @@ -211,9 +214,10 @@ _tt_icon(void *data __UNUSED__, static Evas_Object * _tt_icon2(void *data __UNUSED__, - Evas_Object *obj) + Evas_Object *obj __UNUSED__, + Evas_Object *tt) { - Evas_Object *ic = elm_icon_add(obj); + Evas_Object *ic = elm_icon_add(tt); char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/icon_00.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); @@ -447,6 +451,7 @@ test_tooltip(void *data __UNUSED__, elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL); li = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL); elm_list_item_tooltip_content_cb_set(li, _tt_item_icon2, NULL, NULL); + elm_list_item_tooltip_size_restrict_disable(li, EINA_TRUE); evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL); diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 195f340cd7..0036a82b35 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -332,17 +332,19 @@ extern "C" { * Called back when a widget's tooltip is activated and needs content. * @param data user-data given to elm_object_tooltip_content_cb_set() * @param obj owner widget. + * @param tooltip The tooltip object (affix content to this!) */ - typedef Evas_Object *(*Elm_Tooltip_Content_Cb) (void *data, Evas_Object *obj); + typedef Evas_Object *(*Elm_Tooltip_Content_Cb) (void *data, Evas_Object *obj, Evas_Object *tooltip); /** * Called back when a widget's item tooltip is activated and needs content. * @param data user-data given to elm_object_tooltip_content_cb_set() * @param obj owner widget. + * @param tooltip The tooltip object (affix content to this!) * @param item context dependent item. As an example, if tooltip was * set on Elm_List_Item, then it is of this type. */ - typedef Evas_Object *(*Elm_Tooltip_Item_Content_Cb) (void *data, Evas_Object *obj, void *item); + typedef Evas_Object *(*Elm_Tooltip_Item_Content_Cb) (void *data, Evas_Object *obj, Evas_Object *tooltip, void *item); typedef Eina_Bool (*Elm_Event_Cb) (void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); @@ -5491,7 +5493,26 @@ extern "C" { * @ingroup Gengrid */ EAPI const char *elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1); - + /** + * @brief Disable size restrictions on an object's tooltip + * @param item The tooltip's anchor object + * @param disable If EINA_TRUE, size restrictions are disabled + * @return EINA_FALSE on failure, EINA_TRUE on success + * + * This function allows a tooltip to expand beyond its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable); + /** + * @brief Retrieve size restriction state of an object's tooltip + * @param item The tooltip's anchor object + * @return If EINA_TRUE, size restrictions are disabled + * + * This function returns whether a tooltip is allowed to expand beyond + * its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item); /** * Set the type of mouse pointer/cursor decoration to be shown, * when the mouse pointer is over the given gengrid widget item @@ -9217,6 +9238,8 @@ extern "C" { EAPI const char *elm_object_cursor_style_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_object_cursor_engine_only_set(Evas_Object *obj, Eina_Bool engine_only) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_object_cursor_engine_only_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable); EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_tooltip_size_restrict_disabled_get(const Evas_Object *obj); EINA_ARG_NONNULL(1); /* cursors */ EAPI int elm_cursor_engine_only_get(void); @@ -10225,6 +10248,28 @@ extern "C" { */ EAPI void elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text) EINA_ARG_NONNULL(1); + + /** + * @brief Disable size restrictions on an object's tooltip + * @param item The tooltip's anchor object + * @param disable If EINA_TRUE, size restrictions are disabled + * @return EINA_FALSE on failure, EINA_TRUE on success + * + * This function allows a tooltip to expand beyond its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable) EINA_ARG_NONNULL(1); + /** + * @brief Retrieve size restriction state of an object's tooltip + * @param obj The tooltip's anchor object + * @return If EINA_TRUE, size restrictions are disabled + * + * This function returns whether a tooltip is allowed to expand beyond + * its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item) EINA_ARG_NONNULL(1); + /** * Set the content to be shown in the tooltip item. * @@ -10710,6 +10755,26 @@ extern "C" { EAPI void elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); EAPI void elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item, const char *style) EINA_ARG_NONNULL(1); EAPI const char *elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); + /** + * @brief Disable size restrictions on an object's tooltip + * @param item The tooltip's anchor object + * @param disable If EINA_TRUE, size restrictions are disabled + * @return EINA_FALSE on failure, EINA_TRUE on success + * + * This function allows a tooltip to expand beyond its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_genlist_item_tooltip_size_restrict_disable(Elm_Genlist_Item *item, Eina_Bool disable); + /** + * @brief Retrieve size restriction state of an object's tooltip + * @param item The tooltip's anchor object + * @return If EINA_TRUE, size restrictions are disabled + * + * This function returns whether a tooltip is allowed to expand beyond + * its parant window's canvas. + * It will instead be limited only by the size of the display. + */ + EAPI Eina_Bool elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Genlist_Item *item); EAPI void elm_genlist_item_cursor_set(Elm_Genlist_Item *item, const char *cursor) EINA_ARG_NONNULL(1); EAPI const char *elm_genlist_item_cursor_get(const Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); EAPI void elm_genlist_item_cursor_unset(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index cc0bf6e93e..d80585b452 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -2142,10 +2142,11 @@ elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item) static Evas_Object * _elm_gengrid_item_label_create(void *data, - Evas_Object *obj, + Evas_Object *obj __UNUSED__, + Evas_Object *tooltip, void *item __UNUSED__) { - Evas_Object *label = elm_label_add(obj); + Evas_Object *label = elm_label_add(tooltip); if (!label) return NULL; elm_object_style_set(label, "tooltip"); @@ -2235,6 +2236,20 @@ elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item) return item->tooltip.style; } +EAPI Eina_Bool +elm_gengrid_item_tooltip_size_restrict_disable(Elm_Gengrid_Item *item, Eina_Bool disable) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disable(item, disable); +} + +EAPI Eina_Bool +elm_gengrid_item_tooltip_size_restrict_disabled_get(const Elm_Gengrid_Item *item) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disabled_get(item); +} + EAPI void elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item, const char *cursor) diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index f5e9d677c9..7ec6e3a507 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -4920,10 +4920,11 @@ elm_genlist_item_item_class_get(const Elm_Genlist_Item *it) static Evas_Object * _elm_genlist_item_label_create(void *data, - Evas_Object *obj, + Evas_Object *obj __UNUSED__, + Evas_Object *tooltip, void *item __UNUSED__) { - Evas_Object *label = elm_label_add(obj); + Evas_Object *label = elm_label_add(tooltip); if (!label) return NULL; elm_object_style_set(label, "tooltip"); @@ -5080,6 +5081,20 @@ elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item) return item->tooltip.style; } +EAPI Eina_Bool +elm_genlist_item_tooltip_size_restrict_disable(Elm_Genlist_Item *item, Eina_Bool disable) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disable(item, disable); +} + +EAPI Eina_Bool +elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Genlist_Item *item) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disabled_get(item); +} + /** * Set the cursor to be shown when mouse is over the genlist item * diff --git a/legacy/elementary/src/lib/elm_list.c b/legacy/elementary/src/lib/elm_list.c index e9a094ac18..b53b933ac3 100644 --- a/legacy/elementary/src/lib/elm_list.c +++ b/legacy/elementary/src/lib/elm_list.c @@ -1905,6 +1905,20 @@ elm_list_item_tooltip_unset(Elm_List_Item *item) elm_widget_item_tooltip_unset(item); } +EAPI Eina_Bool +elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable) +{ + ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disable(item, disable); +} + +EAPI Eina_Bool +elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item) +{ + ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE); + return elm_widget_item_tooltip_size_restrict_disabled_get(item); +} + EAPI void elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style) { diff --git a/legacy/elementary/src/lib/elm_widget.c b/legacy/elementary/src/lib/elm_widget.c index dc58c275c6..9f321e4a2c 100644 --- a/legacy/elementary/src/lib/elm_widget.c +++ b/legacy/elementary/src/lib/elm_widget.c @@ -2460,10 +2460,11 @@ struct _Elm_Widget_Item_Tooltip static Evas_Object * _elm_widget_item_tooltip_label_create(void *data, - Evas_Object *obj, + Evas_Object *obj __UNUSED__, + Evas_Object *tooltip, void *item __UNUSED__) { - Evas_Object *label = elm_label_add(obj); + Evas_Object *label = elm_label_add(tooltip); if (!label) return NULL; elm_object_style_set(label, "tooltip"); @@ -2507,10 +2508,11 @@ _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, static Evas_Object * _elm_widget_item_tooltip_create(void *data, - Evas_Object *obj) + Evas_Object *obj, + Evas_Object *tooltip) { Elm_Widget_Item_Tooltip *wit = data; - return wit->func((void *)wit->data, obj, wit->item); + return wit->func((void *)wit->data, obj, tooltip, wit->item); } static void @@ -2625,6 +2627,20 @@ _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, elm_object_tooltip_style_set(item->view, style); } +EAPI Eina_Bool +_elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_tooltip_size_restrict_disable(item->view, disable); +} + +EAPI Eina_Bool +_elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE); + return elm_tooltip_size_restrict_disabled_get(item->view); +} + /** * @internal * diff --git a/legacy/elementary/src/lib/elm_widget.h b/legacy/elementary/src/lib/elm_widget.h index 523ba25297..b8885beb42 100644 --- a/legacy/elementary/src/lib/elm_widget.h +++ b/legacy/elementary/src/lib/elm_widget.h @@ -324,6 +324,8 @@ EAPI void _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, c EAPI void _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb); EAPI void _elm_widget_item_tooltip_unset(Elm_Widget_Item *item); EAPI void _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style); +EAPI Eina_Bool _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable); +EAPI Eina_Bool _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item); EAPI const char *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item); EAPI void _elm_widget_item_cursor_set(Elm_Widget_Item *item, const char *cursor); EAPI const char *_elm_widget_item_cursor_get(const Elm_Widget_Item *item); @@ -403,6 +405,12 @@ EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out */ #define elm_widget_item_tooltip_style_set(item, style) \ _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style) + +#define elm_widget_item_tooltip_size_restrict_disable(item, disable) \ + _elm_widget_item_tooltip_size_restrict_disable((Elm_Widget_Item *)item, disable) + +#define elm_widget_item_tooltip_size_restrict_disabled_get(item) \ + _elm_widget_item_tooltip_size_restrict_disabled_get((Elm_Widget_Item *)item) /** * Convenience function to query item's tooltip style. * @see _elm_widget_item_tooltip_style_get() diff --git a/legacy/elementary/src/lib/els_tooltip.c b/legacy/elementary/src/lib/els_tooltip.c index 82fd15c8ae..357b0d7ba3 100644 --- a/legacy/elementary/src/lib/els_tooltip.c +++ b/legacy/elementary/src/lib/els_tooltip.c @@ -35,9 +35,10 @@ struct _Elm_Tooltip Evas_Smart_Cb del_cb; const void *data; const char *style; - Evas *evas; + Evas *evas, *tt_evas; Evas_Object *eventarea, *owner; Evas_Object *tooltip, *content; + Evas_Object *tt_win; Ecore_Timer *show_timer; Ecore_Timer *hide_timer; Ecore_Job *reconfigure_job; @@ -50,6 +51,7 @@ struct _Elm_Tooltip double hide_timeout; /* from theme */ Eina_Bool visible_lock:1; Eina_Bool changed_style:1; + Eina_Bool free_size : 1; }; static void _elm_tooltip_reconfigure(Elm_Tooltip *tt); @@ -109,10 +111,24 @@ _elm_tooltip_show(Elm_Tooltip *tt) _elm_tooltip_reconfigure_job_start(tt); return; } - tt->tooltip = edje_object_add(tt->evas); + if (tt->free_size) + { + tt->tt_win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC); + elm_win_transparent_set(tt->tt_win, EINA_TRUE); + elm_win_override_set(tt->tt_win, EINA_TRUE); + elm_win_borderless_set(tt->tt_win, EINA_TRUE); + elm_object_focus_allow_set(tt->tt_win, EINA_FALSE); + tt->tt_evas = evas_object_evas_get(tt->tt_win); + tt->tooltip = edje_object_add(tt->tt_evas); + evas_object_move(tt->tooltip, 0, 0); + elm_win_resize_object_add(tt->tt_win, tt->tooltip); + evas_object_show(tt->tt_win); + } + else + tt->tooltip = edje_object_add(tt->evas); if (!tt->tooltip) return; - evas_object_layer_set(tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP); + evas_object_layer_set(tt->tt_win ?: tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP); evas_object_event_callback_add (tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt); @@ -162,7 +178,11 @@ _elm_tooltip_hide(Elm_Tooltip *tt) evas_object_event_callback_del_full (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt); - evas_object_del(tt->tooltip); + if (tt->tt_win) evas_object_del(tt->tt_win); + else evas_object_del(tt->tooltip); + + tt->tt_win = NULL; + tt->tt_evas = NULL; tt->tooltip = NULL; } @@ -221,10 +241,13 @@ _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt) static void _elm_tooltip_reconfigure(Elm_Tooltip *tt) { - Evas_Coord ox, oy, ow, oh, px, py, tx, ty, tw, th, cw, ch; + Evas_Coord ox, oy, ow, oh, px, py, tx, ty, tw, th, cw = 0, ch = 0; Evas_Coord eminw, eminh, ominw, ominh; double rel_x, rel_y; Eina_Bool inside_eventarea; +#ifdef HAVE_ELEMENTARY_X + Ecore_X_Window xwin; +#endif _elm_tooltip_reconfigure_job_stop(tt); @@ -234,11 +257,14 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt) { const char *style = tt->style ? tt->style : "default"; const char *str; - if (!_elm_theme_object_set - (tt->owner, tt->tooltip, "tooltip", "base", style)) + if (!_elm_theme_object_set(tt->owner, tt->tooltip, "tooltip", "base", style)) { ERR("Could not apply the theme to the tooltip! style=%s", style); - evas_object_del(tt->tooltip); + if (tt->tt_win) evas_object_del(tt->tt_win); + else evas_object_del(tt->tooltip); + + tt->tt_win = NULL; + tt->tt_evas = NULL; tt->tooltip = NULL; return; } @@ -272,31 +298,34 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt) evas_object_pass_events_set(tt->tooltip, EINA_TRUE); tt->changed_style = EINA_FALSE; if (tt->tooltip) - edje_object_part_swallow - (tt->tooltip, "elm.swallow.content", tt->content); + edje_object_part_swallow(tt->tooltip, "elm.swallow.content", + tt->content); edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm"); } if (!tt->content) { - tt->content = tt->func((void *)tt->data, tt->owner); + tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner); if (!tt->content) { WRN("could not create tooltip content!"); - evas_object_del(tt->tooltip); + if (tt->tt_win) evas_object_del(tt->tt_win); + else evas_object_del(tt->tooltip); + + tt->tt_win = NULL; + tt->tt_evas = NULL; tt->tooltip = NULL; return; } + evas_object_show(tt->content); evas_object_layer_set(tt->content, ELM_OBJECT_LAYER_TOOLTIP); evas_object_pass_events_set(tt->content, EINA_TRUE); edje_object_part_swallow (tt->tooltip, "elm.swallow.content", tt->content); - evas_object_event_callback_add - (tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + evas_object_event_callback_add(tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _elm_tooltip_content_changed_hints_cb, tt); - evas_object_event_callback_add - (tt->content, EVAS_CALLBACK_DEL, + evas_object_event_callback_add(tt->content, EVAS_CALLBACK_DEL, _elm_tooltip_content_del_cb, tt); } @@ -310,16 +339,30 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt) if (ominw < 1) ominw = 10; /* at least it is noticeable */ if (ominh < 1) ominh = 10; /* at least it is noticeable */ - edje_object_size_min_restricted_calc - (tt->tooltip, &tw, &th, ominw, ominh); + edje_object_size_min_restricted_calc(tt->tooltip, &tw, &th, ominw, ominh); - evas_output_size_get(tt->evas, &cw, &ch); +#ifdef HAVE_ELEMENTARY_X + if (tt->tt_win) + { + xwin = elm_win_xwindow_get(elm_object_top_widget_get(tt->owner)); + if (xwin) + { + xwin = ecore_x_window_root_get(xwin); + ecore_x_randr_screen_current_size_get(xwin, &cw, &ch, NULL, NULL); + } + } + if (!cw) +#endif + evas_output_size_get(tt->tt_evas ?: tt->evas, &cw, &ch); evas_pointer_canvas_xy_get(tt->evas, &px, &py); evas_object_geometry_get(tt->eventarea, &ox, &oy, &ow, &oh); inside_eventarea = ((px >= ox) && (py >= oy) && (px <= ox + ow) && (py <= oy + oh)); +#ifdef HAVE_ELEMENTARY_X + if (tt->tt_win) ecore_x_pointer_xy_get(xwin, &px, &py); +#endif if (inside_eventarea) { tx = px; @@ -347,8 +390,8 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt) else if (ty + th >= ch - tt->pad.by) ty = ch - th - tt->pad.by; } - evas_object_move(tt->tooltip, tx, ty); - evas_object_resize(tt->tooltip, tw, th); + evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty); + evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th); evas_object_show(tt->tooltip); if (inside_eventarea) @@ -468,9 +511,9 @@ _elm_tooltip_obj_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void } static Evas_Object * -_elm_tooltip_label_create(void *data, Evas_Object *obj) +_elm_tooltip_label_create(void *data, Evas_Object *obj __UNUSED__, Evas_Object *tooltip) { - Evas_Object *label = elm_label_add(obj); + Evas_Object *label = elm_label_add(tooltip); if (!label) return NULL; elm_object_style_set(label, "tooltip"); @@ -786,3 +829,35 @@ elm_tooltip_delay_set(double delay) _elm_config->tooltip_delay = delay; return EINA_TRUE; } + +/** + * @brief Disable size restrictions on an object's tooltip + * @param obj The tooltip's anchor object + * @param disable If EINA_TRUE, size restrictions are disabled + * @return EINA_FALSE on failure, EINA_TRUE on success + * + * This function allows a tooltip to expand beyond its parant window's canvas. + * It will instead be limited only by the size of the display. + */ +EAPI Eina_Bool +elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable) +{ + ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE); + return tt->free_size = disable; +} + +/** + * @brief Retrieve size restriction state of an object's tooltip + * @param obj The tooltip's anchor object + * @return If EINA_TRUE, size restrictions are disabled + * + * This function returns whether a tooltip is allowed to expand beyond + * its parant window's canvas. + * It will instead be limited only by the size of the display. + */ +EAPI Eina_Bool +elm_tooltip_size_restrict_disabled_get(const Evas_Object *obj) +{ + ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE); + return tt->free_size; +}