From: Ryuan Choi Date: Thu, 19 Aug 2010 04:20:10 +0000 (+0900) Subject: [elm_webview]add bounce api X-Git-Tag: beat-winset-test_0.1.1-40~40^2~27^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e81314f1216bd3aecfdda0c996242dafa61d165;p=framework%2Fuifw%2Felementary.git [elm_webview]add bounce api --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index f3d9711..6ab6108 100755 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -2519,6 +2519,7 @@ extern "C" { EAPI Eina_Bool elm_webview_auto_fitting_get(); EAPI Evas_Object *elm_webview_minimap_get(Evas_Object *obj); EAPI void elm_webview_uri_set(Evas_Object *obj, const char *uri); + EAPI void elm_webview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce); /* NoContents */ EAPI Evas_Object *elm_nocontents_add(Evas_Object *parent); diff --git a/src/lib/elm_webview.c b/src/lib/elm_webview.c index 6043b01..7948791 100644 --- a/src/lib/elm_webview.c +++ b/src/lib/elm_webview.c @@ -152,4 +152,26 @@ elm_webview_uri_set(Evas_Object *obj, const char *uri) if (!wd) return; _elm_smart_webview_uri_set(wd->webkit, uri); } + +/** + * Set bouncing behavior + * + * When scrolling, the WebView may "bounce" when reaching an edge of contents + * This is a visual way to indicate the end has been reached. This is enabled + * by default for both axes. This will set if it is enabled for that axis with + * the boolean parameers for each axis. + * + * @param obj The WebView object + * @param h_bounce Will the WebView bounce horizontally or not + * @param v_bounce Will the WebView bounce vertically or not + * + * @ingroup WebView + */ +EAPI void +elm_webview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + _elm_smart_webview_bounce_allow_set(wd->webkit, h_bounce, v_bounce); +} #endif diff --git a/src/lib/els_webview.c b/src/lib/els_webview.c index 662a0b2..b4403e9 100644 --- a/src/lib/els_webview.c +++ b/src/lib/els_webview.c @@ -49,6 +49,8 @@ struct _Smart_Data { Evas_Object* widget; int locked_dx; int locked_dy; + unsigned char bounce_horiz : 1; + unsigned char bounce_vert : 1; /* ewk functions */ void (*ewk_view_theme_set)(Evas_Object *, const char *); @@ -462,6 +464,14 @@ _elm_smart_webview_widget_set(Evas_Object *obj, Evas_Object *wid) sd->widget = wid; } +void +_elm_smart_webview_bounce_allow_set(Evas_Object* obj, Eina_Bool horiz, Eina_Bool vert) +{ + API_ENTRY return; + sd->bounce_horiz = horiz; + sd->bounce_vert = vert; +} + /* local subsystem functions */ static void _smart_show(Evas_Object* obj) @@ -1313,6 +1323,7 @@ _smart_cb_pan_by(void* data, Evas_Object* webview, void* ev) content_h *= zoom; DBG("<< ========content [%d, %d] new pos [%d, %d] >>\n", content_w, content_h, old_x + dx, old_y + dy); +#if 0 if ((old_x + dx) >= 0 && (old_x + dx) <= content_w && !elm_widget_drag_lock_x_get(sd->widget)) elm_widget_drag_lock_x_set(sd->widget, EINA_TRUE); if ((old_y + dy) >= 0 && (old_y + dy) <= content_h && !elm_widget_drag_lock_y_get(sd->widget)) @@ -1352,6 +1363,50 @@ _smart_cb_pan_by(void* data, Evas_Object* webview, void* ev) locked = EINA_TRUE; } } +#else + Eina_Bool locked = EINA_FALSE; + if (!sd->bounce_horiz) + { + if (!elm_widget_drag_lock_x_get(sd->widget)) + { + if ((old_x + dx) >= 0 && (old_x + dx) <=content_w) + elm_widget_drag_lock_x_set(sd->widget, EINA_TRUE); + else if ((sd->locked_dx > 0 && (sd->locked_dx + dx) <= 0) + || (sd->locked_dx < 0 && (sd->locked_dx + dx) >= 0)) + { + elm_widget_drag_lock_x_set(sd->widget, EINA_TRUE); + DBG("===============<< widget x lock >>\n"); + dx += sd->locked_dx; + } + else + { + sd->locked_dx += dx; + locked = EINA_TRUE; + } + } + } + if (!sd->bounce_vert) + { + if (!elm_widget_drag_lock_y_get(sd->widget)) + { + if ((old_y + dy) >= 0 && (old_y + dy) <= content_h) + elm_widget_drag_lock_y_set(sd->widget, EINA_TRUE); + else if ((sd->locked_dy > 0 && (sd->locked_dy + dy) <= 0) + || (sd->locked_dy < 0 && (sd->locked_dy + dy) >= 0)) + { + elm_widget_drag_lock_y_set(sd->widget, EINA_TRUE); + DBG("===============<< widget y lock >>\n"); + dy += sd->locked_dy; + + } + else + { + sd->locked_dy += dy; + locked = EINA_TRUE; + } + } + } +#endif if (locked) return; diff --git a/src/lib/els_webview.h b/src/lib/els_webview.h index a680640..033d599 100644 --- a/src/lib/els_webview.h +++ b/src/lib/els_webview.h @@ -1 +1,2 @@ -Evas_Object* _els_webview_add(Evas_Object *parent, Eina_Bool tiled); +Evas_Object* _elm_smart_webview_add(Evas *evas, Eina_Bool tiled); +void _elm_smart_webview_bounce_allow_set(Evas_Object* obj, Eina_Bool horiz, Eina_Bool vert);