page next/prev
authorPatryk Kaczmarek <patryk.k@samsung.com>
Mon, 8 Jun 2015 16:16:38 +0000 (18:16 +0200)
committerPatryk Kaczmarek <patryk.k@samsung.com>
Thu, 11 Jun 2015 16:05:54 +0000 (01:05 +0900)
      * on gesture: on finger flick left/right return
            move highlight one page forward/back

Change-Id: I8c48f6267c5bc4955ae2afe9762a11ec18a37062
Signed-off-by: Patryk Kaczmarek <patryk.k@samsung.com>
include/flat_navi.h
src/flat_navi.c
src/navigator.c

index ddcb4b4..78c1363 100644 (file)
@@ -163,4 +163,13 @@ AtspiAccessible *flat_navi_context_line_last(FlatNaviContext *ctx);
  */
 Eina_Bool flat_navi_context_current_at_x_y_set( FlatNaviContext *ctx, gint x_cord, gint y_cord , AtspiAccessible **obj);
 
+/**
+ * Give the number of visible items in context.
+ *
+ * @param ctx FlatNaviContext
+ *
+ * @return int number of visible items in context
+ */
+int flat_navi_context_current_children_count_visible_get( FlatNaviContext *ctx);
+
 #endif /* end of include guard: FLAT_NAVI_H_ */
index ab0b300..a6c87dd 100644 (file)
@@ -310,6 +310,32 @@ Eina_Bool flat_navi_context_current_at_x_y_set( FlatNaviContext *ctx, gint x_cor
    return found;
 }
 
+int flat_navi_context_current_children_count_visible_get( FlatNaviContext *ctx)
+{
+   if(!ctx) return -1;
+
+   int count = 0;
+   AtspiAccessible *obj = NULL;
+   AtspiStateSet *ss = NULL;
+
+   Eina_List *l, *l2, *line;
+   AtspiAccessible *current = flat_navi_context_current_get(ctx);
+   AtspiAccessible *parent = atspi_accessible_get_parent (current, NULL);
+
+   EINA_LIST_FOREACH(ctx->lines, l, line)
+   {
+      EINA_LIST_FOREACH(line, l2, obj)
+      {
+         ss = atspi_accessible_get_state_set(obj);
+         if (atspi_state_set_contains(ss, ATSPI_STATE_SHOWING) && parent == atspi_accessible_get_parent(obj, NULL))
+            count++;
+         g_object_unref(ss);
+      }
+   }
+   return count;
+
+}
+
 FlatNaviContext *flat_navi_context_create(AtspiAccessible *root)
 {
    FlatNaviContext *ret;
index f15e130..35bac0a 100644 (file)
@@ -650,6 +650,7 @@ static void _focus_prev(void)
       DEBUG("Previous widget not found. Abort");
 }
 
+#if 0
 static void _value_inc_widget(void)
 {
    AtspiAccessible* current_widget = NULL;
@@ -775,6 +776,7 @@ static void _value_dec_widget(void)
    else
       ERROR("No value interface supported!\n");
 }
