Implements a way to select if we should use ecore_evas for cursor or only engine

With this commit is now possible to not use theme's cursor (default behevior)
that could be overriding cursors defined by the engine.



SVN revision: 52761
This commit is contained in:
Bruno Dilly 2010-09-25 22:03:37 +00:00
parent 816c77b3fa
commit 3dd29a961c
9 changed files with 270 additions and 4 deletions

View File

@ -145,18 +145,27 @@ test_cursor3(void *data, Evas_Object *obj, void *event_info)
o = elm_button_add(win);
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
elm_button_label_set(o, "hand2 x");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_button_label_set(o, "hand2");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_button_label_set(o, "hand3");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_cursor_style_set(o, "transparent");
elm_button_label_set(o, "hand3 transparent");
elm_box_pack_end(bx, o);
@ -164,6 +173,7 @@ test_cursor3(void *data, Evas_Object *obj, void *event_info)
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_cursor_unset(o);
elm_button_label_set(o, "unset");
elm_box_pack_end(bx, o);
@ -171,6 +181,7 @@ test_cursor3(void *data, Evas_Object *obj, void *event_info)
o = elm_button_add(win);
elm_object_cursor_set(o, "hand4");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_button_label_set(o, "not existent");
elm_box_pack_end(bx, o);
evas_object_show(o);
@ -179,14 +190,19 @@ test_cursor3(void *data, Evas_Object *obj, void *event_info)
elm_box_pack_end(bx, o);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND2);
lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND2);
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, "hand3");
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
NULL, NULL);
elm_list_item_cursor_set(lit, "hand3");
elm_list_item_cursor_style_set(lit, "transparent");
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
elm_list_go(o);
evas_object_show(o);

View File

@ -674,6 +674,8 @@ extern "C" {
EAPI void elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item);
EAPI void elm_gengrid_item_cursor_style_set(Elm_Gengrid_Item *item, const char *style);
EAPI const char *elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item);
EAPI void elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item, Eina_Bool engine_only);
EAPI Eina_Bool elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item);
EAPI void elm_gengrid_clear(Evas_Object *obj);
EAPI void *elm_gengrid_item_data_get(const Elm_Gengrid_Item *item);
@ -1026,6 +1028,8 @@ extern "C" {
EAPI void elm_toolbar_item_cursor_unset(Elm_Toolbar_Item *item);
EAPI void elm_toolbar_item_cursor_style_set(Elm_Toolbar_Item *item, const char *style);
EAPI const char *elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item);
EAPI void elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only);
EAPI Eina_Bool elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item);
EAPI Eina_List *elm_toolbar_item_get_all(Evas_Object *obj);
EAPI Elm_Toolbar_Item *elm_toolbar_item_get_first(Evas_Object *obj);
@ -1069,6 +1073,8 @@ extern "C" {
EAPI void elm_object_cursor_unset(Evas_Object *obj);
EAPI void elm_object_cursor_style_set(Evas_Object *obj, const char *style);
EAPI const char *elm_object_cursor_style_get(const Evas_Object *obj);
EAPI void elm_object_cursor_engine_only_set(Evas_Object *obj, Eina_Bool engine_only);
EAPI Eina_Bool elm_object_cursor_engine_only_get(const Evas_Object *obj);
typedef struct _Elm_Menu_Item Elm_Menu_Item; /**< Item of Elm_Menu. Sub-type of Elm_Widget_Item */
EAPI Evas_Object *elm_menu_add(Evas_Object *parent);
@ -1147,6 +1153,8 @@ extern "C" {
EAPI void elm_list_item_cursor_unset(Elm_List_Item *item);
EAPI void elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style);
EAPI const char *elm_list_item_cursor_style_get(const Elm_List_Item *item);
EAPI void elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only);
EAPI Eina_Bool elm_list_item_cursor_engine_only_get(const Elm_List_Item *item);
EAPI void elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
EAPI void elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v);
@ -1293,6 +1301,8 @@ extern "C" {
EAPI void elm_genlist_item_cursor_unset(Elm_Genlist_Item *item);
EAPI void elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item, const char *style);
EAPI const char *elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item);
EAPI void elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item, Eina_Bool engine_only);
EAPI Eina_Bool elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item);
EAPI Evas_Object *elm_check_add(Evas_Object *parent);

