focus: Added optional focus feature - focus movement by mouse_in.
authorDaniel Juyung Seo <juyung.seo@samsung.com>
Thu, 20 Mar 2014 14:50:46 +0000 (23:50 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sat, 22 Mar 2014 17:04:16 +0000 (02:04 +0900)
Focus is moved by mouse click by default. This patch makes moving focus
by mouse_in optionally by configuration and API. Widget item focus
movement is not applied yet. Need to do that as well.

- configuration: "focus_move_policy"
- API: elm_config_focus_move_policy_set/get
- enum
  ELM_FOCUS_MOVE_POLICY_CLICK
  ELM_FOCUS_MOVE_POLICY_IN

@feature

config/default/base.src
config/mobile/base.src
config/standard/base.src
src/lib/elm_config.c
src/lib/elm_config.h
src/lib/elm_priv.h
src/lib/elm_widget.c

index 1f274e1..c786049 100644 (file)
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 0;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 0;
   value "inwin_dialogs_enable" uchar: 1;
index 9fa7520..60a1521 100644 (file)
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 0;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 0;
   value "inwin_dialogs_enable" uchar: 1;
index e09e857..838d958 100644 (file)
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 1;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 1;
   value "fileselector_double_tap_navigation_enable" uchar: 1;
index dea64ce..754a9b9 100644 (file)
@@ -505,6 +505,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_highlight_clip_disable, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, focus_move_policy, T_UCHAR);
    ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
    ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, fileselector_double_tap_navigation_enable, T_UCHAR);
@@ -1504,6 +1505,7 @@ _config_load(void)
    _elm_config->focus_highlight_enable = EINA_FALSE;
    _elm_config->focus_highlight_animate = EINA_TRUE;
    _elm_config->focus_highlight_clip_disable = EINA_FALSE;
+   _elm_config->focus_move_policy = ELM_FOCUS_MOVE_POLICY_CLICK;
    _elm_config->toolbar_shrink_mode = 2;
    _elm_config->fileselector_expand_enable = EINA_FALSE;
    _elm_config->fileselector_double_tap_navigation_enable = EINA_FALSE;
@@ -2032,6 +2034,9 @@ _env_get(void)
    s = getenv("ELM_FOCUS_HIGHLIGHT_CLIP_DISABLE");
    if (s) _elm_config->focus_highlight_clip_disable = !!atoi(s);
 
+   s = getenv("ELM_FOCUS_MOVE_POLICY");
+   if (s) _elm_config->focus_move_policy = !!atoi(s);
+
    s = getenv("ELM_TOOLBAR_SHRINK_MODE");
    if (s) _elm_config->toolbar_shrink_mode = atoi(s);
 
@@ -2555,6 +2560,17 @@ elm_config_focus_highlight_clip_disabled_set(Eina_Bool disable)
    _elm_config->focus_highlight_clip_disable = !!disable;
 }
 
+EAPI Elm_Focus_Move_Policy
+elm_config_focus_move_policy_get(void)
+{
+   return _elm_config->focus_move_policy;
+}
+
+EAPI void
+elm_config_focus_move_policy_set(Elm_Focus_Move_Policy policy)
+{
+   _elm_config->focus_move_policy = policy;
+}
 
 EAPI Eina_Bool
 elm_config_scroll_bounce_enabled_get(void)
index bd5a8b5..e1494e0 100644 (file)
@@ -1239,6 +1239,45 @@ EAPI Eina_Bool elm_config_focus_highlight_clip_disabled_get(void);
 EAPI void elm_config_focus_highlight_clip_disabled_set(Eina_Bool disable);
 
 /**
+ * Focus Movement Policy
+ *
+ * @since 1.10
+ * @ingroup Focus
+ */
+typedef enum
+{
+   ELM_FOCUS_MOVE_POLICY_CLICK,
+   ELM_FOCUS_MOVE_POLICY_IN
+} Elm_Focus_Move_Policy;
+
+/**
+ * Get the focus movement policy
+ *
+ * @return The focus movement policy
+ *
+ * Get how the focus is moved to another object. It can be @c
+ * ELM_FOCUS_MOVE_POLICY_CLICK or @c ELM_FOCUS_MOVE_POLICY_IN. The first means
+ * elementary focus is moved on elementary object click. The second means
+ * elementary focus is moved on elementary object mouse in.
+ *
+ * @see elm_config_focus_move_policy_set()
+ * @since 1.10
+ * @ingroup Focus
+ */
+EAPI Elm_Focus_Move_Policy elm_config_focus_move_policy_get(void);
+
+/**
+ * Set elementary focus movement policy
+ *
+ * @param policy A policy to apply for the focus movement
+ *
+ * @see elm_config_focus_move_policy_get()
+ * @since 1.10
+ * @ingroup Focus
+ */
+EAPI void elm_config_focus_move_policy_set(Elm_Focus_Move_Policy policy);
+
+/**
  * Get the system mirrored mode. This determines the default mirrored mode
  * of widgets.
  *
index 85e421c..f977cbc 100644 (file)
@@ -224,6 +224,7 @@ struct _Elm_Config
    unsigned char focus_highlight_enable;
    unsigned char focus_highlight_animate;
    unsigned char focus_highlight_clip_disable; /**< This shows disabled status of focus highlight clip feature. This value is false by default so the focus highlight is clipped. */
+   unsigned char focus_move_policy; /**< This show how the elementary focus is moved to another object. Focus can be moved by click or mouse_in. */
    int           toolbar_shrink_mode;
    unsigned char fileselector_expand_enable;
    unsigned char fileselector_double_tap_navigation_enable;
index 973b113..4249d75 100644 (file)
@@ -250,11 +250,23 @@ _obj_mouse_up(void *data,
               void *event_info EINA_UNUSED)
 {
    ELM_WIDGET_DATA_GET(data, sd);
-   if (sd->still_in)
+   if (sd->still_in &&
+       (_elm_config->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,
+              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_focus_mouse_up_handle(obj);
+}
+
 EOLIAN static void
 _elm_widget_evas_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
 {
@@ -271,6 +283,8 @@ _elm_widget_evas_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
                                   _obj_mouse_move, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
                                   _obj_mouse_up, obj);
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_IN,
+                                  _obj_mouse_in, obj);
    /* just a helper for inheriting classes */
    if (priv->resize_obj)
      {