+#endif
 
 static void _activate_widget(void)
 {
@@ -1109,16 +1111,18 @@ static void _widget_scroll(Gesture_Info *gi)
 
    AtspiAccessible *obj = NULL;
    obj = flat_navi_context_current_get(context);
-   if (!obj) {
-      ERROR("No context");
-      return;
-   }
+   if (!obj)
+      {
+         ERROR("No context");
+         return;
+      }
 
    AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
-   if (!ss) {
-      ERROR("no stetes");
-      return;
-   }
+   if (!ss)
+      {
+         ERROR("no stetes");
+         return;
+      }
 
    if (!atspi_state_set_contains(ss, ATSPI_STATE_SHOWING))
       {
@@ -1145,12 +1149,139 @@ static void
 _direct_scroll_back(void)
 {
    DEBUG("ONE_FINGER_FLICK_LEFT_RETURN");
+   if (!context)
+      {
+         ERROR("No navigation context created");
+         return;
+      }
+
+   int visi = 0;
+   AtspiAccessible *obj = NULL;
+   AtspiAccessible *current = NULL;
+   AtspiAccessible *parent = NULL;
+   gchar *role = NULL;
+
+   current = flat_navi_context_current_get(context);
+   parent = atspi_accessible_get_parent (current, NULL);
+   role = atspi_accessible_get_role_name(parent, NULL);
+
+   if (strcmp(role, "list"))
+      {
+         DEBUG("That operation can be done only on list, it is:%s", role);
+         g_free(role);
+         return;
+      }
+
+   g_free(role);
+   visi = flat_navi_context_current_children_count_visible_get(context);
+   DEBUG("There is %d elements visible", visi);
+
+   int index = atspi_accessible_get_index_in_parent(current, NULL);
+   int children_count = atspi_accessible_get_child_count(parent, NULL);
+
+   if (visi <=0 || children_count <=0)
+      {
+         ERROR("NO visible element on list");
+         return;
+      }
+
+   DEBUG("start from element with index:%d/%d", index, children_count);
+
+   int target = index - visi;
+
+   if (target <=0)
+      {
+         DEBUG("first element");
+         obj = atspi_accessible_get_child_at_index (parent, 0, NULL);
+         smart_notification(FOCUS_CHAIN_END_NOTIFICATION_EVENT, 0, 0);
+      }
+
+   else
+      {
+         DEBUG("go back to %d element", target);
+         obj = atspi_accessible_get_child_at_index (parent, target, NULL);
+      }
+
+
+   if (obj)
+      {
+         DEBUG("Will set highlight and context");
+         if (flat_navi_context_current_set(context, obj))
+            {
+               DEBUG("current obj set");
+            }
+         _current_highlight_object_set(obj);
+      }
 }
 
 static void
 _direct_scroll_forward(void)
 {
    DEBUG("ONE_FINGER_FLICK_RIGHT_RETURN");
+
+   if (!context)
+      {
+         ERROR("No navigation context created");
+         return;
+      }
+
+   int visi = 0;
+   AtspiAccessible *obj = NULL;
+   AtspiAccessible *current = NULL;
+   AtspiAccessible *parent = NULL;
+   gchar *role = NULL;
+
+   current = flat_navi_context_current_get(context);
+   parent = atspi_accessible_get_parent (current, NULL);
+   role = atspi_accessible_get_role_name(parent, NULL);
+
+   if (strcmp(role, "list"))
+      {
+         DEBUG("That operation can be done only on list, it is:%s", role);
+         g_free(role);
+         return;
+      }
+
+   g_free(role);
+   visi = flat_navi_context_current_children_count_visible_get(context);
+   DEBUG("There is %d elements visible", visi);
+
+   int index = atspi_accessible_get_index_in_parent(current, NULL);
+   int children_count = atspi_accessible_get_child_count(parent, NULL);
+
+   if (visi <=0 || children_count <=0)
+      {
+         ERROR("NO visible element on list");
+         return;
+      }
+
+   DEBUG("start from element with index:%d/%d", index, children_count);
+
+   int target = index + visi;
+
+   if (target >= children_count)
+      {
+         DEBUG("last element");
+         obj = atspi_accessible_get_child_at_index (parent, children_count-1, NULL);
+         smart_notification(FOCUS_CHAIN_END_NOTIFICATION_EVENT, 0, 0);
+      }
+
+   else
+      {
+         DEBUG("go back to %d element", target);
+         obj = atspi_accessible_get_child_at_index (parent, target, NULL);
+      }
+
+
+   if (obj)
+      {
+         DEBUG("Will set highlight and context");
+         if (flat_navi_context_current_set(context, obj))
+            {
+               DEBUG("current obj set");
+            }
+         _current_highlight_object_set(obj);
+      }
 }
 
 static void