scroller: add key action move option.
authorHosang Kim <hosang12.kim@samsung.com>
Fri, 25 Nov 2016 04:14:06 +0000 (13:14 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 29 Nov 2016 12:32:35 +0000 (21:32 +0900)
Summary:
when scroller page is enabled and key is pressed,
     scroller will move in page by page.

     Test Plan: elementary_test -> scroller

     Reviewers: woohyun, cedric, jaehwan, raster, Hermet

     Subscribers: akanad, jpeg

     Differential Revision: https://phab.enlightenment.org/D4425

Change-Id: I7446d4fb62944e7107dde790c57bb0fbf02684fd

src/lib/elm_scroller.c

index 2f133b8..303ca98 100644 (file)
@@ -105,6 +105,8 @@ _key_action_move(Evas_Object *obj, const char *params)
    Evas_Coord f_y = 0;
    Evas_Coord f_w = 0;
    Evas_Coord f_h = 0;
+   Evas_Coord pagesize_h = 0, pagesize_v = 0;
+   Evas_Coord pagenumber_h = 0, pagenumber_v = 0;
 
    eo_do(obj,
          elm_interface_scrollable_content_pos_get(&x, &y),
@@ -188,25 +190,53 @@ _key_action_move(Evas_Object *obj, const char *params)
 
    eina_list_free(can_focus_list);
 
+   eo_do(obj,
+         elm_interface_scrollable_paging_get(NULL, NULL, &pagesize_h, &pagesize_v),
+         elm_interface_scrollable_current_page_get(&pagenumber_h, &pagenumber_v));
+
    if (!strcmp(dir, "left"))
      {
         if ((x <= 0) && (!sd->loop_h)) return EINA_FALSE;
-        x -= step_x;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h - 1, pagenumber_v));
+             return EINA_TRUE;
+          }
+        else
+          x -= step_x;
      }
    else if (!strcmp(dir, "right"))
      {
         if ((x >= (max_x - v_w)) && (!sd->loop_h)) return EINA_FALSE;
-        x += step_x;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h + 1, pagenumber_v));
+             return EINA_TRUE;
+          }
+        else
+          x += step_x;
      }
    else if (!strcmp(dir, "up"))
      {
         if ((y <= 0) && (!sd->loop_v)) return EINA_FALSE;
-        y -= step_y;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h, pagenumber_v - 1));
+             return EINA_TRUE;
+          }
+        else
+          y -= step_y;
      }
    else if (!strcmp(dir, "down"))
      {
         if ((y >= (max_y - v_h)) && (!sd->loop_v)) return EINA_FALSE;
-        y += step_y;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h, pagenumber_v + 1));
+             return EINA_TRUE;
+          }
+        else
+          y += step_y;
      }
    else if (!strcmp(dir, "first"))
      {
@@ -218,17 +248,33 @@ _key_action_move(Evas_Object *obj, const char *params)
      }
    else if (!strcmp(dir, "prior"))
      {
-        if (page_y < 0)
-          y -= -(page_y * v_h) / 100;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h, pagenumber_v - 1));
+             return EINA_TRUE;
+          }
         else
-          y -= page_y;
+          {
+             if (page_y < 0)
+               y -= -(page_y * v_h) / 100;
+             else
+               y -= page_y;
+          }
      }
    else if (!strcmp(dir, "next"))
      {
-        if (page_y < 0)
-          y += -(page_y * v_h) / 100;
+        if (pagesize_h)
+          {
+             eo_do(obj, elm_interface_scrollable_page_bring_in(pagenumber_h, pagenumber_v + 1));
+             return EINA_TRUE;
+          }
         else
-          y += page_y;
+          {
+             if (page_y < 0)
+               y += -(page_y * v_h) / 100;
+             else
+               y += page_y;
+          }
      }
    else return EINA_FALSE;