summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2015-06-02 13:42:00 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2015-06-02 13:42:00 +0900
commitf0a7fafa5959f7b182100e31cab2a808e3543c9b (patch)
treed7d30ea6f41162d2b0e983707ed27ebbea79cfe0
parent6e4b49549dad5da547479a87aa92cc117f39ea73 (diff)
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
-rw-r--r--src/bin/Makefile.am1
-rw-r--r--src/bin/test.c2
-rw-r--r--src/lib/elm_config.h3
-rw-r--r--src/lib/elm_focus.h36
-rw-r--r--src/lib/elm_main.c15
-rw-r--r--src/lib/elm_widget.c38
-rw-r--r--src/lib/elm_widget.eo11
-rw-r--r--src/lib/elm_widget.h3
8 files changed, 105 insertions, 4 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 3d0a990a9..fdaafa46b 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -65,6 +65,7 @@ test_flipselector.c \
65test_floating.c \ 65test_floating.c \
66test_focus.c \ 66test_focus.c \
67test_focus_custom_chain.c \ 67test_focus_custom_chain.c \
68test_focus_policy.c \
68test_focus_style.c \ 69test_focus_style.c \
69test_gengrid.c \ 70test_gengrid.c \
70test_genlist.c \ 71test_genlist.c \
diff --git a/src/bin/test.c b/src/bin/test.c
index 9a7de33aa..443d69c69 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -206,6 +206,7 @@ void test_focus_style(void *data, Evas_Object *obj, void *event_info);
206void test_focus_part(void *data, Evas_Object *obj, void *event_info); 206void test_focus_part(void *data, Evas_Object *obj, void *event_info);
207void test_focus3(void *data, Evas_Object *obj, void *event_info); 207void test_focus3(void *data, Evas_Object *obj, void *event_info);
208void test_focus_object_style(void *data, Evas_Object *obj, void *event_info); 208void test_focus_object_style(void *data, Evas_Object *obj, void *event_info);
209void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info);
209void test_flipselector(void *data, Evas_Object *obj, void *event_info); 210void test_flipselector(void *data, Evas_Object *obj, void *event_info);
210void test_diskselector(void *data, Evas_Object *obj, void *event_info); 211void test_diskselector(void *data, Evas_Object *obj, void *event_info);
211void test_colorselector(void *data, Evas_Object *obj, void *event_info); 212void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@@ -804,6 +805,7 @@ add_tests:
804 ADD_TEST(NULL, "Focus", "Focus On Part", test_focus_part); 805 ADD_TEST(NULL, "Focus", "Focus On Part", test_focus_part);
805 ADD_TEST(NULL, "Focus", "Focus 3", test_focus3); 806 ADD_TEST(NULL, "Focus", "Focus 3", test_focus3);
806 ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style); 807 ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style);
808 ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy);
807 809
808 //------------------------------// 810 //------------------------------//
809 ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe); 811 ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index b069c6021..5718790d9 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -1422,7 +1422,8 @@ EAPI void elm_config_focus_highlight_clip_disabled_set(Eina_Bool disable);
1422typedef enum 1422typedef enum
1423{ 1423{
1424 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) */ 1424 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) */
1425 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. */ 1425 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. */
1426 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.*/
1426} Elm_Focus_Move_Policy; 1427} Elm_Focus_Move_Policy;
1427 1428
1428/** 1429/**
diff --git a/src/lib/elm_focus.h b/src/lib/elm_focus.h
index 3aad5e94c..29883f784 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);
335 * @since 1.10 335 * @since 1.10
336 */ 336 */
337EAPI Elm_Object_Item *elm_object_focused_item_get(const Evas_Object *obj); 337EAPI Elm_Object_Item *elm_object_focused_item_get(const Evas_Object *obj);
338
339/**
340 * Set the focus movement policy to a given Elementary object.
341 *
342 * @param obj The Elementary object to operate on
343 * @param policy A policy to apply for the focus movement
344 *
345 * @see elm_object_focus_move_policy_get
346 *
347 * @since 1.15
348 *
349 * @ingroup Focus
350 */
351EAPI void elm_object_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy);
352
353/**
354 * Get the focus movement policy from a given Elementary objet.
355 *
356 * @param obj The Elementary widget to get the information from
357 * @return The focus movement policy
358 *
359 * Get how the focus is moved to the give Elemenray object. It can be
360 * #ELM_FOCUS_MOVE_POLICY_CLICK, #ELM_FOCUS_MOVE_POLICY_IN,
361 * or #ELM_FOCUS_MOVE_POLICY_KEY_ONLY.
362 * The first means elementary focus is moved on elementary object click.
363 * The second means elementary focus is moved on elementary object mouse in.
364 * The last means elementary focus is moved only by key input like Left,
365 * Right, Up, Down, Tab, or Shift+Tab.
366 *
367 * @see elm_object_focus_move_policy_set
368 *
369 * @since 1.15
370 *
371 * @ingroup Focus
372 */
373EAPI 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 c1f57c777..0fcebc543 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -1484,6 +1484,21 @@ elm_object_tree_focus_allow_get(const Evas_Object *obj)
1484} 1484}
1485 1485
1486EAPI void 1486EAPI void
1487elm_object_focus_move_policy_set(Evas_Object *obj,
1488 Elm_Focus_Move_Policy policy)
1489{
1490 EINA_SAFETY_ON_NULL_RETURN(obj);
1491 elm_widget_focus_move_policy_set(obj, policy);
1492}
1493
1494EAPI Elm_Focus_Move_Policy
1495elm_object_focus_move_policy_get(Evas_Object *obj)
1496{
1497 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1498 return elm_widget_focus_move_policy_get(obj);
1499}
1500
1501EAPI void
1487elm_object_scroll_hold_push(Evas_Object *obj) 1502elm_object_scroll_hold_push(Evas_Object *obj)
1488{ 1503{
1489 EINA_SAFETY_ON_NULL_RETURN(obj); 1504 EINA_SAFETY_ON_NULL_RETURN(obj);
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 1fe8a99f4..c21981fe0 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -352,19 +352,20 @@ _obj_mouse_up(void *data,
352{ 352{
353 ELM_WIDGET_DATA_GET(data, sd); 353 ELM_WIDGET_DATA_GET(data, sd);
354 if (sd->still_in && 354 if (sd->still_in &&
355 (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK)) 355 (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
356 elm_widget_focus_mouse_up_handle(obj); 356 elm_widget_focus_mouse_up_handle(obj);
357 357
358 sd->still_in = EINA_FALSE; 358 sd->still_in = EINA_FALSE;
359} 359}
360 360
361static void 361static void
362_obj_mouse_in(void *data EINA_UNUSED, 362_obj_mouse_in(void *data,
363 Evas *e EINA_UNUSED, 363 Evas *e EINA_UNUSED,
364 Evas_Object *obj, 364 Evas_Object *obj,
365 void *event_info EINA_UNUSED) 365 void *event_info EINA_UNUSED)
366{ 366{
367 if (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN) 367 ELM_WIDGET_DATA_GET(data, sd);
368 if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
368 elm_widget_focus_mouse_up_handle(obj); 369 elm_widget_focus_mouse_up_handle(obj);
369} 370}
370 371
@@ -377,6 +378,7 @@ _elm_widget_evas_object_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
377 * settings */ 378 * settings */
378 elm_widget_can_focus_set(obj, EINA_TRUE); 379 elm_widget_can_focus_set(obj, EINA_TRUE);
379 priv->is_mirrored = elm_config_mirrored_get(); 380 priv->is_mirrored = elm_config_mirrored_get();
381 priv->focus_move_policy = _elm_config->focus_move_policy;
380 382
381 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, 383 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
382 _obj_mouse_down, obj); 384 _obj_mouse_down, obj);
@@ -4108,6 +4110,36 @@ _elm_widget_orientation_set(Eo *obj, Elm_Widget_Smart_Data *sd, int orient_mode)
4108 } 4110 }
4109} 4111}
4110 4112
4113/**
4114 * @internal
4115 *
4116 * Returns the widget's focus move policy.
4117 *
4118 * @param obj The widget.
4119 * @return focus move policy of the object.
4120 *
4121 **/
4122EOLIAN static Elm_Focus_Move_Policy
4123_elm_widget_focus_move_policy_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4124{
4125 return sd->focus_move_policy;
4126}
4127
4128/**
4129 * @internal
4130 *
4131 * Sets the widget's focus move policy.
4132 *
4133 * @param obj The widget.
4134 * @param policy Elm_Focus_Momve_Policy to set object's focus move policy.
4135 */
4136
4137EOLIAN static void
4138_elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Move_Policy policy)
4139{
4140 if (sd->focus_move_policy == policy) return;
4141 sd->focus_move_policy = policy;
4142}
4111static void 4143static void
4112_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info); 4144_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
4113 4145
diff --git a/src/lib/elm_widget.eo b/src/lib/elm_widget.eo
index 4b58a8653..22b4417f5 100644
--- a/src/lib/elm_widget.eo
+++ b/src/lib/elm_widget.eo
@@ -793,6 +793,17 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte
793 @in relative_child: Evas.Object * @optional; 793 @in relative_child: Evas.Object * @optional;
794 } 794 }
795 } 795 }
796 @property focus_move_policy {
797 set {
798 /*@ No description supplied by the EAPI. */
799 }
800 get {
801 /*@ No description supplied by the EAPI. */
802 }
803 values {
804 policy: Elm_Focus_Move_Policy;
805 }
806 }
796 } 807 }
797 implements { 808 implements {
798 class.constructor; 809 class.constructor;
diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h
index 7ab1a587e..12e6ebb94 100644
--- a/src/lib/elm_widget.h
+++ b/src/lib/elm_widget.h
@@ -419,6 +419,7 @@ typedef struct _Elm_Widget_Smart_Data
419 Evas_Object *obj); 419 Evas_Object *obj);
420 420
421 int orient_mode; /* -1 is disabled */ 421 int orient_mode; /* -1 is disabled */
422 Elm_Focus_Move_Policy focus_move_policy;
422 423
423 Eina_Bool drag_x_locked : 1; 424 Eina_Bool drag_x_locked : 1;
424 Eina_Bool drag_y_locked : 1; 425 Eina_Bool drag_y_locked : 1;
@@ -775,6 +776,8 @@ EAPI void elm_widget_orientation_mode_disabled_set(Evas_Object *obj,
775EAPI Eina_Bool elm_widget_orientation_mode_disabled_get(const Evas_Object *obj); 776EAPI Eina_Bool elm_widget_orientation_mode_disabled_get(const Evas_Object *obj);
776EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); 777EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
777void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it); 778void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it);
779EAPI void elm_widget_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy);
780EAPI Elm_Focus_Move_Policy elm_widget_focus_move_policy_get(const Evas_Object *obj);
778 781
779/** 782/**
780 * Function to operate on a given widget's scrollabe children when necessary. 783 * Function to operate on a given widget's scrollabe children when necessary.