From: WooHyun Jung Date: Tue, 2 Jun 2015 04:42:00 +0000 (+0900) Subject: elm_focus: added new focus move policy and elm_object_focus_move_policy_set/get X-Git-Tag: submit/tizen/20150917.040840~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F48234%2F3;p=platform%2Fupstream%2Felementary.git elm_focus: added new focus move policy and elm_object_focus_move_policy_set/get New focus move policy, ELM_FOCUS_MOVE_POLICY_KEY_ONLY, is added. If you set this policy as base focus move policy, objects cannot steal focus by using mouse click or mouse in. Only keyboard input (such as Left, Right, Up, Down, ...) can make focus be moved. Additaionally, an object can have its own focus move policy by using elm_object_focus_move_policy_set API. @feature Change-Id: Iaa64ce2e92b2a376d000907e2986873fa542e655 origin: upstream --- diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 73c7df3..4732189 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -64,6 +64,7 @@ test_flipselector.c \ test_floating.c \ test_focus.c \ test_focus_custom_chain.c \ +test_focus_policy.c \ test_focus_style.c \ test_gengrid.c \ test_genlist.c \ diff --git a/src/bin/test.c b/src/bin/test.c index d03b184..692914d 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -204,6 +204,7 @@ void test_focus_style(void *data, Evas_Object *obj, void *event_info); void test_focus_part(void *data, Evas_Object *obj, void *event_info); void test_focus3(void *data, Evas_Object *obj, void *event_info); void test_focus_object_style(void *data, Evas_Object *obj, void *event_info); +void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info); void test_flipselector(void *data, Evas_Object *obj, void *event_info); void test_diskselector(void *data, Evas_Object *obj, void *event_info); void test_colorselector(void *data, Evas_Object *obj, void *event_info); @@ -796,6 +797,7 @@ add_tests: ADD_TEST(NULL, "Focus", "Focus On Part", test_focus_part); ADD_TEST(NULL, "Focus", "Focus 3", test_focus3); ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style); + ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy); //------------------------------// ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe); diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h index 322e621..ad91710 100644 --- a/src/lib/elm_config.h +++ b/src/lib/elm_config.h @@ -1406,7 +1406,8 @@ EAPI void elm_config_focus_highlight_clip_disabled_set(Eina_Bool disable); typedef enum { ELM_FOCUS_MOVE_POLICY_CLICK, /**< move focus by mouse click or touch. Elementary focus is set on mouse click and this is checked at mouse up time. (default) */ - ELM_FOCUS_MOVE_POLICY_IN /**< move focus by mouse in. Elementary focus is set on mouse move when the mouse pointer is moved into an object. */ + ELM_FOCUS_MOVE_POLICY_IN, /**< move focus by mouse in. Elementary focus is set on mouse move when the mouse pointer is moved into an object. */ + ELM_FOCUS_MOVE_POLICY_KEY_ONLY /**< move focus by key. Elementary focus is set on key input like Left, Right, Up, Down, Tab, or Shift+Tab.*/ } Elm_Focus_Move_Policy; /** diff --git a/src/lib/elm_focus.h b/src/lib/elm_focus.h index 3aad5e9..29883f7 100644 --- a/src/lib/elm_focus.h +++ b/src/lib/elm_focus.h @@ -335,3 +335,39 @@ EAPI const char *elm_object_focus_highlight_style_get(const Evas_Object *obj); * @since 1.10 */ EAPI Elm_Object_Item *elm_object_focused_item_get(const Evas_Object *obj); + +/** + * Set the focus movement policy to a given Elementary object. + * + * @param obj The Elementary object to operate on + * @param policy A policy to apply for the focus movement + * + * @see elm_object_focus_move_policy_get + * + * @since 1.15 + * + * @ingroup Focus + */ +EAPI void elm_object_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy); + +/** + * Get the focus movement policy from a given Elementary objet. + * + * @param obj The Elementary widget to get the information from + * @return The focus movement policy + * + * Get how the focus is moved to the give Elemenray object. It can be + * #ELM_FOCUS_MOVE_POLICY_CLICK, #ELM_FOCUS_MOVE_POLICY_IN, + * or #ELM_FOCUS_MOVE_POLICY_KEY_ONLY. + * The first means elementary focus is moved on elementary object click. + * The second means elementary focus is moved on elementary object mouse in. + * The last means elementary focus is moved only by key input like Left, + * Right, Up, Down, Tab, or Shift+Tab. + * + * @see elm_object_focus_move_policy_set + * + * @since 1.15 + * + * @ingroup Focus + */ +EAPI Elm_Focus_Move_Policy elm_object_focus_move_policy_get(Evas_Object *obj); diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 4bb135e..30e0286 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1485,6 +1485,21 @@ elm_object_tree_focus_allow_get(const Evas_Object *obj) } EAPI void +elm_object_focus_move_policy_set(Evas_Object *obj, + Elm_Focus_Move_Policy policy) +{ + EINA_SAFETY_ON_NULL_RETURN(obj); + elm_widget_focus_move_policy_set(obj, policy); +} + +EAPI Elm_Focus_Move_Policy +elm_object_focus_move_policy_get(Evas_Object *obj) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE); + return elm_widget_focus_move_policy_get(obj); +} + +EAPI void elm_object_scroll_hold_push(Evas_Object *obj) { EINA_SAFETY_ON_NULL_RETURN(obj); diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index 3ad7e66..9dd9390 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -352,19 +352,20 @@ _obj_mouse_up(void *data, { ELM_WIDGET_DATA_GET(data, sd); if (sd->still_in && - (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK)) + (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK)) elm_widget_focus_mouse_up_handle(obj); sd->still_in = EINA_FALSE; } static void -_obj_mouse_in(void *data EINA_UNUSED, +_obj_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { - if (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN) + ELM_WIDGET_DATA_GET(data, sd); + if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN) elm_widget_focus_mouse_up_handle(obj); } @@ -377,6 +378,7 @@ _elm_widget_evas_object_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv) * settings */ elm_widget_can_focus_set(obj, EINA_TRUE); priv->is_mirrored = elm_config_mirrored_get(); + priv->focus_move_policy = _elm_config->focus_move_policy; evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _obj_mouse_down, obj); @@ -4104,6 +4106,36 @@ _elm_widget_orientation_set(Eo *obj, Elm_Widget_Smart_Data *sd, int orient_mode) } } +/** + * @internal + * + * Returns the widget's focus move policy. + * + * @param obj The widget. + * @return focus move policy of the object. + * + **/ +EOLIAN static Elm_Focus_Move_Policy +_elm_widget_focus_move_policy_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd) +{ + return sd->focus_move_policy; +} + +/** + * @internal + * + * Sets the widget's focus move policy. + * + * @param obj The widget. + * @param policy Elm_Focus_Momve_Policy to set object's focus move policy. + */ + +EOLIAN static void +_elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Move_Policy policy) +{ + if (sd->focus_move_policy == policy) return; + sd->focus_move_policy = policy; +} static void _track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info); diff --git a/src/lib/elm_widget.eo b/src/lib/elm_widget.eo index 53e3c4f..cf40e1b 100644 --- a/src/lib/elm_widget.eo +++ b/src/lib/elm_widget.eo @@ -434,6 +434,17 @@ abstract Elm_Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte const(char)* label; } } + focus_move_policy { + set { + /*@ No description supplied by the EAPI. */ + } + get { + /*@ No description supplied by the EAPI. */ + } + values { + Elm_Focus_Move_Policy policy; + } + } } methods { newest_focus_order_get @const { diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index 84c3442..e118af4 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -419,6 +419,7 @@ typedef struct _Elm_Widget_Smart_Data Evas_Object *obj); int orient_mode; /* -1 is disabled */ + Elm_Focus_Move_Policy focus_move_policy; Eina_Bool drag_x_locked : 1; Eina_Bool drag_y_locked : 1; @@ -774,6 +775,8 @@ EAPI void elm_widget_orientation_mode_disabled_set(Evas_Object *obj, EAPI Eina_Bool elm_widget_orientation_mode_disabled_get(const Evas_Object *obj); EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it); +EAPI void elm_widget_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy); +EAPI Elm_Focus_Move_Policy elm_widget_focus_move_policy_get(const Evas_Object *obj); /** * Function to operate on a given widget's scrollabe children when necessary.