View File

@ -1637,6 +1637,42 @@ elm_gengrid_item_cursor_style_get(const Elm_Gengrid_Item *item)
return elm_widget_item_cursor_style_get(item);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param item widget item with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @ingroup Gengrid
*/
EAPI void
elm_gengrid_item_cursor_engine_only_set(Elm_Gengrid_Item *item, Eina_Bool engine_only)
{
elm_widget_item_cursor_engine_only_set(item, engine_only);
}
/**
* Get the cursor engine only usage for this item cursor.
*
* @param item widget item with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @ingroup Gengrid
*/
EAPI Eina_Bool
elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
{
return elm_widget_item_cursor_engine_only_get(item);
}
/**
* Set the always select mode.
*

View File

@ -3054,6 +3054,42 @@ elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
return elm_widget_item_cursor_style_get(item);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param item widget item with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @ingroup Genlist
*/
EAPI void
elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item, Eina_Bool engine_only)
{
elm_widget_item_cursor_engine_only_set(item, engine_only);
}
/**
* Get the cursor engine only usage for this item cursor.
*
* @param item widget item with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @ingroup Genlist
*/
EAPI Eina_Bool
elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
{
return elm_widget_item_cursor_engine_only_get(item);
}
/**
* This sets the horizontal stretching mode
*

View File

@ -1668,6 +1668,42 @@ elm_list_item_cursor_style_get(const Elm_List_Item *item)
return elm_widget_item_cursor_style_get(item);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param item widget item with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @ingroup List
*/
EAPI void
elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
{
elm_widget_item_cursor_engine_only_set(item, engine_only);
}
/**
* Get the cursor engine only usage for this item cursor.
*
* @param item widget item with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @ingroup List
*/
EAPI Eina_Bool
elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
{
return elm_widget_item_cursor_engine_only_get(item);
}
/**
* Set bounce mode
*

View File

@ -1010,6 +1010,42 @@ elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item)
return elm_widget_item_cursor_style_get(item);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param item widget item with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @ingroup Toolbar
*/
EAPI void
elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only)
{
elm_widget_item_cursor_engine_only_set(item, engine_only);
}
/**
* Get the cursor engine only usage for this item cursor.
*
* @param item widget item with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @ingroup Toolbar
*/
EAPI Eina_Bool
elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item)
{
return elm_widget_item_cursor_engine_only_get(item);
}
/**
* Get whether the toolbar item opens a menu.
*

View File

@ -1814,6 +1814,44 @@ _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
return elm_object_cursor_style_get(item->view);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param item widget item with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @internal
*/
EAPI void
_elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
elm_object_cursor_engine_only_set(item->view, engine_only);
}
/**
* Get the cursor engine only usage for this item cursor.
*
* @param item widget item with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @internal
*/
EAPI Eina_Bool
_elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
return elm_object_cursor_engine_only_get(item->view);
}
// smart object funcs
static void
_smart_reconfigure(Smart_Data *sd)

View File

