raster pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=bdcdd02c9c9891d41f15ce8d57001e10a028b968

commit bdcdd02c9c9891d41f15ce8d57001e10a028b968
Author: Amitesh Singh <[email protected]>
Date:   Tue Apr 1 20:26:13 2014 +0900

    gengrid: Added focus movement on widget items by mouse in.
    
    Summary:
    - Added a test case in "Gengrid Focus".
    @feature
    
    Test Plan: elementary_test->Gengrid Focus
    
    Reviewers: raster, cedric, woohyun
    
    Reviewed By: raster
    
    CC: seoz
    
    Differential Revision: https://phab.enlightenment.org/D664
---
 src/bin/test_gengrid.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/lib/elm_gengrid.c  | 13 +++++++++++++
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index b153767..4d5341a 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -1323,12 +1323,26 @@ _gengrid_focus_key_down_cb(void *data EINA_UNUSED, Evas 
*e EINA_UNUSED,
    printf("\n=== Key Down : %s ===\n", ev->keyname);
 }
 
+static void
+test_gengrid_focus_focus_move_policy_changed(void *data EINA_UNUSED,
+                                             Evas_Object *obj,
+                                             void *event_info EINA_UNUSED)
+{
+   int val = elm_radio_value_get(obj);
+
+   if (val == 0)
+     elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
+   else if (val == 1)
+     elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_IN);
+}
+
 void
 test_gengrid_focus(void *data EINA_UNUSED,
                    Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
-   Evas_Object *win, *bx, *bx_horiz, *gengrid, *btn, *fr, *lb;
+   Evas_Object *win, *bx, *bx_horiz, *gengrid, *btn, *fr, *lb, *bx_mv, *rdg,
+   *rd;
    Elm_Gengrid_Item_Class *ic;
    Item_Data *id;
    char buf[PATH_MAX];
@@ -1399,6 +1413,40 @@ test_gengrid_focus(void *data EINA_UNUSED,
    elm_box_pack_end(bx_horiz, btn);
    evas_object_show(btn);
 
+   //Focus movement policy
+   fr = elm_frame_add(bx);
+   elm_object_text_set(fr, "Focus Movement Policy");
+   evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(bx, fr);
+   evas_object_show(fr);
+
+   bx_mv = elm_box_add(fr);
+   elm_box_horizontal_set(bx_mv, EINA_TRUE);
+   elm_object_content_set(fr, bx_mv);
+   evas_object_show(bx_mv);
+
+   rdg = rd = elm_radio_add(bx_mv);
+   elm_object_text_set(rd, "Focus Move by Click");
+   elm_radio_state_value_set(rd, 0);
+   evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
+   evas_object_smart_callback_add(rd, "changed",
+                                  test_gengrid_focus_focus_move_policy_changed,
+                                  NULL);
+   elm_box_pack_end(bx_mv, rd);
+   evas_object_show(rd);
+
+   rd = elm_radio_add(bx_mv);
+   elm_object_text_set(rd, "Focus Move by Mouse-In");
+   elm_radio_group_add(rd, rdg);
+   elm_radio_state_value_set(rd, 1);
+   evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
+   evas_object_smart_callback_add(rd, "changed",
+                                  test_gengrid_focus_focus_move_policy_changed,
+                                  NULL);
+   elm_box_pack_end(bx_mv, rd);
+   evas_object_show(rd);
+
    ic = elm_gengrid_item_class_new();
    ic->item_style = "default";
    ic->func.text_get = grid_text_get;
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index a362aa9..0f359f5 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -306,6 +306,17 @@ _item_unselect(Elm_Gen_Item *it)
 }
 
 static void
+_item_mouse_in_cb(void *data,
+                  Evas *evas EINA_UNUSED,
+                  Evas_Object *obj EINA_UNUSED,
+                  void *event_info EINA_UNUSED)
+{
+   if (!elm_object_item_disabled_get(data) &&
+       (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN))
+     elm_object_item_focus_set(data, EINA_TRUE);
+}
+
+static void
 _item_mouse_move_cb(void *data,
                     Evas *evas EINA_UNUSED,
                     Evas_Object *obj,
@@ -872,6 +883,8 @@ _item_realize(Elm_Gen_Item *it)
           (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _item_mouse_up_cb, it);
         evas_object_event_callback_add
           (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _item_mouse_move_cb, it);
+        evas_object_event_callback_add
+          (VIEW(it), EVAS_CALLBACK_MOUSE_IN, _item_mouse_in_cb, it);
 
         _elm_gengrid_item_index_update(it);
 

-- 


Reply via email to