Adding elm_tooltip_movement_lock_set() and elm_tooltip_movement_lock_get()

Summary: These APIs allow to enable/disable a tooltip to move with respect to mouse pointer

Test Plan: elm_tooltip_movement_lock_set(), elm_tooltip_movement_lock_get(), elementary_test -to tooltip

Reviewers: singh.amitesh, seoz, raster

Reviewed By: raster

CC: raster

Differential Revision: https://phab.enlightenment.org/D369
This commit is contained in:
abhi 2014-01-13 15:22:47 +09:00 committed by Carsten Haitzler (Rasterman)
parent 17083663ac
commit cc03e646c9
5 changed files with 86 additions and 5 deletions

View File

@ -1772,3 +1772,7 @@
2013-12-01 Mike Blumenkrantz
* fix mouse eventing on e border theme
2013-12-09 Abhinandan Aryadipta (aryarockstar)
* tooltip: Added elm_tooltip_move_lock_set() and elm_tooltip_move_lock_get().

View File

@ -7,6 +7,8 @@ Changes since Elementary 1.8.0:
Additions:
* Add elm_tooltip_move_lock_set() and elm_tooltip_move_lock_get()
Improvements:
Fixes:

View File

@ -199,6 +199,23 @@ _tt_text_replace(void *data EINA_UNUSED,
elm_object_tooltip_text_set(obj, buf);
}
static void
_tt_move_lock(void *data EINA_UNUSED,
Evas_Object *obj,
void *event_info EINA_UNUSED)
{
if (!elm_tooltip_move_lock_get(obj))
{
elm_tooltip_move_lock_set(obj, EINA_TRUE);
elm_object_tooltip_text_set(obj, "Locked");
}
else
{
elm_tooltip_move_lock_set(obj, EINA_FALSE);
elm_object_tooltip_text_set(obj, "Free");
}
}
static void
_tt_orient_text_replace(void *data EINA_UNUSED,
Evas_Object *obj,
@ -488,6 +505,13 @@ test_tooltip(void *data EINA_UNUSED,
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Movement Lock Tooltip, click to change");
elm_object_tooltip_text_set(bt, "Free");
evas_object_smart_callback_add(bt, "clicked", _tt_move_lock, NULL);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Orient Tooltip, click to change");
elm_object_tooltip_text_set(bt, "Top Left");

View File

@ -32,6 +32,38 @@ typedef enum
ELM_TOOLTIP_ORIENT_LAST /**< Sentinel value, @b don't use */
} Elm_Tooltip_Orient;
/**
* @def elm_tooltip_move_lock_set
* @since 1.9
*
* @brief Enable/Disable tooltip movement with respect to mouse pointer
*
* @param[in] obj The tooltip's anchor object
* @param[in] lock If EINA_TRUE, tooltip movement with respect to mouse pointer is disabled
*
* This function allows to enable/disable a tooltip to move with respect to mouse pointer
*
* @ingroup Tooltips
* @see elm_tooltip_move_lock_get
*/
EAPI void elm_tooltip_move_lock_set(Evas_Object *obj, Eina_Bool lock);
/**
* @def elm_tooltip_move_lock_get
* @since 1.9
*
* @brief Get the lock status of tooltip movement with respect to mouse pointer
*
* @param[in] obj The tooltip's anchor object
* @return The lock status of tooltip movement with respect to mouse pointer
*
* This function returns the status of tooltip movement with respect to mouse pointer
*
* @ingroup Tooltips
* @see elm_tooltip_move_lock_set
*/
EAPI Eina_Bool elm_tooltip_move_lock_get(const Evas_Object *obj);
/**
* @def elm_object_tooltip_orient_set
* @since 1.9

View File

@ -58,6 +58,7 @@ struct _Elm_Tooltip
} rel_pos;
Elm_Tooltip_Orient orient; /** orientation for tooltip */
double hide_timeout; /* from theme */
Eina_Bool move_lock : 1; /* set/reset tooltip movement with respect to mouse pointer*/
Eina_Bool visible_lock:1;
Eina_Bool changed_style:1;
Eina_Bool free_size : 1;
@ -156,13 +157,15 @@ _elm_tooltip_show(Elm_Tooltip *tt)
(tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
evas_object_event_callback_add
(tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
//No movement of tooltip upon mouse move if orientation set
if ((tt->orient <= ELM_TOOLTIP_ORIENT_NONE) || (tt->orient >= ELM_TOOLTIP_ORIENT_LAST))
if (!tt->move_lock)
{
evas_object_event_callback_add
(tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_move_cb, tt);
//No movement of tooltip upon mouse move if orientation set
if ((tt->orient <= ELM_TOOLTIP_ORIENT_NONE) || (tt->orient >= ELM_TOOLTIP_ORIENT_LAST))
{
evas_object_event_callback_add
(tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_move_cb, tt);
}
}
tt->changed_style = EINA_TRUE;
_elm_tooltip_reconfigure_job_start(tt);
}
@ -723,6 +726,22 @@ _elm_tooltip_data_clean(Elm_Tooltip *tt)
tt->del_cb = NULL;
}
EAPI void
elm_tooltip_move_lock_set(Evas_Object *obj, Eina_Bool lock)
{
ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
tt->move_lock = lock;
}
EAPI Eina_Bool
elm_tooltip_move_lock_get(const Evas_Object *obj)
{
ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE);
return tt->move_lock;
}
EAPI void
elm_object_tooltip_orient_set(Evas_Object *obj, Elm_Tooltip_Orient orient)
{