2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2011-11-23 20:16:03 -08:00
|
|
|
#ifdef ISCOMFITOR
|
|
|
|
# define STR(X) #X
|
|
|
|
# define STUPID(X) STR(X)
|
|
|
|
# define TTDBG(x...) fprintf(stderr, STUPID(__LINE__)": " x)
|
|
|
|
#else
|
|
|
|
# define TTDBG(X...)
|
|
|
|
#endif
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static const char _tooltip_key[] = "_elm_tooltip";
|
|
|
|
|
|
|
|
#define ELM_TOOLTIP_GET_OR_RETURN(tt, obj, ...) \
|
|
|
|
Elm_Tooltip *tt; \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (!(obj)) \
|
|
|
|
{ \
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Null pointer: " #obj); \
|
2010-09-10 17:52:33 -07:00
|
|
|
return __VA_ARGS__; \
|
|
|
|
} \
|
|
|
|
tt = evas_object_data_get((obj), _tooltip_key); \
|
|
|
|
if (!tt) \
|
|
|
|
{ \
|
|
|
|
ERR("Object does not have tooltip: " #obj); \
|
|
|
|
return __VA_ARGS__; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2017-09-19 01:05:15 -07:00
|
|
|
#define ELM_TOOLTIP_GET_OR_CREATE(tt, obj, ...) \
|
|
|
|
Elm_Tooltip *tt; \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (!(obj)) \
|
|
|
|
{ \
|
|
|
|
CRI("Null pointer: " #obj); \
|
|
|
|
return __VA_ARGS__; \
|
|
|
|
} \
|
|
|
|
tt = evas_object_data_get((obj), _tooltip_key); \
|
|
|
|
if (!tt) \
|
|
|
|
{ \
|
|
|
|
tt = _elm_tooltip_create((obj)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
struct _Elm_Tooltip
|
|
|
|
{
|
|
|
|
Elm_Tooltip_Content_Cb func;
|
|
|
|
Evas_Smart_Cb del_cb;
|
|
|
|
const void *data;
|
|
|
|
const char *style;
|
2011-07-26 02:38:23 -07:00
|
|
|
Evas *evas, *tt_evas;
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
Evas_Object *eventarea, *owner;
|
2010-09-10 17:52:33 -07:00
|
|
|
Evas_Object *tooltip, *content;
|
2011-07-26 02:38:23 -07:00
|
|
|
Evas_Object *tt_win;
|
2010-09-10 17:52:33 -07:00
|
|
|
Ecore_Timer *show_timer;
|
2010-09-12 10:24:45 -07:00
|
|
|
Ecore_Timer *hide_timer;
|
2010-09-10 17:52:33 -07:00
|
|
|
Ecore_Job *reconfigure_job;
|
2012-03-11 15:13:24 -07:00
|
|
|
Evas_Coord mouse_x, mouse_y;
|
2012-03-28 02:02:22 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, bx, by;
|
|
|
|
} pad;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
} rel_pos;
|
2013-11-27 07:27:13 -08:00
|
|
|
Elm_Tooltip_Orient orient; /** orientation for tooltip */
|
2014-02-20 03:44:19 -08:00
|
|
|
int move_freeze;
|
2016-01-02 04:46:53 -08:00
|
|
|
unsigned short ref;
|
2014-02-20 03:44:19 -08:00
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
double hide_timeout; /* from theme */
|
2010-09-10 17:52:33 -07:00
|
|
|
Eina_Bool visible_lock:1;
|
|
|
|
Eina_Bool changed_style:1;
|
2011-07-26 02:38:23 -07:00
|
|
|
Eina_Bool free_size : 1;
|
2016-01-02 04:46:53 -08:00
|
|
|
Eina_Bool unset_me : 1;
|
2010-09-10 17:52:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _elm_tooltip_reconfigure(Elm_Tooltip *tt);
|
|
|
|
static void _elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt);
|
|
|
|
static void _elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt);
|
2010-09-12 10:24:45 -07:00
|
|
|
static void _elm_tooltip_hide_anim_start(Elm_Tooltip *tt);
|
|
|
|
static void _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
static void _elm_tooltip_show_timer_stop(Elm_Tooltip *tt);
|
|
|
|
static void _elm_tooltip_hide(Elm_Tooltip *tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
static void _elm_tooltip_data_clean(Elm_Tooltip *tt);
|
2016-01-02 04:46:53 -08:00
|
|
|
static void _elm_tooltip_unset(Elm_Tooltip *tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_content_changed_hints_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
_elm_tooltip_reconfigure_job_start(data);
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("HINTS CHANGED\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_content_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
tt->content = NULL;
|
|
|
|
tt->visible_lock = EINA_FALSE;
|
2011-10-02 21:12:40 -07:00
|
|
|
if (tt->tooltip) _elm_tooltip_hide(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_obj_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("TT MOVED\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_obj_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("TT RESIZE\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-04 08:08:10 -07:00
|
|
|
_elm_tooltip_obj_mouse_move_cb(void *data, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED, void *event_info)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2014-09-04 08:08:10 -07:00
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
|
2012-03-11 15:13:24 -07:00
|
|
|
if (tt->mouse_x || tt->mouse_y)
|
|
|
|
{
|
|
|
|
if ((abs(ev->cur.output.x - tt->mouse_x) < 3) &&
|
|
|
|
(abs(ev->cur.output.y - tt->mouse_y) < 3))
|
|
|
|
{
|
|
|
|
TTDBG("MOUSE MOVE REJECTED!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tt->mouse_x = ev->cur.output.x;
|
|
|
|
tt->mouse_y = ev->cur.output.y;
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("MOUSE MOVED\n");
|
2012-03-11 15:13:24 -07:00
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_show(Elm_Tooltip *tt)
|
|
|
|
{
|
|
|
|
_elm_tooltip_show_timer_stop(tt);
|
2010-09-12 10:24:45 -07:00
|
|
|
_elm_tooltip_hide_anim_stop(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("TT SHOW\n");
|
2010-09-12 10:46:44 -07:00
|
|
|
if (tt->tooltip)
|
|
|
|
{
|
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("RECURSIVE JOB\n");
|
2010-09-12 10:46:44 -07:00
|
|
|
return;
|
|
|
|
}
|
2011-07-26 02:38:23 -07:00
|
|
|
if (tt->free_size)
|
|
|
|
{
|
2017-10-17 08:39:04 -07:00
|
|
|
tt->tt_win = elm_win_add(elm_win_get(tt->owner), "tooltip", ELM_WIN_TOOLTIP);
|
2011-07-26 23:43:51 -07:00
|
|
|
elm_win_override_set(tt->tt_win, EINA_TRUE);
|
2011-07-26 02:38:23 -07:00
|
|
|
tt->tt_evas = evas_object_evas_get(tt->tt_win);
|
|
|
|
tt->tooltip = edje_object_add(tt->tt_evas);
|
2012-08-05 23:43:59 -07:00
|
|
|
evas_object_size_hint_weight_set(tt->tooltip, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2011-07-26 02:38:23 -07:00
|
|
|
elm_win_resize_object_add(tt->tt_win, tt->tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tt->tooltip = edje_object_add(tt->evas);
|
2010-09-10 17:52:33 -07:00
|
|
|
if (!tt->tooltip) return;
|
2016-02-12 15:23:36 -08:00
|
|
|
evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2012-08-05 23:43:59 -07:00
|
|
|
if (tt->free_size)
|
|
|
|
evas_object_layer_set(tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP);
|
2010-09-11 10:01:40 -07:00
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_event_callback_add
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_event_callback_add
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
|
2014-02-20 03:44:19 -08:00
|
|
|
|
|
|
|
if (tt->move_freeze == 0)
|
2013-11-27 07:27:13 -08:00
|
|
|
{
|
2014-01-12 22:22:47 -08:00
|
|
|
//No movement of tooltip upon mouse move if orientation set
|
|
|
|
if ((tt->orient <= ELM_TOOLTIP_ORIENT_NONE) || (tt->orient >= ELM_TOOLTIP_ORIENT_LAST))
|
|
|
|
{
|
2014-09-04 08:08:10 -07:00
|
|
|
evas_object_event_callback_add(tt->eventarea,
|
|
|
|
EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_elm_tooltip_obj_mouse_move_cb, tt);
|
2014-01-12 22:22:47 -08:00
|
|
|
}
|
2013-11-27 07:27:13 -08:00
|
|
|
}
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->changed_style = EINA_TRUE;
|
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_content_del(Elm_Tooltip *tt)
|
|
|
|
{
|
|
|
|
if (!tt->content) return;
|
|
|
|
|
2012-03-11 15:21:41 -07:00
|
|
|
TTDBG("CONTENT DEL\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_elm_tooltip_content_changed_hints_cb, tt);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(tt->content, EVAS_CALLBACK_DEL,
|
|
|
|
_elm_tooltip_content_del_cb, tt);
|
2011-07-24 15:05:02 -07:00
|
|
|
evas_object_hide(tt->content);
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(tt->content, evas_object_del);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_hide(Elm_Tooltip *tt)
|
|
|
|
{
|
2011-10-02 21:12:40 -07:00
|
|
|
Evas_Object *del;
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("TT HIDE\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
_elm_tooltip_show_timer_stop(tt);
|
2010-09-12 10:24:45 -07:00
|
|
|
_elm_tooltip_hide_anim_stop(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
_elm_tooltip_reconfigure_job_stop(tt);
|
|
|
|
|
|
|
|
if (!tt->tooltip) return;
|
|
|
|
if (tt->visible_lock) return;
|
|
|
|
|
|
|
|
_elm_tooltip_content_del(tt);
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_event_callback_del_full
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_event_callback_del_full
|
2012-03-11 15:13:24 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_move_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2015-02-13 06:22:28 -08:00
|
|
|
del = tt->tt_win ? tt->tt_win : tt->tooltip;
|
2011-07-26 02:38:23 -07:00
|
|
|
|
|
|
|
tt->tt_win = NULL;
|
|
|
|
tt->tt_evas = NULL;
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->tooltip = NULL;
|
2011-10-02 21:12:40 -07:00
|
|
|
evas_object_del(del);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_reconfigure_job(void *data)
|
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
tt->reconfigure_job = NULL;
|
|
|
|
_elm_tooltip_reconfigure(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_reconfigure_job_stop(Elm_Tooltip *tt)
|
|
|
|
{
|
2013-05-29 05:12:04 -07:00
|
|
|
ELM_SAFE_FREE(tt->reconfigure_job, ecore_job_del);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_reconfigure_job_start(Elm_Tooltip *tt)
|
|
|
|
{
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_job_del(tt->reconfigure_job);
|
2011-11-21 11:12:35 -08:00
|
|
|
tt->reconfigure_job = ecore_job_add(_elm_tooltip_reconfigure_job, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_tooltip_hide_anim_cb(void *data)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
2010-09-12 10:24:45 -07:00
|
|
|
tt->hide_timer = NULL;
|
|
|
|
_elm_tooltip_hide(tt);
|
|
|
|
return EINA_FALSE;
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-12 10:24:45 -07:00
|
|
|
_elm_tooltip_hide_anim_start(Elm_Tooltip *tt)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2011-07-26 23:43:51 -07:00
|
|
|
double extra = 0;
|
2010-09-12 10:24:45 -07:00
|
|
|
if (tt->hide_timer) return;
|
2012-03-11 15:21:41 -07:00
|
|
|
TTDBG("HIDE START\n");
|
2011-07-26 23:43:51 -07:00
|
|
|
/* hide slightly faster when in window mode to look less stupid */
|
|
|
|
if ((tt->hide_timeout > 0) && tt->tt_win) extra = 0.1;
|
2018-04-26 04:24:09 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(tt->owner))
|
|
|
|
edje_object_signal_emit(tt->tooltip, "elm,action,hide", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(tt->tooltip, "efl,action,hide", "efl");
|
2010-09-12 10:24:45 -07:00
|
|
|
tt->hide_timer = ecore_timer_add
|
2011-07-26 23:43:51 -07:00
|
|
|
(tt->hide_timeout - extra, _elm_tooltip_hide_anim_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-12 10:24:45 -07:00
|
|
|
_elm_tooltip_hide_anim_stop(Elm_Tooltip *tt)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2010-09-12 10:24:45 -07:00
|
|
|
if (!tt->hide_timer) return;
|
2010-09-12 10:46:44 -07:00
|
|
|
if (tt->tooltip)
|
2018-04-26 04:24:09 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_is_legacy(tt->owner))
|
|
|
|
edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(tt->tooltip, "efl,action,show", "efl");
|
|
|
|
}
|
2013-05-22 23:54:49 -07:00
|
|
|
|
2013-05-29 05:12:04 -07:00
|
|
|
ELM_SAFE_FREE(tt->hide_timer, ecore_timer_del);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
2016-06-06 16:41:41 -07:00
|
|
|
static void
|
|
|
|
_elm_tooltip_reconfigure_orient(Elm_Tooltip *tt,
|
|
|
|
Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh,
|
|
|
|
Evas_Coord tw, Evas_Coord th, Evas_Coord cw, Evas_Coord ch)
|
|
|
|
{
|
|
|
|
Evas_Coord mx, my;
|
2017-02-27 03:13:06 -08:00
|
|
|
Evas_Coord dx, dy;
|
|
|
|
Evas_Coord tcw, tch;
|
|
|
|
Evas_Coord px, py;
|
2016-06-06 16:41:41 -07:00
|
|
|
|
|
|
|
switch (tt->orient)
|
|
|
|
{
|
|
|
|
case ELM_TOOLTIP_ORIENT_TOP_LEFT:
|
|
|
|
mx = ox - tw;
|
|
|
|
my = oy - th;
|
|
|
|
tt->rel_pos.x = 1.1;
|
|
|
|
tt->rel_pos.y = 1.1;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_TOP:
|
|
|
|
mx = ox + ((ow - tw) / 2);
|
|
|
|
my = oy - th;
|
|
|
|
tt->rel_pos.x = 0.5;
|
|
|
|
tt->rel_pos.y = 1.1;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_TOP_RIGHT:
|
|
|
|
mx = ox + ow;
|
|
|
|
my = oy - th;
|
|
|
|
tt->rel_pos.x = -1.1;
|
|
|
|
tt->rel_pos.y = 1.1;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_LEFT:
|
|
|
|
mx = ox - tw;
|
|
|
|
my = oy + ((oh - th) / 2);
|
|
|
|
tt->rel_pos.x = 1.1;
|
|
|
|
tt->rel_pos.y = 0.5;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_CENTER:
|
|
|
|
mx = ox + ((ow - tw) / 2);
|
|
|
|
my = oy + ((oh - th) / 2);
|
|
|
|
tt->rel_pos.x = 0.5;
|
|
|
|
tt->rel_pos.y = 0.5;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_RIGHT:
|
|
|
|
mx = ox + ow;
|
|
|
|
my = oy + ((oh - th) / 2);
|
|
|
|
tt->rel_pos.x = -1.1;
|
|
|
|
tt->rel_pos.y = 0.5;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_BOTTOM_LEFT:
|
|
|
|
mx = ox - tw;
|
|
|
|
my = oy + oh;
|
|
|
|
tt->rel_pos.x = 1.1;
|
|
|
|
tt->rel_pos.y = -1.1;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_BOTTOM:
|
|
|
|
mx = ox + ((ow - tw) / 2);
|
|
|
|
my = oy + oh;
|
|
|
|
tt->rel_pos.x = 0.5;
|
|
|
|
tt->rel_pos.y = -1.1;
|
|
|
|
break;
|
|
|
|
case ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT:
|
|
|
|
mx = ox + ow;
|
|
|
|
my = oy + oh;
|
|
|
|
tt->rel_pos.x = -1.1;
|
|
|
|
tt->rel_pos.y = -1.1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-27 03:13:06 -08:00
|
|
|
evas_object_geometry_get(tt->content, NULL, NULL, &tcw, &tch);
|
|
|
|
if (tcw <= 0 || tcw > tw) tcw = tw;
|
|
|
|
if (tch <= 0 || tch > th) tch = th;
|
2016-06-06 16:41:41 -07:00
|
|
|
|
2017-02-27 03:13:06 -08:00
|
|
|
px = (tw - tcw) / 2;
|
|
|
|
py = (th - tch) / 2;
|
|
|
|
|
|
|
|
if (mx < 0)
|
|
|
|
{
|
|
|
|
dx = -mx;
|
|
|
|
mx = -(px / 2);
|
|
|
|
if (tt->rel_pos.x == 0.5)
|
|
|
|
{
|
|
|
|
tt->rel_pos.x = 0.5 - dx / (double)tcw;
|
|
|
|
if (tt->rel_pos.x < 0.0) tt->rel_pos.x = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mx + tw > cw)
|
|
|
|
{
|
|
|
|
dx = mx + tw - cw;
|
|
|
|
mx = cw - tw + px / 2;
|
|
|
|
if (tt->rel_pos.x == 0.5)
|
|
|
|
{
|
|
|
|
tt->rel_pos.x = 0.5 + dx / (double)tcw;
|
|
|
|
if (tt->rel_pos.x > 1.0) tt->rel_pos.x = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (my < 0)
|
|
|
|
{
|
|
|
|
dy = -my;
|
|
|
|
my = -(py / 2);
|
|
|
|
if (tt->rel_pos.y == 0.5)
|
|
|
|
{
|
|
|
|
tt->rel_pos.y = 0.5 - dy / (double)tch;
|
|
|
|
if (tt->rel_pos.y < 0.0) tt->rel_pos.y = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (my + th > ch)
|
|
|
|
{
|
|
|
|
dy = my + th - ch;
|
|
|
|
my = ch - th + py / 2;
|
|
|
|
if (tt->rel_pos.y == 0.5)
|
|
|
|
{
|
|
|
|
tt->rel_pos.y = 0.5 + dy / (double)tch;
|
|
|
|
if (tt->rel_pos.y > 1.0) tt->rel_pos.y = 1.0;
|
|
|
|
}
|
|
|
|
}
|
2016-06-06 16:41:41 -07:00
|
|
|
|
|
|
|
evas_object_move(tt->tooltip, mx, my);
|
|
|
|
evas_object_show(tt->tooltip);
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static void
|
|
|
|
_elm_tooltip_reconfigure(Elm_Tooltip *tt)
|
|
|
|
{
|
2016-07-13 02:37:21 -07:00
|
|
|
Evas_Coord ox, oy, ow, oh, px = 0, py = 0, tx, ty, tw, th;
|
2016-08-04 07:23:30 -07:00
|
|
|
Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0, basex = 0, basey = 0;;
|
2010-09-10 17:52:33 -07:00
|
|
|
Evas_Coord eminw, eminh, ominw, ominh;
|
2016-08-04 07:23:30 -07:00
|
|
|
double rel_x = 0.0, rel_y = 0.0;
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
Eina_Bool inside_eventarea;
|
2018-01-11 13:27:22 -08:00
|
|
|
Eina_Bool new_content = EINA_FALSE;
|
2010-09-10 17:52:33 -07:00
|
|
|
|
|
|
|
_elm_tooltip_reconfigure_job_stop(tt);
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
if (tt->hide_timer) return;
|
2010-09-10 17:52:33 -07:00
|
|
|
if (!tt->tooltip) return;
|
|
|
|
if (tt->changed_style)
|
|
|
|
{
|
|
|
|
const char *style = tt->style ? tt->style : "default";
|
|
|
|
const char *str;
|
2018-05-31 06:46:12 -07:00
|
|
|
if (!_elm_theme_object_set(tt->tt_win ? : tt->owner, tt->tooltip,
|
2018-01-16 20:39:52 -08:00
|
|
|
"tooltip", NULL, style))
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
ERR("Could not apply the theme to the tooltip! style=%s", style);
|
2011-07-26 02:38:23 -07:00
|
|
|
if (tt->tt_win) evas_object_del(tt->tt_win);
|
|
|
|
else evas_object_del(tt->tooltip);
|
|
|
|
tt->tt_win = NULL;
|
|
|
|
tt->tt_evas = NULL;
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->tooltip = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
tt->rel_pos.x = 0;
|
|
|
|
tt->rel_pos.y = 0;
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->pad.x = 0;
|
|
|
|
tt->pad.y = 0;
|
|
|
|
tt->pad.bx = 0;
|
|
|
|
tt->pad.by = 0;
|
2010-09-12 10:24:45 -07:00
|
|
|
tt->hide_timeout = 0.0;
|
2011-07-28 03:08:07 -07:00
|
|
|
|
|
|
|
str = edje_object_data_get(tt->tooltip, "transparent");
|
2011-07-26 23:43:51 -07:00
|
|
|
if (tt->tt_win)
|
|
|
|
{ /* FIXME: hardcoded here is bad */
|
2011-07-28 03:08:07 -07:00
|
|
|
if (str && (!strcmp(str, "enabled")))
|
2011-07-27 12:09:50 -07:00
|
|
|
{
|
2012-08-05 23:43:59 -07:00
|
|
|
evas_object_hide(tt->tt_win);
|
2011-07-27 12:09:50 -07:00
|
|
|
elm_win_alpha_set(tt->tt_win, EINA_TRUE);
|
|
|
|
}
|
2011-07-26 23:43:51 -07:00
|
|
|
else
|
2011-07-27 12:09:50 -07:00
|
|
|
{
|
2012-08-05 23:43:59 -07:00
|
|
|
evas_object_hide(tt->tt_win);
|
2011-07-27 12:09:50 -07:00
|
|
|
elm_win_alpha_set(tt->tt_win, EINA_FALSE);
|
2013-06-11 03:18:25 -07:00
|
|
|
}
|
2011-07-26 23:43:51 -07:00
|
|
|
}
|
2010-09-10 17:52:33 -07:00
|
|
|
|
|
|
|
str = edje_object_data_get(tt->tooltip, "pad_x");
|
|
|
|
if (str) tt->pad.x = atoi(str);
|
|
|
|
str = edje_object_data_get(tt->tooltip, "pad_y");
|
|
|
|
if (str) tt->pad.y = atoi(str);
|
|
|
|
|
|
|
|
str = edje_object_data_get(tt->tooltip, "pad_border_x");
|
|
|
|
if (str) tt->pad.bx = atoi(str);
|
|
|
|
str = edje_object_data_get(tt->tooltip, "pad_border_y");
|
|
|
|
if (str) tt->pad.by = atoi(str);
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
str = edje_object_data_get(tt->tooltip, "hide_timeout");
|
|
|
|
if (str)
|
|
|
|
{
|
2012-04-25 20:32:18 -07:00
|
|
|
tt->hide_timeout = _elm_atof(str);
|
2010-09-12 10:24:45 -07:00
|
|
|
if (tt->hide_timeout < 0.0) tt->hide_timeout = 0.0;
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->changed_style = EINA_FALSE;
|
|
|
|
if (tt->tooltip)
|
2018-04-26 03:27:43 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_is_legacy(tt->owner))
|
|
|
|
edje_object_part_swallow(tt->tooltip, "elm.swallow.content",
|
|
|
|
tt->content);
|
|
|
|
else
|
|
|
|
edje_object_part_swallow(tt->tooltip, "efl.content",
|
|
|
|
tt->content);
|
|
|
|
}
|
2010-09-12 10:24:45 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
if (elm_widget_is_legacy(tt->owner))
|
|
|
|
edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(tt->tooltip, "efl,action,show", "efl");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!tt->content)
|
|
|
|
{
|
2016-01-02 04:46:53 -08:00
|
|
|
tt->ref++;
|
2011-07-26 02:38:23 -07:00
|
|
|
tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner);
|
2016-01-02 04:46:53 -08:00
|
|
|
tt->ref--;
|
|
|
|
if (tt->unset_me)
|
|
|
|
{
|
|
|
|
_elm_tooltip_unset(tt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
if (!tt->content)
|
|
|
|
{
|
|
|
|
WRN("could not create tooltip content!");
|
2011-07-26 02:38:23 -07:00
|
|
|
if (tt->tt_win) evas_object_del(tt->tt_win);
|
|
|
|
else evas_object_del(tt->tooltip);
|
|
|
|
|
|
|
|
tt->tt_win = NULL;
|
|
|
|
tt->tt_evas = NULL;
|
2010-09-10 17:52:33 -07:00
|
|
|
tt->tooltip = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(tt->owner))
|
|
|
|
edje_object_part_swallow
|
|
|
|
(tt->tooltip, "elm.swallow.content", tt->content);
|
|
|
|
else
|
|
|
|
edje_object_part_swallow
|
|
|
|
(tt->tooltip, "efl.content", tt->content);
|
2018-01-11 13:27:22 -08:00
|
|
|
new_content = EINA_TRUE;
|
2011-07-26 02:38:23 -07:00
|
|
|
evas_object_event_callback_add(tt->content, EVAS_CALLBACK_DEL,
|
2010-09-10 17:52:33 -07:00
|
|
|
_elm_tooltip_content_del_cb, tt);
|
|
|
|
|
2015-02-05 03:02:24 -08:00
|
|
|
/* tooltip has to use layer tooltip */
|
|
|
|
evas_object_layer_set(tt->tooltip, ELM_OBJECT_LAYER_TOOLTIP);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
2011-11-23 20:16:03 -08:00
|
|
|
TTDBG("*******RECALC\n");
|
2017-09-18 00:22:01 -07:00
|
|
|
evas_object_size_hint_combined_min_get(tt->content, &ominw, &ominh);
|
2018-01-11 13:27:22 -08:00
|
|
|
/* force size hints to update */
|
|
|
|
if ((!ominw) || (!ominh))
|
|
|
|
{
|
|
|
|
evas_object_smart_need_recalculate_set(tt->content, 1);
|
|
|
|
evas_object_smart_calculate(tt->content);
|
|
|
|
evas_object_size_hint_combined_min_get(tt->content, &ominw, &ominh);
|
|
|
|
}
|
|
|
|
if (new_content)
|
|
|
|
evas_object_event_callback_add(tt->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_elm_tooltip_content_changed_hints_cb, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
edje_object_size_min_get(tt->tooltip, &eminw, &eminh);
|
|
|
|
|
2011-07-31 07:29:04 -07:00
|
|
|
if (eminw && (ominw < eminw)) ominw = eminw;
|
2013-01-08 20:57:54 -08:00
|
|
|
if (eminh && (ominh < eminh)) ominh = eminh;
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2011-07-26 02:38:23 -07:00
|
|
|
edje_object_size_min_restricted_calc(tt->tooltip, &tw, &th, ominw, ominh);
|
2011-11-23 20:52:16 -08:00
|
|
|
TTDBG("TTSIZE: tw=%d,th=%d,ominw=%d,ominh=%d\n", tw, th, ominw, ominh);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2011-07-26 02:38:23 -07:00
|
|
|
if (tt->tt_win)
|
2014-04-22 06:29:49 -07:00
|
|
|
{
|
2016-07-13 02:37:21 -07:00
|
|
|
elm_win_screen_size_get(elm_widget_top_get(tt->owner),
|
2016-08-04 07:23:30 -07:00
|
|
|
&basex, &basey, &cw, &ch);
|
2016-07-13 02:37:21 -07:00
|
|
|
elm_win_screen_position_get(elm_widget_top_get(tt->owner),
|
|
|
|
&cx, &cy);
|
2017-10-31 00:36:32 -07:00
|
|
|
evas_pointer_canvas_xy_get(tt->evas, &px, &py);
|
2016-08-04 07:23:30 -07:00
|
|
|
cx -= basex;
|
|
|
|
cy -= basey;
|
2016-07-13 02:37:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_output_size_get(tt->evas, &cw, &ch);
|
2017-10-31 00:36:32 -07:00
|
|
|
evas_pointer_canvas_xy_get(tt->evas, &px, &py);
|
2014-04-22 06:29:49 -07:00
|
|
|
}
|
2011-11-23 20:52:16 -08:00
|
|
|
TTDBG("SCREEN: cw=%d,ch=%d\n", cw, ch);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
evas_object_geometry_get(tt->eventarea, &ox, &oy, &ow, &oh);
|
2015-05-28 18:34:25 -07:00
|
|
|
/* win reports its screen position for x/y;
|
|
|
|
* reset to 0 since we expect canvas coords here
|
|
|
|
*/
|
2016-08-15 06:44:41 -07:00
|
|
|
if (efl_isa(tt->eventarea, EFL_UI_WIN_CLASS))
|
2015-05-28 18:34:25 -07:00
|
|
|
ox = oy = 0;
|
2011-11-23 20:16:03 -08:00
|
|
|
TTDBG("EVENTAREA: ox=%d,oy=%d,ow=%d,oh=%d\n", ox, oy, ow, oh);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
2011-07-26 23:43:51 -07:00
|
|
|
inside_eventarea = ((px >= ox) && (py >= oy) &&
|
2016-07-13 02:37:21 -07:00
|
|
|
(px <= (ox + ow)) && (py <= (oy + oh)));
|
2016-08-04 07:23:30 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
if (inside_eventarea)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2011-11-23 20:52:16 -08:00
|
|
|
/* try to position bottom right corner at pointer */
|
2016-08-04 07:23:30 -07:00
|
|
|
tx = cx + px - tw - 1;
|
|
|
|
ty = cy + py - th - 1;
|
|
|
|
if (tx < 0)
|
|
|
|
{
|
|
|
|
tx = 0;
|
|
|
|
if (ELM_RECTS_INTERSECT(tx, ty, tw, th, (cx + ox), (cy + oy),
|
|
|
|
ow, oh))
|
|
|
|
tx = cx + ox + ow;
|
|
|
|
}
|
|
|
|
if (ty < 0)
|
|
|
|
{
|
|
|
|
ty = 0;
|
|
|
|
if (ELM_RECTS_INTERSECT(tx, ty, tw, th, (cx + ox), (cy + oy),
|
|
|
|
ow, oh))
|
|
|
|
ty = cy + oy + oh;
|
|
|
|
}
|
|
|
|
if ((tx + tw) > cw) tx = cw - tw;
|
|
|
|
if ((ty + th) > ch) ty = ch - th;
|
|
|
|
if (tx < 0) tx = 0;
|
|
|
|
if (ty < 0) ty = 0;
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-23 20:52:16 -08:00
|
|
|
/* try centered on middle of eventarea */
|
2016-08-04 07:23:30 -07:00
|
|
|
tx = cx + ox + (ow / 2) - (tw / 2);
|
2016-07-13 02:37:21 -07:00
|
|
|
if (py < oy)
|
2014-12-07 17:08:36 -08:00
|
|
|
{
|
2016-08-04 07:23:30 -07:00
|
|
|
ty = cx + oy - th;
|
|
|
|
if (ty < cx) ty = cx + oy + oh;
|
|
|
|
if ((ty + th) > (cx + ch)) ty = cy + ch - th;
|
2014-12-07 17:08:36 -08:00
|
|
|
}
|
2016-07-13 02:37:21 -07:00
|
|
|
else
|
2012-12-02 04:41:09 -08:00
|
|
|
{
|
2016-08-04 07:23:30 -07:00
|
|
|
ty = cy + oy + oh;
|
|
|
|
if (ty < cy) ty = cy;
|
|
|
|
if ((ty + th) > (cy + ch)) ty = cy + oy - th;
|
2014-12-07 17:08:36 -08:00
|
|
|
}
|
2016-08-04 07:23:30 -07:00
|
|
|
if (tx < cx) tx = cx;
|
|
|
|
if ((tx + th) > (cx + cw)) tx = cy + cw - tw;
|
2016-07-13 02:37:21 -07:00
|
|
|
|
2011-11-23 20:52:16 -08:00
|
|
|
}
|
2016-08-04 07:23:30 -07:00
|
|
|
// jf tt is over the pointer even after positiong then screen
|
|
|
|
// limiting, just use the poitner dumbly and choose to theleft or right
|
|
|
|
// above or below depending which has more space/ we're in a mess
|
|
|
|
// anyway
|
|
|
|
if (ELM_RECTS_INTERSECT(tx, ty, tw, th, (cx + px), (cy + py), 1, 1))
|
|
|
|
{
|
|
|
|
if ((px + cx) > (cw / 2)) tx = cx + px - 1 - tw;
|
|
|
|
else tx = cx + px + 1;
|
|
|
|
if ((py + cy) > (ch / 2)) ty = cy + py - 1 - th;
|
|
|
|
else ty = cy + py + 1;
|
|
|
|
}
|
2018-09-20 23:05:43 -07:00
|
|
|
|
|
|
|
if (inside_eventarea)
|
|
|
|
{
|
|
|
|
rel_x = (px - (tx - cx)) / (double)tw;
|
|
|
|
rel_y = (py - (ty - cy)) / (double)th;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rel_x = (ox + (ow / 2) - (tx - cx)) / (double)tw;
|
|
|
|
rel_y = (oy + (oh / 2) - (ty - cy)) / (double)th;
|
|
|
|
}
|
|
|
|
|
2016-08-04 07:23:30 -07:00
|
|
|
tx += basex;
|
|
|
|
ty += basey;
|
2016-07-13 02:37:21 -07:00
|
|
|
// XXX: if this is a window for toolkit this relies on abs positioning
|
|
|
|
// and this is not portable to wayland so we need relative positioning
|
|
|
|
// implemented lower down for this
|
2011-07-26 02:38:23 -07:00
|
|
|
evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty);
|
|
|
|
evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th);
|
2012-03-11 15:21:41 -07:00
|
|
|
TTDBG("FINAL: tx=%d,ty=%d,tw=%d,th=%d\n", tx, ty, tw, th);
|
2010-09-10 17:52:33 -07:00
|
|
|
evas_object_show(tt->tooltip);
|
2010-09-12 10:24:45 -07:00
|
|
|
|
|
|
|
#define FDIF(a, b) (fabs((a) - (b)) > 0.0001)
|
2010-10-22 14:41:22 -07:00
|
|
|
if ((FDIF(rel_x, tt->rel_pos.x)) || (FDIF(rel_y, tt->rel_pos.y)))
|
2010-09-12 10:24:45 -07:00
|
|
|
{
|
|
|
|
Edje_Message_Float_Set *msg;
|
|
|
|
|
|
|
|
msg = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double));
|
|
|
|
msg->count = 2;
|
2013-11-27 07:27:13 -08:00
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
tt->rel_pos.x = rel_x;
|
|
|
|
tt->rel_pos.y = rel_y;
|
|
|
|
|
2016-07-13 02:37:21 -07:00
|
|
|
_elm_tooltip_reconfigure_orient(tt,
|
|
|
|
cx + ox, cy + oy, ow, oh,
|
|
|
|
tw, th, cw, ch);
|
2016-06-06 16:41:41 -07:00
|
|
|
|
|
|
|
msg->val[0] = tt->rel_pos.x;
|
|
|
|
msg->val[1] = tt->rel_pos.y;
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
edje_object_message_send(tt->tooltip, EDJE_MESSAGE_FLOAT_SET, 1, msg);
|
|
|
|
}
|
|
|
|
#undef FDIF
|
2013-10-16 05:29:22 -07:00
|
|
|
if (tt->tt_win) evas_object_show(tt->tt_win);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_tooltip_show_timer_stop(Elm_Tooltip *tt)
|
|
|
|
{
|
|
|
|
if (!tt->show_timer) return;
|
2013-05-29 05:12:04 -07:00
|
|
|
ELM_SAFE_FREE(tt->show_timer, ecore_timer_del);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_tooltip_timer_show_cb(void *data)
|
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
tt->show_timer = NULL;
|
|
|
|
_elm_tooltip_show(tt);
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_obj_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
_elm_tooltip_hide_anim_stop(tt);
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
if ((tt->show_timer) || (tt->tooltip)) return;
|
|
|
|
|
2012-03-11 15:01:55 -07:00
|
|
|
tt->show_timer = ecore_timer_add(_elm_config->tooltip_delay, _elm_tooltip_timer_show_cb, tt);
|
|
|
|
TTDBG("MOUSE IN\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_obj_mouse_out_cb(Elm_Tooltip *tt, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Event_Mouse_Out *event EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2010-09-12 10:24:45 -07:00
|
|
|
if (tt->visible_lock) return;
|
|
|
|
|
|
|
|
if (!tt->tooltip)
|
|
|
|
{
|
|
|
|
_elm_tooltip_show_timer_stop(tt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_elm_tooltip_hide_anim_start(tt);
|
2012-03-11 15:01:55 -07:00
|
|
|
TTDBG("MOUSE OUT\n");
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
2014-01-06 06:30:02 -08:00
|
|
|
static void _elm_tooltip_obj_free_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
|
2010-09-16 16:44:02 -07:00
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static void
|
2010-09-16 16:44:02 -07:00
|
|
|
_elm_tooltip_unset(Elm_Tooltip *tt)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2016-01-02 04:46:53 -08:00
|
|
|
if (tt->ref > 0)
|
|
|
|
{
|
|
|
|
tt->unset_me = EINA_TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2010-09-16 16:44:02 -07:00
|
|
|
tt->visible_lock = EINA_FALSE;
|
|
|
|
_elm_tooltip_hide(tt);
|
|
|
|
_elm_tooltip_data_clean(tt);
|
|
|
|
|
|
|
|
if (tt->eventarea)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(tt->eventarea, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_elm_tooltip_obj_mouse_in_cb, tt);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(tt->eventarea, EVAS_CALLBACK_MOUSE_OUT,
|
2011-07-26 23:43:51 -07:00
|
|
|
(Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
evas_object_event_callback_del_full
|
2011-06-15 07:07:28 -07:00
|
|
|
(tt->eventarea, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
|
|
|
|
evas_object_data_del(tt->eventarea, _tooltip_key);
|
|
|
|
}
|
|
|
|
if (tt->owner)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full
|
2011-06-15 07:07:28 -07:00
|
|
|
(tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
elm_widget_tooltip_del(tt->owner, tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_stringshare_del(tt->style);
|
|
|
|
free(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_obj_free_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2010-09-16 16:44:02 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = data;
|
|
|
|
if (tt->eventarea == obj) tt->eventarea = NULL;
|
|
|
|
if (tt->owner == obj) tt->owner = NULL;
|
|
|
|
_elm_tooltip_unset(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
2017-09-19 01:05:15 -07:00
|
|
|
static Elm_Tooltip *
|
|
|
|
_elm_tooltip_create(Evas_Object *eventarea)
|
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = NULL;
|
|
|
|
|
|
|
|
tt = ELM_NEW(Elm_Tooltip);
|
|
|
|
if (!tt) return NULL;
|
|
|
|
|
|
|
|
tt->eventarea = eventarea;
|
|
|
|
tt->evas = evas_object_evas_get(eventarea);
|
|
|
|
evas_object_data_set(eventarea, _tooltip_key, tt);
|
|
|
|
|
|
|
|
evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_elm_tooltip_obj_mouse_in_cb, tt);
|
|
|
|
evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
(Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_out_cb, tt);
|
|
|
|
evas_object_event_callback_add(eventarea, EVAS_CALLBACK_FREE,
|
|
|
|
_elm_tooltip_obj_free_cb, tt);
|
|
|
|
|
|
|
|
return tt;
|
|
|
|
}
|
|
|
|
|
2015-03-24 15:23:07 -07:00
|
|
|
static void
|
|
|
|
_tooltip_label_style_set(Evas_Object *obj, Evas_Object *label)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
|
|
|
char buf[100] = {0};
|
2015-05-19 02:09:50 -07:00
|
|
|
const char *style = tt->style ? tt->style : "default";
|
2015-03-24 15:23:07 -07:00
|
|
|
|
2015-05-19 02:09:50 -07:00
|
|
|
sprintf(buf, "tooltip/%s", style);
|
2015-03-24 15:23:07 -07:00
|
|
|
if (!elm_object_style_set(label, buf))
|
|
|
|
{
|
|
|
|
WRN("Failed to set tooltip label style: %s, reverting to old style",
|
|
|
|
buf);
|
|
|
|
elm_object_style_set(label, "tooltip"); //XXX: remove it in EFL 2.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static Evas_Object *
|
2015-03-24 15:23:07 -07:00
|
|
|
_elm_tooltip_label_create(void *data, Evas_Object *obj, Evas_Object *tooltip)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
2011-07-26 02:38:23 -07:00
|
|
|
Evas_Object *label = elm_label_add(tooltip);
|
2010-09-10 17:52:33 -07:00
|
|
|
if (!label)
|
|
|
|
return NULL;
|
2015-03-24 15:23:07 -07:00
|
|
|
_tooltip_label_style_set(obj, label);
|
2011-06-28 23:41:31 -07:00
|
|
|
elm_object_text_set(label, data);
|
2010-09-10 17:52:33 -07:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2011-10-19 07:17:14 -07:00
|
|
|
static Evas_Object *
|
2015-03-24 15:23:07 -07:00
|
|
|
_elm_tooltip_trans_label_create(void *data, Evas_Object *obj, Evas_Object *tooltip)
|
2011-10-19 07:17:14 -07:00
|
|
|
{
|
|
|
|
Evas_Object *label = elm_label_add(tooltip);
|
|
|
|
const char **text = data;
|
|
|
|
if (!label)
|
|
|
|
return NULL;
|
2015-03-24 15:23:07 -07:00
|
|
|
_tooltip_label_style_set(obj, label);
|
2011-10-19 07:17:14 -07:00
|
|
|
elm_object_domain_translatable_text_set(label, text[0], text[1]);
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_label_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
}
|
|
|
|
|
2011-10-19 07:17:14 -07:00
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_elm_tooltip_trans_label_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2011-10-19 07:17:14 -07:00
|
|
|
{
|
|
|
|
const char **text = data;
|
|
|
|
eina_stringshare_del(text[0]);
|
|
|
|
eina_stringshare_del(text[1]);
|
|
|
|
free(text);
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
static void
|
|
|
|
_elm_tooltip_data_clean(Elm_Tooltip *tt)
|
|
|
|
{
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
if (tt->del_cb) tt->del_cb((void *)tt->data, tt->owner, NULL);
|
2015-08-05 00:22:02 -07:00
|
|
|
tt->del_cb = NULL;
|
|
|
|
tt->data = NULL;
|
2010-09-10 17:52:33 -07:00
|
|
|
|
|
|
|
_elm_tooltip_content_del(tt);
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:22:47 -08:00
|
|
|
EAPI void
|
2014-02-21 12:22:35 -08:00
|
|
|
elm_object_tooltip_move_freeze_push(Evas_Object *obj)
|
2014-02-20 03:44:19 -08:00
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
|
|
|
|
|
|
|
tt->move_freeze++;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2014-02-21 12:22:35 -08:00
|
|
|
elm_object_tooltip_move_freeze_pop(Evas_Object *obj)
|
2014-01-12 22:22:47 -08:00
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
|
|
|
|
2014-02-20 03:44:19 -08:00
|
|
|
tt->move_freeze--;
|
|
|
|
if (tt->move_freeze < 0) tt->move_freeze = 0;
|
2014-01-12 22:22:47 -08:00
|
|
|
}
|
|
|
|
|
2014-02-20 03:44:19 -08:00
|
|
|
EAPI int
|
2014-02-21 12:22:35 -08:00
|
|
|
elm_object_tooltip_move_freeze_get(const Evas_Object *obj)
|
2014-01-12 22:22:47 -08:00
|
|
|
{
|
2014-02-20 03:44:19 -08:00
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj, 0);
|
2014-01-12 22:22:47 -08:00
|
|
|
|
2014-02-20 03:44:19 -08:00
|
|
|
return tt->move_freeze;
|
2014-01-12 22:22:47 -08:00
|
|
|
}
|
|
|
|
|
2013-11-27 07:27:13 -08:00
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_orient_set(Evas_Object *obj, Elm_Tooltip_Orient orient)
|
|
|
|
{
|
2017-09-19 01:05:15 -07:00
|
|
|
ELM_TOOLTIP_GET_OR_CREATE(tt, obj);
|
2013-11-27 07:27:13 -08:00
|
|
|
|
|
|
|
if ((orient > ELM_TOOLTIP_ORIENT_NONE) && (orient < ELM_TOOLTIP_ORIENT_LAST))
|
|
|
|
tt->orient = orient;
|
|
|
|
else
|
|
|
|
tt->orient = ELM_TOOLTIP_ORIENT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Tooltip_Orient
|
|
|
|
elm_object_tooltip_orient_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj, ELM_TOOLTIP_ORIENT_NONE);
|
|
|
|
|
|
|
|
Elm_Tooltip_Orient orient = ELM_TOOLTIP_ORIENT_NONE;
|
|
|
|
|
|
|
|
orient = tt->orient;
|
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
/**
|
|
|
|
* Notify tooltip should recalculate its theme.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
elm_tooltip_theme(Elm_Tooltip *tt)
|
|
|
|
{
|
|
|
|
if (!tt->tooltip) return;
|
|
|
|
tt->changed_style = EINA_TRUE;
|
|
|
|
_elm_tooltip_reconfigure_job_start(tt);
|
|
|
|
}
|
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
/**
|
|
|
|
* Set the content to be shown in the tooltip object for specific event area.
|
|
|
|
*
|
|
|
|
* Setup the tooltip to object. The object @a eventarea can have only
|
|
|
|
* one tooltip, so any previous tooltip data is removed. @p func(with
|
|
|
|
* @p data) will be called every time that need show the tooltip and
|
|
|
|
* it should return a valid Evas_Object. This object is then managed
|
|
|
|
* fully by tooltip system and is deleted when the tooltip is gone.
|
|
|
|
*
|
|
|
|
* This is an internal function that is used by objects with sub-items
|
|
|
|
* that want to provide different tooltips for each of them. The @a
|
|
|
|
* owner object should be an elm_widget and will be used to track
|
|
|
|
* theme changes and to feed @a func and @a del_cb. The @a eventarea
|
|
|
|
* may be any object and is the one that should be used later on with
|
|
|
|
* elm_object_tooltip apis, such as elm_object_tooltip_hide(),
|
|
|
|
* elm_object_tooltip_show() or elm_object_tooltip_unset().
|
|
|
|
*
|
|
|
|
* @param eventarea the object being attached a tooltip.
|
|
|
|
* @param owner the elm_widget that owns this object, will be used to
|
|
|
|
* track theme changes and to be used in @a func or @a del_cb.
|
|
|
|
* @param func the function used to create the tooltip contents. The
|
|
|
|
* @a Evas_Object parameters will receive @a owner as value.
|
|
|
|
* @param data what to provide to @a func as callback data/context.
|
|
|
|
* @param del_cb called when data is not needed anymore, either when
|
2011-08-03 12:07:43 -07:00
|
|
|
* another callback replaces @p func, the tooltip is unset with
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
* elm_object_tooltip_unset() or the owner object @a obj
|
|
|
|
* dies. This callback receives as the first parameter the
|
|
|
|
* given @a data, and @c event_info is NULL.
|
|
|
|
*
|
|
|
|
* @internal
|
2016-03-16 08:05:31 -07:00
|
|
|
* @ingroup Elm_Tooltips
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
*/
|
2010-09-13 00:56:23 -07:00
|
|
|
void
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
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)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
|
|
|
Elm_Tooltip *tt = NULL;
|
2017-09-19 01:05:15 -07:00
|
|
|
Eina_Bool just_created = EINA_TRUE;
|
2010-09-10 17:52:33 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
EINA_SAFETY_ON_NULL_GOTO(owner, error);
|
|
|
|
EINA_SAFETY_ON_NULL_GOTO(eventarea, error);
|
2010-09-10 17:52:33 -07:00
|
|
|
|
|
|
|
if (!func)
|
|
|
|
{
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
elm_object_tooltip_unset(eventarea);
|
2010-09-10 17:52:33 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
tt = evas_object_data_get(eventarea, _tooltip_key);
|
2017-09-19 01:05:15 -07:00
|
|
|
if (tt && tt->owner)
|
2010-09-10 17:52:33 -07:00
|
|
|
{
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
if (tt->owner != owner)
|
|
|
|
{
|
2010-09-16 16:44:02 -07:00
|
|
|
if (tt->owner != eventarea)
|
|
|
|
evas_object_event_callback_del_full
|
2011-06-15 07:07:28 -07:00
|
|
|
(tt->owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
elm_widget_tooltip_del(tt->owner, tt);
|
|
|
|
|
2010-09-16 16:44:02 -07:00
|
|
|
if (owner != eventarea)
|
|
|
|
evas_object_event_callback_add
|
2011-06-15 07:07:28 -07:00
|
|
|
(owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
elm_widget_tooltip_add(tt->owner, tt);
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
if ((tt->func == func) && (tt->data == data) &&
|
|
|
|
(tt->del_cb == del_cb))
|
|
|
|
return;
|
|
|
|
_elm_tooltip_data_clean(tt);
|
|
|
|
just_created = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-19 01:05:15 -07:00
|
|
|
if (!tt)
|
|
|
|
{
|
|
|
|
tt = _elm_tooltip_create(eventarea);
|
|
|
|
if (!tt) goto error;
|
|
|
|
}
|
2010-09-10 17:52:33 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
tt->owner = owner;
|
2010-09-16 16:44:02 -07:00
|
|
|
if (owner != eventarea)
|
|
|
|
evas_object_event_callback_add
|
2011-06-15 07:07:28 -07:00
|
|
|
(owner, EVAS_CALLBACK_FREE, _elm_tooltip_obj_free_cb, tt);
|
2010-09-16 16:44:02 -07:00
|
|
|
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
elm_widget_tooltip_add(tt->owner, tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
tt->func = func;
|
|
|
|
tt->data = data;
|
|
|
|
tt->del_cb = del_cb;
|
|
|
|
|
2010-09-12 10:24:45 -07:00
|
|
|
if (!just_created) _elm_tooltip_reconfigure_job_start(tt);
|
2018-01-11 13:28:16 -08:00
|
|
|
else if (efl_canvas_pointer_inside_get(eventarea, NULL) && (!tt->tooltip))
|
|
|
|
_elm_tooltip_show(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
Tooltips: split owner/eventarea, allow subitems to have indepentent tooltips.
Now owner widget (elm_widget) is just used to listen for theme changes
and create/destroy the tooltip data. The actual mouse events operates
on all Evas_Object and is the one where tooltip data is actually
stored.
The public API is basically the same, just the event_info is now NULL
to avoid confusion.
The internal API introduces elm_object_sub_tooltip_content_cb_set()
and as the first parameter the eventarea. While this may be confusing,
as the second parameter is the actual elementary object, it is the one
that all other calls receive, like elm_object_tooltip_hide() or
elm_object_tooltip_unset(), thus it does make sense to have such order.
Also internal API, elm_widget_item_tooltip_* functions were
added. They are a variation of the widget API to handle its items, as
such the func() gets one more parameter: item, and the del_cb() gets
the item as event_info (that's why the public widget version got
event_info always NULL, to not confuse with this one!)
Widgets with items that makes sense to have tooltips got extra API:
* toolbar
* list
* gengrid
* genlist
SVN revision: 52173
2010-09-12 14:05:13 -07:00
|
|
|
if (del_cb) del_cb((void *)data, owner, NULL);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
2010-09-13 00:56:23 -07:00
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
|
|
|
tt->visible_lock = EINA_TRUE;
|
|
|
|
_elm_tooltip_show(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
|
|
|
tt->visible_lock = EINA_FALSE;
|
|
|
|
_elm_tooltip_hide_anim_start(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_text_set(Evas_Object *obj, const char *text)
|
|
|
|
{
|
2016-11-27 15:14:26 -08:00
|
|
|
Elm_Tooltip *tt;
|
2010-09-13 00:56:23 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(obj);
|
2016-11-12 13:23:40 -08:00
|
|
|
|
|
|
|
if (!text)
|
|
|
|
{
|
2016-11-27 15:14:26 -08:00
|
|
|
tt = evas_object_data_get((obj), _tooltip_key);
|
|
|
|
if (tt)
|
|
|
|
elm_object_tooltip_unset(obj);
|
2016-11-12 13:23:40 -08:00
|
|
|
return;
|
|
|
|
}
|
2010-09-13 00:56:23 -07:00
|
|
|
|
|
|
|
text = eina_stringshare_add(text);
|
|
|
|
elm_object_tooltip_content_cb_set
|
|
|
|
(obj, _elm_tooltip_label_create, text, _elm_tooltip_label_del_cb);
|
|
|
|
}
|
|
|
|
|
2011-10-19 07:17:14 -07:00
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_domain_translatable_text_set(Evas_Object *obj, const char *domain, const char *text)
|
|
|
|
{
|
|
|
|
const char **data;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(text);
|
|
|
|
|
|
|
|
data = malloc(2 * sizeof(char *));
|
|
|
|
if (!data) return;
|
|
|
|
data[0] = eina_stringshare_add(domain);
|
|
|
|
data[1] = eina_stringshare_add(text);
|
|
|
|
elm_object_tooltip_content_cb_set
|
|
|
|
(obj, _elm_tooltip_trans_label_create, data,
|
|
|
|
_elm_tooltip_trans_label_del_cb);
|
|
|
|
}
|
|
|
|
|
2010-09-13 00:56:23 -07:00
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
|
|
|
|
{
|
|
|
|
elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb);
|
|
|
|
}
|
|
|
|
|
2010-09-10 17:52:33 -07:00
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
|
2010-09-16 16:44:02 -07:00
|
|
|
_elm_tooltip_unset(tt);
|
2010-09-10 17:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_object_tooltip_style_set(Evas_Object *obj, const char *style)
|
|
|
|
{
|
2017-09-19 01:05:15 -07:00
|
|
|
ELM_TOOLTIP_GET_OR_CREATE(tt, obj);
|
2010-09-10 17:52:33 -07:00
|
|
|
if (!eina_stringshare_replace(&tt->style, style)) return;
|
|
|
|
elm_tooltip_theme(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_object_tooltip_style_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj, NULL);
|
|
|
|
return tt->style ? tt->style : "default";
|
|
|
|
}
|
|
|
|
|
2011-07-26 02:38:23 -07:00
|
|
|
EAPI Eina_Bool
|
2011-12-05 07:25:09 -08:00
|
|
|
elm_object_tooltip_window_mode_set(Evas_Object *obj, Eina_Bool disable)
|
2011-07-26 02:38:23 -07:00
|
|
|
{
|
2017-09-19 01:05:15 -07:00
|
|
|
ELM_TOOLTIP_GET_OR_CREATE(tt, obj, EINA_FALSE);
|
2011-07-26 02:38:23 -07:00
|
|
|
return tt->free_size = disable;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2011-12-05 07:25:09 -08:00
|
|
|
elm_object_tooltip_window_mode_get(const Evas_Object *obj)
|
2011-07-26 02:38:23 -07:00
|
|
|
{
|
|
|
|
ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
|
|
|
|
return tt->free_size;
|
|
|
|
}
|