1 #include <Elementary.h>
3 #include "els_scroller.h"
6 #define SMART_NAME "els_scroller"
7 #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)))
8 #define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
9 typedef struct _Smart_Data Smart_Data;
16 Evas_Coord x, y, w, h;
17 Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */
19 Evas_Object *smart_obj;
20 Evas_Object *child_obj;
22 Evas_Object *edje_obj;
23 Evas_Object *event_obj;
27 Elm_Smart_Scroller_Policy hbar_flags, vbar_flags;
41 double timestamp, localtimestamp;
44 double tadd, dxsum, dysum;
45 double est_timestamp_diff;
50 double onhold_vx, onhold_vy, onhold_tlast, onhold_vxe, onhold_vye;
52 Evas_Coord hold_x, hold_y;
53 Ecore_Animator *hold_animator;
54 Ecore_Animator *onhold_animator;
55 Ecore_Animator *momentum_animator;
56 Ecore_Animator *bounce_x_animator;
57 Ecore_Animator *bounce_y_animator;
58 Evas_Coord locked_x, locked_y;
61 Eina_Bool cancelled : 1;
63 Eina_Bool hold_parent : 1;
64 Eina_Bool want_dragged : 1;
65 Eina_Bool dragged : 1;
66 Eina_Bool dragged_began : 1;
70 Eina_Bool bounce_x_hold : 1;
71 Eina_Bool bounce_y_hold : 1;
77 Eina_Bool resized : 1;
84 void (*set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
85 void (*get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
86 void (*max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
87 void (*min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
88 void (*child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
89 void (*gravity_set) (Evas_Object *obj, double x, double y);
90 void (*gravity_get) (Evas_Object *obj, double *x, double *y);
95 Evas_Coord start, end;
96 double t_start, t_end;
97 Ecore_Animator *animator;
101 double pagerel_h, pagerel_v;
102 Evas_Coord pagesize_h, pagesize_v;
104 Eina_Bool hbar_visible : 1;
105 Eina_Bool vbar_visible : 1;
106 Eina_Bool extern_pan : 1;
107 Eina_Bool one_dir_at_a_time : 1;
109 Eina_Bool freeze : 1;
110 Eina_Bool bouncemex : 1;
111 Eina_Bool bouncemey : 1;
112 Eina_Bool bounce_horiz : 1;
113 Eina_Bool bounce_vert : 1;
114 Eina_Bool momentum_animator_disabled :1;
115 Eina_Bool bounce_animator_disabled :1;
116 Eina_Bool is_mirrored : 1;
117 Eina_Bool wheel_disabled : 1;
120 /* local subsystem functions */
121 static void _smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
122 static void _smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
123 static void _smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
124 static void _smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
125 static Eina_Bool _smart_hold_animator(void *data);
126 static Eina_Bool _smart_momentum_animator(void *data);
127 static void _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
128 static Eina_Bool _smart_onhold_animator(void *data);
129 static void _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
130 static void _smart_edje_drag_v_start(void *data, Evas_Object *obj, const char *emission, const char *source);
131 static void _smart_edje_drag_v_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
132 static void _smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source);
133 static void _smart_edje_drag_h_start(void *data, Evas_Object *obj, const char *emission, const char *source);
134 static void _smart_edje_drag_h_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
135 static void _smart_edje_drag_h(void *data, Evas_Object *obj, const char *emission, const char *source);
136 static void _smart_scrollbar_read(Smart_Data *sd);
137 static void _smart_scrollbar_reset(Smart_Data *sd);
138 static int _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd);
139 static int _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd);
140 static void _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd);
141 static void _smart_scrollbar_size_adjust(Smart_Data *sd);
142 static void _smart_reconfigure(Smart_Data *sd);
143 static void _smart_add(Evas_Object *obj);
144 static void _smart_del(Evas_Object *obj);
145 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
146 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
147 static void _smart_show(Evas_Object *obj);
148 static void _smart_hide(Evas_Object *obj);
149 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
150 static void _smart_clip_set(Evas_Object *obj, Evas_Object *clip);
151 static void _smart_clip_unset(Evas_Object *obj);
152 static void _smart_init(void);
154 static void _elm_smart_scroller_wanted_region_set(Evas_Object *obj);
156 /* local subsystem globals */
157 static Evas_Smart *_smart = NULL;
159 /* externally accessible functions */
161 elm_smart_scroller_add(Evas *evas)
164 return evas_object_smart_add(evas, _smart);
168 _elm_smart_scroller_x_mirrored_get(Evas_Object *obj, Evas_Coord x)
172 Evas_Coord cw, ch, w, ret;
173 elm_smart_scroller_child_viewport_size_get(obj, &w, NULL);
174 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
175 ret = (cw - (x + w));
176 return (ret >= 0) ? ret : 0;
180 elm_smart_scroller_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
184 if (sd->is_mirrored == mirrored)
187 sd->is_mirrored = mirrored;
188 edje_object_mirrored_set(sd->edje_obj, mirrored);
191 wx = _elm_smart_scroller_x_mirrored_get(sd->smart_obj, sd->wx);
195 elm_smart_scroller_child_pos_set(sd->smart_obj, wx, sd->wy);
199 elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
207 _elm_smart_pan_child_set(sd->pan_obj, NULL);
208 evas_object_event_callback_del_full(sd->child_obj, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
211 sd->child_obj = child;
213 /* (-1) means want viewports size */
214 sd->ww = sd->wh = -1;
219 o = _elm_smart_pan_add(evas_object_evas_get(obj));
221 evas_object_smart_callback_add(o, "changed", _smart_pan_changed_hook, sd);
222 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", o);
225 sd->pan_func.set = _elm_smart_pan_set;
226 sd->pan_func.get = _elm_smart_pan_get;
227 sd->pan_func.max_get = _elm_smart_pan_max_get;
228 sd->pan_func.min_get = _elm_smart_pan_min_get;
229 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
230 sd->pan_func.gravity_set = _elm_smart_pan_gravity_set;
231 sd->pan_func.gravity_get = _elm_smart_pan_gravity_get;
233 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL, _smart_child_del_hook, sd);
234 _elm_smart_pan_child_set(sd->pan_obj, child);
235 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
238 _smart_scrollbar_size_adjust(sd);
239 _smart_scrollbar_reset(sd);
243 elm_smart_scroller_extern_pan_set(Evas_Object *obj, Evas_Object *pan,
244 void (*pan_set) (Evas_Object *obj, Evas_Coord x, Evas_Coord y),
245 void (*pan_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
246 void (*pan_max_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
247 void (*pan_min_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y),
248 void (*pan_child_size_get) (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y))
252 elm_smart_scroller_child_set(obj, NULL);
256 evas_object_smart_callback_del(sd->pan_obj, "changed", _smart_pan_changed_hook);
263 edje_object_part_unswallow(sd->edje_obj, sd->pan_obj);
271 evas_object_del(sd->pan_obj);
277 sd->extern_pan = EINA_FALSE;
282 sd->pan_func.set = pan_set;
283 sd->pan_func.get = pan_get;
284 sd->pan_func.max_get = pan_max_get;
285 sd->pan_func.min_get = pan_min_get;
286 sd->pan_func.child_size_get = pan_child_size_get;
287 sd->pan_func.gravity_set = _elm_smart_pan_gravity_set;
288 sd->pan_func.gravity_get = _elm_smart_pan_gravity_get;
289 sd->extern_pan = EINA_TRUE;
290 evas_object_smart_callback_add(sd->pan_obj, "changed", _smart_pan_changed_hook, sd);
291 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
292 evas_object_show(sd->pan_obj);
296 elm_smart_scroller_custom_edje_file_set(Evas_Object *obj, char *file, char *group)
300 edje_object_file_set(sd->edje_obj, file, group);
302 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
303 sd->vbar_visible = !sd->vbar_visible;
304 sd->hbar_visible = !sd->hbar_visible;
305 _smart_scrollbar_bar_visibility_adjust(sd);
306 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
307 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
308 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
309 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
311 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
312 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
313 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
314 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
315 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
317 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
321 elm_smart_scroller_momentum_animator_disabled_get(Evas_Object *obj)
323 API_ENTRY return EINA_FALSE;
324 return sd->momentum_animator_disabled;
328 elm_smart_scroller_momentum_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
331 sd->momentum_animator_disabled = disabled;
332 if (sd->momentum_animator_disabled)
334 if (sd->down.momentum_animator)
336 ecore_animator_del(sd->down.momentum_animator);
337 sd->down.momentum_animator = NULL;
338 if (sd->child.resized)
339 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
345 elm_smart_scroller_bounce_animator_disabled_get(Evas_Object *obj)
347 API_ENTRY return EINA_FALSE;
348 return sd->bounce_animator_disabled;
352 elm_smart_scroller_bounce_animator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
355 sd->bounce_animator_disabled = disabled;
356 if (sd->bounce_animator_disabled)
358 if (sd->scrollto.x.animator)
360 ecore_animator_del(sd->scrollto.x.animator);
361 sd->scrollto.x.animator = NULL;
364 if (sd->scrollto.y.animator)
366 ecore_animator_del(sd->scrollto.y.animator);
367 sd->scrollto.y.animator = NULL;
373 elm_smart_scroller_wheel_disabled_get(Evas_Object *obj)
375 API_ENTRY return EINA_FALSE;
376 return sd->wheel_disabled;
380 elm_smart_scroller_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
383 if ((!sd->wheel_disabled) && (disabled))
384 evas_object_event_callback_del_full(sd->event_obj, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd);
385 else if ((sd->wheel_disabled) && (!disabled))
386 evas_object_event_callback_add(sd->event_obj, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd);
387 sd->wheel_disabled = disabled;
390 /* Update the wanted coordinates according to the x, y passed
391 * widget directionality, child size and etc. */
393 _update_wanted_coordinates(Smart_Data *sd, Evas_Coord x, Evas_Coord y)
397 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
399 /* Update wx/y/w/h - and if the requested positions aren't legal
401 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &sd->ww, &sd->wh);
404 else if ((x + sd->ww) > cw)
405 sd->wx = cw - sd->ww;
406 else if (sd->is_mirrored)
407 sd->wx = _elm_smart_scroller_x_mirrored_get(sd->smart_obj, x);
410 if (y < 0) sd->wy = 0;
411 else if ((y + sd->wh) > ch) sd->wy = ch - sd->wh;
416 _smart_anim_start(Evas_Object *obj)
418 evas_object_smart_callback_call(obj, "animate,start", NULL);
422 _smart_anim_stop(Evas_Object *obj)
424 evas_object_smart_callback_call(obj, "animate,stop", NULL);
428 _smart_drag_start(Evas_Object *obj)
430 evas_object_smart_callback_call(obj, "drag,start", NULL);
434 _smart_drag_stop(Evas_Object *obj)
436 evas_object_smart_callback_call(obj, "drag,stop", NULL);
440 _smart_scrollto_x_animator(void *data)
442 Smart_Data *sd = data;
446 t = ecore_loop_time_get();
447 tt = (t - sd->scrollto.x.t_start) / (sd->scrollto.x.t_end - sd->scrollto.x.t_start);
449 tt = 1.0 - (tt * tt);
450 sd->pan_func.get(sd->pan_obj, &px, &py);
451 px = (sd->scrollto.x.start * (1.0 - tt)) +
452 (sd->scrollto.x.end * tt);
453 if (t >= sd->scrollto.x.t_end)
455 px = sd->scrollto.x.end;
456 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
458 sd->down.x = sd->down.history[0].x;
459 _update_wanted_coordinates(sd, px, py);
460 sd->scrollto.x.animator = NULL;
461 if ((!sd->scrollto.y.animator) && (!sd->down.bounce_y_animator))
462 _smart_anim_stop(sd->smart_obj);
463 return ECORE_CALLBACK_CANCEL;
465 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
466 _update_wanted_coordinates(sd, px, py);
467 return ECORE_CALLBACK_RENEW;
471 _smart_momentum_end(Smart_Data *sd)
473 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator)) return;
474 if (sd->down.momentum_animator)
477 elm_smart_scroller_child_pos_get(sd->smart_obj, &px, &py);
478 _update_wanted_coordinates(sd, px, py);
480 ecore_animator_del(sd->down.momentum_animator);
481 sd->down.momentum_animator = NULL;
482 sd->down.bounce_x_hold = EINA_FALSE;
483 sd->down.bounce_y_hold = EINA_FALSE;
490 if (sd->child.resized)
491 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
496 _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x)
498 Evas_Coord px, py, x, y, w, h;
501 if (sd->freeze) return;
504 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
505 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
507 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
510 t = ecore_loop_time_get();
511 sd->pan_func.get(sd->pan_obj, &px, &py);
512 sd->scrollto.x.start = px;
513 sd->scrollto.x.end = pos_x;
514 sd->scrollto.x.t_start = t;
515 sd->scrollto.x.t_end = t + t_in;
516 if (!sd->scrollto.x.animator)
518 sd->scrollto.x.animator = ecore_animator_add(_smart_scrollto_x_animator, sd);
519 if (!sd->scrollto.y.animator)
520 _smart_anim_start(sd->smart_obj);
522 if (sd->down.bounce_x_animator)
524 ecore_animator_del(sd->down.bounce_x_animator);
525 sd->down.bounce_x_animator = NULL;
526 _smart_momentum_end(sd);
527 if (sd->child.resized)
528 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
530 sd->bouncemex = EINA_FALSE;
534 _smart_scrollto_y_animator(void *data)
536 Smart_Data *sd = data;
540 t = ecore_loop_time_get();
541 tt = (t - sd->scrollto.y.t_start) / (sd->scrollto.y.t_end - sd->scrollto.y.t_start);
543 tt = 1.0 - (tt * tt);
544 sd->pan_func.get(sd->pan_obj, &px, &py);
545 py = (sd->scrollto.y.start * (1.0 - tt)) +
546 (sd->scrollto.y.end * tt);
547 if (t >= sd->scrollto.y.t_end)
549 py = sd->scrollto.y.end;
550 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
552 sd->down.y = sd->down.history[0].y;
553 _update_wanted_coordinates(sd, px, py);
554 sd->scrollto.y.animator = NULL;
555 if ((!sd->scrollto.x.animator) && (!sd->down.bounce_x_animator))
556 _smart_anim_stop(sd->smart_obj);
557 return ECORE_CALLBACK_CANCEL;
559 elm_smart_scroller_child_pos_set(sd->smart_obj, px, py);
560 _update_wanted_coordinates(sd, px, py);
562 return ECORE_CALLBACK_RENEW;
566 _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y)
568 Evas_Coord px, py, x, y, w, h;
571 if (sd->freeze) return;
574 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
575 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
577 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
580 t = ecore_loop_time_get();
581 sd->pan_func.get(sd->pan_obj, &px, &py);
582 sd->scrollto.y.start = py;
583 sd->scrollto.y.end = pos_y;
584 sd->scrollto.y.t_start = t;
585 sd->scrollto.y.t_end = t + t_in;
586 if (!sd->scrollto.y.animator)
588 sd->scrollto.y.animator = ecore_animator_add(_smart_scrollto_y_animator, sd);
589 if (!sd->scrollto.x.animator)
590 _smart_anim_start(sd->smart_obj);
592 if (sd->down.bounce_y_animator)
594 ecore_animator_del(sd->down.bounce_y_animator);
595 sd->down.bounce_y_animator = NULL;
596 _smart_momentum_end(sd);
597 if (sd->child.resized)
598 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
600 sd->bouncemey = EINA_FALSE;
604 _smart_do_page(Smart_Data *sd)
606 if ((sd->pagerel_h == 0.0) && (!sd->pagesize_h) &&
607 (sd->pagerel_v == 0.0) && (!sd->pagesize_v))
613 _smart_page_x_get(Smart_Data *sd, int offset)
615 Evas_Coord x, y, w, h, cw, ch, minx = 0;
617 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
618 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
619 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
620 sd->pan_func.min_get(sd->pan_obj, &minx, NULL);
624 if (sd->pagerel_h > 0.0)
625 sd->pagesize_h = w * sd->pagerel_h;
626 if (sd->pagesize_h > 0)
628 x = x + (sd->pagesize_h * 0.5);
629 x = x / (sd->pagesize_h);
630 x = x * (sd->pagesize_h);
632 if ((x + w) > cw) x = cw - w;
633 if (x < minx) x = minx;
638 _smart_page_y_get(Smart_Data *sd, int offset)
640 Evas_Coord x, y, w, h, cw, ch, miny = 0;
642 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
643 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
644 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
645 sd->pan_func.min_get(sd->pan_obj, NULL, &miny);
649 if (sd->pagerel_v > 0.0)
650 sd->pagesize_v = h * sd->pagerel_v;
651 if (sd->pagesize_v > 0)
653 y = y + (sd->pagesize_v * 0.5);
654 y = y / (sd->pagesize_v);
655 y = y * (sd->pagesize_v);
657 if ((y + h) > ch) y = ch - h;
658 if (y < miny) y = miny;
663 _smart_page_adjust(Smart_Data *sd)
665 Evas_Coord x, y, w, h;
667 if (!_smart_do_page(sd)) return;
669 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
671 x = _smart_page_x_get(sd, 0);
672 y = _smart_page_y_get(sd, 0);
674 elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
678 _smart_bounce_x_animator(void *data)
681 Evas_Coord x, y, dx, w, odx, ed, md;
682 double t, p, dt, pd, r;
685 t = ecore_loop_time_get();
686 dt = t - sd->down.anim_start2;
689 dt = dt / _elm_config->thumbscroll_bounce_friction;
690 odx = sd->down.b2x - sd->down.bx;
691 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, NULL);
692 if (!sd->down.momentum_animator && (w > abs(odx)))
694 pd = (double)odx / (double)w;
695 pd = (pd > 0) ? pd : -pd;
696 pd = 1.0 - ((1.0 - pd) * (1.0 - pd));
699 if (dt > 1.0) dt = 1.0;
700 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
701 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
704 if (sd->down.momentum_animator)
706 ed = abs(sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time) - sd->down.b0x);
707 md = abs(_elm_config->thumbscroll_friction * 5 * w);
708 if (ed > md) r = (double)(md)/(double)ed;
710 x = sd->down.b2x + (int)((double)(dx - odx) * r);
711 if (!sd->down.cancelled)
712 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
715 if (sd->down.momentum_animator)
716 sd->down.bounce_x_hold = EINA_TRUE;
717 if ((!sd->down.bounce_y_animator) &&
718 (!sd->scrollto.y.animator))
719 _smart_anim_stop(sd->smart_obj);
720 sd->down.bounce_x_animator = NULL;
722 sd->bouncemex = EINA_FALSE;
723 _smart_momentum_end(sd);
724 if (sd->child.resized)
725 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
726 return ECORE_CALLBACK_CANCEL;
729 return ECORE_CALLBACK_RENEW;
733 _smart_bounce_y_animator(void *data)
736 Evas_Coord x, y, dy, h, ody, ed, md;
737 double t, p, dt, pd, r;
740 t = ecore_loop_time_get();
741 dt = t - sd->down.anim_start3;
744 dt = dt / _elm_config->thumbscroll_bounce_friction;
745 ody = sd->down.b2y - sd->down.by;
746 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, NULL, &h);
747 if (!sd->down.momentum_animator && (h > abs(ody)))
749 pd = (double)ody / (double)h;
750 pd = (pd > 0) ? pd : -pd;
751 pd = 1.0 - ((1.0 - pd) * (1.0 - pd));
754 if (dt > 1.0) dt = 1.0;
755 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
756 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
759 if (sd->down.momentum_animator)
761 ed = abs(sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time) - sd->down.b0y);
762 md = abs(_elm_config->thumbscroll_friction * 5 * h);
763 if (ed > md) r = (double)(md)/(double)ed;
765 y = sd->down.b2y + (int)((double)(dy - ody) * r);
766 if (!sd->down.cancelled)
767 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
770 if (sd->down.momentum_animator)
771 sd->down.bounce_y_hold = EINA_TRUE;
772 if ((!sd->down.bounce_x_animator) &&
773 (!sd->scrollto.y.animator))
774 _smart_anim_stop(sd->smart_obj);
775 sd->down.bounce_y_animator = NULL;
777 sd->bouncemey = EINA_FALSE;
778 _smart_momentum_end(sd);
779 if (sd->child.resized)
780 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
781 return ECORE_CALLBACK_CANCEL;
784 return ECORE_CALLBACK_RENEW;
792 can_scroll(Smart_Data *sd, int dir)
794 Evas_Coord mx = 0, my = 0, px = 0, py = 0, minx = 0, miny = 0;
796 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
797 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
798 sd->pan_func.get(sd->pan_obj, &px, &py);
802 if (px > minx) return EINA_TRUE;
805 if ((px - minx) < mx) return EINA_TRUE;
808 if (py > miny) return EINA_TRUE;
811 if ((py - miny) < my) return EINA_TRUE;
820 _smart_momentum_animator(void *data)
824 Evas_Coord x, y, dx, dy, px, py, maxx, maxy, minx, miny;
825 Eina_Bool no_bounce_x_end = EINA_FALSE, no_bounce_y_end = EINA_FALSE;
828 t = ecore_loop_time_get();
829 dt = t - sd->down.anim_start;
833 if (sd->down.hold_parent)
835 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
839 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
844 if ((!sd->down.dir_x) && (!sd->down.dir_y))
846 sd->down.cancelled = 1;
849 dt = dt / (_elm_config->thumbscroll_friction + sd->down.extra_time);
850 if (dt > 1.0) dt = 1.0;
851 p = 1.0 - ((1.0 - dt) * (1.0 - dt));
852 dx = (sd->down.dx * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
853 dy = (sd->down.dy * (_elm_config->thumbscroll_friction + sd->down.extra_time) * p);
856 x = sd->down.sx - dx;
857 y = sd->down.sy - dy;
858 elm_smart_scroller_child_pos_get(sd->smart_obj, &px, &py);
859 if ((sd->down.bounce_x_animator) ||
860 (sd->down.bounce_x_hold))
862 sd->down.bx = sd->down.bx0 - dx + sd->down.b0x;
865 if ((sd->down.bounce_y_animator) ||
866 (sd->down.bounce_y_hold))
868 sd->down.by = sd->down.by0 - dy + sd->down.b0y;
871 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
872 _update_wanted_coordinates(sd, x, y);
873 sd->pan_func.max_get(sd->pan_obj, &maxx, &maxy);
874 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
875 if (!sd->bounce_horiz)
877 if (x <= minx) no_bounce_x_end = EINA_TRUE;
878 if ((x - minx) >= maxx) no_bounce_x_end = EINA_TRUE;
880 if (!sd->bounce_vert)
882 if (y <= miny) no_bounce_y_end = EINA_TRUE;
883 if ((y - miny) >= maxy) no_bounce_y_end = EINA_TRUE;
886 ((sd->down.bounce_x_hold) && (sd->down.bounce_y_hold)) ||
887 (no_bounce_x_end && no_bounce_y_end))
889 _smart_anim_stop(sd->smart_obj);
891 sd->down.momentum_animator = NULL;
892 sd->down.bounce_x_hold = EINA_FALSE;
893 sd->down.bounce_y_hold = EINA_FALSE;
898 if (sd->child.resized)
899 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
900 return ECORE_CALLBACK_CANCEL;
903 return ECORE_CALLBACK_RENEW;
907 bounce_eval(Smart_Data *sd)
909 Evas_Coord mx, my, px, py, bx, by, b2x, b2y, minx = 0, miny = 0;
911 if (sd->freeze) return;
912 if ((!sd->bouncemex) && (!sd->bouncemey)) return;
913 if (sd->down.now) return; // down bounce while still held down
914 if (sd->down.onhold_animator)
916 ecore_animator_del(sd->down.onhold_animator);
917 sd->down.onhold_animator = NULL;
918 if (sd->child.resized)
919 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
921 if (sd->down.hold_animator)
923 ecore_animator_del(sd->down.hold_animator);
924 sd->down.hold_animator = NULL;
925 if (sd->child.resized)
926 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
928 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
929 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
930 sd->pan_func.get(sd->pan_obj, &px, &py);
933 if (px < minx) px = minx;
934 if ((px - minx) > mx) px = mx + minx;
935 if (py < miny) py = miny;
936 if ((py - miny) > my) py = my + miny;
940 (!elm_widget_drag_child_locked_x_get(sd->widget)))
942 if ((!sd->down.bounce_x_animator) && (!sd->bounce_animator_disabled))
946 if (sd->scrollto.x.animator)
948 ecore_animator_del(sd->scrollto.x.animator);
949 sd->scrollto.x.animator = NULL;
951 sd->down.bounce_x_animator = ecore_animator_add(_smart_bounce_x_animator, sd);
952 sd->down.anim_start2 = ecore_loop_time_get();
956 if (sd->down.momentum_animator) sd->down.b0x = sd->down.ax;
957 else sd->down.b0x = 0;
962 (!elm_widget_drag_child_locked_y_get(sd->widget)))
964 if ((!sd->down.bounce_y_animator) && (!sd->bounce_animator_disabled))
968 if (sd->scrollto.y.animator)
970 ecore_animator_del(sd->scrollto.y.animator);
971 sd->scrollto.y.animator = NULL;
973 sd->down.bounce_y_animator = ecore_animator_add(_smart_bounce_y_animator, sd);
974 sd->down.anim_start3 = ecore_loop_time_get();
978 if (sd->down.momentum_animator) sd->down.b0y = sd->down.ay;
979 else sd->down.b0y = 0;
986 elm_smart_scroller_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
988 Evas_Coord mx = 0, my = 0, px = 0, py = 0, minx = 0, miny = 0;
992 // FIXME: allow for bounce outside of range
993 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
994 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
995 if (mx > 0) vx = (double)(x - minx) / (double)mx;
997 if (vx < 0.0) vx = 0.0;
998 else if (vx > 1.0) vx = 1.0;
999 if (my > 0) vy = (double)(y - miny) / (double)my;
1001 if (vy < 0.0) vy = 0.0;
1002 else if (vy > 1.0) vy = 1.0;
1003 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, vy);
1004 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", vx, 0.0);
1005 sd->pan_func.get(sd->pan_obj, &px, &py);
1006 if (!_elm_config->thumbscroll_bounce_enable)
1008 if (x < minx) x = minx;
1009 if ((x - minx) > mx) x = mx + minx;
1010 if (y < miny) y = miny;
1011 if ((y - miny) > my) y = my + miny;
1014 if (!sd->bounce_horiz)
1016 if (x < minx) x = minx;
1017 if ((x - minx) > mx) x = mx + minx;
1019 if (!sd->bounce_vert)
1021 if (y < miny) y = miny;
1022 if (y - miny > my) y = my + miny;
1025 sd->pan_func.set(sd->pan_obj, x, y);
1026 if ((px != x) || (py != y))
1027 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
1028 if (!sd->down.bounce_x_animator)
1030 if (((x < minx) && (0 <= sd->down.dx)) ||
1031 ((x > (mx + minx)) && (0 >= sd->down.dx)))
1033 sd->bouncemex = EINA_TRUE;
1037 sd->bouncemex = EINA_FALSE;
1039 if (!sd->down.bounce_y_animator)
1041 if (((y < miny) && (0 <= sd->down.dy)) ||
1042 ((y > (my + miny)) && (0 >= sd->down.dy)))
1044 sd->bouncemey = EINA_TRUE;
1048 sd->bouncemey = EINA_FALSE;
1050 if ((x != px) || (y != py))
1052 evas_object_smart_callback_call(obj, "scroll", NULL);
1054 if ((x != px)/* && (!sd->bouncemex)*/)
1057 evas_object_smart_callback_call(obj, "edge,left", NULL);
1058 if (x == (mx + minx))
1059 evas_object_smart_callback_call(obj, "edge,right", NULL);
1061 if ((y != py)/* && (!sd->bouncemey)*/)
1064 evas_object_smart_callback_call(obj, "edge,top", NULL);
1066 evas_object_smart_callback_call(obj, "edge,bottom", NULL);
1071 elm_smart_scroller_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1074 sd->pan_func.get(sd->pan_obj, x, y);
1077 /* returns TRUE when we need to move the scroller, FALSE otherwise.
1078 * Updates w and h either way, so save them if you need them. */
1080 _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x, Evas_Coord *_y, Evas_Coord w, Evas_Coord h)
1082 Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0, pw = 0, ph = 0, x = *_x, y = *_y;
1084 API_ENTRY return EINA_FALSE;
1085 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
1086 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
1087 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
1088 sd->pan_func.get(sd->pan_obj, &px, &py);
1089 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &pw, &ph);
1092 if ((x < px) && ((x + w) < (px + (cw - mx)))) nx = x;
1093 else if ((x > px) && ((x + w) > (px + (cw - mx)))) nx = x + w - (cw - mx);
1095 if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y;
1096 else if ((y > py) && ((y + h) > (py + (ch - my)))) ny = y + h - (ch - my);
1098 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1099 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1101 _smart_anim_stop(sd->smart_obj);
1103 if (sd->scrollto.x.animator)
1105 ecore_animator_del(sd->scrollto.x.animator);
1106 sd->scrollto.x.animator = NULL;
1108 if (sd->scrollto.y.animator)
1110 ecore_animator_del(sd->scrollto.y.animator);
1111 sd->scrollto.y.animator = NULL;
1113 if (sd->down.bounce_x_animator)
1115 ecore_animator_del(sd->down.bounce_x_animator);
1116 sd->down.bounce_x_animator = NULL;
1117 sd->bouncemex = EINA_FALSE;
1118 if (sd->child.resized)
1119 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1121 if (sd->down.bounce_y_animator)
1123 ecore_animator_del(sd->down.bounce_y_animator);
1124 sd->down.bounce_y_animator = NULL;
1125 sd->bouncemey = EINA_FALSE;
1126 if (sd->child.resized)
1127 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1129 if (sd->down.hold_animator)
1131 ecore_animator_del(sd->down.hold_animator);
1132 sd->down.hold_animator = NULL;
1133 _smart_drag_stop(sd->smart_obj);
1134 if (sd->child.resized)
1135 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1137 if (sd->down.momentum_animator)
1139 ecore_animator_del(sd->down.momentum_animator);
1140 sd->down.momentum_animator = NULL;
1141 sd->down.bounce_x_hold = EINA_FALSE;
1142 sd->down.bounce_y_hold = EINA_FALSE;
1147 if (sd->child.resized)
1148 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1152 if ((x + pw) > cw) x = cw - pw;
1153 if (x < minx) x = minx;
1155 if ((y + ph) > ch) y = ch - ph;
1156 if (y < miny) y = miny;
1158 if ((x == px) && (y == py)) return EINA_FALSE;
1164 /* Set should be used for calculated positions, for example, when we move
1165 * because of an animation or because this is the correct position after
1168 elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1171 if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
1173 elm_smart_scroller_child_pos_set(obj, x, y);
1176 sd->down.x = sd->down.history[0].x;
1177 sd->down.y = sd->down.history[0].y;
1181 /* Set should be used for setting the wanted position, for example a user scroll
1182 * or moving the cursor in an entry. */
1184 elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1191 if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
1193 elm_smart_scroller_child_pos_set(obj, x, y);
1196 sd->down.x = sd->down.history[0].x;
1197 sd->down.y = sd->down.history[0].y;
1202 elm_smart_scroller_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1205 if (!sd->pan_obj) return;
1206 edje_object_calc_force(sd->edje_obj);
1207 evas_object_geometry_get(sd->pan_obj, NULL, NULL, w, h);
1211 elm_smart_scroller_step_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1218 _smart_scrollbar_size_adjust(sd);
1222 elm_smart_scroller_step_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1225 if (x) *x = sd->step.x;
1226 if (y) *y = sd->step.y;
1230 elm_smart_scroller_page_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1235 _smart_scrollbar_size_adjust(sd);
1239 elm_smart_scroller_page_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1242 if (x) *x = sd->page.x;
1243 if (y) *y = sd->page.y;
1247 elm_smart_scroller_policy_set(Evas_Object *obj, Elm_Smart_Scroller_Policy hbar, Elm_Smart_Scroller_Policy vbar)
1250 if ((sd->hbar_flags == hbar) && (sd->vbar_flags == vbar)) return;
1251 sd->hbar_flags = hbar;
1252 sd->vbar_flags = vbar;
1253 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1254 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,hbar", "elm");
1255 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1256 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
1258 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,hbar", "elm");
1259 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
1260 edje_object_signal_emit(sd->edje_obj, "elm,action,show_always,vbar", "elm");
1261 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
1262 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
1264 edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
1265 _smart_scrollbar_size_adjust(sd);
1269 elm_smart_scroller_policy_get(Evas_Object *obj, Elm_Smart_Scroller_Policy *hbar, Elm_Smart_Scroller_Policy *vbar)
1272 if (hbar) *hbar = sd->hbar_flags;
1273 if (vbar) *vbar = sd->vbar_flags;
1277 elm_smart_scroller_edje_object_get(Evas_Object *obj)
1279 API_ENTRY return NULL;
1280 return sd->edje_obj;
1284 elm_smart_scroller_single_dir_set(Evas_Object *obj, Eina_Bool single_dir)
1287 sd->one_dir_at_a_time = single_dir;
1291 elm_smart_scroller_single_dir_get(Evas_Object *obj)
1293 API_ENTRY return EINA_FALSE;
1294 return sd->one_dir_at_a_time;
1298 elm_smart_scroller_object_theme_set(Evas_Object *parent, Evas_Object *obj, const char *clas, const char *group, const char *style)
1302 //Does this API require parent object absolutely? if then remove this exception.
1303 double parent_scale = parent ? elm_widget_scale_get(parent) : 1;
1304 _elm_theme_object_set(parent, sd->edje_obj, clas, group, style);
1305 edje_object_scale_set(sd->edje_obj, parent_scale * _elm_config->scale);
1307 edje_object_part_swallow(sd->edje_obj, "elm.swallow.content", sd->pan_obj);
1309 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1310 if (edje_object_part_exists(sd->edje_obj, "elm.scrollbar.base"))
1313 base = edje_object_part_swallow_get(sd->edje_obj, "elm.scrollbar.base");
1316 base = evas_object_rectangle_add(evas_object_evas_get(sd->edje_obj));
1317 evas_object_color_set(base, 0, 0, 0, 0);
1318 edje_object_part_swallow(sd->edje_obj, "elm.scrollbar.base", base);
1320 if (!_elm_config->thumbscroll_enable)
1321 evas_object_size_hint_min_set(base, mw, mh);
1323 sd->vbar_visible = !sd->vbar_visible;
1324 sd->hbar_visible = !sd->hbar_visible;
1325 _smart_scrollbar_bar_visibility_adjust(sd);
1329 elm_smart_scroller_hold_set(Evas_Object *obj, Eina_Bool hold)
1336 elm_smart_scroller_freeze_set(Evas_Object *obj, Eina_Bool freeze)
1339 sd->freeze = freeze;
1342 if (sd->down.onhold_animator)
1344 ecore_animator_del(sd->down.onhold_animator);
1345 sd->down.onhold_animator = NULL;
1346 if (sd->child.resized)
1347 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1355 elm_smart_scroller_bounce_allow_set(Evas_Object *obj, Eina_Bool horiz, Eina_Bool vert)
1358 sd->bounce_horiz = !!horiz;
1359 sd->bounce_vert = !!vert;
1363 elm_smart_scroller_bounce_allow_get(const Evas_Object *obj, Eina_Bool *horiz, Eina_Bool *vert)
1366 if (horiz) *horiz = sd->bounce_horiz;
1367 if (vert) *vert = sd->bounce_vert;
1371 elm_smart_scroller_paging_set(Evas_Object *obj, double pagerel_h, double pagerel_v, Evas_Coord pagesize_h, Evas_Coord pagesize_v)
1374 sd->pagerel_h = pagerel_h;
1375 sd->pagerel_v = pagerel_v;
1376 sd->pagesize_h = pagesize_h;
1377 sd->pagesize_v = pagesize_v;
1378 _smart_page_adjust(sd);
1382 elm_smart_scroller_paging_get(Evas_Object *obj, double *pagerel_h, double *pagerel_v, Evas_Coord *pagesize_h, Evas_Coord *pagesize_v)
1385 if (pagerel_h) *pagerel_h = sd->pagerel_h;
1386 if (pagerel_v) *pagerel_v = sd->pagerel_v;
1387 if (pagesize_h) *pagesize_h = sd->pagesize_h;
1388 if (pagesize_v) *pagesize_v = sd->pagesize_v;
1392 elm_smart_scroller_current_page_get(Evas_Object *obj, int *pagenumber_h, int *pagenumber_v)
1396 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1399 if (sd->pagesize_h > 0)
1400 *pagenumber_h = (x + sd->pagesize_h - 1) / sd->pagesize_h;
1406 if (sd->pagesize_v > 0)
1407 *pagenumber_v = (y + sd->pagesize_v - 1) / sd->pagesize_v;
1414 elm_smart_scroller_last_page_get(Evas_Object *obj, int *pagenumber_h, int *pagenumber_v)
1418 sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
1421 if (sd->pagesize_h > 0)
1422 *pagenumber_h = cw / sd->pagesize_h + 1;
1428 if (sd->pagesize_v > 0)
1429 *pagenumber_v = ch / sd->pagesize_v + 1;
1436 elm_smart_scroller_page_show(Evas_Object *obj, int pagenumber_h, int pagenumber_v)
1439 Evas_Coord x, y, w, h;
1440 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
1441 if (pagenumber_h >= 0) x = sd->pagesize_h * pagenumber_h;
1442 if (pagenumber_v >= 0) y = sd->pagesize_v * pagenumber_v;
1443 if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
1444 elm_smart_scroller_child_pos_set(obj, x, y);
1448 elm_smart_scroller_page_bring_in(Evas_Object *obj, int pagenumber_h, int pagenumber_v)
1451 Evas_Coord x, y, w, h;
1452 elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
1453 if (pagenumber_h >= 0) x = sd->pagesize_h * pagenumber_h;
1454 if (pagenumber_v >= 0) y = sd->pagesize_v * pagenumber_v;
1455 if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
1457 _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
1458 _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
1463 elm_smart_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1466 if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
1468 _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
1469 _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
1474 elm_smart_scroller_widget_set(Evas_Object *obj, Evas_Object *wid)
1481 _elm_smart_scroller_wanted_region_set(Evas_Object *obj)
1484 Evas_Coord ww, wh, wx = sd->wx;
1486 if (sd->down.now || sd->down.momentum_animator ||
1487 sd->down.bounce_x_animator || sd->down.bounce_y_animator ||
1488 sd->down.hold_animator || sd->down.onhold_animator ||
1489 sd->scrollto.x.animator || sd->scrollto.y.animator) return;
1491 sd->child.resized = EINA_FALSE;
1493 /* Flip to RTL cords only if init in RTL mode */
1494 if (sd->is_mirrored)
1495 wx = _elm_smart_scroller_x_mirrored_get(obj, sd->wx);
1499 elm_smart_scroller_child_viewport_size_get(obj, &ww, &wh);
1507 elm_smart_scroller_child_region_set(obj, wx, sd->wy, ww, wh);
1510 /* local subsystem functions */
1512 _smart_edje_drag_v_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1517 _smart_scrollbar_read(sd);
1518 _smart_drag_start(sd->smart_obj);
1519 sd->freeze = EINA_TRUE;
1523 _smart_edje_drag_v_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1528 _smart_scrollbar_read(sd);
1529 _smart_drag_stop(sd->smart_obj);
1530 sd->freeze = EINA_FALSE;
1534 _smart_edje_drag_v(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1539 _smart_scrollbar_read(sd);
1543 _smart_edje_drag_h_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1548 _smart_scrollbar_read(sd);
1549 _smart_drag_start(sd->smart_obj);
1550 sd->freeze = EINA_TRUE;
1554 _smart_edje_drag_h_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1559 _smart_scrollbar_read(sd);
1560 _smart_drag_stop(sd->smart_obj);
1561 sd->freeze = EINA_FALSE;
1565 _smart_edje_drag_h(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1570 _smart_scrollbar_read(sd);
1574 _smart_child_del_hook(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1579 sd->child_obj = NULL;
1580 _smart_scrollbar_size_adjust(sd);
1581 _smart_scrollbar_reset(sd);
1585 _smart_pan_changed_hook(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1591 sd->pan_func.child_size_get(sd->pan_obj, &w, &h);
1592 if ((w != sd->child.w) || (h != sd->child.h))
1596 _smart_scrollbar_size_adjust(sd);
1597 evas_object_size_hint_min_set(sd->smart_obj, sd->child.w, sd->child.h);
1598 sd->child.resized = EINA_TRUE;
1599 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1604 elm_smart_scroller_gravity_set(Evas_Object *obj, double x, double y)
1608 sd->pan_func.gravity_set(sd->pan_obj, x, y);
1612 elm_smart_scroller_gravity_get(Evas_Object *obj, double *x, double *y)
1616 sd->pan_func.gravity_get(sd->pan_obj, x, y);
1620 _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1622 Evas_Event_Mouse_Wheel *ev;
1624 Evas_Coord x = 0, y = 0;
1628 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1629 if ((evas_key_modifier_is_set(ev->modifiers, "Control")) ||
1630 (evas_key_modifier_is_set(ev->modifiers, "Alt")) ||
1631 (evas_key_modifier_is_set(ev->modifiers, "Shift")) ||
1632 (evas_key_modifier_is_set(ev->modifiers, "Meta")) ||
1633 (evas_key_modifier_is_set(ev->modifiers, "Hyper")) ||
1634 (evas_key_modifier_is_set(ev->modifiers, "Super")))
1636 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1637 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1638 (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
1640 _smart_anim_stop(sd->smart_obj);
1642 if (sd->scrollto.x.animator)
1644 ecore_animator_del(sd->scrollto.x.animator);
1645 sd->scrollto.x.animator = NULL;
1647 if (sd->scrollto.y.animator)
1649 ecore_animator_del(sd->scrollto.y.animator);
1650 sd->scrollto.y.animator = NULL;
1652 if (sd->down.bounce_x_animator)
1654 ecore_animator_del(sd->down.bounce_x_animator);
1655 sd->down.bounce_x_animator = NULL;
1656 sd->bouncemex = EINA_FALSE;
1657 if (sd->child.resized)
1658 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1660 if (sd->down.bounce_y_animator)
1662 ecore_animator_del(sd->down.bounce_y_animator);
1663 sd->down.bounce_y_animator = NULL;
1664 sd->bouncemey = EINA_FALSE;
1665 if (sd->child.resized)
1666 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1669 y += ev->z * sd->step.y;
1670 else if (ev->direction == 1)
1671 x += ev->z * sd->step.x;
1673 if ((!sd->hold) && (!sd->freeze))
1675 _update_wanted_coordinates(sd, x, y);
1676 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
1681 _smart_event_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1683 Evas_Event_Mouse_Down *ev;
1685 Evas_Coord x = 0, y = 0;
1689 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1690 if (_elm_config->thumbscroll_enable)
1692 sd->down.hold = EINA_FALSE;
1693 if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
1694 (sd->down.momentum_animator) || (sd->scrollto.x.animator) ||
1695 (sd->scrollto.y.animator))
1697 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL | EVAS_EVENT_FLAG_ON_HOLD;
1698 sd->down.scroll = EINA_TRUE;
1699 sd->down.hold = EINA_TRUE;
1700 _smart_anim_stop(sd->smart_obj);
1702 if (sd->scrollto.x.animator)
1704 ecore_animator_del(sd->scrollto.x.animator);
1705 sd->scrollto.x.animator = NULL;
1707 if (sd->scrollto.y.animator)
1709 ecore_animator_del(sd->scrollto.y.animator);
1710 sd->scrollto.y.animator = NULL;
1712 if (sd->down.bounce_x_animator)
1714 ecore_animator_del(sd->down.bounce_x_animator);
1715 sd->down.bounce_x_animator = NULL;
1716 sd->bouncemex = EINA_FALSE;
1717 if (sd->child.resized)
1718 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1720 if (sd->down.bounce_y_animator)
1722 ecore_animator_del(sd->down.bounce_y_animator);
1723 sd->down.bounce_y_animator = NULL;
1724 sd->bouncemey = EINA_FALSE;
1725 if (sd->child.resized)
1726 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1728 if (sd->down.hold_animator)
1730 ecore_animator_del(sd->down.hold_animator);
1731 sd->down.hold_animator = NULL;
1732 _smart_drag_stop(sd->smart_obj);
1733 if (sd->child.resized)
1734 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1736 if (sd->down.momentum_animator)
1738 ecore_animator_del(sd->down.momentum_animator);
1739 sd->down.momentum_animator = NULL;
1740 sd->down.bounce_x_hold = EINA_FALSE;
1741 sd->down.bounce_y_hold = EINA_FALSE;
1744 if (sd->child.resized)
1745 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1747 if (ev->button == 1)
1749 sd->down.hist.est_timestamp_diff =
1750 ecore_loop_time_get() - ((double)ev->timestamp / 1000.0);
1751 sd->down.hist.tadd = 0.0;
1752 sd->down.hist.dxsum = 0.0;
1753 sd->down.hist.dysum = 0.0;
1754 sd->down.now = EINA_TRUE;
1755 sd->down.dragged = EINA_FALSE;
1756 sd->down.dir_x = EINA_FALSE;
1757 sd->down.dir_y = EINA_FALSE;
1758 sd->down.x = ev->canvas.x;
1759 sd->down.y = ev->canvas.y;
1760 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
1763 sd->down.locked = EINA_FALSE;
1764 memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 60);
1766 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
1767 sd->down.history[0].localtimestamp = ecore_loop_time_get();
1769 sd->down.history[0].timestamp = ecore_loop_time_get();
1771 sd->down.history[0].x = ev->canvas.x;
1772 sd->down.history[0].y = ev->canvas.y;
1774 sd->down.dragged_began = EINA_FALSE;
1775 sd->down.hold_parent = EINA_FALSE;
1776 sd->down.cancelled = EINA_FALSE;
1781 _down_coord_eval(Smart_Data *sd, Evas_Coord *x, Evas_Coord *y)
1783 Evas_Coord minx, miny;
1785 if (sd->down.dir_x) *x = sd->down.sx - (*x - sd->down.x);
1786 else *x = sd->down.sx;
1787 if (sd->down.dir_y) *y = sd->down.sy - (*y - sd->down.y);
1788 else *y = sd->down.sy;
1790 if ((sd->down.dir_x) || (sd->down.dir_y))
1792 if (!((sd->down.dir_x) && (sd->down.dir_y)))
1794 if (sd->down.dir_x) *y = sd->down.locked_y;
1795 else *x = sd->down.locked_x;
1799 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
1802 *x += (minx - *x) * _elm_config->thumbscroll_border_friction;
1803 else if (sd->child.w <= sd->w)
1804 *x += (sd->down.sx - *x) * _elm_config->thumbscroll_border_friction;
1805 else if ((sd->child.w - sd->w + minx) < *x)
1806 *x += (sd->child.w - sd->w + minx - *x) *
1807 _elm_config->thumbscroll_border_friction;
1810 *y += (miny - *y) * _elm_config->thumbscroll_border_friction;
1811 else if (sd->child.h <= sd->h)
1812 *y += (sd->down.sy - *y) * _elm_config->thumbscroll_border_friction;
1813 else if ((sd->child.h - sd->h + miny) < *y)
1814 *y += (sd->child.h - sd->h + miny - *y) *
1815 _elm_config->thumbscroll_border_friction;
1819 _smart_hold_animator(void *data)
1821 Smart_Data *sd = data;
1822 Evas_Coord ox = 0, oy = 0, fx = 0, fy= 0;
1824 fx = sd->down.hold_x;
1825 fy = sd->down.hold_y;
1826 if (_elm_config->scroll_smooth_amount > 0.0)
1829 Evas_Coord basex = 0, basey = 0, x, y;
1830 double dt, t, tdiff, tnow, twin;
1832 Evas_Coord x, y, dx, dy;
1836 tdiff = sd->down.hist.est_timestamp_diff;
1837 tnow = ecore_time_get() - tdiff;
1839 twin = _elm_config->scroll_smooth_time_window;
1840 for (i = 0; i < 60; i++)
1842 // oldest point is sd->down.history[i]
1843 // newset is sd->down.history[0]
1844 dt = t - sd->down.history[i].timestamp;
1850 x = sd->down.history[i].x;
1851 y = sd->down.history[i].y;
1852 _down_coord_eval(sd, &x, &y);
1858 pos[i].x = x - basex;
1859 pos[i].y = y - basey;
1861 sd->down.history[i].timestamp - sd->down.history[0].timestamp;
1867 double dtsum = 0.0, tadd, maxdt;
1868 double dxsum = 0.0, dysum = 0.0, xsum = 0.0, ysum = 0.0;
1870 for (i = 0; i < (count - 1); i++)
1872 pos[i].dx = pos[i].x - pos[i + 1].x;
1873 pos[i].dy = pos[i].y - pos[i + 1].y;
1874 pos[i].dt = pos[i].t - pos[i + 1].t;
1887 tadd = tnow - sd->down.history[0].timestamp + _elm_config->scroll_smooth_future_time;
1888 tadd = tadd - (maxdt / 2);
1889 #define WEIGHT(n, o, v) n = (((double)o * (1.0 - v)) + ((double)n * v))
1890 WEIGHT(tadd, sd->down.hist.tadd, _elm_config->scroll_smooth_history_weight);
1891 WEIGHT(dxsum, sd->down.hist.dxsum, _elm_config->scroll_smooth_history_weight);
1892 WEIGHT(dysum, sd->down.hist.dysum, _elm_config->scroll_smooth_history_weight);
1893 fx = basex + xsum + ((dxsum * tadd) / dtsum);
1894 fy = basey + ysum + ((dysum * tadd) / dtsum);
1895 sd->down.hist.tadd = tadd;
1896 sd->down.hist.dxsum = dxsum;
1897 sd->down.hist.dysum = dysum;
1898 WEIGHT(fx, sd->down.hold_x, _elm_config->scroll_smooth_amount);
1899 WEIGHT(fy, sd->down.hold_y, _elm_config->scroll_smooth_amount);
1901 // printf("%3.5f %i %i\n", ecore_time_get(), sd->down.hold_y, fy);
1904 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
1907 if ((!sd->widget) ||
1908 (!elm_widget_drag_child_locked_x_get(sd->widget)))
1913 if ((!sd->widget) ||
1914 (!elm_widget_drag_child_locked_y_get(sd->widget)))
1918 elm_smart_scroller_child_pos_set(sd->smart_obj, ox, oy);
1919 return ECORE_CALLBACK_RENEW;
1923 _smart_event_post_up(void *data, Evas *e __UNUSED__)
1925 Smart_Data *sd = data;
1928 if (sd->down.dragged)
1930 elm_widget_drag_lock_x_set(sd->widget, 0);
1931 elm_widget_drag_lock_y_set(sd->widget, 0);
1938 _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
1940 Evas_Event_Mouse_Down *ev;
1942 Evas_Coord x = 0, y = 0, ox = 0, oy = 0;
1946 sd->down.hold_parent = EINA_FALSE;
1949 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1950 evas_post_event_callback_push(e, _smart_event_post_up, sd);
1951 // FIXME: respect elm_widget_scroll_hold_get of parent container
1952 if (_elm_config->thumbscroll_enable)
1954 if (ev->button == 1)
1956 if (sd->down.onhold_animator)
1958 ecore_animator_del(sd->down.onhold_animator);
1959 sd->down.onhold_animator = NULL;
1960 if (sd->child.resized)
1961 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
1963 x = ev->canvas.x - sd->down.x;
1964 y = ev->canvas.y - sd->down.y;
1965 if (sd->down.dragged)
1967 _smart_drag_stop(sd->smart_obj);
1968 if ((!sd->hold) && (!sd->freeze))
1972 Evas_Coord ax, ay, dx, dy, vel;
1975 t = ev->timestamp / 1000.0;
1977 t = ecore_loop_time_get();
1979 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1984 printf("------ %i %i\n", ev->canvas.x, ev->canvas.y);
1986 for (i = 0; i < 60; i++)
1988 dt = t - sd->down.history[i].timestamp;
1989 if (dt > 0.2) break;
1991 printf("H: %i %i @ %1.3f\n",
1992 sd->down.history[i].x,
1993 sd->down.history[i].y, dt);
1996 ax += sd->down.history[i].x;
1997 ay += sd->down.history[i].y;
2002 at /= _elm_config->thumbscroll_sensitivity_friction;
2003 dx = ev->canvas.x - ax;
2004 dy = ev->canvas.y - ay;
2007 vel = sqrt((dx * dx) + (dy * dy)) / at;
2008 if ((_elm_config->thumbscroll_friction > 0.0) &&
2009 (vel > _elm_config->thumbscroll_momentum_threshold))
2011 int minx, miny, mx, my, px, py;
2012 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2013 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2014 sd->pan_func.get(sd->pan_obj, &px, &py);
2015 sd->down.dx = ((double)dx / at);
2016 sd->down.dy = ((double)dy / at);
2017 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
2018 ((sd->down.dx < 0) && (sd->down.pdx < 0)))
2019 if (px > minx && px < mx)
2020 sd->down.dx += (double)sd->down.pdx * 1.5; // FIXME: * 1.5 - probably should be config
2021 if (((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
2022 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
2023 if (py > miny && py < my)
2024 sd->down.dy += (double)sd->down.pdy * 1.5; // FIXME: * 1.5 - probably should be config
2025 if (((sd->down.dx > 0) && (sd->down.pdx > 0)) ||
2026 ((sd->down.dx < 0) && (sd->down.pdx < 0)) ||
2027 ((sd->down.dy > 0) && (sd->down.pdy > 0)) ||
2028 ((sd->down.dy < 0) && (sd->down.pdy < 0)))
2030 double t = ecore_loop_time_get();
2031 double dt = t - sd->down.anim_start;
2033 if (dt < 0.0) dt = 0.0;
2034 else if (dt > _elm_config->thumbscroll_friction)
2035 dt = _elm_config->thumbscroll_friction;
2036 sd->down.extra_time = _elm_config->thumbscroll_friction - dt;
2039 sd->down.extra_time = 0.0;
2040 sd->down.pdx = sd->down.dx;
2041 sd->down.pdy = sd->down.dy;
2044 if (!_smart_do_page(sd))
2046 if ((!sd->down.momentum_animator) && (!sd->momentum_animator_disabled))
2048 sd->down.momentum_animator = ecore_animator_add(_smart_momentum_animator, sd);
2049 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
2050 _smart_anim_start(sd->smart_obj);
2052 sd->down.anim_start = ecore_loop_time_get();
2053 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
2067 evas_event_feed_hold(e, 0, ev->timestamp, ev->data);
2068 if (_smart_do_page(sd))
2070 Evas_Coord pgx, pgy;
2072 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
2073 if ((!sd->widget) ||
2074 (!elm_widget_drag_child_locked_x_get(sd->widget)))
2076 pgx = _smart_page_x_get(sd, ox);
2079 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
2080 _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
2083 if ((!sd->widget) ||
2084 (!elm_widget_drag_child_locked_y_get(sd->widget)))
2086 pgy = _smart_page_y_get(sd, oy);
2089 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
2090 _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
2099 if (_smart_do_page(sd))
2101 Evas_Coord pgx, pgy;
2103 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
2104 if ((!sd->widget) ||
2105 (!elm_widget_drag_child_locked_x_get(sd->widget)))
2107 pgx = _smart_page_x_get(sd, ox);
2108 if (pgx != x) _smart_scrollto_x(sd, _elm_config->page_scroll_friction, pgx);
2110 if ((!sd->widget) ||
2111 (!elm_widget_drag_child_locked_y_get(sd->widget)))
2113 pgy = _smart_page_y_get(sd, oy);
2114 if (pgy != y) _smart_scrollto_y(sd, _elm_config->page_scroll_friction, pgy);
2118 if (sd->down.hold_animator)
2120 ecore_animator_del(sd->down.hold_animator);
2121 sd->down.hold_animator = NULL;
2122 if (sd->child.resized)
2123 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
2125 if (sd->down.scroll)
2127 ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
2128 sd->down.scroll = EINA_FALSE;
2132 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2133 sd->down.hold = EINA_FALSE;
2135 sd->down.dragged_began = EINA_FALSE;
2136 sd->down.dir_x = EINA_FALSE;
2137 sd->down.dir_y = EINA_FALSE;
2138 sd->down.want_dragged = EINA_FALSE;
2139 sd->down.dragged = EINA_FALSE;
2140 sd->down.now = EINA_FALSE;
2141 elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
2142 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
2143 _update_wanted_coordinates(sd, x, y);
2145 if (sd->child.resized)
2146 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
2148 if (!_smart_do_page(sd))
2155 _smart_onhold_animator(void *data)
2160 Evas_Coord x, y, ox, oy;
2163 t = ecore_loop_time_get();
2164 if (sd->down.onhold_tlast > 0.0)
2166 td = t - sd->down.onhold_tlast;
2167 vx = sd->down.onhold_vx * td * (double)_elm_config->thumbscroll_threshold * 2.0;
2168 vy = sd->down.onhold_vy * td * (double)_elm_config->thumbscroll_threshold * 2.0;
2169 elm_smart_scroller_child_pos_get(sd->smart_obj, &ox, &oy);
2175 if ((!sd->widget) ||
2176 (!elm_widget_drag_child_locked_x_get(sd->widget)))
2178 sd->down.onhold_vxe += vx;
2179 x = ox + (int)sd->down.onhold_vxe;
2180 sd->down.onhold_vxe -= (int)sd->down.onhold_vxe;
2186 if ((!sd->widget) ||
2187 (!elm_widget_drag_child_locked_y_get(sd->widget)))
2189 sd->down.onhold_vye += vy;
2190 y = oy + (int)sd->down.onhold_vye;
2191 sd->down.onhold_vye -= (int)sd->down.onhold_vye;
2195 elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
2197 sd->down.onhold_tlast = t;
2198 return ECORE_CALLBACK_RENEW;
2202 _smart_event_post_move(void *data, Evas *e __UNUSED__)
2204 Smart_Data *sd = data;
2206 if (sd->down.want_dragged)
2210 if (sd->down.hold_parent)
2212 if ((sd->down.dir_x) && !can_scroll(sd, sd->down.hdir))
2214 sd->down.dir_x = EINA_FALSE;
2216 if ((sd->down.dir_y) && !can_scroll(sd, sd->down.vdir))
2218 sd->down.dir_y = EINA_FALSE;
2223 if ((!sd->widget) ||
2224 (!elm_widget_drag_child_locked_x_get(sd->widget)))
2226 sd->down.want_dragged = EINA_FALSE;
2227 sd->down.dragged = EINA_TRUE;
2230 elm_widget_drag_lock_x_set(sd->widget, 1);
2235 sd->down.dir_x = EINA_FALSE;
2239 if ((!sd->widget) ||
2240 (!elm_widget_drag_child_locked_y_get(sd->widget)))
2242 sd->down.want_dragged = EINA_FALSE;
2243 sd->down.dragged = EINA_TRUE;
2246 elm_widget_drag_lock_y_set(sd->widget, 1);
2251 sd->down.dir_y = EINA_FALSE;
2253 if ((!sd->down.dir_x) && (!sd->down.dir_y))
2255 sd->down.cancelled = EINA_TRUE;
2257 if (start) _smart_drag_start(sd->smart_obj);
2263 _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
2265 Evas_Event_Mouse_Move *ev;
2267 Evas_Coord x = 0, y = 0;
2271 // if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
2272 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2273 sd->down.hold_parent = EINA_TRUE;
2274 evas_post_event_callback_push(e, _smart_event_post_move, sd);
2276 if (sd->scrollto.x.animator)
2279 ecore_animator_del(sd->scrollto.x.animator);
2280 sd->scrollto.x.animator = NULL;
2281 sd->pan_func.get(sd->pan_obj, &px, NULL);
2283 sd->down.x = sd->down.history[0].x;
2286 if (sd->scrollto.y.animator)
2289 ecore_animator_del(sd->scrollto.y.animator);
2290 sd->scrollto.y.animator = NULL;
2291 sd->pan_func.get(sd->pan_obj, NULL, &py);
2293 sd->down.y = sd->down.history[0].y;
2295 // FIXME: respect elm_widget_scroll_hold_get of parent container
2296 if (_elm_config->thumbscroll_enable)
2303 printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
2305 memmove(&(sd->down.history[1]), &(sd->down.history[0]),
2306 sizeof(sd->down.history[0]) * (60 - 1));
2308 sd->down.history[0].timestamp = ev->timestamp / 1000.0;
2309 sd->down.history[0].localtimestamp = ecore_loop_time_get();
2311 sd->down.history[0].timestamp = ecore_loop_time_get();
2313 sd->down.history[0].x = ev->cur.canvas.x;
2314 sd->down.history[0].y = ev->cur.canvas.y;
2316 if (!sd->down.dragged_began)
2318 x = ev->cur.canvas.x - sd->down.x;
2319 y = ev->cur.canvas.y - sd->down.y;
2324 if (x > 0) sd->down.hdir = LEFT;
2325 else if (x < 0) sd->down.hdir = RIGHT;
2326 if (y > 0) sd->down.vdir = UP;
2327 else if (y < 0) sd->down.vdir = DOWN;
2332 if ((sd->one_dir_at_a_time) &&
2333 (!((sd->down.dir_x) || (sd->down.dir_y))))
2335 if (x > _elm_config->thumbscroll_threshold)
2339 sd->down.dir_x = EINA_TRUE;
2340 sd->down.dir_y = EINA_FALSE;
2344 if (y > _elm_config->thumbscroll_threshold)
2348 sd->down.dir_x = EINA_FALSE;
2349 sd->down.dir_y = EINA_TRUE;
2355 sd->down.dir_x = EINA_TRUE;
2356 sd->down.dir_y = EINA_TRUE;
2361 sd->down.dir_x = EINA_TRUE;
2362 sd->down.dir_y = EINA_TRUE;
2365 if ((!sd->hold) && (!sd->freeze))
2367 if ((sd->down.dragged) ||
2368 (((x * x) + (y * y)) >
2369 (_elm_config->thumbscroll_threshold *
2370 _elm_config->thumbscroll_threshold)))
2372 sd->down.dragged_began = EINA_TRUE;
2373 if (!sd->down.dragged)
2375 sd->down.want_dragged = EINA_TRUE;
2376 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2377 // evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
2378 // _smart_drag_start(sd->smart_obj);
2380 if (sd->down.dragged)
2382 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2384 // ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2385 // sd->down.dragged = 1;
2387 x = sd->down.sx - (ev->cur.canvas.x - sd->down.x);
2391 y = sd->down.sy - (ev->cur.canvas.y - sd->down.y);
2394 if ((sd->down.dir_x) || (sd->down.dir_y))
2396 if (!sd->down.locked)
2398 sd->down.locked_x = x;
2399 sd->down.locked_y = y;
2400 sd->down.locked = EINA_TRUE;
2402 if (!((sd->down.dir_x) && (sd->down.dir_y)))
2404 if (sd->down.dir_x) y = sd->down.locked_y;
2405 else x = sd->down.locked_x;
2409 Evas_Coord minx, miny;
2410 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2413 _elm_config->thumbscroll_border_friction;
2414 else if (sd->child.h <= sd->h)
2415 y += (sd->down.sy - y) *
2416 _elm_config->thumbscroll_border_friction;
2417 else if ((sd->child.h - sd->h + miny) < y)
2418 y += (sd->child.h - sd->h + miny - y) *
2419 _elm_config->thumbscroll_border_friction;
2422 _elm_config->thumbscroll_border_friction;
2423 else if (sd->child.w <= sd->w)
2424 x += (sd->down.sx - x) *
2425 _elm_config->thumbscroll_border_friction;
2426 else if ((sd->child.w - sd->w + minx) < x)
2427 x += (sd->child.w - sd->w + minx - x) *
2428 _elm_config->thumbscroll_border_friction;
2431 sd->down.hold_x = x;
2432 sd->down.hold_y = y;
2433 if (!sd->down.hold_animator)
2434 sd->down.hold_animator =
2435 ecore_animator_add(_smart_hold_animator, sd);
2436 // printf("a %i %i\n", sd->down.hold_x, sd->down.hold_y);
2437 // _smart_onhold_animator(sd);
2438 // elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
2442 if (sd->down.dragged_began)
2444 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2447 sd->down.hold = EINA_TRUE;
2448 evas_event_feed_hold(e, 1, ev->timestamp, ev->data);
2453 else if (!sd->freeze)
2455 Evas_Coord ex, ey, ew, eh;
2456 double vx = 0.0, vy = 0.0;
2458 evas_object_geometry_get(sd->event_obj, &ex, &ey, &ew, &eh);
2459 x = ev->cur.canvas.x - ex;
2460 y = ev->cur.canvas.y - ey;
2461 if (x < _elm_config->thumbscroll_threshold)
2463 if (_elm_config->thumbscroll_threshold > 0.0)
2464 vx = -(double)(_elm_config->thumbscroll_threshold - x) /
2465 _elm_config->thumbscroll_threshold;
2469 else if (x > (ew - _elm_config->thumbscroll_threshold))
2471 if (_elm_config->thumbscroll_threshold > 0.0)
2472 vx = (double)(_elm_config->thumbscroll_threshold - (ew - x)) /
2473 _elm_config->thumbscroll_threshold;
2477 if (y < _elm_config->thumbscroll_threshold)
2479 if (_elm_config->thumbscroll_threshold > 0.0)
2480 vy = -(double)(_elm_config->thumbscroll_threshold - y) /
2481 _elm_config->thumbscroll_threshold;
2485 else if (y > (eh - _elm_config->thumbscroll_threshold))
2487 if (_elm_config->thumbscroll_threshold > 0.0)
2488 vy = (double)(_elm_config->thumbscroll_threshold - (eh - y)) /
2489 _elm_config->thumbscroll_threshold;
2493 if ((vx != 0.0) || (vy != 0.0))
2495 sd->down.onhold_vx = vx;
2496 sd->down.onhold_vy = vy;
2497 if (!sd->down.onhold_animator)
2499 sd->down.onhold_vxe = 0.0;
2500 sd->down.onhold_vye = 0.0;
2501 sd->down.onhold_tlast = 0.0;
2502 sd->down.onhold_animator = ecore_animator_add(_smart_onhold_animator, sd);
2504 // printf("b %i %i\n", sd->down.hold_x, sd->down.hold_y);
2508 if (sd->down.onhold_animator)
2510 ecore_animator_del(sd->down.onhold_animator);
2511 sd->down.onhold_animator = NULL;
2512 if (sd->child.resized)
2513 _elm_smart_scroller_wanted_region_set(sd->smart_obj);
2522 _smart_scrollbar_read(Smart_Data *sd)
2524 Evas_Coord x, y, mx = 0, my = 0, px, py, minx = 0, miny = 0;
2527 if ((sd->down.dragged) || (sd->down.bounce_x_animator)
2528 || (sd->down.bounce_y_animator) || (sd->down.momentum_animator)
2529 || (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
2531 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2532 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2533 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2534 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2535 x = vx * (double)mx + minx;
2536 y = vy * (double)my + miny;
2537 sd->pan_func.get(sd->pan_obj, &px, &py);
2538 sd->pan_func.set(sd->pan_obj, x, y);
2539 if ((px != x) || (py != y))
2540 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2544 _smart_scrollbar_reset(Smart_Data *sd)
2546 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2548 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2549 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2550 if ((!sd->child_obj) && (!sd->extern_pan))
2552 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2553 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2557 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2558 sd->pan_func.get(sd->pan_obj, &px, &py);
2559 sd->pan_func.set(sd->pan_obj, minx, miny);
2561 if ((px != minx) || (py != miny))
2562 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2566 _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
2568 int scroll_v_vis_change = 0;
2569 Evas_Coord h, vw = 0, vh = 0;
2573 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2574 if (sd->vbar_visible)
2576 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2578 if ((sd->child_obj) || (sd->extern_pan))
2582 scroll_v_vis_change = 1;
2583 sd->vbar_visible = EINA_FALSE;
2588 scroll_v_vis_change = 1;
2589 sd->vbar_visible = EINA_FALSE;
2592 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2594 scroll_v_vis_change = 1;
2595 sd->vbar_visible = EINA_FALSE;
2600 if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2602 if ((sd->child_obj) || (sd->extern_pan))
2606 scroll_v_vis_change = 1;
2607 sd->vbar_visible = EINA_TRUE;
2611 else if (sd->vbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2613 scroll_v_vis_change = 1;
2614 sd->vbar_visible = EINA_TRUE;
2617 if (scroll_v_vis_change)
2619 if (sd->vbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2621 if (sd->vbar_visible)
2622 edje_object_signal_emit(sd->edje_obj, "elm,action,show,vbar", "elm");
2624 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2625 edje_object_message_signal_process(sd->edje_obj);
2626 _smart_scrollbar_size_adjust(sd);
2629 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
2631 return scroll_v_vis_change;
2635 _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
2637 int scroll_h_vis_change = 0;
2638 Evas_Coord w, vw = 0, vh = 0;
2642 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
2643 if (sd->hbar_visible)
2645 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2647 if ((sd->child_obj) || (sd->extern_pan))
2651 scroll_h_vis_change = 1;
2652 sd->hbar_visible = EINA_FALSE;
2657 scroll_h_vis_change = 1;
2658 sd->hbar_visible = EINA_FALSE;
2661 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_OFF)
2663 scroll_h_vis_change = 1;
2664 sd->hbar_visible = EINA_FALSE;
2669 if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_AUTO)
2671 if ((sd->child_obj) || (sd->extern_pan))
2675 scroll_h_vis_change = 1;
2676 sd->hbar_visible = EINA_TRUE;
2680 else if (sd->hbar_flags == ELM_SMART_SCROLLER_POLICY_ON)
2682 scroll_h_vis_change = 1;
2683 sd->hbar_visible = EINA_TRUE;
2686 if (scroll_h_vis_change)
2688 if (sd->hbar_flags != ELM_SMART_SCROLLER_POLICY_OFF)
2690 if (sd->hbar_visible)
2691 edje_object_signal_emit(sd->edje_obj, "elm,action,show,hbar", "elm");
2693 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2694 edje_object_message_signal_process(sd->edje_obj);
2695 _smart_scrollbar_size_adjust(sd);
2698 edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
2699 _smart_scrollbar_size_adjust(sd);
2701 return scroll_h_vis_change;
2705 _smart_scrollbar_bar_visibility_adjust(Smart_Data *sd)
2709 changed |= _smart_scrollbar_bar_h_visibility_adjust(sd);
2710 changed |= _smart_scrollbar_bar_v_visibility_adjust(sd);
2713 _smart_scrollbar_bar_h_visibility_adjust(sd);
2714 _smart_scrollbar_bar_v_visibility_adjust(sd);
2719 _smart_scrollbar_size_adjust(Smart_Data *sd)
2721 if ((sd->child_obj) || (sd->extern_pan))
2723 Evas_Coord x, y, w, h, mx = 0, my = 0, vw = 0, vh = 0, px, py, minx = 0, miny = 0;
2724 double vx, vy, size;
2726 edje_object_part_geometry_get(sd->edje_obj, "elm.swallow.content",
2727 NULL, NULL, &vw, &vh);
2730 size = (double)vw / (double)w;
2734 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.hbar", 0.0, 0.0);
2736 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", size, 1.0);
2740 size = (double)vh / (double)h;
2744 edje_object_part_drag_value_set(sd->edje_obj, "elm.dragable.vbar", 0.0, 0.0);
2746 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, size);
2748 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.hbar", &vx, NULL);
2749 edje_object_part_drag_value_get(sd->edje_obj, "elm.dragable.vbar", NULL, &vy);
2750 sd->pan_func.max_get(sd->pan_obj, &mx, &my);
2751 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2755 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->step.x / (double)w, 0.0);
2756 edje_object_part_drag_step_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->step.y / (double)h);
2758 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", (double)sd->page.x / (double)w, 0.0);
2760 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.hbar", -((double)sd->page.x * ((double)vw / (double)w)) / 100.0, 0.0);
2762 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, (double)sd->page.y / (double)h);
2764 edje_object_part_drag_page_set(sd->edje_obj, "elm.dragable.vbar", 0.0, -((double)sd->page.y * ((double)vh / (double)h)) / 100.0);
2766 sd->pan_func.get(sd->pan_obj, &px, &py);
2767 if (vx != mx) x = px;
2768 if (vy != my) y = py;
2769 sd->pan_func.set(sd->pan_obj, x, y);
2770 // if ((px != 0) || (py != 0))
2771 // edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2775 Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
2777 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.vbar", 1.0, 1.0);
2778 edje_object_part_drag_size_set(sd->edje_obj, "elm.dragable.hbar", 1.0, 1.0);
2779 sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
2780 sd->pan_func.get(sd->pan_obj, &px, &py);
2781 sd->pan_func.set(sd->pan_obj, minx, miny);
2782 if ((px != minx) || (py != miny))
2783 edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
2785 _smart_scrollbar_bar_visibility_adjust(sd);
2789 _smart_reconfigure(Smart_Data *sd)
2791 evas_object_move(sd->edje_obj, sd->x, sd->y);
2792 evas_object_resize(sd->edje_obj, sd->w, sd->h);
2793 evas_object_move(sd->event_obj, sd->x, sd->y);
2794 evas_object_resize(sd->event_obj, sd->w, sd->h);
2795 _smart_scrollbar_size_adjust(sd);
2796 _smart_page_adjust(sd);
2800 _smart_add(Evas_Object *obj)
2805 sd = calloc(1, sizeof(Smart_Data));
2807 evas_object_smart_data_set(obj, sd);
2809 sd->smart_obj = obj;
2818 sd->hbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2819 sd->vbar_flags = ELM_SMART_SCROLLER_POLICY_AUTO;
2820 sd->hbar_visible = EINA_TRUE;
2821 sd->vbar_visible = EINA_TRUE;
2823 sd->bounce_horiz = EINA_TRUE;
2824 sd->bounce_vert = EINA_TRUE;
2826 sd->one_dir_at_a_time = EINA_TRUE;
2827 sd->momentum_animator_disabled = EINA_FALSE;
2828 sd->bounce_animator_disabled = EINA_FALSE;
2830 o = edje_object_add(evas_object_evas_get(obj));
2831 evas_object_propagate_events_set(o, 0);
2833 elm_smart_scroller_object_theme_set(NULL, obj, "scroller", "base", "default");
2834 edje_object_signal_callback_add(o, "drag", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2835 edje_object_signal_callback_add(o, "drag,set", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2836 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.vbar", _smart_edje_drag_v_start, sd);
2837 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.vbar", _smart_edje_drag_v_stop, sd);
2838 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2839 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.vbar", _smart_edje_drag_v, sd);
2840 edje_object_signal_callback_add(o, "drag", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2841 edje_object_signal_callback_add(o, "drag,set", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2842 edje_object_signal_callback_add(o, "drag,start", "elm.dragable.hbar", _smart_edje_drag_h_start, sd);
2843 edje_object_signal_callback_add(o, "drag,stop", "elm.dragable.hbar", _smart_edje_drag_h_stop, sd);
2844 edje_object_signal_callback_add(o, "drag,step", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2845 edje_object_signal_callback_add(o, "drag,page", "elm.dragable.hbar", _smart_edje_drag_h, sd);
2846 evas_object_smart_member_add(o, obj);
2848 o = evas_object_rectangle_add(evas_object_evas_get(obj));
2850 evas_object_color_set(o, 0, 0, 0, 0);
2851 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _smart_event_wheel, sd);
2852 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _smart_event_mouse_down, sd);
2853 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _smart_event_mouse_up, sd);
2854 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _smart_event_mouse_move, sd);
2855 evas_object_smart_member_add(o, obj);
2856 evas_object_repeat_events_set(o, 1);
2858 sd->pan_func.set = _elm_smart_pan_set;
2859 sd->pan_func.get = _elm_smart_pan_get;
2860 sd->pan_func.max_get = _elm_smart_pan_max_get;
2861 sd->pan_func.min_get = _elm_smart_pan_min_get;
2862 sd->pan_func.child_size_get = _elm_smart_pan_child_size_get;
2864 _smart_scrollbar_reset(sd);
2868 _smart_del(Evas_Object *obj)
2871 elm_smart_scroller_child_set(obj, NULL);
2872 if (!sd->extern_pan) evas_object_del(sd->pan_obj);
2873 evas_object_del(sd->edje_obj);
2874 evas_object_del(sd->event_obj);
2875 if (sd->down.hold_animator) ecore_animator_del(sd->down.hold_animator);
2876 if (sd->down.onhold_animator) ecore_animator_del(sd->down.onhold_animator);
2877 if (sd->down.momentum_animator) ecore_animator_del(sd->down.momentum_animator);
2878 if (sd->down.bounce_x_animator) ecore_animator_del(sd->down.bounce_x_animator);
2879 if (sd->down.bounce_y_animator) ecore_animator_del(sd->down.bounce_y_animator);
2880 if (sd->scrollto.x.animator) ecore_animator_del(sd->scrollto.x.animator);
2881 if (sd->scrollto.y.animator) ecore_animator_del(sd->scrollto.y.animator);
2883 evas_object_smart_data_set(obj, NULL);
2887 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2892 _smart_reconfigure(sd);
2896 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2901 _smart_reconfigure(sd);
2902 _elm_smart_scroller_wanted_region_set(obj);
2906 _smart_show(Evas_Object *obj)
2909 evas_object_show(sd->edje_obj);
2910 evas_object_show(sd->event_obj);
2914 _smart_hide(Evas_Object *obj)
2917 evas_object_hide(sd->edje_obj);
2918 evas_object_hide(sd->event_obj);
2922 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
2925 evas_object_color_set(sd->edje_obj, r, g, b, a);
2929 _smart_clip_set(Evas_Object *obj, Evas_Object *clip)
2932 evas_object_clip_set(sd->edje_obj, clip);
2933 evas_object_clip_set(sd->event_obj, clip);
2937 _smart_clip_unset(Evas_Object *obj)
2940 evas_object_clip_unset(sd->edje_obj);
2941 evas_object_clip_unset(sd->event_obj);
2944 /* never need to touch this */
2951 static const Evas_Smart_Class sc =
2954 EVAS_SMART_CLASS_VERSION,
2972 _smart = evas_smart_class_new(&sc);