3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
8 #ifdef BOUNCING_SUPPORT
10 #define SMART_NAME "els_webview_container"
11 #define API_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
12 #define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
13 typedef struct _Smart_Data Smart_Data;
17 Evas_Coord x, y, w, h;
19 Evas_Object *smart_obj;
20 Evas_Object *child_obj;
24 /* local subsystem functions */
25 static void _smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
26 static void _smart_child_resize_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
28 static void _smart_reconfigure(Smart_Data *sd);
29 static void _smart_add(Evas_Object *obj);
30 static void _smart_del(Evas_Object *obj);
31 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
32 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
33 static void _smart_show(Evas_Object *obj);
34 static void _smart_hide(Evas_Object *obj);
35 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
36 static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
37 static void _smart_clip_unset(Evas_Object *obj);
38 static void _smart_init(void);
40 /* local subsystem globals */
41 static Evas_Smart *_smart = NULL;
43 /* externally accessible functions */
45 elm_smart_webview_container_add(Evas *evas)
48 return evas_object_smart_add(evas, _smart);
52 _elm_smart_webview_container_child_set(Evas_Object *obj, Evas_Object *child)
55 if (child == sd->child_obj) return;
58 evas_object_clip_unset(sd->child_obj);
59 evas_object_smart_member_del(sd->child_obj);
60 evas_object_event_callback_del_full(sd->child_obj, EVAS_CALLBACK_FREE, _smart_child_del_hook, sd);
61 evas_object_event_callback_del_full(sd->child_obj, EVAS_CALLBACK_RESIZE, _smart_child_resize_hook, sd);
67 sd->child_obj = child;
68 _elm_smart_webview_container_set(child, obj);
69 evas_object_clip_set(sd->child_obj, sd->clip);
70 _smart_reconfigure(sd);
72 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
76 _elm_smart_webview_container_scroll_adjust(Evas_Object *obj, int *dx, int *dy)
79 Eina_Bool changed = EINA_FALSE;
80 printf(" [ WCSA ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
84 int xsum = sd->bx + *dx;
85 if ((*dx < 0 && sd->bx > 0 && xsum < 0) ||
86 (*dx > 0 && sd->bx < 0 && xsum > 0))
99 int ysum = sd->by + *dy;
100 if ((*dy < 0 && sd->by > 0 && ysum < 0) ||
101 (*dy > 0 && sd->by < 0 && ysum > 0))
113 if (sd->bx > 0 && *dx < 0)
125 else if (sd->bx < 0 && *dx > 0)
137 if (sd->by > 0 && *dy < 0)
149 else if (sd->by < 0 && *dy > 0)
162 printf(" [ WCSA(A) ] %d , %d vs %d, %d\n", *dx, *dy, sd->bx, sd->by);
167 _elm_smart_webview_container_bounce_add(Evas_Object *obj, int dx, int dy)
172 if (sd->bx != 0 || sd->by != 0)
173 _smart_reconfigure(sd);
177 _elm_smart_webview_container_mouse_up(Evas_Object *obj)
180 if (sd->bx != 0 || sd->by != 0)
184 _smart_reconfigure(sd);
189 _elm_smart_webview_container_decelerated_flick_get(Evas_Object *obj, int *dx, int *dy)
192 if (sd->bx != 0) *dx /= 2;
193 if (sd->by != 0) *dy /= 2;
196 /* local subsystem functions */
198 _smart_child_del_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
203 sd->child_obj = NULL;
204 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
208 _smart_child_resize_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
214 evas_object_geometry_get(sd->child_obj, NULL, NULL, &w, &h);
215 /*if ((w != sd->child_w) || (h != sd->child_h))
219 _smart_reconfigure(sd);
222 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
226 _smart_reconfigure(Smart_Data *sd)
228 evas_object_move(sd->child_obj, sd->x - sd->bx, sd->y - sd->by);
229 //evas_object_move(sd->child_obj, sd->x, sd->y);
233 _smart_add(Evas_Object *obj)
237 sd = calloc(1, sizeof(Smart_Data));
246 printf("#########################%s\n",__func__);
247 sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
248 evas_object_color_set(sd->clip, 255, 255, 255, 255);
250 evas_object_smart_data_set(obj, sd);
254 _smart_del(Evas_Object *obj)
257 _elm_smart_pan_child_set(obj, NULL);
262 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
267 printf("#########################%s\n",__func__);
268 printf(" %d %d\n", x, y);
269 evas_object_move(sd->clip, x, y);
270 _smart_reconfigure(sd);
274 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
279 printf("#########################%s\n",__func__);
280 printf(" %d %d\n", w, h);
281 evas_object_resize(sd->clip, w, h);
282 _smart_reconfigure(sd);
283 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
287 _smart_show(Evas_Object *obj)
290 printf("#########################%s(clip_show)\n",__func__);
291 evas_object_show(sd->clip);
293 evas_object_show(sd->child_obj);
297 _smart_hide(Evas_Object *obj)
300 evas_object_hide(sd->child_obj);
304 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
306 printf("#########################%s\n",__func__);
308 evas_object_color_set(sd->child_obj, r, g, b, a);
312 _smart_clip_set(Evas_Object *obj, Evas_Object *clip)
314 printf("#########################%s\n",__func__);
316 //evas_object_clip_set(sd->child_obj, clip);
320 _smart_clip_unset(Evas_Object *obj)
322 printf("#########################%s\n",__func__);
324 evas_object_clip_unset(sd->child_obj);
332 static const Evas_Smart_Class sc =
335 EVAS_SMART_CLASS_VERSION,
353 _smart = evas_smart_class_new(&sc);