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
This commit is contained in:
WooHyun Jung 2015-06-02 13:42:00 +09:00
parent d495b6874e
commit 98060bd8da
8 changed files with 105 additions and 4 deletions

View File

@ -65,6 +65,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 \

View File

@ -206,6 +206,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);
@ -804,6 +805,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);

View File

@ -1422,7 +1422,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;
/**

View File

@ -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);

View File

@ -1483,6 +1483,21 @@ elm_object_tree_focus_allow_get(const Evas_Object *obj)
return !elm_widget_tree_unfocusable_get(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)
{

View File

@ -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);
@ -4108,6 +4110,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);

View File

@ -793,6 +793,17 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte
@in relative_child: Evas.Object * @optional;
}
}
@property focus_move_policy {
set {
/*@ No description supplied by the EAPI. */
}
get {
/*@ No description supplied by the EAPI. */
}
values {
policy: Elm_Focus_Move_Policy;
}
}
}
implements {
class.constructor;

View File

@ -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;
@ -775,6 +776,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.