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;
15 Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */
17 Evas_Object *smart_obj;
18 Evas_Object *child_obj;
20 Evas_Object *edje_obj;
21 Evas_Object *event_obj;
25 Elm_Smart_Scroller_Policy hbar_flags, vbar_flags;
44 double onhold_vx, onhold_vy, onhold_tlast, onhold_vxe, onhold_vye;
46 Evas_Coord hold_x, hold_y;
47 Ecore_Animator *hold_animator;
48 Ecore_Animator *onhold_animator;
49 Ecore_Animator *momentum_animator;
50 Ecore_Animator *bounce_x_animator;
51 Ecore_Animator *bounce_y_animator;
52 Evas_Coord locked_x, locked_y;
54 unsigned char now : 1;
55 unsigned char cancelled : 1;
56 unsigned char hold : 1;
57 unsigned char hold_parent : 1;
58 unsigned char want_dragged : 1;
59 unsigned char dragged : 1;
60 unsigned char dragged_began : 1;
61 unsigned char dir_x : 1;
62 unsigned char dir_y : 1;
63 unsigned char locked : 1;
64 unsigned char bounce_x_hold : 1;
65 unsigned char bounce_y_hold : 1;
66 unsigned char scroll : 1;
77 void (*set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
78 void (*get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
79 void (*max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
80 void (*min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
81 void (*child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
86 Evas_Coord start, end;
87 double t_start, t_end;
88 Ecore_Animator *animator;
92 double pagerel_h, pagerel_v;
93 Evas_Coord pagesize_h, pagesize_v;
95 unsigned char hbar_visible : 1;
96 unsigned char vbar_visible : 1;
97 unsigned char extern_pan : 1;
98 unsigned char one_dir_at_a_time : 1;
99 unsigned char hold : 1;
100 unsigned char freeze : 1;
101 unsigned char bouncemex : 1;
102 unsigned char bouncemey : 1;
103 unsigned char bounce_horiz : 1;
104 unsigned char bounce_vert : 1;
105 unsigned char momentum_animator_disabled :1;
106 unsigned char bounce_animator_disabled :1;
109 /* local subsystem functions */
110 static void _smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
111 static void _smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
112 static void _smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
113 static void _smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
114 static void _smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
115 static Eina_Bool _smart_hold_animator(void *data);
116 static Eina_Bool _smart_momentum_animator(void *data);
117 static void _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
118 static Eina_Bool _smart_onhold_animator(void *data);
119 static void _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
120 static void _smart_edje_drag_v_start(void *data, Evas_Object *obj, const char *emission, const char *source);
121 static void _smart_edje_drag_v_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
122 static void _smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source);
123 static void _smart_edje_drag_h_start(void *data, Evas_Object *obj, const char *emission, const char *source);
124 static void _smart_edje_drag_h_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
125 static void _smart_edje_drag_h(void *data, Evas_Object *obj, const char *emission, const char *source);
126 static void _smart_scrollbar_read(Smart_Data *sd);
127 static void _smart_scrollbar_reset(Smart_Data *sd);
128 static int _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd);
129 static int _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd);
130 static void _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd);
131 static void _smart_scrollbar_size_adjust(Smart_Data *sd);
132 static void _smart_reconfigure(Smart_Data *sd);
133 static void _smart_add(Evas_Object *obj);
134 static void _smart_del(Evas_Object *obj);
135 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
136 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
137 static void _smart_show(Evas_Object *obj);
138 static void _smart_hide(Evas_Object *obj);
139 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
140 static void _smart_clip_set(Evas_Object *obj, Evas_Object *clip);
141 static void _smart_clip_unset(Evas_Object *obj);
142 static void _smart_init(void);
144 /* local subsystem globals */
145 static Evas_Smart *_smart = NULL;
147 /* externally accessible functions */
149 elm_smart_scroller_add(Evas *evas)
152 return evas_object_smart_add(evas, _smart);
156 elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
164 _elm_smart_pan_child_set(sd->pan_obj, NULL);
165 evas_object_event_callback_del_full(sd->child_obj, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
168 sd->child_obj = child;
169 sd->wx = sd->wy = sd->ww = sd->wh = 0;
174 o = _elm_smart_pan_add(evas_object_evas_get(obj));
176 evas_object_smart_callback_add(o, "changed", _smart_pan_changed_hook, sd);
177 evas_object_smart_callback_add(o, "pan_changed", _smart_pan_pan_changed_hook, sd);
179 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", o);
182 sd->pan_func.set = _elm_smart_pan_set;
183 sd->pan_func.get = _elm_smart_pan_get;
184 sd->pan_func.max_get = _elm_smart_pan_max_get;
185 sd->pan_func.min_get = _elm_smart_pan_min_get;
186 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
188 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
189 _elm_smart_pan_child_set(sd->pan_obj, sd->child_obj);
190 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
193 _smart_scrollbar_size_adjust(sd);
194 _smart_scrollbar_reset(sd);
198 elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
199 void (*pan_set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y),
200 void (*pan_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
201 void (*pan_max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
202 void (*pan_min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
203 void (*pan_child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y))
207 elm_smart_scroller_child_set(obj, NULL);
211 evas_object_smart_callback_del(sd->pan_obj, "changed", _smart_pan_changed_hook);
212 evas_object_smart_callback_del(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook);
219 edje_object_part_unswallow(sd->edje_obj, sd->pan_obj);
227 evas_object_del(sd->pan_obj);
238 sd->pan_func.set = pan_set;
239 sd->pan_func.get = pan_get;
240 sd->pan_func.max_get = pan_max_get;
241 sd->pan_func.min_get = pan_min_get;
242 sd->pan_func.child_size_get = pan_child_size_get;
244 evas_object_smart_callback_add(sd->pan_obj, "changed", _smart_pan_changed_hook, sd);
245 evas_object_smart_callback_add(sd->pan_obj, "pan_changed", _smart_pan_pan_changed_hook, sd);
246 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
247 evas_object_show(sd->pan_obj);
251 elm_smart_scroller_custom_edje_file_set(Evas_Object *obj, char *file, char *group)
255 edje_object_file_set(sd->edje_obj, file, group);
257 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
258 sd->vbar_visible = !sd->vbar_visible;
259 sd->hbar_visible = !sd->hbar_visible;
260 _smart_scrollbar_bar_visibility_adjust(sd);
261 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
262 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
263 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
264 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
266 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
267 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
268 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
269 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
270 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
272 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
276 elm_smart_scroller_momentum_animator_disabled_get(Evas_Object *obj)
278 API_ENTRY return EINA_FALSE;
279 return sd->momentum_animator_disabled;
283 elm_smart_scroller_momentum_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
286 sd->momentum_animator_disabled = disabled;
287 if (sd->momentum_animator_disabled)
289 if (sd->down.momentum_animator)
291 ecore_animator_del(sd->down.momentum_animator);
292 sd->down.momentum_animator = NULL;
298 elm_smart_scroller_bounce_animator_disabled_get(Evas_Object *obj)
300 API_ENTRY return EINA_FALSE;
301 return sd->bounce_animator_disabled;
305 elm_smart_scroller_bounce_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
308 sd->bounce_animator_disabled = disabled;
309 if (sd->bounce_animator_disabled)
311 if (sd->scrollto.x.animator)
313 ecore_animator_del(sd->scrollto.x.animator);
314 sd->scrollto.x.animator = NULL;
317 if (sd->scrollto.y.animator)
319 ecore_animator_del(sd->scrollto.y.animator);
320 sd->scrollto.y.animator = NULL;
326 _smart_anim_start(Evas_Object *obj)
328 evas_object_smart_callback_call(obj, "animate,start", NULL);
332 _smart_anim_stop(Evas_Object *obj)
334 evas_object_smart_callback_call(obj, "animate,stop", NULL);
338 _smart_drag_start(Evas_Object *obj)
340 evas_object_smart_callback_call(obj, "drag,start", NULL);
344 _smart_drag_stop(Evas_Object *obj)
346 evas_object_smart_callback_call(obj, "drag,stop", NULL);
350 _smart_scrollto_x_animator(void *data)
352 Smart_Data *sd = data;
356 t = ecore_loop_time_get();
357 tt = (t - sd->scrollto.x.t_start) / (sd->scrollto.x.t_end - sd->scrollto.x.t_start);
359 tt = 1.0 - (tt * tt);
360 sd->pan_func.get(sd->pan_obj, &px, &py);
361 px = (sd->scrollto.x.start * (1.0 - tt)) +
362 (sd->scrollto.x.end * tt);
363 if (t >= sd->scrollto.x.t_end)
365 px = sd->scrollto.x.end;
366 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
367 sd->scrollto.x.animator = NULL;
368 if ((!sd->scrollto.y.animator) && (!sd->down.bounce_y_animator))
369 _smart_anim_stop(sd->smart_obj);
370 return ECORE_CALLBACK_CANCEL;
372 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
373 return ECORE_CALLBACK_RENEW;
377 _smart_momentum_end(Smart_Data *sd)
379 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator)) return;
380 if (sd->down.momentum_animator)
382 ecore_animator_del(sd->down.momentum_animator);
383 sd->down.momentum_animator = NULL;
384 sd->down.bounce_x_hold = 0;
385 sd->down.bounce_y_hold = 0;
394 _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x)
396 Evas_Coord px, py, x, y, w, h;
399 if (sd->freeze) return;
402 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
403 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
405 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
408 t = ecore_loop_time_get();
409 sd->pan_func.get(sd->pan_obj, &px, &py);
410 sd->scrollto.x.start = px;
411 sd->scrollto.x.end = pos_x;
412 sd->scrollto.x.t_start = t;
413 sd->scrollto.x.t_end = t + t_in;
414 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
415 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
416 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
417 if (!sd->scrollto.x.animator)
419 if (!sd->scrollto.y.animator)
420 _smart_anim_start(sd->smart_obj);
421 sd->scrollto.x.animator = ecore_animator_add(_smart_scrollto_x_animator, sd);
423 if (sd->down.bounce_x_animator)
425 ecore_animator_del(sd->down.bounce_x_animator);
426 sd->down.bounce_x_animator = NULL;
427 _smart_momentum_end(sd);
433 _smart_scrollto_y_animator(void *data)
435 Smart_Data *sd = data;
439 t = ecore_loop_time_get();
440 tt = (t - sd->scrollto.y.t_start) / (sd->scrollto.y.t_end - sd->scrollto.y.t_start);
442 tt = 1.0 - (tt * tt);
443 sd->pan_func.get(sd->pan_obj, &px, &py);
444 py = (sd->scrollto.y.start * (1.0 - tt)) +
445 (sd->scrollto.y.end * tt);
446 if (t >= sd->scrollto.y.t_end)
448 py = sd->scrollto.y.end;
449 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
450 sd->scrollto.y.animator = NULL;
451 if ((!sd->scrollto.x.animator) && (!sd->down.bounce_x_animator))
452 _smart_anim_stop(sd->smart_obj);
453 return ECORE_CALLBACK_CANCEL;
455 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
457 return ECORE_CALLBACK_RENEW;
461 _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y)
463 Evas_Coord px, py, x, y, w, h;
466 if (sd->freeze) return;
469 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
470 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
472 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
475 t = ecore_loop_time_get();
476 sd->pan_func.get(sd->pan_obj, &px, &py);
477 sd->scrollto.y.start = py;
478 sd->scrollto.y.end = pos_y;
479 sd->scrollto.y.t_start = t;
480 sd->scrollto.y.t_end = t + t_in;
481 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
482 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
483 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
484 if (!sd->scrollto.y.animator)
486 if (!sd->scrollto.x.animator)
487 _smart_anim_start(sd->smart_obj);
488 sd->scrollto.y.animator = ecore_animator_add(_smart_scrollto_y_animator, sd);
490 if (sd->down.bounce_y_animator)
492 ecore_animator_del(sd->down.bounce_y_animator);
493 sd->down.bounce_y_animator = NULL;
494 _smart_momentum_end(sd);
500 _smart_do_page(Smart_Data *sd)
502 if ((sd->pagerel_h == 0.0) && (!sd->pagesize_h) &&
503 (sd->pagerel_v == 0.0) && (!sd->pagesize_v))
509 _smart_page_x_get(Smart_Data *sd, int offset)
511 Evas_Coord x, y, w, h, cw, ch, minx = 0;
513 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
514 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
515 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
516 sd->pan_func.min_get(sd->pan_obj, &minx, NULL);
520 if (sd->pagerel_h > 0.0)
522 x = x + (w * sd->pagerel_h * 0.5);
523 x = x / (w * sd->pagerel_h);
524 x = x * (w * sd->pagerel_h);
526 else if (sd->pagesize_h > 0)
528 x = x + (sd->pagesize_h * 0.5);
529 x = x / (sd->pagesize_h);
530 x = x * (sd->pagesize_h);
532 if (x < minx) x = minx;
533 else if ((x + w) > cw) x = cw - w;
538 _smart_page_y_get(Smart_Data *sd, int offset)
540 Evas_Coord x, y, w, h, cw, ch, miny = 0;
542 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
543 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
544 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
545 sd->pan_func.min_get(sd->pan_obj, NULL, &miny);
549 if (sd->pagerel_v > 0.0)
551 y = y + (h * sd->pagerel_v * 0.5);
552 y = y / (h * sd->pagerel_v);
553 y = y * (h * sd->pagerel_v);
555 else if (sd->pagesize_v > 0)
557 y = y + (sd->pagesize_v * 0.5);
558 y = y / (sd->pagesize_v);
559 y = y * (sd->pagesize_v);
561 if (y < miny) y = miny;
562 else if ((y + h) > ch) y = ch - h;
567 _smart_page_adjust(Smart_Data *sd)
569 Evas_Coord x, y, w, h;
571 if (!_smart_do_page(sd)) return;
573 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
575 x = _smart_page_x_get(sd, 0);
576 y = _smart_page_y_get(sd, 0);
578 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
582 _smart_bounce_x_animator(void *data)
589 t = ecore_loop_time_get();
590 dt = t - sd->down.anim_start2;
593 dt = dt / _elm_config->thumbscroll_bounce_friction;
594 if (dt > 1.0) dt = 1.0;
595 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
596 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
597 dx = sd->down.b2x - sd->down.bx;
599 x = sd->down.bx + dx;
600 if (!sd->down.cancelled)
601 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
604 if (sd->down.momentum_animator)
605 sd->down.bounce_x_hold = 1;
606 else if ((!sd->down.bounce_y_animator) &&
607 (!sd->scrollto.y.animator))
608 _smart_anim_stop(sd->smart_obj);
609 sd->down.bounce_x_animator = NULL;
612 _smart_momentum_end(sd);
613 return ECORE_CALLBACK_CANCEL;
616 return ECORE_CALLBACK_RENEW;
620 _smart_bounce_y_animator(void *data)
627 t = ecore_loop_time_get();
628 dt = t - sd->down.anim_start3;
631 dt = dt / _elm_config->thumbscroll_bounce_friction;
632 if (dt > 1.0) dt = 1.0;
633 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
634 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
635 dy = sd->down.b2y - sd->down.by;
637 y = sd->down.by + dy;
638 if (!sd->down.cancelled)
639 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
642 if (sd->down.momentum_animator)
643 sd->down.bounce_y_hold = 1;
644 else if ((!sd->down.bounce_x_animator) &&
645 (!sd->scrollto.y.animator))
646 _smart_anim_stop(sd->smart_obj);
647 sd->down.bounce_y_animator = NULL;
650 _smart_momentum_end(sd);
651 return ECORE_CALLBACK_CANCEL;
654 return ECORE_CALLBACK_RENEW;
662 can_scroll(Smart_Data *sd, int dir)
664 Evas_Coord mx = 0, my = 0, px = 0, py = 0, minx = 0, miny = 0;
666 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
667 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
668 sd->pan_func.get(sd->pan_obj, &px, &py);
672 if (px > minx) return EINA_TRUE;
675 if ((px - minx) < mx) return EINA_TRUE;
678 if (py > miny) return EINA_TRUE;
681 if ((py - miny) < my) return EINA_TRUE;
690 _smart_momentum_animator(void *data)
694 Evas_Coord x, y, dx, dy, px, py, maxx, maxy, minx, miny;
695 Eina_Bool no_bounce_x_end = EINA_FALSE, no_bounce_y_end = EINA_FALSE;
698 t = ecore_loop_time_get();
699 dt = t - sd->down.anim_start;
703 if (sd->down.hold_parent)
705 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
709 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
714 if ((!sd->down.dir_x) && (!sd->down.dir_y))
716 sd->down.cancelled = 1;
719 dt = dt / (_elm_config->thumbscroll_friction + sd->down.extra_time);
720 if (dt > 1.0) dt = 1.0;
721 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
722 dx = (sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
723 dy = (sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
726 x = sd->down.sx - dx;
727 y = sd->down.sy - dy;
728 elm_smart_scroller_child_pos_get(sd->smart_obj, &px, &py);
729 if ((sd->down.bounce_x_animator) ||
730 (sd->down.bounce_x_hold))
732 sd->down.bx = sd->down.bx0 - dx + sd->down.b0x;
735 if ((sd->down.bounce_y_animator) ||
736 (sd->down.bounce_y_hold))
738 sd->down.by = sd->down.by0 - dy + sd->down.b0y;
741 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
742 sd->pan_func.max_get(sd->pan_obj, &maxx, &maxy);
743 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
744 if (!sd->bounce_horiz)
746 if (x <= minx) no_bounce_x_end = EINA_TRUE;
747 if ((x - minx) >= maxx) no_bounce_x_end = EINA_TRUE;
749 if (!sd->bounce_vert)
751 if (y <= miny) no_bounce_y_end = EINA_TRUE;
752 if ((y - miny) >= maxy) no_bounce_y_end = EINA_TRUE;
755 ((sd->down.bounce_x_hold) && (sd->down.bounce_y_hold)) ||
756 (no_bounce_x_end && no_bounce_y_end))
758 _smart_anim_stop(sd->smart_obj);
759 sd->down.momentum_animator = NULL;
760 sd->down.bounce_x_hold = 0;
761 sd->down.bounce_y_hold = 0;
766 return ECORE_CALLBACK_CANCEL;
769 return ECORE_CALLBACK_RENEW;
773 bounce_eval(Smart_Data *sd)
775 Evas_Coord mx, my, px, py, bx, by, b2x, b2y, minx = 0, miny = 0;
777 if (sd->freeze) return;
778 if ((!sd->bouncemex) && (!sd->bouncemey)) return;
779 if (sd->down.now) return; // down bounce while still held down
780 if (sd->down.onhold_animator)
782 ecore_animator_del(sd->down.onhold_animator);
783 sd->down.onhold_animator = NULL;
785 if (sd->down.hold_animator)
787 ecore_animator_del(sd->down.hold_animator);
788 sd->down.hold_animator = NULL;
790 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
791 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
792 sd->pan_func.get(sd->pan_obj, &px, &py);
795 if (px < minx) px = minx;
796 if ((px - minx) > mx) px = mx + minx;
797 if (py < miny) py = miny;
798 if ((py - miny) > my) py = my + miny;
802 (!elm_widget_drag_child_locked_x_get(sd->widget)))
804 if (!sd->down.bounce_x_animator && !sd->bounce_animator_disabled)
808 if (sd->scrollto.x.animator)
810 ecore_animator_del(sd->scrollto.x.animator);
811 sd->scrollto.x.animator = NULL;
813 sd->down.bounce_x_animator = ecore_animator_add(_smart_bounce_x_animator, sd);
814 sd->down.anim_start2 = ecore_loop_time_get();
818 if (sd->down.momentum_animator) sd->down.b0x = sd->down.ax;
819 else sd->down.b0x = 0;
824 (!elm_widget_drag_child_locked_y_get(sd->widget)))
826 if (!sd->down.bounce_y_animator && !sd->bounce_animator_disabled)
830 if (sd->scrollto.y.animator)
832 ecore_animator_del(sd->scrollto.y.animator);
833 sd->scrollto.y.animator = NULL;
835 sd->down.bounce_y_animator = ecore_animator_add(_smart_bounce_y_animator, sd);
836 sd->down.anim_start3 = ecore_loop_time_get();
840 if (sd->down.momentum_animator) sd->down.b0y = sd->down.ay;
841 else sd->down.b0y = 0;
848 elm_smart_scroller_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
850 Evas_Coord mx = 0, my = 0, px, py, minx = 0, miny = 0;
854 // FIXME: allow for bounce outside of range
855 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
856 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
857 if (mx > 0) vx = (double)(x - minx) / (double)mx;
859 if (vx < 0.0) vx = 0.0;
860 else if (vx > 1.0) vx = 1.0;
861 if (my > 0) vy = (double)(y - miny) / (double)my;
863 if (vy < 0.0) vy = 0.0;
864 else if (vy > 1.0) vy = 1.0;
865 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, vy);
866 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", vx, 0.0);
867 sd->pan_func.get(sd->pan_obj, &px, &py);
868 if (!_elm_config->thumbscroll_bounce_enable)
870 if (x < minx) x = minx;
871 if ((x - minx) > mx) x = mx + minx;
872 if (y < miny) y = miny;
873 if ((y - miny) > my) y = my + miny;
876 if (!sd->bounce_horiz)
878 if (x < minx) x = minx;
879 if ((x - minx) > mx) x = mx + minx;
881 if (!sd->bounce_vert)
883 if (y < miny) y = miny;
884 if (y - miny > my) y = my + miny;
887 sd->pan_func.set(sd->pan_obj, x, y);
888 if ((px != x) || (py != y))
889 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
890 if (!sd->down.bounce_x_animator)
892 if ((x < minx) || (x > (mx + minx)))
898 if (!sd->down.bounce_y_animator)
900 if ((y < miny) || (y > my + miny))
906 if ((x != px) || (y != py))
908 evas_object_smart_callback_call(obj, "scroll", NULL);
910 if ((x != px)/* && (!sd->bouncemex)*/)
913 evas_object_smart_callback_call(obj, "edge,left", NULL);
914 if (x == (mx + minx))
915 evas_object_smart_callback_call(obj, "edge,right", NULL);
917 if ((y != py)/* && (!sd->bouncemey)*/)
920 evas_object_smart_callback_call(obj, "edge,top", NULL);
922 evas_object_smart_callback_call(obj, "edge,bottom", NULL);
927 elm_smart_scroller_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
930 sd->pan_func.get(sd->pan_obj, x, y);
933 /* "internal_call" actually toggles whether we should save the coords and do
934 * extra "speedup" checks, or not. */
936 _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool internal_call)
938 Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0;
941 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
942 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
943 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
944 sd->pan_func.get(sd->pan_obj, &px, &py);
948 else if ((x + w) > (px + (cw - mx)))
950 nx = x + w - (cw - mx);
955 else if ((y + h) > (py + (ch - my)))
957 ny = y + h - (ch - my);
966 if ((nx == px) && (ny == py)) return;
969 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
970 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
972 _smart_anim_stop(sd->smart_obj);
974 if (sd->scrollto.x.animator)
976 ecore_animator_del(sd->scrollto.x.animator);
977 sd->scrollto.x.animator = NULL;
979 if (sd->scrollto.y.animator)
981 ecore_animator_del(sd->scrollto.y.animator);
982 sd->scrollto.y.animator = NULL;
984 if (sd->down.bounce_x_animator)
986 ecore_animator_del(sd->down.bounce_x_animator);
987 sd->down.bounce_x_animator = NULL;
990 if (sd->down.bounce_y_animator)
992 ecore_animator_del(sd->down.bounce_y_animator);
993 sd->down.bounce_y_animator = NULL;
996 if (sd->down.hold_animator)
998 ecore_animator_del(sd->down.hold_animator);
999 sd->down.hold_animator = NULL;
1000 _smart_drag_stop(sd->smart_obj);
1002 if (sd->down.momentum_animator)
1004 ecore_animator_del(sd->down.momentum_animator);
1005 sd->down.momentum_animator = NULL;
1006 sd->down.bounce_x_hold = 0;
1007 sd->down.bounce_y_hold = 0;
1013 elm_smart_scroller_child_pos_set(obj, nx, ny);
1016 /* Set should be used for calculated positions, for example, when we move
1017 * because of an animation or because this is the correct position after
1020 elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1022 _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_TRUE);
1025 /* Set should be used for setting the wanted position, for example a user scroll
1026 * or moving the cursor in an entry. */
1028 elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1030 _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_FALSE);
1034 elm_smart_scroller_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1037 edje_object_calc_force(sd->edje_obj);
1038 evas_object_geometry_get(sd->pan_obj, NULL, NULL, w, h);
1042 elm_smart_scroller_step_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1049 _smart_scrollbar_size_adjust(sd);
1053 elm_smart_scroller_step_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1056 if (x) *x = sd->step.x;
1057 if (y) *y = sd->step.y;
1061 elm_smart_scroller_page_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1066 _smart_scrollbar_size_adjust(sd);
1070 elm_smart_scroller_page_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1073 if (x) *x = sd->page.x;
1074 if (y) *y = sd->page.y;
1078 elm_smart_scroller_policy_set(Evas_Object *obj, Elm_Smart_Scroller_Policy hbar, Elm_Smart_Scroller_Policy vbar)
1081 if ((sd->hbar_flags == hbar) && (sd->vbar_flags == vbar)) return;
1082 sd->hbar_flags = hbar;
1083 sd->vbar_flags = vbar;
1084 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1085 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
1086 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1087 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
1089 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
1090 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1091 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
1092 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1093 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
1095 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
1096 _smart_scrollbar_size_adjust(sd);
1100 elm_smart_scroller_policy_get(Evas_Object *obj, Elm_Smart_Scroller_Policy *hbar, Elm_Smart_Scroller_Policy *vbar)
1103 if (hbar) *hbar = sd->hbar_flags;
1104 if (vbar) *vbar = sd->vbar_flags;
1108 elm_smart_scroller_edje_object_get(Evas_Object *obj)
1110 API_ENTRY return NULL;
1111 return sd->edje_obj;
1115 elm_smart_scroller_single_dir_set(Evas_Object *obj, Eina_Bool single_dir)
1118 sd->one_dir_at_a_time = single_dir;
1122 elm_smart_scroller_single_dir_get(Evas_Object *obj)
1124 API_ENTRY return EINA_FALSE;
1125 return sd->one_dir_at_a_time;
1129 elm_smart_scroller_object_theme_set(Evas_Object *parent, Evas_Object *obj, const char *clas, const char *group, const char *style)
1133 _elm_theme_object_set(parent, sd->edje_obj, clas, group, style);
1134 edje_object_scale_set(sd->edje_obj, elm_widget_scale_get(parent) * _elm_config->scale);
1136 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
1138 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1139 if (edje_object_part_exists(sd->edje_obj, "elm.scrollbar.base"))
1142 base = edje_object_part_swallow_get(sd->edje_obj, "elm.scrollbar.base");
1145 base = evas_object_rectangle_add(evas_object_evas_get(sd->edje_obj));
1146 evas_object_color_set(base, 0, 0, 0, 0);
1147 edje_object_part_swallow(sd->edje_obj, "elm.scrollbar.base", base);
1149 if (!_elm_config->thumbscroll_enable)
1150 evas_object_size_hint_min_set(base, mw, mh);
1152 sd->vbar_visible = !sd->vbar_visible;
1153 sd->hbar_visible = !sd->hbar_visible;
1154 _smart_scrollbar_bar_visibility_adjust(sd);
1158 elm_smart_scroller_hold_set(Evas_Object *obj, Eina_Bool hold)
1165 elm_smart_scroller_freeze_set(Evas_Object *obj, Eina_Bool freeze)
1168 sd->freeze = freeze;
1171 if (sd->down.onhold_animator)
1173 ecore_animator_del(sd->down.onhold_animator);
1174 sd->down.onhold_animator = NULL;
1180 elm_smart_scroller_bounce_allow_set(Evas_Object *obj, Eina_Bool horiz, Eina_Bool vert)
1183 sd->bounce_horiz = horiz;
1184 sd->bounce_vert = vert;
1188 elm_smart_scroller_bounce_allow_get(const Evas_Object *obj, Eina_Bool *horiz, Eina_Bool *vert)
1191 *horiz = sd->bounce_horiz;
1192 *vert = sd->bounce_vert;
1196 elm_smart_scroller_paging_set(Evas_Object *obj, double pagerel_h, double pagerel_v, Evas_Coord pagesize_h, Evas_Coord pagesize_v)
1199 sd->pagerel_h = pagerel_h;
1200 sd->pagerel_v = pagerel_v;
1201 sd->pagesize_h = pagesize_h;
1202 sd->pagesize_v = pagesize_v;
1203 _smart_page_adjust(sd);
1207 elm_smart_scroller_paging_get(Evas_Object *obj, double *pagerel_h, double *pagerel_v, Evas_Coord *pagesize_h, Evas_Coord *pagesize_v)
1210 if(pagerel_h) *pagerel_h = sd->pagerel_h;
1211 if(pagerel_v) *pagerel_v = sd->pagerel_v;
1212 if(pagesize_h) *pagesize_h = sd->pagesize_h;
1213 if(pagesize_v) *pagesize_v = sd->pagesize_v;
1217 elm_smart_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1219 Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0;
1222 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
1223 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
1224 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
1225 sd->pan_func.get(sd->pan_obj, &px, &py);
1228 if ((x < px) && ((x + w) < (px + (cw - mx)))) nx = x;
1229 else if ((x > px) && ((x + w) > (px + (cw - mx)))) nx = x + w - (cw - mx);
1231 if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y;
1232 else if ((y > py) && ((y + h) > (py + (ch - my)))) ny = y + h - (ch - my);
1233 if ((nx == px) && (ny == py)) return;
1234 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1235 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1237 _smart_anim_stop(sd->smart_obj);
1239 if (sd->scrollto.x.animator)
1241 ecore_animator_del(sd->scrollto.x.animator);
1242 sd->scrollto.x.animator = NULL;
1244 if (sd->scrollto.y.animator)
1246 ecore_animator_del(sd->scrollto.y.animator);
1247 sd->scrollto.y.animator = NULL;
1249 if (sd->down.bounce_x_animator)
1251 ecore_animator_del(sd->down.bounce_x_animator);
1252 sd->down.bounce_x_animator = NULL;
1255 if (sd->down.bounce_y_animator)
1257 ecore_animator_del(sd->down.bounce_y_animator);
1258 sd->down.bounce_y_animator = NULL;
1261 if (sd->down.hold_animator)
1263 ecore_animator_del(sd->down.hold_animator);
1264 sd->down.hold_animator = NULL;
1265 _smart_drag_stop(sd->smart_obj);
1267 if (sd->down.momentum_animator)
1269 ecore_animator_del(sd->down.momentum_animator);
1270 sd->down.momentum_animator = NULL;
1271 sd->down.bounce_x_hold = 0;
1272 sd->down.bounce_y_hold = 0;
1279 if (x < minx) x = minx;
1280 else if ((x + w) > cw) x = cw - w;
1281 _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
1283 if (y < miny) y = miny;
1284 else if ((y + h) > ch) y = ch - h;
1285 _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
1289 elm_smart_scroller_widget_set(Evas_Object *obj, Evas_Object *wid)
1295 /* local subsystem functions */
1297 _smart_edje_drag_v_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1302 _smart_scrollbar_read(sd);
1303 _smart_drag_start(sd->smart_obj);
1307 _smart_edje_drag_v_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1312 _smart_scrollbar_read(sd);
1313 _smart_drag_stop(sd->smart_obj);
1317 _smart_edje_drag_v(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1322 _smart_scrollbar_read(sd);
1326 _smart_edje_drag_h_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1331 _smart_scrollbar_read(sd);
1332 _smart_drag_start(sd->smart_obj);
1336 _smart_edje_drag_h_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1341 _smart_scrollbar_read(sd);
1342 _smart_drag_stop(sd->smart_obj);
1346 _smart_edje_drag_h(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1351 _smart_scrollbar_read(sd);
1355 _smart_child_del_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1360 sd->child_obj = NULL;
1361 _smart_scrollbar_size_adjust(sd);
1362 _smart_scrollbar_reset(sd);
1366 _smart_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1373 sd->pan_func.get(sd->pan_obj, &x, &y);
1374 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
1375 if ((w != sd->child.w) || (h != sd->child.h))
1379 _smart_scrollbar_size_adjust(sd);
1380 evas_object_size_hint_min_set(sd->smart_obj, sd->child.w, sd->child.h);
1381 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1386 _smart_pan_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1392 sd->pan_func.get(sd->pan_obj, &x, &y);
1393 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1394 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1396 _smart_anim_stop(sd->smart_obj);
1398 if (sd->scrollto.x.animator)
1400 ecore_animator_del(sd->scrollto.x.animator);
1401 sd->scrollto.x.animator = NULL;
1403 if (sd->scrollto.y.animator)
1405 ecore_animator_del(sd->scrollto.y.animator);
1406 sd->scrollto.y.animator = NULL;
1408 if (sd->down.bounce_x_animator)
1410 ecore_animator_del(sd->down.bounce_x_animator);
1411 sd->down.bounce_x_animator = NULL;
1414 if (sd->down.bounce_y_animator)
1416 ecore_animator_del(sd->down.bounce_y_animator);
1417 sd->down.bounce_y_animator = NULL;
1420 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1424 _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1426 Evas_Event_Mouse_Wheel *ev;
1428 Evas_Coord x = 0, y = 0;
1432 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1433 if ((evas_key_modifier_is_set(ev->modifiers, "Control")) ||
1434 (evas_key_modifier_is_set(ev->modifiers, "Alt")) ||
1435 (evas_key_modifier_is_set(ev->modifiers, "Shift")) ||
1436 (evas_key_modifier_is_set(ev->modifiers, "Meta")) ||
1437 (evas_key_modifier_is_set(ev->modifiers, "Hyper")) ||
1438 (evas_key_modifier_is_set(ev->modifiers, "Super")))
1440 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1441 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1442 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1444 _smart_anim_stop(sd->smart_obj);
1446 if (sd->scrollto.x.animator)
1448 ecore_animator_del(sd->scrollto.x.animator);
1449 sd->scrollto.x.animator = NULL;
1451 if (sd->scrollto.y.animator)
1453 ecore_animator_del(sd->scrollto.y.animator);
1454 sd->scrollto.y.animator = NULL;
1456 if (sd->down.bounce_x_animator)
1458 ecore_animator_del(sd->down.bounce_x_animator);
1459 sd->down.bounce_x_animator = NULL;
1462 if (sd->down.bounce_y_animator)
1464 ecore_animator_del(sd->down.bounce_y_animator);
1465 sd->down.bounce_y_animator = NULL;
1469 y += ev->z * sd->step.y;
1470 else if (ev->direction == 1)
1471 x += ev->z * sd->step.x;
1473 if ((!sd->hold) && (!sd->freeze))
1477 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &sd->ww, &sd->wh);
1478 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1483 _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1485 Evas_Event_Mouse_Down *ev;
1487 Evas_Coord x = 0, y = 0;
1491 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1492 if (_elm_config->thumbscroll_enable)
1495 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1496 (sd->down.momentum_animator) || (sd->scrollto.x.animator) ||
1497 (sd->scrollto.y.animator))
1499 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL | EVAS_EVENT_FLAG_ON_HOLD;
1500 sd->down.scroll = 1;
1502 _smart_anim_stop(sd->smart_obj);
1504 if (sd->scrollto.x.animator)
1506 ecore_animator_del(sd->scrollto.x.animator);
1507 sd->scrollto.x.animator = NULL;
1509 if (sd->scrollto.y.animator)
1511 ecore_animator_del(sd->scrollto.y.animator);
1512 sd->scrollto.y.animator = NULL;
1514 if (sd->down.bounce_x_animator)
1516 ecore_animator_del(sd->down.bounce_x_animator);
1517 sd->down.bounce_x_animator = NULL;
1520 if (sd->down.bounce_y_animator)
1522 ecore_animator_del(sd->down.bounce_y_animator);
1523 sd->down.bounce_y_animator = NULL;
1526 if (sd->down.hold_animator)
1528 ecore_animator_del(sd->down.hold_animator);
1529 sd->down.hold_animator = NULL;
1530 _smart_drag_stop(sd->smart_obj);
1532 if (sd->down.momentum_animator)
1534 ecore_animator_del(sd->down.momentum_animator);
1535 sd->down.momentum_animator = NULL;
1536 sd->down.bounce_x_hold = 0;
1537 sd->down.bounce_y_hold = 0;
1541 if (ev->button == 1)
1544 sd->down.dragged = 0;
1547 sd->down.x = ev->canvas.x;
1548 sd->down.y = ev->canvas.y;
1549 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1552 sd->down.locked = 0;
1553 memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 20);
1555 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
1557 sd->down.history[0].timestamp = ecore_loop_time_get();
1559 sd->down.history[0].x = ev->canvas.x;
1560 sd->down.history[0].y = ev->canvas.y;
1562 sd->down.dragged_began = 0;
1563 sd->down.hold_parent = 0;
1564 sd->down.cancelled = 0;
1569 _smart_hold_animator(void *data)
1571 Smart_Data *sd = data;
1574 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
1577 if ((!sd->widget) ||
1578 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1580 ox = sd->down.hold_x;
1585 if ((!sd->widget) ||
1586 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1588 oy = sd->down.hold_y;
1591 elm_smart_scroller_child_pos_set(sd->smart_obj, ox, oy);
1592 return ECORE_CALLBACK_RENEW;
1596 _smart_event_post_up(void *data, Evas *e __UNUSED__)
1598 Smart_Data *sd = data;
1601 if (sd->down.dragged)
1603 elm_widget_drag_lock_x_set(sd->widget, 0);
1604 elm_widget_drag_lock_y_set(sd->widget, 0);
1611 _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
1613 Evas_Event_Mouse_Down *ev;
1615 Evas_Coord x = 0, y = 0, ox = 0, oy = 0;
1619 sd->down.hold_parent = 0;
1620 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1621 evas_post_event_callback_push(e, _smart_event_post_up, sd);
1622 // FIXME: respect elm_widget_scroll_hold_get of parent container
1623 if (_elm_config->thumbscroll_enable)
1625 if (ev->button == 1)
1627 if (sd->down.onhold_animator)
1629 ecore_animator_del(sd->down.onhold_animator);
1630 sd->down.onhold_animator = NULL;
1632 x = ev->canvas.x - sd->down.x;
1633 y = ev->canvas.y - sd->down.y;
1634 if (sd->down.dragged)
1636 _smart_drag_stop(sd->smart_obj);
1637 if ((!sd->hold) && (!sd->freeze))
1641 Evas_Coord ax, ay, dx, dy, vel;
1644 t = ev->timestamp / 1000.0;
1646 t = ecore_loop_time_get();
1648 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1653 printf("------ %i %i\n", ev->canvas.x, ev->canvas.y);
1655 for (i = 0; i < 20; i++)
1657 dt = t - sd->down.history[i].timestamp;
1658 if (dt > 0.2) break;
1660 printf("H: %i %i @ %1.3f\n",
1661 sd->down.history[i].x,
1662 sd->down.history[i].y, dt);
1665 ax += sd->down.history[i].x;
1666 ay += sd->down.history[i].y;
1672 dx = ev->canvas.x - ax;
1673 dy = ev->canvas.y - ay;
1676 vel = sqrt((dx * dx) + (dy * dy)) / at;
1677 if ((_elm_config->thumbscroll_friction > 0.0) &&
1678 (vel > _elm_config->thumbscroll_momentum_threshold) &&
1681 sd->down.dx = ((double)dx / at);
1682 sd->down.dy = ((double)dy / at);
1683 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
1684 ((sd->down.dx < 0) && (sd->down.pdx < 0)))
1685 sd->down.dx += (double)sd->down.pdx * 1.5; // FIXME: * 1.5 - probably should be config
1686 if (((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
1687 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
1688 sd->down.dy += (double)sd->down.pdy * 1.5; // FIXME: * 1.5 - probably should be config
1689 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
1690 ((sd->down.dx < 0) && (sd->down.pdx < 0)) ||
1691 ((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
1692 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
1694 double t = ecore_loop_time_get();
1695 double dt = t - sd->down.anim_start;
1697 if (dt < 0.0) dt = 0.0;
1698 else if (dt > _elm_config->thumbscroll_friction)
1699 dt = _elm_config->thumbscroll_friction;
1700 sd->down.extra_time = _elm_config->thumbscroll_friction - dt;
1703 sd->down.extra_time = 0.0;
1704 sd->down.pdx = sd->down.dx;
1705 sd->down.pdy = sd->down.dy;
1708 if (!_smart_do_page(sd))
1710 if (!sd->down.momentum_animator && !sd->momentum_animator_disabled)
1712 sd->down.momentum_animator = ecore_animator_add(_smart_momentum_animator, sd);
1713 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1714 _smart_anim_start(sd->smart_obj);
1716 sd->down.anim_start = ecore_loop_time_get();
1717 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1725 if (sd->down.hold_animator)
1727 ecore_animator_del(sd->down.hold_animator);
1728 sd->down.hold_animator = NULL;
1736 evas_event_feed_hold(e, 0, ev->timestamp, ev->data);
1737 if (_smart_do_page(sd))
1739 Evas_Coord pgx, pgy;
1741 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1742 if ((!sd->widget) ||
1743 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1745 pgx = _smart_page_x_get(sd, ox);
1748 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1749 _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
1752 if ((!sd->widget) ||
1753 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1755 pgy = _smart_page_y_get(sd, oy);
1758 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1759 _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
1768 if (_smart_do_page(sd))
1770 Evas_Coord pgx, pgy;
1772 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1773 if ((!sd->widget) ||
1774 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1776 pgx = _smart_page_x_get(sd, ox);
1777 if (pgx != x) _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
1779 if ((!sd->widget) ||
1780 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1782 pgy = _smart_page_y_get(sd, oy);
1783 if (pgy != y) _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
1786 if (sd->down.hold_animator)
1788 ecore_animator_del(sd->down.hold_animator);
1789 sd->down.hold_animator = NULL;
1792 if (sd->down.scroll)
1794 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
1795 sd->down.scroll = 0;
1799 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1802 sd->down.dragged_began = 0;
1805 sd->down.want_dragged = 0;
1806 sd->down.dragged = 0;
1808 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1809 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1812 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &sd->ww, &sd->wh);
1813 if (!_smart_do_page(sd))
1820 _smart_onhold_animator(void *data)
1825 Evas_Coord x, y, ox, oy;
1828 t = ecore_loop_time_get();
1829 if (sd->down.onhold_tlast > 0.0)
1831 td = t - sd->down.onhold_tlast;
1832 vx = sd->down.onhold_vx * td * (double)_elm_config->thumbscroll_threshold * 2.0;
1833 vy = sd->down.onhold_vy * td * (double)_elm_config->thumbscroll_threshold * 2.0;
1834 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
1840 if ((!sd->widget) ||
1841 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1843 sd->down.onhold_vxe += vx;
1844 x = ox + (int)sd->down.onhold_vxe;
1845 sd->down.onhold_vxe -= (int)sd->down.onhold_vxe;
1851 if ((!sd->widget) ||
1852 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1854 sd->down.onhold_vye += vy;
1855 y = oy + (int)sd->down.onhold_vye;
1856 sd->down.onhold_vye -= (int)sd->down.onhold_vye;
1860 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1862 sd->down.onhold_tlast = t;
1863 return ECORE_CALLBACK_RENEW;
1867 _smart_event_post_move(void *data, Evas *e __UNUSED__)
1869 Smart_Data *sd = data;
1871 if (sd->down.want_dragged)
1875 if (sd->down.hold_parent)
1877 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
1881 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
1888 if ((!sd->widget) ||
1889 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1891 sd->down.want_dragged = 0;
1892 sd->down.dragged = 1;
1895 elm_widget_drag_lock_x_set(sd->widget, 1);
1904 if ((!sd->widget) ||
1905 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1907 sd->down.want_dragged = 0;
1908 sd->down.dragged = 1;
1911 elm_widget_drag_lock_y_set(sd->widget, 1);
1918 if ((!sd->down.dir_x) && (!sd->down.dir_y))
1920 sd->down.cancelled = 1;
1922 if (start) _smart_drag_start(sd->smart_obj);
1928 _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
1930 Evas_Event_Mouse_Move *ev;
1932 Evas_Coord x = 0, y = 0;
1936 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1937 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->down.hold_parent = 1;
1938 evas_post_event_callback_push(e, _smart_event_post_move, sd);
1939 // FIXME: respect elm_widget_scroll_hold_get of parent container
1940 if (_elm_config->thumbscroll_enable)
1947 printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
1949 memmove(&(sd->down.history[1]), &(sd->down.history[0]),
1950 sizeof(sd->down.history[0]) * 19);
1952 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
1954 sd->down.history[0].timestamp = ecore_loop_time_get();
1956 sd->down.history[0].x = ev->cur.canvas.x;
1957 sd->down.history[0].y = ev->cur.canvas.y;
1959 if (!sd->down.dragged_began)
1961 x = ev->cur.canvas.x - sd->down.x;
1962 y = ev->cur.canvas.y - sd->down.y;
1967 if (x > 0) sd->down.hdir = LEFT;
1968 else if (x < 0) sd->down.hdir = RIGHT;
1969 if (y > 0) sd->down.vdir = UP;
1970 else if (y < 0) sd->down.vdir = DOWN;
1975 if ((sd->one_dir_at_a_time) &&
1976 (!((sd->down.dir_x) || (sd->down.dir_y))))
1978 if (x > _elm_config->thumbscroll_threshold)
1987 if (y > _elm_config->thumbscroll_threshold)
2004 // can_scroll(sd, LEFT);
2005 // can_scroll(sd, RIGHT);
2006 // can_scroll(sd, UP);
2007 // can_scroll(sd, DOWN);
2012 if ((!sd->hold) && (!sd->freeze))
2014 if ((sd->down.dragged) ||
2015 (((x * x) + (y * y)) >
2016 (_elm_config->thumbscroll_threshold *
2017 _elm_config->thumbscroll_threshold)))
2019 sd->down.dragged_began = 1;
2020 if (!sd->down.dragged)
2022 sd->down.want_dragged = 1;
2023 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2024 // evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
2025 // _smart_drag_start(sd->smart_obj);
2027 if (sd->down.dragged)
2029 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2031 // ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2032 // sd->down.dragged = 1;
2034 x = sd->down.sx - (ev->cur.canvas.x - sd->down.x);
2038 y = sd->down.sy - (ev->cur.canvas.y - sd->down.y);
2041 if ((sd->down.dir_x) || (sd->down.dir_y))
2043 if (!sd->down.locked)
2045 sd->down.locked_x = x;
2046 sd->down.locked_y = y;
2047 sd->down.locked = 1;
2049 if (!((sd->down.dir_x) && (sd->down.dir_y)))
2051 if (sd->down.dir_x) y = sd->down.locked_y;
2052 else x = sd->down.locked_x;
2055 if (_elm_config->thumbscroll_border_friction > 0.0)
2057 Evas_Coord minx, miny;
2058 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2061 _elm_config->thumbscroll_border_friction;
2062 else if (sd->child.h <= sd->h)
2063 y += (sd->down.sy - y) *
2064 _elm_config->thumbscroll_border_friction;
2065 else if ((sd->child.h - sd->h + miny) < y)
2066 y += (sd->child.h - sd->h + miny - y) *
2067 _elm_config->thumbscroll_border_friction;
2070 _elm_config->thumbscroll_border_friction;
2071 else if (sd->child.w <= sd->w)
2072 x += (sd->down.sx - x) *
2073 _elm_config->thumbscroll_border_friction;
2074 else if ((sd->child.w - sd->w + minx) < x)
2075 x += (sd->child.w - sd->w + minx - x) *
2076 _elm_config->thumbscroll_border_friction;
2079 sd->down.hold_x = x;
2080 sd->down.hold_y = y;
2081 if (!sd->down.hold_animator)
2082 sd->down.hold_animator =
2083 ecore_animator_add(_smart_hold_animator, sd);
2084 // printf("a %i %i\n", sd->down.hold_x, sd->down.hold_y);
2085 // _smart_onhold_animator(sd);
2086 // elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
2090 if (sd->down.dragged_began)
2092 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2096 evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
2101 else if (!sd->freeze)
2103 Evas_Coord ex, ey, ew, eh;
2104 double vx = 0.0, vy = 0.0;
2106 evas_object_geometry_get(sd->event_obj, &ex, &ey, &ew, &eh);
2107 x = ev->cur.canvas.x - ex;
2108 y = ev->cur.canvas.y - ey;
2109 if (x < _elm_config->thumbscroll_threshold)
2111 if (_elm_config->thumbscroll_threshold > 0.0)
2112 vx = -(double)(_elm_config->thumbscroll_threshold - x) /
2113 _elm_config->thumbscroll_threshold;
2117 else if (x > (ew - _elm_config->thumbscroll_threshold))
2119 if (_elm_config->thumbscroll_threshold > 0.0)
2120 vx = (double)(_elm_config->thumbscroll_threshold - (ew - x)) /
2121 _elm_config->thumbscroll_threshold;
2125 if (y < _elm_config->thumbscroll_threshold)
2127 if (_elm_config->thumbscroll_threshold > 0.0)
2128 vy = -(double)(_elm_config->thumbscroll_threshold - y) /
2129 _elm_config->thumbscroll_threshold;
2133 else if (y > (eh - _elm_config->thumbscroll_threshold))
2135 if (_elm_config->thumbscroll_threshold > 0.0)
2136 vy = (double)(_elm_config->thumbscroll_threshold - (eh - y)) /
2137 _elm_config->thumbscroll_threshold;
2141 if ((vx != 0.0) || (vy != 0.0))
2143 sd->down.onhold_vx = vx;
2144 sd->down.onhold_vy = vy;
2145 if (!sd->down.onhold_animator)
2147 sd->down.onhold_vxe = 0.0;
2148 sd->down.onhold_vye = 0.0;
2149 sd->down.onhold_tlast = 0.0;
2150 sd->down.onhold_animator = ecore_animator_add(_smart_onhold_animator, sd);
2152 // printf("b %i %i\n", sd->down.hold_x, sd->down.hold_y);
2156 if (sd->down.onhold_animator)
2158 ecore_animator_del(sd->down.onhold_animator);
2159 sd->down.onhold_animator = NULL;
2168 _smart_scrollbar_read(Smart_Data *sd)
2170 Evas_Coord x, y, mx = 0, my = 0, px, py, minx = 0, miny = 0;
2173 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2174 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2175 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2176 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2177 x = vx * (double)mx + minx;
2178 y = vy * (double)my + miny;
2179 sd->pan_func.get(sd->pan_obj, &px, &py);
2180 sd->pan_func.set(sd->pan_obj, x, y);
2181 if ((px != x) || (py != y))
2182 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2186 _smart_scrollbar_reset(Smart_Data *sd)
2188 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2190 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2191 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2192 if ((!sd->child_obj) && (!sd->extern_pan))
2194 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2195 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2197 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2198 sd->pan_func.get(sd->pan_obj, &px, &py);
2199 sd->pan_func.set(sd->pan_obj, minx, miny);
2200 if ((px != minx) || (py != miny))
2201 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2205 _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
2207 int scroll_v_vis_change = 0;
2208 Evas_Coord h, vw, vh;
2211 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2212 if (sd->vbar_visible)
2214 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2216 if ((sd->child_obj) || (sd->extern_pan))
2220 scroll_v_vis_change = 1;
2221 sd->vbar_visible = 0;
2226 scroll_v_vis_change = 1;
2227 sd->vbar_visible = 0;
2230 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2232 scroll_v_vis_change = 1;
2233 sd->vbar_visible = 0;
2238 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2240 if ((sd->child_obj) || (sd->extern_pan))
2244 scroll_v_vis_change = 1;
2245 sd->vbar_visible = 1;
2249 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2251 scroll_v_vis_change = 1;
2252 sd->vbar_visible = 1;
2255 if (scroll_v_vis_change)
2257 if (sd->vbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2259 if (sd->vbar_visible)
2260 edje_object_signal_emit(sd->edje_obj, "elm,action,show,vbar", "elm");
2262 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2263 edje_object_message_signal_process(sd->edje_obj);
2264 _smart_scrollbar_size_adjust(sd);
2267 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2269 return scroll_v_vis_change;
2273 _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
2275 int scroll_h_vis_change = 0;
2276 Evas_Coord w, vw, vh;
2279 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2280 if (sd->hbar_visible)
2282 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2284 if ((sd->child_obj) || (sd->extern_pan))
2288 scroll_h_vis_change = 1;
2289 sd->hbar_visible = 0;
2294 scroll_h_vis_change = 1;
2295 sd->hbar_visible = 0;
2298 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2300 scroll_h_vis_change = 1;
2301 sd->hbar_visible = 0;
2306 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2308 if ((sd->child_obj) || (sd->extern_pan))
2312 scroll_h_vis_change = 1;
2313 sd->hbar_visible = 1;
2317 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2319 scroll_h_vis_change = 1;
2320 sd->hbar_visible = 1;
2323 if (scroll_h_vis_change)
2325 if (sd->hbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2327 if (sd->hbar_visible)
2328 edje_object_signal_emit(sd->edje_obj, "elm,action,show,hbar", "elm");
2330 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2331 edje_object_message_signal_process(sd->edje_obj);
2332 _smart_scrollbar_size_adjust(sd);
2335 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2336 _smart_scrollbar_size_adjust(sd);
2338 return scroll_h_vis_change;
2342 _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd)
2346 changed |= _smart_scrollbar_bar_h_visibility_adjust(sd);
2347 changed |= _smart_scrollbar_bar_v_visibility_adjust(sd);
2350 _smart_scrollbar_bar_h_visibility_adjust(sd);
2351 _smart_scrollbar_bar_v_visibility_adjust(sd);
2356 _smart_scrollbar_size_adjust(Smart_Data *sd)
2358 if ((sd->child_obj) || (sd->extern_pan))
2360 Evas_Coord x, y, w, h, mx = 0, my = 0, vw = 0, vh = 0, px, py, minx = 0, miny = 0;
2361 double vx, vy, size;
2363 edje_object_part_geometry_get(sd->edje_obj, "elm.swallow.content",
2364 NULL, NULL, &vw, &vh);
2367 size = (double)vw / (double)w;
2371 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2373 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", size, 1.0);
2377 size = (double)vh / (double)h;
2381 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2383 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, size);
2385 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2386 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2387 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2388 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2392 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->step.x / (double)w, 0.0);
2393 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->step.y / (double)h);
2395 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->page.x / (double)w, 0.0);
2397 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", -((double)sd->page.x * ((double)vw / (double)w)) / 100.0, 0.0);
2399 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->page.y / (double)h);
2401 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, -((double)sd->page.y * ((double)vh / (double)h)) / 100.0);
2403 sd->pan_func.get(sd->pan_obj, &px, &py);
2404 if (vx != mx) x = px;
2405 if (vy != my) y = py;
2406 sd->pan_func.set(sd->pan_obj, x, y);
2407 // if ((px != 0) || (py != 0))
2408 // edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2412 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2414 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2415 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2416 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2417 sd->pan_func.get(sd->pan_obj, &px, &py);
2418 sd->pan_func.set(sd->pan_obj, minx, miny);
2419 if ((px != minx) || (py != miny))
2420 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2422 _smart_scrollbar_bar_visibility_adjust(sd);
2426 _smart_reconfigure(Smart_Data *sd)
2428 evas_object_move(sd->edje_obj, sd->x, sd->y);
2429 evas_object_resize(sd->edje_obj, sd->w, sd->h);
2430 evas_object_move(sd->event_obj, sd->x, sd->y);
2431 evas_object_resize(sd->event_obj, sd->w, sd->h);
2432 _smart_scrollbar_size_adjust(sd);
2436 _smart_add(Evas_Object *obj)
2441 sd = calloc(1, sizeof(Smart_Data));
2443 evas_object_smart_data_set(obj, sd);
2445 sd->smart_obj = obj;
2454 sd->hbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2455 sd->vbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2456 sd->hbar_visible = 1;
2457 sd->vbar_visible = 1;
2459 sd->bounce_horiz = 1;
2460 sd->bounce_vert = 1;
2462 sd->one_dir_at_a_time = 1;
2463 sd->momentum_animator_disabled = 0;
2464 sd->bounce_animator_disabled = 0;
2466 o = edje_object_add(evas_object_evas_get(obj));
2467 evas_object_propagate_events_set(o, 0);
2469 // FIXME: null parent obj ... :(
2470 elm_smart_scroller_object_theme_set(NULL, obj, "scroller", "base", "default");
2471 edje_object_signal_callback_add(o, "drag", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2472 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.vbar", _smart_edje_drag_v_start, sd);
2473 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.vbar", _smart_edje_drag_v_stop, sd);
2474 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2475 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2476 edje_object_signal_callback_add(o, "drag", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2477 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.hbar", _smart_edje_drag_h_start, sd);
2478 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.hbar", _smart_edje_drag_h_stop, sd);
2479 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2480 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2481 evas_object_smart_member_add(o, obj);
2483 o = evas_object_rectangle_add(evas_object_evas_get(obj));
2485 evas_object_color_set(o, 0, 0, 0, 0);
2486 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd);
2487 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _smart_event_mouse_down, sd);
2488 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _smart_event_mouse_up, sd);
2489 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _smart_event_mouse_move, sd);
2490 evas_object_smart_member_add(o, obj);
2491 evas_object_repeat_events_set(o, 1);
2493 sd->pan_func.set = _elm_smart_pan_set;
2494 sd->pan_func.get = _elm_smart_pan_get;
2495 sd->pan_func.max_get = _elm_smart_pan_max_get;
2496 sd->pan_func.min_get = _elm_smart_pan_min_get;
2497 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
2499 _smart_scrollbar_reset(sd);
2503 _smart_del(Evas_Object *obj)
2506 elm_smart_scroller_child_set(obj, NULL);
2507 if (!sd->extern_pan) evas_object_del(sd->pan_obj);
2508 evas_object_del(sd->edje_obj);
2509 evas_object_del(sd->event_obj);
2510 if (sd->down.hold_animator) ecore_animator_del(sd->down.hold_animator);
2511 if (sd->down.onhold_animator) ecore_animator_del(sd->down.onhold_animator);
2512 if (sd->down.momentum_animator) ecore_animator_del(sd->down.momentum_animator);
2513 if (sd->down.bounce_x_animator) ecore_animator_del(sd->down.bounce_x_animator);
2514 if (sd->down.bounce_y_animator) ecore_animator_del(sd->down.bounce_y_animator);
2515 if (sd->scrollto.x.animator) ecore_animator_del(sd->scrollto.x.animator);
2516 if (sd->scrollto.y.animator) ecore_animator_del(sd->scrollto.y.animator);
2518 evas_object_smart_data_set(obj, NULL);
2522 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2527 _smart_reconfigure(sd);
2531 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2536 _smart_reconfigure(sd);
2537 elm_smart_scroller_child_region_set(obj, sd->wx, sd->wy, sd->ww, sd->h);
2541 _smart_show(Evas_Object *obj)
2544 evas_object_show(sd->edje_obj);
2545 evas_object_show(sd->event_obj);
2549 _smart_hide(Evas_Object *obj)
2552 evas_object_hide(sd->edje_obj);
2553 evas_object_hide(sd->event_obj);
2557 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
2560 evas_object_color_set(sd->edje_obj, r, g, b, a);
2564 _smart_clip_set(Evas_Object *obj, Evas_Object *clip)
2567 evas_object_clip_set(sd->edje_obj, clip);
2568 evas_object_clip_set(sd->event_obj, clip);
2572 _smart_clip_unset(Evas_Object *obj)
2575 evas_object_clip_unset(sd->edje_obj);
2576 evas_object_clip_unset(sd->event_obj);
2579 /* never need to touch this */
2586 static const Evas_Smart_Class sc =
2589 EVAS_SMART_CLASS_VERSION,
2607 _smart = evas_smart_class_new(&sc);