[elm_webview]modify BOUNCE feature
authorryuan choi <ryuan.choi@samsung.com>
Tue, 7 Sep 2010 10:51:24 +0000 (19:51 +0900)
committerryuan choi <ryuan.choi@samsung.com>
Tue, 7 Sep 2010 10:51:24 +0000 (19:51 +0900)
src/lib/elm_webview.c
src/lib/els_webview.c
src/lib/els_webview_container.c

index 6f37428..1b759e1 100644 (file)
@@ -115,7 +115,6 @@ elm_webview_add(Evas_Object *parent, Eina_Bool tiled)
 #ifdef BOUNCING_SUPPORT
    wd->container = elm_smart_webview_container_add(e);
    _elm_smart_webview_container_child_set(wd->container, wd->webkit);
-   _elm_smart_webview_container_set(wd->webkit, wd->container);
 #endif
    _elm_smart_webview_widget_set(wd->webkit, obj);
    evas_object_event_callback_add(wd->webkit, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
index e182142..ccfb423 100644 (file)
@@ -1889,6 +1889,7 @@ _smart_cb_pan_by(void* data, Evas_Object* webview, void* ev)
 
    int dx = sd->pan_s.x - point->x;
    int dy = sd->pan_s.y - point->y;
+   if (dx == 0 && dy == 0) return;
 
    if (!sd->ewk_view_frame_main_get)
      sd->ewk_view_frame_main_get = (Evas_Object *(*)(const Evas_Object *))dlsym(ewk_handle, "ewk_view_frame_main_get");
@@ -1949,8 +1950,13 @@ _smart_cb_pan_by(void* data, Evas_Object* webview, void* ev)
 #endif
 
 #ifdef BOUNCING_SUPPORT
+   //_elm_smart_webview_container_bounce_add(sd->container, 10, 10);
+   //return;
+
    printf(":::::::: %s\n", __func__);
-   _elm_smart_webview_container_scroll_adjust(sd->container, &dx, &dy);
+
+   Eina_Bool container_scrolled;
+   container_scrolled = _elm_smart_webview_container_scroll_adjust(sd->container, &dx, &dy);
    if (dx == 0 && dy == 0)
      {
        sd->pan_s = *point;
@@ -1978,14 +1984,16 @@ _smart_cb_pan_by(void* data, Evas_Object* webview, void* ev)
      _text_selection_move_by(sd, old_x - new_x, old_y - new_y);
 
 #ifdef BOUNCING_SUPPORT
+   printf("<< ========content [%d, %d] old pos [%d, %d] new pos [%d, %d] >>(remained(%d, %d)\n",
+        content_w, content_h,
+        old_x, old_y,
+        old_x + dx, old_y + dy,
+        old_x + dx - new_x, old_y + dy - new_y);
    int bx, by;
    bx = old_x + dx - new_x;
    by = old_y + dy - new_y;
-   if (sd->on_flick && (bx != 0 || by != 0))
-     {
-       _elm_smart_webview_container_decelerated_flick_get(sd->container, &bx, &by);
-     }
-   _elm_smart_webview_container_bounce_add(sd->container, bx, by);
+   if (container_scrolled == EINA_TRUE || (bx != 0 || by != 0))
+     _elm_smart_webview_container_bounce_add(sd->container, bx, by);
 #endif
 
 #if 0 // comment out below code until it is completed
index 6ce3998..042ab43 100644 (file)
@@ -75,11 +75,11 @@ _elm_smart_webview_container_child_set(Evas_Object *obj, Evas_Object *child)
 Eina_Bool
 _elm_smart_webview_container_scroll_adjust(Evas_Object *obj, int *dx, int *dy)
 {
-   API_ENTRY return;
+   API_ENTRY return EINA_FALSE;
    Eina_Bool changed = EINA_FALSE;
-   printf(" [ WCSA ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
+   //printf(" [ WCSA ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
 
-   if (sd->bx != 0)
+   if (sd->bx != 0 && *dx != 0)
      {
        int xsum = sd->bx + *dx;
         if ((*dx < 0 && sd->bx > 0 && xsum < 0) ||
@@ -93,8 +93,9 @@ _elm_smart_webview_container_scroll_adjust(Evas_Object *obj, int *dx, int *dy)
             sd->bx = xsum;
             *dx = 0;
          }
+       changed = EINA_TRUE;
      }
-   if (sd->by != 0)
+   if (sd->by != 0 && *dy != 0)
      {
        int ysum = sd->by + *dy;
         if ((*dy < 0 && sd->by > 0 && ysum < 0) ||
@@ -108,6 +109,7 @@ _elm_smart_webview_container_scroll_adjust(Evas_Object *obj, int *dx, int *dy)
             sd->by = ysum;
             *dy = 0;
          }
+       changed = EINA_TRUE;
      }
 #if 0
    if (sd->bx > 0 && *dx < 0)
@@ -159,7 +161,7 @@ _elm_smart_webview_container_scroll_adjust(Evas_Object *obj, int *dx, int *dy)
        changed = EINA_TRUE;
      }
 #endif
-   printf(" [ WCSA(A) ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
+   //printf(" [ WCSA(A) ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
    return changed;
 }
 
@@ -226,7 +228,6 @@ static void
 _smart_reconfigure(Smart_Data *sd)
 {
    evas_object_move(sd->child_obj, sd->x - sd->bx, sd->y - sd->by);
-   //evas_object_move(sd->child_obj, sd->x, sd->y);
 }
 
 static void