1 #include <Elementary.h>
4 #define SMART_NAME "els_scroller"
5 #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)))
6 #define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
7 typedef struct _Smart_Data Smart_Data;
14 Evas_Coord x, y, w, h;
16 Evas_Object *smart_obj;
17 Evas_Object *child_obj;
19 Evas_Object *edje_obj;
20 Evas_Object *event_obj;
24 Elm_Smart_Scroller_Policy hbar_flags, vbar_flags;
43 double onhold_vx, onhold_vy, onhold_tlast, onhold_vxe, onhold_vye;
45 Evas_Coord hold_x, hold_y;
46 Ecore_Animator *hold_animator;
47 Ecore_Animator *onhold_animator;
48 Ecore_Animator *momentum_animator;
49 Ecore_Animator *bounce_x_animator;
50 Ecore_Animator *bounce_y_animator;
51 Evas_Coord locked_x, locked_y;
53 unsigned char now : 1;
54 unsigned char cancelled : 1;
55 unsigned char hold : 1;
56 unsigned char hold_parent : 1;
57 unsigned char want_dragged : 1;
58 unsigned char dragged : 1;
59 unsigned char dragged_began : 1;
60 unsigned char dir_x : 1;
61 unsigned char dir_y : 1;
62 unsigned char locked : 1;
63 unsigned char bounce_x_hold : 1;
64 unsigned char bounce_y_hold : 1;
65 unsigned char scroll : 1;
76 void (*set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
77 void (*get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
78 void (*max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
79 void (*min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
80 void (*child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
85 Evas_Coord start, end;
86 double t_start, t_end;
87 Ecore_Animator *animator;
91 double pagerel_h, pagerel_v;
92 Evas_Coord pagesize_h, pagesize_v;
94 unsigned char hbar_visible : 1;
95 unsigned char vbar_visible : 1;
96 unsigned char extern_pan : 1;
97 unsigned char one_dir_at_a_time : 1;
98 unsigned char hold : 1;
99 unsigned char freeze : 1;
100 unsigned char bouncemex : 1;
101 unsigned char bouncemey : 1;
102 unsigned char bounce_horiz : 1;
103 unsigned char bounce_vert : 1;
104 unsigned char momentum_animator_disabled :1;
105 unsigned char bounce_animator_disabled :1;
108 /* local subsystem functions */
109 static void _smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
110 static void _smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
111 static void _smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
112 static void _smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
113 static void _smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
114 static Eina_Bool _smart_hold_animator(void *data);
115 static Eina_Bool _smart_momentum_animator(void *data);
116 static void _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
117 static Eina_Bool _smart_onhold_animator(void *data);
118 static void _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
119 static void _smart_edje_drag_v_start(void *data, Evas_Object *obj, const char *emission, const char *source);
120 static void _smart_edje_drag_v_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
121 static void _smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source);
122 static void _smart_edje_drag_h_start(void *data, Evas_Object *obj, const char *emission, const char *source);
123 static void _smart_edje_drag_h_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
124 static void _smart_edje_drag_h(void *data, Evas_Object *obj, const char *emission, const char *source);
125 static void _smart_scrollbar_read(Smart_Data *sd);
126 static void _smart_scrollbar_reset(Smart_Data *sd);
127 static int _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd);
128 static int _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd);
129 static void _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd);
130 static void _smart_scrollbar_size_adjust(Smart_Data *sd);
131 static void _smart_reconfigure(Smart_Data *sd);
132 static void _smart_add(Evas_Object *obj);
133 static void _smart_del(Evas_Object *obj);
134 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
135 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
136 static void _smart_show(Evas_Object *obj);
137 static void _smart_hide(Evas_Object *obj);
138 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
139 static void _smart_clip_set(Evas_Object *obj, Evas_Object *clip);
140 static void _smart_clip_unset(Evas_Object *obj);
141 static void _smart_init(void);
143 /* local subsystem globals */
144 static Evas_Smart *_smart = NULL;
146 /* externally accessible functions */
148 elm_smart_scroller_add(Evas *evas)
151 return evas_object_smart_add(evas, _smart);
155 elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
163 _elm_smart_pan_child_set(sd->pan_obj, NULL);
164 evas_object_event_callback_del_full(sd->child_obj, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
167 sd->child_obj = child;
172 o = _elm_smart_pan_add(evas_object_evas_get(obj));
174 evas_object_smart_callback_add(o, "changed", _smart_pan_changed_hook, sd);
175 evas_object_smart_callback_add(o, "pan_changed", _smart_pan_pan_changed_hook, sd);
177 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", o);
180 sd->pan_func.set = _elm_smart_pan_set;
181 sd->pan_func.get = _elm_smart_pan_get;
182 sd->pan_func.max_get = _elm_smart_pan_max_get;
183 sd->pan_func.min_get = _elm_smart_pan_min_get;
184 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
186 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
187 _elm_smart_pan_child_set(sd->pan_obj, sd->child_obj);
188 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
191 _smart_scrollbar_size_adjust(sd);
192 _smart_scrollbar_reset(sd);
196 elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
197 void (*pan_set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y),
198 void (*pan_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
199 void (*pan_max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
200 void (*pan_min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
201 void (*pan_child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y))
205 elm_smart_scroller_child_set(obj, NULL);
209 evas_object_smart_callback_del(sd->pan_obj, "changed", _smart_pan_changed_hook);
210 evas_object_smart_callback_del(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook);
217 edje_object_part_unswallow(sd->edje_obj, sd->pan_obj);
225 evas_object_del(sd->pan_obj);
236 sd->pan_func.set = pan_set;
237 sd->pan_func.get = pan_get;
238 sd->pan_func.max_get = pan_max_get;
239 sd->pan_func.min_get = pan_min_get;
240 sd->pan_func.child_size_get = pan_child_size_get;
242 evas_object_smart_callback_add(sd->pan_obj, "changed", _smart_pan_changed_hook, sd);
243 evas_object_smart_callback_add(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook, sd);
244 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
245 evas_object_show(sd->pan_obj);
249 elm_smart_scroller_custom_edje_file_set(Evas_Object *obj, char *file, char *group)
253 edje_object_file_set(sd->edje_obj, file, group);
255 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
256 sd->vbar_visible = !sd->vbar_visible;
257 sd->hbar_visible = !sd->hbar_visible;
258 _smart_scrollbar_bar_visibility_adjust(sd);
259 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
260 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
261 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
262 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
264 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
265 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
266 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
267 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
268 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
270 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
274 elm_smart_scroller_momentum_animator_disabled_get(Evas_Object *obj)
276 API_ENTRY return EINA_FALSE;
277 return sd->momentum_animator_disabled;
281 elm_smart_scroller_momentum_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
284 sd->momentum_animator_disabled = disabled;
285 if (sd->momentum_animator_disabled)
287 if (sd->down.momentum_animator)
289 ecore_animator_del(sd->down.momentum_animator);
290 sd->down.momentum_animator = NULL;
296 elm_smart_scroller_bounce_animator_disabled_get(Evas_Object *obj)
298 API_ENTRY return EINA_FALSE;
299 return sd->bounce_animator_disabled;
303 elm_smart_scroller_bounce_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
306 sd->bounce_animator_disabled = disabled;
307 if (sd->bounce_animator_disabled)
309 if (sd->scrollto.x.animator)
311 ecore_animator_del(sd->scrollto.x.animator);
312 sd->scrollto.x.animator = NULL;
315 if (sd->scrollto.y.animator)
317 ecore_animator_del(sd->scrollto.y.animator);
318 sd->scrollto.y.animator = NULL;
324 _smart_anim_start(Evas_Object *obj)
326 evas_object_smart_callback_call(obj, "animate,start", NULL);
330 _smart_anim_stop(Evas_Object *obj)
332 evas_object_smart_callback_call(obj, "animate,stop", NULL);
336 _smart_drag_start(Evas_Object *obj)
338 evas_object_smart_callback_call(obj, "drag,start", NULL);
342 _smart_drag_stop(Evas_Object *obj)
344 evas_object_smart_callback_call(obj, "drag,stop", NULL);
348 _smart_scrollto_x_animator(void *data)
350 Smart_Data *sd = data;
354 t = ecore_loop_time_get();
355 tt = (t - sd->scrollto.x.t_start) / (sd->scrollto.x.t_end - sd->scrollto.x.t_start);
357 tt = 1.0 - (tt * tt);
358 sd->pan_func.get(sd->pan_obj, &px, &py);
359 px = (sd->scrollto.x.start * (1.0 - tt)) +
360 (sd->scrollto.x.end * tt);
361 if (t >= sd->scrollto.x.t_end)
363 px = sd->scrollto.x.end;
364 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
365 sd->scrollto.x.animator = NULL;
366 if ((!sd->scrollto.y.animator) && (!sd->down.bounce_y_animator))
367 _smart_anim_stop(sd->smart_obj);
368 return ECORE_CALLBACK_CANCEL;
370 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
371 return ECORE_CALLBACK_RENEW;
375 _smart_momentum_end(Smart_Data *sd)
377 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator)) return;
378 if (sd->down.momentum_animator)
380 ecore_animator_del(sd->down.momentum_animator);
381 sd->down.momentum_animator = NULL;
382 sd->down.bounce_x_hold = 0;
383 sd->down.bounce_y_hold = 0;
392 _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x)
394 Evas_Coord px, py, x, y, w, h;
397 if (sd->freeze) return;
400 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
401 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
403 elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
406 t = ecore_loop_time_get();
407 sd->pan_func.get(sd->pan_obj, &px, &py);
408 sd->scrollto.x.start = px;
409 sd->scrollto.x.end = pos_x;
410 sd->scrollto.x.t_start = t;
411 sd->scrollto.x.t_end = t + t_in;
412 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
413 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
414 elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
415 if (!sd->scrollto.x.animator)
417 if (!sd->scrollto.y.animator)
418 _smart_anim_start(sd->smart_obj);
419 sd->scrollto.x.animator = ecore_animator_add(_smart_scrollto_x_animator, sd);
421 if (sd->down.bounce_x_animator)
423 ecore_animator_del(sd->down.bounce_x_animator);
424 sd->down.bounce_x_animator = NULL;
425 _smart_momentum_end(sd);
431 _smart_scrollto_y_animator(void *data)
433 Smart_Data *sd = data;
437 t = ecore_loop_time_get();
438 tt = (t - sd->scrollto.y.t_start) / (sd->scrollto.y.t_end - sd->scrollto.y.t_start);
440 tt = 1.0 - (tt * tt);
441 sd->pan_func.get(sd->pan_obj, &px, &py);
442 py = (sd->scrollto.y.start * (1.0 - tt)) +
443 (sd->scrollto.y.end * tt);
444 if (t >= sd->scrollto.y.t_end)
446 py = sd->scrollto.y.end;
447 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
448 sd->scrollto.y.animator = NULL;
449 if ((!sd->scrollto.x.animator) && (!sd->down.bounce_x_animator))
450 _smart_anim_stop(sd->smart_obj);
451 return ECORE_CALLBACK_CANCEL;
453 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
455 return ECORE_CALLBACK_RENEW;
459 _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y)
461 Evas_Coord px, py, x, y, w, h;
464 if (sd->freeze) return;
467 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
468 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
470 elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
473 t = ecore_loop_time_get();
474 sd->pan_func.get(sd->pan_obj, &px, &py);
475 sd->scrollto.y.start = py;
476 sd->scrollto.y.end = pos_y;
477 sd->scrollto.y.t_start = t;
478 sd->scrollto.y.t_end = t + t_in;
479 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
480 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
481 elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
482 if (!sd->scrollto.y.animator)
484 if (!sd->scrollto.x.animator)
485 _smart_anim_start(sd->smart_obj);
486 sd->scrollto.y.animator = ecore_animator_add(_smart_scrollto_y_animator, sd);
488 if (sd->down.bounce_y_animator)
490 ecore_animator_del(sd->down.bounce_y_animator);
491 sd->down.bounce_y_animator = NULL;
492 _smart_momentum_end(sd);
498 _smart_do_page(Smart_Data *sd)
500 if ((sd->pagerel_h == 0.0) && (!sd->pagesize_h) &&
501 (sd->pagerel_v == 0.0) && (!sd->pagesize_v))
507 _smart_page_x_get(Smart_Data *sd, int offset)
509 Evas_Coord x, y, w, h, cw, ch, minx = 0;
511 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
512 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
513 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
514 sd->pan_func.min_get(sd->pan_obj, &minx, NULL);
518 if (sd->pagerel_h > 0.0)
520 x = x + (w * sd->pagerel_h * 0.5);
521 x = x / (w * sd->pagerel_h);
522 x = x * (w * sd->pagerel_h);
524 else if (sd->pagesize_h > 0)
526 x = x + (sd->pagesize_h * 0.5);
527 x = x / (sd->pagesize_h);
528 x = x * (sd->pagesize_h);
530 if (x < minx) x = minx;
531 else if ((x + w) > cw) x = cw - w;
536 _smart_page_y_get(Smart_Data *sd, int offset)
538 Evas_Coord x, y, w, h, cw, ch, miny = 0;
540 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
541 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
542 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
543 sd->pan_func.min_get(sd->pan_obj, NULL, &miny);
547 if (sd->pagerel_v > 0.0)
549 y = y + (h * sd->pagerel_v * 0.5);
550 y = y / (h * sd->pagerel_v);
551 y = y * (h * sd->pagerel_v);
553 else if (sd->pagesize_v > 0)
555 y = y + (sd->pagesize_v * 0.5);
556 y = y / (sd->pagesize_v);
557 y = y * (sd->pagesize_v);
559 if (y < miny) y = miny;
560 else if ((y + h) > ch) y = ch - h;
565 _smart_page_adjust(Smart_Data *sd)
567 Evas_Coord x, y, w, h;
569 if (!_smart_do_page(sd)) return;
571 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
573 x = _smart_page_x_get(sd, 0);
574 y = _smart_page_y_get(sd, 0);
576 elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
580 _smart_bounce_x_animator(void *data)
587 t = ecore_loop_time_get();
588 dt = t - sd->down.anim_start2;
591 dt = dt / _elm_config->thumbscroll_bounce_friction;
592 if (dt > 1.0) dt = 1.0;
593 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
594 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
595 dx = sd->down.b2x - sd->down.bx;
597 x = sd->down.bx + dx;
598 if (!sd->down.cancelled)
599 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
602 if (sd->down.momentum_animator)
603 sd->down.bounce_x_hold = 1;
604 else if ((!sd->down.bounce_y_animator) &&
605 (!sd->scrollto.y.animator))
606 _smart_anim_stop(sd->smart_obj);
607 sd->down.bounce_x_animator = NULL;
610 _smart_momentum_end(sd);
611 return ECORE_CALLBACK_CANCEL;
614 return ECORE_CALLBACK_RENEW;
618 _smart_bounce_y_animator(void *data)
625 t = ecore_loop_time_get();
626 dt = t - sd->down.anim_start3;
629 dt = dt / _elm_config->thumbscroll_bounce_friction;
630 if (dt > 1.0) dt = 1.0;
631 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
632 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
633 dy = sd->down.b2y - sd->down.by;
635 y = sd->down.by + dy;
636 if (!sd->down.cancelled)
637 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
640 if (sd->down.momentum_animator)
641 sd->down.bounce_y_hold = 1;
642 else if ((!sd->down.bounce_x_animator) &&
643 (!sd->scrollto.y.animator))
644 _smart_anim_stop(sd->smart_obj);
645 sd->down.bounce_y_animator = NULL;
648 _smart_momentum_end(sd);
649 return ECORE_CALLBACK_CANCEL;
652 return ECORE_CALLBACK_RENEW;
660 can_scroll(Smart_Data *sd, int dir)
662 Evas_Coord mx = 0, my = 0, px = 0, py = 0, minx = 0, miny = 0;
664 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
665 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
666 sd->pan_func.get(sd->pan_obj, &px, &py);
670 if (px > minx) return EINA_TRUE;
673 if ((px - minx) < mx) return EINA_TRUE;
676 if (py > miny) return EINA_TRUE;
679 if ((py - miny) < my) return EINA_TRUE;
688 _smart_momentum_animator(void *data)
692 Evas_Coord x, y, dx, dy, px, py, maxx, maxy, minx, miny;
695 t = ecore_loop_time_get();
696 dt = t - sd->down.anim_start;
700 if (sd->down.hold_parent)
702 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
706 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
711 if ((!sd->down.dir_x) && (!sd->down.dir_y))
713 sd->down.cancelled = 1;
716 dt = dt / (_elm_config->thumbscroll_friction + sd->down.extra_time);
717 if (dt > 1.0) dt = 1.0;
718 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
719 dx = (sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
720 dy = (sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
723 x = sd->down.sx - dx;
724 y = sd->down.sy - dy;
725 elm_smart_scroller_child_pos_get(sd->smart_obj, &px, &py);
726 if ((sd->down.bounce_x_animator) ||
727 (sd->down.bounce_x_hold))
729 sd->down.bx = sd->down.bx0 - dx + sd->down.b0x;
732 if ((sd->down.bounce_y_animator) ||
733 (sd->down.bounce_y_hold))
735 sd->down.by = sd->down.by0 - dy + sd->down.b0y;
738 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
739 sd->pan_func.max_get(sd->pan_obj, &maxx, &maxy);
740 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
742 ((sd->down.bounce_x_hold) && (sd->down.bounce_y_hold)))
744 _smart_anim_stop(sd->smart_obj);
745 sd->down.momentum_animator = NULL;
746 sd->down.bounce_x_hold = 0;
747 sd->down.bounce_y_hold = 0;
752 return ECORE_CALLBACK_CANCEL;
755 return ECORE_CALLBACK_RENEW;
759 bounce_eval(Smart_Data *sd)
761 Evas_Coord mx, my, px, py, bx, by, b2x, b2y, minx = 0, miny = 0;
763 if (sd->freeze) return;
764 if ((!sd->bouncemex) && (!sd->bouncemey)) return;
765 if (sd->down.now) return; // down bounce while still held down
766 if (sd->down.onhold_animator)
768 ecore_animator_del(sd->down.onhold_animator);
769 sd->down.onhold_animator = NULL;
771 if (sd->down.hold_animator)
773 ecore_animator_del(sd->down.hold_animator);
774 sd->down.hold_animator = NULL;
776 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
777 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
778 sd->pan_func.get(sd->pan_obj, &px, &py);
781 if (px < minx) px = minx;
782 if ((px - minx) > mx) px = mx + minx;
783 if (py < miny) py = miny;
784 if ((py - miny) > my) py = my + miny;
788 (!elm_widget_drag_child_locked_x_get(sd->widget)))
790 if (!sd->down.bounce_x_animator && !sd->bounce_animator_disabled)
794 if (sd->scrollto.x.animator)
796 ecore_animator_del(sd->scrollto.x.animator);
797 sd->scrollto.x.animator = NULL;
799 sd->down.bounce_x_animator = ecore_animator_add(_smart_bounce_x_animator, sd);
800 sd->down.anim_start2 = ecore_loop_time_get();
804 if (sd->down.momentum_animator) sd->down.b0x = sd->down.ax;
805 else sd->down.b0x = 0;
810 (!elm_widget_drag_child_locked_y_get(sd->widget)))
812 if (!sd->down.bounce_y_animator && !sd->bounce_animator_disabled)
816 if (sd->scrollto.y.animator)
818 ecore_animator_del(sd->scrollto.y.animator);
819 sd->scrollto.y.animator = NULL;
821 sd->down.bounce_y_animator = ecore_animator_add(_smart_bounce_y_animator, sd);
822 sd->down.anim_start3 = ecore_loop_time_get();
826 if (sd->down.momentum_animator) sd->down.b0y = sd->down.ay;
827 else sd->down.b0y = 0;
834 elm_smart_scroller_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
836 Evas_Coord mx = 0, my = 0, px, py, minx = 0, miny = 0;
840 // FIXME: allow for bounce outside of range
841 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
842 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
843 if (mx > 0) vx = (double)(x - minx) / (double)mx;
845 if (vx < 0.0) vx = 0.0;
846 else if (vx > 1.0) vx = 1.0;
847 if (my > 0) vy = (double)(y - miny) / (double)my;
849 if (vy < 0.0) vy = 0.0;
850 else if (vy > 1.0) vy = 1.0;
851 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, vy);
852 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", vx, 0.0);
853 sd->pan_func.get(sd->pan_obj, &px, &py);
854 if (!_elm_config->thumbscroll_bounce_enable)
856 if (x < minx) x = minx;
857 if ((x - minx) > mx) x = mx + minx;
858 if (y < miny) y = miny;
859 if ((y - miny) > my) y = my + miny;
862 if (!sd->bounce_horiz)
864 if (x < minx) x = minx;
865 if ((x - minx) > mx) x = mx + minx;
867 if (!sd->bounce_vert)
869 if (y < miny) y = miny;
870 if (y - miny > my) y = my + miny;
873 sd->pan_func.set(sd->pan_obj, x, y);
874 if ((px != x) || (py != y))
875 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
876 if (!sd->down.bounce_x_animator)
878 if ((x < minx) || (x > (mx + minx)))
884 if (!sd->down.bounce_y_animator)
886 if ((y < miny) || (y > my + miny))
892 if ((x != px) || (y != py))
894 evas_object_smart_callback_call(obj, "scroll", NULL);
896 if ((x != px)/* && (!sd->bouncemex)*/)
899 evas_object_smart_callback_call(obj, "edge,left", NULL);
900 if (x == (mx + minx))
901 evas_object_smart_callback_call(obj, "edge,right", NULL);
903 if ((y != py)/* && (!sd->bouncemey)*/)
906 evas_object_smart_callback_call(obj, "edge,top", NULL);
908 evas_object_smart_callback_call(obj, "edge,bottom", NULL);
913 elm_smart_scroller_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
916 sd->pan_func.get(sd->pan_obj, x, y);
920 elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
922 Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0;
925 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
926 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
927 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
928 sd->pan_func.get(sd->pan_obj, &px, &py);
932 else if ((x + w) > (px + (cw - mx)))
934 nx = x + w - (cw - mx);
939 else if ((y + h) > (py + (ch - my)))
941 ny = y + h - (ch - my);
944 if ((nx == px) && (ny == py)) return;
945 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
946 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
948 _smart_anim_stop(sd->smart_obj);
950 if (sd->scrollto.x.animator)
952 ecore_animator_del(sd->scrollto.x.animator);
953 sd->scrollto.x.animator = NULL;
955 if (sd->scrollto.y.animator)
957 ecore_animator_del(sd->scrollto.y.animator);
958 sd->scrollto.y.animator = NULL;
960 if (sd->down.bounce_x_animator)
962 ecore_animator_del(sd->down.bounce_x_animator);
963 sd->down.bounce_x_animator = NULL;
966 if (sd->down.bounce_y_animator)
968 ecore_animator_del(sd->down.bounce_y_animator);
969 sd->down.bounce_y_animator = NULL;
972 if (sd->down.hold_animator)
974 ecore_animator_del(sd->down.hold_animator);
975 sd->down.hold_animator = NULL;
976 _smart_drag_stop(sd->smart_obj);
978 if (sd->down.momentum_animator)
980 ecore_animator_del(sd->down.momentum_animator);
981 sd->down.momentum_animator = NULL;
982 sd->down.bounce_x_hold = 0;
983 sd->down.bounce_y_hold = 0;
989 elm_smart_scroller_child_pos_set(obj, nx, ny);
993 elm_smart_scroller_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
996 edje_object_calc_force(sd->edje_obj);
997 evas_object_geometry_get(sd->pan_obj, NULL, NULL, w, h);
1001 elm_smart_scroller_step_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1008 _smart_scrollbar_size_adjust(sd);
1012 elm_smart_scroller_step_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1015 if (x) *x = sd->step.x;
1016 if (y) *y = sd->step.y;
1020 elm_smart_scroller_page_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1025 _smart_scrollbar_size_adjust(sd);
1029 elm_smart_scroller_page_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1032 if (x) *x = sd->page.x;
1033 if (y) *y = sd->page.y;
1037 elm_smart_scroller_policy_set(Evas_Object *obj, Elm_Smart_Scroller_Policy hbar, Elm_Smart_Scroller_Policy vbar)
1040 if ((sd->hbar_flags == hbar) && (sd->vbar_flags == vbar)) return;
1041 sd->hbar_flags = hbar;
1042 sd->vbar_flags = vbar;
1043 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1044 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
1045 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1046 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
1048 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
1049 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1050 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
1051 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1052 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
1054 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
1055 _smart_scrollbar_size_adjust(sd);
1059 elm_smart_scroller_policy_get(Evas_Object *obj, Elm_Smart_Scroller_Policy *hbar, Elm_Smart_Scroller_Policy *vbar)
1062 if (hbar) *hbar = sd->hbar_flags;
1063 if (vbar) *vbar = sd->vbar_flags;
1067 elm_smart_scroller_edje_object_get(Evas_Object *obj)
1069 API_ENTRY return NULL;
1070 return sd->edje_obj;
1074 elm_smart_scroller_single_dir_set(Evas_Object *obj, Eina_Bool single_dir)
1077 sd->one_dir_at_a_time = single_dir;
1081 elm_smart_scroller_single_dir_get(Evas_Object *obj)
1083 API_ENTRY return EINA_FALSE;
1084 return sd->one_dir_at_a_time;
1088 elm_smart_scroller_object_theme_set(Evas_Object *parent, Evas_Object *obj, const char *clas, const char *group, const char *style)
1092 _elm_theme_object_set(parent, sd->edje_obj, clas, group, style);
1093 edje_object_scale_set(sd->edje_obj, elm_widget_scale_get(parent) * _elm_config->scale);
1095 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
1097 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1098 if (edje_object_part_exists(sd->edje_obj, "elm.scrollbar.base"))
1101 base = edje_object_part_swallow_get(sd->edje_obj, "elm.scrollbar.base");
1104 base = evas_object_rectangle_add(evas_object_evas_get(sd->edje_obj));
1105 evas_object_color_set(base, 0, 0, 0, 0);
1106 edje_object_part_swallow(sd->edje_obj, "elm.scrollbar.base", base);
1108 if (!_elm_config->thumbscroll_enable)
1109 evas_object_size_hint_min_set(base, mw, mh);
1111 sd->vbar_visible = !sd->vbar_visible;
1112 sd->hbar_visible = !sd->hbar_visible;
1113 _smart_scrollbar_bar_visibility_adjust(sd);
1117 elm_smart_scroller_hold_set(Evas_Object *obj, Eina_Bool hold)
1124 elm_smart_scroller_freeze_set(Evas_Object *obj, Eina_Bool freeze)
1127 sd->freeze = freeze;
1130 if (sd->down.onhold_animator)
1132 ecore_animator_del(sd->down.onhold_animator);
1133 sd->down.onhold_animator = NULL;
1139 elm_smart_scroller_bounce_allow_set(Evas_Object *obj, Eina_Bool horiz, Eina_Bool vert)
1142 sd->bounce_horiz = horiz;
1143 sd->bounce_vert = vert;
1147 elm_smart_scroller_bounce_allow_get(const Evas_Object *obj, Eina_Bool *horiz, Eina_Bool *vert)
1150 *horiz = sd->bounce_horiz;
1151 *vert = sd->bounce_vert;
1155 elm_smart_scroller_paging_set(Evas_Object *obj, double pagerel_h, double pagerel_v, Evas_Coord pagesize_h, Evas_Coord pagesize_v)
1158 sd->pagerel_h = pagerel_h;
1159 sd->pagerel_v = pagerel_v;
1160 sd->pagesize_h = pagesize_h;
1161 sd->pagesize_v = pagesize_v;
1162 _smart_page_adjust(sd);
1166 elm_smart_scroller_paging_get(Evas_Object *obj, double *pagerel_h, double *pagerel_v, Evas_Coord *pagesize_h, Evas_Coord *pagesize_v)
1169 if(pagerel_h) *pagerel_h = sd->pagerel_h;
1170 if(pagerel_v) *pagerel_v = sd->pagerel_v;
1171 if(pagesize_h) *pagesize_h = sd->pagesize_h;
1172 if(pagesize_v) *pagesize_v = sd->pagesize_v;
1176 elm_smart_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1178 Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0;
1181 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
1182 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
1183 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
1184 sd->pan_func.get(sd->pan_obj, &px, &py);
1188 else if ((x + w) > (px + (cw - mx)))
1190 nx = x + w - (cw - mx);
1195 else if ((y + h) > (py + (ch - my)))
1197 ny = y + h - (ch - my);
1200 if ((nx == px) && (ny == py)) return;
1201 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1202 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1204 _smart_anim_stop(sd->smart_obj);
1206 if (sd->scrollto.x.animator)
1208 ecore_animator_del(sd->scrollto.x.animator);
1209 sd->scrollto.x.animator = NULL;
1211 if (sd->scrollto.y.animator)
1213 ecore_animator_del(sd->scrollto.y.animator);
1214 sd->scrollto.y.animator = NULL;
1216 if (sd->down.bounce_x_animator)
1218 ecore_animator_del(sd->down.bounce_x_animator);
1219 sd->down.bounce_x_animator = NULL;
1222 if (sd->down.bounce_y_animator)
1224 ecore_animator_del(sd->down.bounce_y_animator);
1225 sd->down.bounce_y_animator = NULL;
1228 if (sd->down.hold_animator)
1230 ecore_animator_del(sd->down.hold_animator);
1231 sd->down.hold_animator = NULL;
1232 _smart_drag_stop(sd->smart_obj);
1234 if (sd->down.momentum_animator)
1236 ecore_animator_del(sd->down.momentum_animator);
1237 sd->down.momentum_animator = NULL;
1238 sd->down.bounce_x_hold = 0;
1239 sd->down.bounce_y_hold = 0;
1246 if (x < minx) x = minx;
1247 else if ((x + w) > cw) x = cw - w;
1248 _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
1250 if (y < miny) y = miny;
1251 else if ((y + h) > ch) y = ch - h;
1252 _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
1256 elm_smart_scroller_widget_set(Evas_Object *obj, Evas_Object *wid)
1262 /* local subsystem functions */
1264 _smart_edje_drag_v_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1269 _smart_scrollbar_read(sd);
1270 _smart_drag_start(sd->smart_obj);
1274 _smart_edje_drag_v_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1279 _smart_scrollbar_read(sd);
1280 _smart_drag_stop(sd->smart_obj);
1284 _smart_edje_drag_v(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1289 _smart_scrollbar_read(sd);
1293 _smart_edje_drag_h_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1298 _smart_scrollbar_read(sd);
1299 _smart_drag_start(sd->smart_obj);
1303 _smart_edje_drag_h_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1308 _smart_scrollbar_read(sd);
1309 _smart_drag_stop(sd->smart_obj);
1313 _smart_edje_drag_h(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1318 _smart_scrollbar_read(sd);
1322 _smart_child_del_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1327 sd->child_obj = NULL;
1328 _smart_scrollbar_size_adjust(sd);
1329 _smart_scrollbar_reset(sd);
1333 _smart_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1340 sd->pan_func.get(sd->pan_obj, &x, &y);
1341 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
1342 if ((w != sd->child.w) || (h != sd->child.h))
1346 _smart_scrollbar_size_adjust(sd);
1347 evas_object_size_hint_min_set(sd->smart_obj, sd->child.w, sd->child.h);
1348 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1353 _smart_pan_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1359 sd->pan_func.get(sd->pan_obj, &x, &y);
1360 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1361 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1363 _smart_anim_stop(sd->smart_obj);
1365 if (sd->scrollto.x.animator)
1367 ecore_animator_del(sd->scrollto.x.animator);
1368 sd->scrollto.x.animator = NULL;
1370 if (sd->scrollto.y.animator)
1372 ecore_animator_del(sd->scrollto.y.animator);
1373 sd->scrollto.y.animator = NULL;
1375 if (sd->down.bounce_x_animator)
1377 ecore_animator_del(sd->down.bounce_x_animator);
1378 sd->down.bounce_x_animator = NULL;
1381 if (sd->down.bounce_y_animator)
1383 ecore_animator_del(sd->down.bounce_y_animator);
1384 sd->down.bounce_y_animator = NULL;
1387 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1391 _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1393 Evas_Event_Mouse_Wheel *ev;
1395 Evas_Coord x = 0, y = 0;
1399 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1400 if ((evas_key_modifier_is_set(ev->modifiers, "Control")) ||
1401 (evas_key_modifier_is_set(ev->modifiers, "Alt")) ||
1402 (evas_key_modifier_is_set(ev->modifiers, "Shift")) ||
1403 (evas_key_modifier_is_set(ev->modifiers, "Meta")) ||
1404 (evas_key_modifier_is_set(ev->modifiers, "Hyper")) ||
1405 (evas_key_modifier_is_set(ev->modifiers, "Super")))
1407 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1408 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1409 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1411 _smart_anim_stop(sd->smart_obj);
1413 if (sd->scrollto.x.animator)
1415 ecore_animator_del(sd->scrollto.x.animator);
1416 sd->scrollto.x.animator = NULL;
1418 if (sd->scrollto.y.animator)
1420 ecore_animator_del(sd->scrollto.y.animator);
1421 sd->scrollto.y.animator = NULL;
1423 if (sd->down.bounce_x_animator)
1425 ecore_animator_del(sd->down.bounce_x_animator);
1426 sd->down.bounce_x_animator = NULL;
1429 if (sd->down.bounce_y_animator)
1431 ecore_animator_del(sd->down.bounce_y_animator);
1432 sd->down.bounce_y_animator = NULL;
1436 y += ev->z * sd->step.y;
1437 else if (ev->direction == 1)
1438 x += ev->z * sd->step.x;
1440 if ((!sd->hold) && (!sd->freeze))
1441 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1445 _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1447 Evas_Event_Mouse_Down *ev;
1449 Evas_Coord x = 0, y = 0;
1453 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1454 if (_elm_config->thumbscroll_enable)
1457 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1458 (sd->down.momentum_animator) || (sd->scrollto.x.animator) ||
1459 (sd->scrollto.y.animator))
1461 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL | EVAS_EVENT_FLAG_ON_HOLD;
1462 sd->down.scroll = 1;
1464 _smart_anim_stop(sd->smart_obj);
1466 if (sd->scrollto.x.animator)
1468 ecore_animator_del(sd->scrollto.x.animator);
1469 sd->scrollto.x.animator = NULL;
1471 if (sd->scrollto.y.animator)
1473 ecore_animator_del(sd->scrollto.y.animator);
1474 sd->scrollto.y.animator = NULL;
1476 if (sd->down.bounce_x_animator)
1478 ecore_animator_del(sd->down.bounce_x_animator);
1479 sd->down.bounce_x_animator = NULL;
1482 if (sd->down.bounce_y_animator)
1484 ecore_animator_del(sd->down.bounce_y_animator);
1485 sd->down.bounce_y_animator = NULL;
1488 if (sd->down.hold_animator)
1490 ecore_animator_del(sd->down.hold_animator);
1491 sd->down.hold_animator = NULL;
1492 _smart_drag_stop(sd->smart_obj);
1494 if (sd->down.momentum_animator)
1496 ecore_animator_del(sd->down.momentum_animator);
1497 sd->down.momentum_animator = NULL;
1498 sd->down.bounce_x_hold = 0;
1499 sd->down.bounce_y_hold = 0;
1503 if (ev->button == 1)
1506 sd->down.dragged = 0;
1509 sd->down.x = ev->canvas.x;
1510 sd->down.y = ev->canvas.y;
1511 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1514 sd->down.locked = 0;
1515 memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 20);
1517 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
1519 sd->down.history[0].timestamp = ecore_loop_time_get();
1521 sd->down.history[0].x = ev->canvas.x;
1522 sd->down.history[0].y = ev->canvas.y;
1524 sd->down.dragged_began = 0;
1525 sd->down.hold_parent = 0;
1526 sd->down.cancelled = 0;
1531 _smart_hold_animator(void *data)
1533 Smart_Data *sd = data;
1536 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
1539 if ((!sd->widget) ||
1540 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1542 ox = sd->down.hold_x;
1547 if ((!sd->widget) ||
1548 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1550 oy = sd->down.hold_y;
1553 elm_smart_scroller_child_pos_set(sd->smart_obj, ox, oy);
1554 return ECORE_CALLBACK_RENEW;
1558 _smart_event_post_up(void *data, Evas *e __UNUSED__)
1560 Smart_Data *sd = data;
1563 if (sd->down.dragged)
1565 elm_widget_drag_lock_x_set(sd->widget, 0);
1566 elm_widget_drag_lock_y_set(sd->widget, 0);
1573 _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
1575 Evas_Event_Mouse_Down *ev;
1577 Evas_Coord x = 0, y = 0, ox = 0, oy = 0;
1581 sd->down.hold_parent = 0;
1582 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1583 evas_post_event_callback_push(e, _smart_event_post_up, sd);
1584 // FIXME: respect elm_widget_scroll_hold_get of parent container
1585 if (_elm_config->thumbscroll_enable)
1587 if (ev->button == 1)
1589 if (sd->down.onhold_animator)
1591 ecore_animator_del(sd->down.onhold_animator);
1592 sd->down.onhold_animator = NULL;
1594 x = ev->canvas.x - sd->down.x;
1595 y = ev->canvas.y - sd->down.y;
1596 if (sd->down.dragged)
1598 _smart_drag_stop(sd->smart_obj);
1599 if ((!sd->hold) && (!sd->freeze))
1603 Evas_Coord ax, ay, dx, dy, vel;
1606 t = ev->timestamp / 1000.0;
1608 t = ecore_loop_time_get();
1610 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1615 printf("------ %i %i\n", ev->canvas.x, ev->canvas.y);
1617 for (i = 0; i < 20; i++)
1619 dt = t - sd->down.history[i].timestamp;
1620 if (dt > 0.2) break;
1622 printf("H: %i %i @ %1.3f\n",
1623 sd->down.history[i].x,
1624 sd->down.history[i].y, dt);
1627 ax += sd->down.history[i].x;
1628 ay += sd->down.history[i].y;
1634 dx = ev->canvas.x - ax;
1635 dy = ev->canvas.y - ay;
1638 vel = sqrt((dx * dx) + (dy * dy)) / at;
1639 if ((_elm_config->thumbscroll_friction > 0.0) &&
1640 (vel > _elm_config->thumbscroll_momentum_threshold) &&
1643 sd->down.dx = ((double)dx / at);
1644 sd->down.dy = ((double)dy / at);
1645 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
1646 ((sd->down.dx < 0) && (sd->down.pdx < 0)))
1647 sd->down.dx += (double)sd->down.pdx * 1.5; // FIXME: * 1.5 - probably should be config
1648 if (((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
1649 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
1650 sd->down.dy += (double)sd->down.pdy * 1.5; // FIXME: * 1.5 - probably should be config
1651 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
1652 ((sd->down.dx < 0) && (sd->down.pdx < 0)) ||
1653 ((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
1654 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
1656 double t = ecore_loop_time_get();
1657 double dt = t - sd->down.anim_start;
1659 if (dt < 0.0) dt = 0.0;
1660 else if (dt > _elm_config->thumbscroll_friction)
1661 dt = _elm_config->thumbscroll_friction;
1662 sd->down.extra_time = _elm_config->thumbscroll_friction - dt;
1665 sd->down.extra_time = 0.0;
1666 sd->down.pdx = sd->down.dx;
1667 sd->down.pdy = sd->down.dy;
1670 if (!_smart_do_page(sd))
1672 if (!sd->down.momentum_animator && !sd->momentum_animator_disabled)
1674 sd->down.momentum_animator = ecore_animator_add(_smart_momentum_animator, sd);
1675 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1676 _smart_anim_start(sd->smart_obj);
1678 sd->down.anim_start = ecore_loop_time_get();
1679 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1687 if (sd->down.hold_animator)
1689 ecore_animator_del(sd->down.hold_animator);
1690 sd->down.hold_animator = NULL;
1698 evas_event_feed_hold(e, 0, ev->timestamp, ev->data);
1699 if (_smart_do_page(sd))
1701 Evas_Coord pgx, pgy;
1703 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1704 if ((!sd->widget) ||
1705 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1707 pgx = _smart_page_x_get(sd, ox);
1710 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1711 _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
1714 if ((!sd->widget) ||
1715 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1717 pgy = _smart_page_y_get(sd, oy);
1720 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1721 _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
1730 if (_smart_do_page(sd))
1732 Evas_Coord pgx, pgy;
1734 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1735 if ((!sd->widget) ||
1736 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1738 pgx = _smart_page_x_get(sd, ox);
1739 if (pgx != x) _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
1741 if ((!sd->widget) ||
1742 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1744 pgy = _smart_page_y_get(sd, oy);
1745 if (pgy != y) _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
1748 if (sd->down.hold_animator)
1750 ecore_animator_del(sd->down.hold_animator);
1751 sd->down.hold_animator = NULL;
1754 if (sd->down.scroll)
1756 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1757 sd->down.scroll = 0;
1761 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1764 sd->down.dragged_began = 0;
1767 sd->down.want_dragged = 0;
1768 sd->down.dragged = 0;
1770 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1771 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1772 if (!_smart_do_page(sd))
1779 _smart_onhold_animator(void *data)
1784 Evas_Coord x, y, ox, oy;
1787 t = ecore_loop_time_get();
1788 if (sd->down.onhold_tlast > 0.0)
1790 td = t - sd->down.onhold_tlast;
1791 vx = sd->down.onhold_vx * td * (double)_elm_config->thumbscroll_threshold * 2.0;
1792 vy = sd->down.onhold_vy * td * (double)_elm_config->thumbscroll_threshold * 2.0;
1793 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
1799 if ((!sd->widget) ||
1800 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1802 sd->down.onhold_vxe += vx;
1803 x = ox + (int)sd->down.onhold_vxe;
1804 sd->down.onhold_vxe -= (int)sd->down.onhold_vxe;
1810 if ((!sd->widget) ||
1811 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1813 sd->down.onhold_vye += vy;
1814 y = oy + (int)sd->down.onhold_vye;
1815 sd->down.onhold_vye -= (int)sd->down.onhold_vye;
1819 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1820 // printf("scroll %i %i\n", sd->down.hold_x, sd->down.hold_y);
1822 sd->down.onhold_tlast = t;
1823 return ECORE_CALLBACK_RENEW;
1827 _smart_event_post_move(void *data, Evas *e __UNUSED__)
1829 Smart_Data *sd = data;
1831 if (sd->down.want_dragged)
1835 if (sd->down.hold_parent)
1837 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
1841 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
1848 if ((!sd->widget) ||
1849 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1851 sd->down.want_dragged = 0;
1852 sd->down.dragged = 1;
1855 elm_widget_drag_lock_x_set(sd->widget, 1);
1864 if ((!sd->widget) ||
1865 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1867 sd->down.want_dragged = 0;
1868 sd->down.dragged = 1;
1871 elm_widget_drag_lock_y_set(sd->widget, 1);
1878 if ((!sd->down.dir_x) && (!sd->down.dir_y))
1880 sd->down.cancelled = 1;
1882 if (start) _smart_drag_start(sd->smart_obj);
1888 _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
1890 Evas_Event_Mouse_Move *ev;
1892 Evas_Coord x = 0, y = 0;
1896 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1897 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->down.hold_parent = 1;
1898 evas_post_event_callback_push(e, _smart_event_post_move, sd);
1899 // FIXME: respect elm_widget_scroll_hold_get of parent container
1900 if (_elm_config->thumbscroll_enable)
1907 printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
1909 memmove(&(sd->down.history[1]), &(sd->down.history[0]),
1910 sizeof(sd->down.history[0]) * 19);
1912 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
1914 sd->down.history[0].timestamp = ecore_loop_time_get();
1916 sd->down.history[0].x = ev->cur.canvas.x;
1917 sd->down.history[0].y = ev->cur.canvas.y;
1919 if (!sd->down.dragged_began)
1921 x = ev->cur.canvas.x - sd->down.x;
1922 y = ev->cur.canvas.y - sd->down.y;
1927 if (x > 0) sd->down.hdir = LEFT;
1928 else if (x < 0) sd->down.hdir = RIGHT;
1929 if (y > 0) sd->down.vdir = UP;
1930 else if (y < 0) sd->down.vdir = DOWN;
1935 if ((sd->one_dir_at_a_time) &&
1936 (!((sd->down.dir_x) || (sd->down.dir_y))))
1938 if (x > _elm_config->thumbscroll_threshold)
1947 if (y > _elm_config->thumbscroll_threshold)
1964 // can_scroll(sd, LEFT);
1965 // can_scroll(sd, RIGHT);
1966 // can_scroll(sd, UP);
1967 // can_scroll(sd, DOWN);
1972 if ((!sd->hold) && (!sd->freeze))
1974 if ((sd->down.dragged) ||
1975 (((x * x) + (y * y)) >
1976 (_elm_config->thumbscroll_threshold *
1977 _elm_config->thumbscroll_threshold)))
1979 sd->down.dragged_began = 1;
1980 if (!sd->down.dragged)
1982 sd->down.want_dragged = 1;
1983 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1984 // evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
1985 // _smart_drag_start(sd->smart_obj);
1987 if (sd->down.dragged)
1989 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1991 // ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1992 // sd->down.dragged = 1;
1994 x = sd->down.sx - (ev->cur.canvas.x - sd->down.x);
1998 y = sd->down.sy - (ev->cur.canvas.y - sd->down.y);
2001 if ((sd->down.dir_x) || (sd->down.dir_y))
2003 if (!sd->down.locked)
2005 sd->down.locked_x = x;
2006 sd->down.locked_y = y;
2007 sd->down.locked = 1;
2009 if (!((sd->down.dir_x) && (sd->down.dir_y)))
2011 if (sd->down.dir_x) y = sd->down.locked_y;
2012 else x = sd->down.locked_x;
2015 if (_elm_config->thumbscroll_border_friction > 0.0)
2017 Evas_Coord minx, miny;
2018 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2021 _elm_config->thumbscroll_border_friction;
2022 else if (sd->child.h <= sd->h)
2023 y += (sd->down.sy - y) *
2024 _elm_config->thumbscroll_border_friction;
2025 else if ((sd->child.h - sd->h + miny) < y)
2026 y += (sd->child.h - sd->h + miny - y) *
2027 _elm_config->thumbscroll_border_friction;
2030 _elm_config->thumbscroll_border_friction;
2031 else if (sd->child.w <= sd->w)
2032 x += (sd->down.sx - x) *
2033 _elm_config->thumbscroll_border_friction;
2034 else if ((sd->child.w - sd->w + minx) < x)
2035 x += (sd->child.w - sd->w + minx - x) *
2036 _elm_config->thumbscroll_border_friction;
2039 sd->down.hold_x = x;
2040 sd->down.hold_y = y;
2041 if (!sd->down.hold_animator)
2042 sd->down.hold_animator =
2043 ecore_animator_add(_smart_hold_animator, sd);
2044 // printf("a %i %i\n", sd->down.hold_x, sd->down.hold_y);
2045 // _smart_onhold_animator(sd);
2046 // elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
2050 if (sd->down.dragged_began)
2052 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2056 evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
2061 else if (!sd->freeze)
2063 Evas_Coord ex, ey, ew, eh;
2064 double vx = 0.0, vy = 0.0;
2066 evas_object_geometry_get(sd->event_obj, &ex, &ey, &ew, &eh);
2067 x = ev->cur.canvas.x - ex;
2068 y = ev->cur.canvas.y - ey;
2069 if (x < _elm_config->thumbscroll_threshold)
2071 if (_elm_config->thumbscroll_threshold > 0.0)
2072 vx = -(double)(_elm_config->thumbscroll_threshold - x) /
2073 _elm_config->thumbscroll_threshold;
2077 else if (x > (ew - _elm_config->thumbscroll_threshold))
2079 if (_elm_config->thumbscroll_threshold > 0.0)
2080 vx = (double)(_elm_config->thumbscroll_threshold - (ew - x)) /
2081 _elm_config->thumbscroll_threshold;
2085 if (y < _elm_config->thumbscroll_threshold)
2087 if (_elm_config->thumbscroll_threshold > 0.0)
2088 vy = -(double)(_elm_config->thumbscroll_threshold - y) /
2089 _elm_config->thumbscroll_threshold;
2093 else if (y > (eh - _elm_config->thumbscroll_threshold))
2095 if (_elm_config->thumbscroll_threshold > 0.0)
2096 vy = (double)(_elm_config->thumbscroll_threshold - (eh - y)) /
2097 _elm_config->thumbscroll_threshold;
2101 if ((vx != 0.0) || (vy != 0.0))
2103 sd->down.onhold_vx = vx;
2104 sd->down.onhold_vy = vy;
2105 if (!sd->down.onhold_animator)
2107 sd->down.onhold_vxe = 0.0;
2108 sd->down.onhold_vye = 0.0;
2109 sd->down.onhold_tlast = 0.0;
2110 sd->down.onhold_animator = ecore_animator_add(_smart_onhold_animator, sd);
2112 // printf("b %i %i\n", sd->down.hold_x, sd->down.hold_y);
2116 if (sd->down.onhold_animator)
2118 ecore_animator_del(sd->down.onhold_animator);
2119 sd->down.onhold_animator = NULL;
2128 _smart_scrollbar_read(Smart_Data *sd)
2130 Evas_Coord x, y, mx = 0, my = 0, px, py, minx = 0, miny = 0;
2133 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2134 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2135 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2136 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2137 x = vx * (double)mx + minx;
2138 y = vy * (double)my + miny;
2139 sd->pan_func.get(sd->pan_obj, &px, &py);
2140 sd->pan_func.set(sd->pan_obj, x, y);
2141 if ((px != x) || (py != y))
2142 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2146 _smart_scrollbar_reset(Smart_Data *sd)
2148 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2150 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2151 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2152 if ((!sd->child_obj) && (!sd->extern_pan))
2154 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2155 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2157 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2158 sd->pan_func.get(sd->pan_obj, &px, &py);
2159 sd->pan_func.set(sd->pan_obj, minx, miny);
2160 if ((px != minx) || (py != miny))
2161 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2165 _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
2167 int scroll_v_vis_change = 0;
2168 Evas_Coord h, vw, vh;
2171 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2172 if (sd->vbar_visible)
2174 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2176 if ((sd->child_obj) || (sd->extern_pan))
2180 scroll_v_vis_change = 1;
2181 sd->vbar_visible = 0;
2186 scroll_v_vis_change = 1;
2187 sd->vbar_visible = 0;
2190 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2192 scroll_v_vis_change = 1;
2193 sd->vbar_visible = 0;
2198 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2200 if ((sd->child_obj) || (sd->extern_pan))
2204 scroll_v_vis_change = 1;
2205 sd->vbar_visible = 1;
2209 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2211 scroll_v_vis_change = 1;
2212 sd->vbar_visible = 1;
2215 if (scroll_v_vis_change)
2217 if (sd->vbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2219 if (sd->vbar_visible)
2220 edje_object_signal_emit(sd->edje_obj, "elm,action,show,vbar", "elm");
2222 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2223 edje_object_message_signal_process(sd->edje_obj);
2224 _smart_scrollbar_size_adjust(sd);
2227 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2229 return scroll_v_vis_change;
2233 _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
2235 int scroll_h_vis_change = 0;
2236 Evas_Coord w, vw, vh;
2239 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2240 if (sd->hbar_visible)
2242 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2244 if ((sd->child_obj) || (sd->extern_pan))
2248 scroll_h_vis_change = 1;
2249 sd->hbar_visible = 0;
2254 scroll_h_vis_change = 1;
2255 sd->hbar_visible = 0;
2258 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2260 scroll_h_vis_change = 1;
2261 sd->hbar_visible = 0;
2266 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2268 if ((sd->child_obj) || (sd->extern_pan))
2272 scroll_h_vis_change = 1;
2273 sd->hbar_visible = 1;
2277 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2279 scroll_h_vis_change = 1;
2280 sd->hbar_visible = 1;
2283 if (scroll_h_vis_change)
2285 if (sd->hbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2287 if (sd->hbar_visible)
2288 edje_object_signal_emit(sd->edje_obj, "elm,action,show,hbar", "elm");
2290 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2291 edje_object_message_signal_process(sd->edje_obj);
2292 _smart_scrollbar_size_adjust(sd);
2295 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2296 _smart_scrollbar_size_adjust(sd);
2298 return scroll_h_vis_change;
2302 _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd)
2306 changed |= _smart_scrollbar_bar_h_visibility_adjust(sd);
2307 changed |= _smart_scrollbar_bar_v_visibility_adjust(sd);
2310 _smart_scrollbar_bar_h_visibility_adjust(sd);
2311 _smart_scrollbar_bar_v_visibility_adjust(sd);
2316 _smart_scrollbar_size_adjust(Smart_Data *sd)
2318 if ((sd->child_obj) || (sd->extern_pan))
2320 Evas_Coord x, y, w, h, mx = 0, my = 0, vw = 0, vh = 0, px, py, minx = 0, miny = 0;
2321 double vx, vy, size;
2323 edje_object_part_geometry_get(sd->edje_obj, "elm.swallow.content",
2324 NULL, NULL, &vw, &vh);
2327 size = (double)vw / (double)w;
2331 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2333 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", size, 1.0);
2337 size = (double)vh / (double)h;
2341 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2343 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, size);
2345 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2346 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2347 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2348 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2352 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->step.x / (double)w, 0.0);
2353 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->step.y / (double)h);
2355 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->page.x / (double)w, 0.0);
2357 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", -((double)sd->page.x * ((double)vw / (double)w)) / 100.0, 0.0);
2359 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->page.y / (double)h);
2361 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, -((double)sd->page.y * ((double)vh / (double)h)) / 100.0);
2363 sd->pan_func.get(sd->pan_obj, &px, &py);
2364 if (vx != mx) x = px;
2365 if (vy != my) y = py;
2366 sd->pan_func.set(sd->pan_obj, x, y);
2367 // if ((px != 0) || (py != 0))
2368 // edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2372 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2374 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2375 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2376 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2377 sd->pan_func.get(sd->pan_obj, &px, &py);
2378 sd->pan_func.set(sd->pan_obj, minx, miny);
2379 if ((px != minx) || (py != miny))
2380 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2382 _smart_scrollbar_bar_visibility_adjust(sd);
2386 _smart_reconfigure(Smart_Data *sd)
2388 evas_object_move(sd->edje_obj, sd->x, sd->y);
2389 evas_object_resize(sd->edje_obj, sd->w, sd->h);
2390 evas_object_move(sd->event_obj, sd->x, sd->y);
2391 evas_object_resize(sd->event_obj, sd->w, sd->h);
2392 _smart_scrollbar_size_adjust(sd);
2396 _smart_add(Evas_Object *obj)
2401 sd = calloc(1, sizeof(Smart_Data));
2403 evas_object_smart_data_set(obj, sd);
2405 sd->smart_obj = obj;
2414 sd->hbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2415 sd->vbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2416 sd->hbar_visible = 1;
2417 sd->vbar_visible = 1;
2419 sd->bounce_horiz = 1;
2420 sd->bounce_vert = 1;
2422 sd->one_dir_at_a_time = 1;
2423 sd->momentum_animator_disabled = 0;
2424 sd->bounce_animator_disabled = 0;
2426 o = edje_object_add(evas_object_evas_get(obj));
2427 evas_object_propagate_events_set(o, 0);
2429 // FIXME: null parent obj ... :(
2430 elm_smart_scroller_object_theme_set(NULL, obj, "scroller", "base", "default");
2431 edje_object_signal_callback_add(o, "drag", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2432 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.vbar", _smart_edje_drag_v_start, sd);
2433 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.vbar", _smart_edje_drag_v_stop, sd);
2434 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2435 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2436 edje_object_signal_callback_add(o, "drag", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2437 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.hbar", _smart_edje_drag_h_start, sd);
2438 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.hbar", _smart_edje_drag_h_stop, sd);
2439 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2440 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2441 evas_object_smart_member_add(o, obj);
2443 o = evas_object_rectangle_add(evas_object_evas_get(obj));
2445 evas_object_color_set(o, 0, 0, 0, 0);
2446 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd);
2447 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _smart_event_mouse_down, sd);
2448 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _smart_event_mouse_up, sd);
2449 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _smart_event_mouse_move, sd);
2450 evas_object_smart_member_add(o, obj);
2451 evas_object_repeat_events_set(o, 1);
2453 sd->pan_func.set = _elm_smart_pan_set;
2454 sd->pan_func.get = _elm_smart_pan_get;
2455 sd->pan_func.max_get = _elm_smart_pan_max_get;
2456 sd->pan_func.min_get = _elm_smart_pan_min_get;
2457 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
2459 _smart_scrollbar_reset(sd);
2463 _smart_del(Evas_Object *obj)
2466 elm_smart_scroller_child_set(obj, NULL);
2467 if (!sd->extern_pan) evas_object_del(sd->pan_obj);
2468 evas_object_del(sd->edje_obj);
2469 evas_object_del(sd->event_obj);
2470 if (sd->down.hold_animator) ecore_animator_del(sd->down.hold_animator);
2471 if (sd->down.onhold_animator) ecore_animator_del(sd->down.onhold_animator);
2472 if (sd->down.momentum_animator) ecore_animator_del(sd->down.momentum_animator);
2473 if (sd->down.bounce_x_animator) ecore_animator_del(sd->down.bounce_x_animator);
2474 if (sd->down.bounce_y_animator) ecore_animator_del(sd->down.bounce_y_animator);
2475 if (sd->scrollto.x.animator) ecore_animator_del(sd->scrollto.x.animator);
2476 if (sd->scrollto.y.animator) ecore_animator_del(sd->scrollto.y.animator);
2478 evas_object_smart_data_set(obj, NULL);
2482 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2487 _smart_reconfigure(sd);
2491 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2496 _smart_reconfigure(sd);
2500 _smart_show(Evas_Object *obj)
2503 evas_object_show(sd->edje_obj);
2504 evas_object_show(sd->event_obj);
2508 _smart_hide(Evas_Object *obj)
2511 evas_object_hide(sd->edje_obj);
2512 evas_object_hide(sd->event_obj);
2516 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
2519 evas_object_color_set(sd->edje_obj, r, g, b, a);
2523 _smart_clip_set(Evas_Object *obj, Evas_Object *clip)
2526 evas_object_clip_set(sd->edje_obj, clip);
2527 evas_object_clip_set(sd->event_obj, clip);
2531 _smart_clip_unset(Evas_Object *obj)
2534 evas_object_clip_unset(sd->edje_obj);
2535 evas_object_clip_unset(sd->event_obj);
2538 /* never need to touch this */
2545 static const Evas_Smart_Class sc =
2548 EVAS_SMART_CLASS_VERSION,
2566 _smart = evas_smart_class_new(&sc);