@ -309,6 +309,8 @@ EAPI void _elm_widget_item_cursor_set(Elm_Widget_Item *item, const c
EAPI void _elm_widget_item_cursor_unset(Elm_Widget_Item *item);
EAPI void _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, const char *style);
EAPI const char *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item);
EAPI void _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only);
EAPI Eina_Bool _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item);
/**
* Convenience macro to create new widget item, doing casts for you.
@ -406,6 +408,18 @@ EAPI const char *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *i
*/
#define elm_widget_item_cursor_style_get(item) \
_elm_widget_item_cursor_style_get((const Elm_Widget_Item *)item)
/**
* Convenience function to change item's cursor engine_only.
* @see _elm_widget_item_cursor_engine_only_set()
*/
#define elm_widget_item_cursor_engine_only_set(item, engine_only) \
_elm_widget_item_cursor_engine_only_set((Elm_Widget_Item *)item, engine_only)
/**
* Convenience function to query item's cursor engine_only.
* @see _elm_widget_item_cursor_engine_only_get()
*/
#define elm_widget_item_cursor_engine_only_get(item) \
_elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item)
/**
* Cast and ensure the given pointer is an Elm_Widget_Item or return NULL.

View File

@ -148,6 +148,7 @@ struct _Elm_Cursor
#endif
Eina_Bool visible:1;
Eina_Bool use_engine:1;
Eina_Bool engine_only:1;
};
static void
@ -200,17 +201,17 @@ _elm_cursor_set_hot_spots(Elm_Cursor *cur)
}
static void
_elm_cursor_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info __UNUSED__)
_elm_cursor_mouse_in(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Elm_Cursor *cur = data;
if (cur->visible) return;
evas_event_freeze(cur->evas);
cur->visible = EINA_TRUE;
if (!cur->use_engine)
if ((!cur->engine_only) && (!cur->use_engine))
{
if (!cur->obj)
_elm_cursor_obj_add(obj, cur);
_elm_cursor_obj_add(cur->eventarea, cur);
ecore_evas_object_cursor_set(cur->ee, cur->obj,
ELM_OBJECT_LAYER_CURSOR, cur->hot_x,
cur->hot_y);
@ -232,7 +233,7 @@ _elm_cursor_mouse_out(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUS
if (!cur->visible) return;
evas_event_freeze(cur->evas);
cur->visible = EINA_FALSE;
if (!cur->use_engine)
if ((!cur->engine_only) || (!cur->use_engine))
{
ecore_evas_object_cursor_set(cur->ee, NULL, ELM_OBJECT_LAYER_CURSOR,
cur->hot_x, cur->hot_y);
@ -302,6 +303,7 @@ elm_object_sub_cursor_set(Evas_Object *eventarea, Evas_Object *owner, const char
cur->owner = owner;
cur->eventarea = eventarea;
cur->engine_only = EINA_TRUE;
cur->visible = EINA_FALSE;
cur->cursor_name = eina_stringshare_add(cursor);
@ -432,6 +434,8 @@ elm_object_cursor_unset(Evas_Object *obj)
*
* @param obj an object with cursor already set.
* @param style the theme style to use (default, transparent, ...)
*
* @ingroup Cursors
*/
EAPI void
elm_object_cursor_style_set(Evas_Object *obj, const char *style)
@ -466,6 +470,8 @@ elm_object_cursor_style_set(Evas_Object *obj, const char *style)
* @param obj an object with cursor already set.
* @return style the theme style in use, defaults to "default". If the
* object does not have a cursor set, then NULL is returned.
*
* @ingroup Cursors
*/
EAPI const char *
elm_object_cursor_style_get(const Evas_Object *obj)
@ -488,3 +494,41 @@ elm_cursor_theme(Elm_Cursor *cur)
else
_elm_cursor_set_hot_spots(cur);
}
/**
* Set if the cursor set should be searched on the theme or should use
* the provided by the engine, only.
*
* @note before you set if should look on theme you should define a cursor
* with elm_object_cursor_set(). By default it will only look for cursors
* provided by the engine.
*
* @param obj an object with cursor already set.
* @param engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well.
*
* @ingroup Cursors
*/
EAPI void
elm_object_cursor_engine_only_set(Evas_Object *obj, Eina_Bool engine_only)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj);
cur->engine_only = engine_only;
}
/**
* Get the cursor engine only usage for this object cursor.
*
* @param obj an object with cursor already set.
* @return engine_only boolean to define it cursors should be looked only
* between the provided by the engine or searched on widget's theme as well. If
* the object does not have a cursor set, then EINA_FALSE is returned.
*
* @ingroup Cursors
*/
EAPI Eina_Bool
elm_object_cursor_engine_only_get(const Evas_Object *obj)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, EINA_FALSE);
return cur->engine_only;
}