sd->pan_func.get(sd->pan_obj, x, y);
}
-/* "internal_call" actually toggles whether we should save the coords and do
- * extra "speedup" checks, or not. */
-static void
-_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)
+/* returns TRUE when we need to move the scroller, FALSE otherwise.
+ * Updates w and h either way, so save them if you need them. */
+static Eina_Bool
+_elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord *_x, Evas_Coord *_y, Evas_Coord w, Evas_Coord h)
{
- Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0, pw = 0, ph = 0;
+ 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;
- API_ENTRY return;
+ API_ENTRY return EINA_FALSE;
sd->pan_func.max_get(sd->pan_obj, &mx, &my);
sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
ny = py;
if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y;
else if ((y > py) && ((y + h) > (py + (ch - my)))) ny = y + h - (ch - my);
- if (!internal_call)
- {
- sd->wx = x;
- sd->wy = y;
- sd->ww = w;
- sd->wh = h;
- }
if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
(sd->scrollto.x.animator) || (sd->scrollto.y.animator))
if ((y + ph) > ch) y = ch - ph;
if (y < miny) y = miny;
- if ((x == px) && (y == py)) return;
- elm_smart_scroller_child_pos_set(obj, x, y);
+ if ((x == px) && (y == py)) return EINA_FALSE;
+ *_x = x;
+ *_y = y;
+ return EINA_TRUE;
}
/* Set should be used for calculated positions, for example, when we move
void
elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
- _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_TRUE);
+ if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
+ elm_smart_scroller_child_pos_set(obj, x, y);
}
/* Set should be used for setting the wanted position, for example a user scroll
void
elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
- _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_FALSE);
+ API_ENTRY return;
+ sd->wx = x;
+ sd->wy = y;
+ sd->ww = w;
+ sd->wh = h;
+ if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
+ elm_smart_scroller_child_pos_set(obj, x, y);
}
void
void
elm_smart_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
- Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0, pw = 0, ph = 0;
-
API_ENTRY return;
- sd->pan_func.max_get(sd->pan_obj, &mx, &my);
- sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
- sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
- sd->pan_func.get(sd->pan_obj, &px, &py);
- evas_object_geometry_get(sd->pan_obj, NULL, NULL, &pw, &ph);
-
- nx = px;
- if ((x < px) && ((x + w) < (px + (cw - mx)))) nx = x;
- else if ((x > px) && ((x + w) > (px + (cw - mx)))) nx = x + w - (cw - mx);
- ny = py;
- if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y;
- else if ((y > py) && ((y + h) > (py + (ch - my)))) ny = y + h - (ch - my);
- sd->wx = x;
- sd->wy = y;
- sd->ww = w;
- sd->wh = h;
- if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
- (sd->scrollto.x.animator) || (sd->scrollto.y.animator))
- {
- _smart_anim_stop(sd->smart_obj);
- }
- if (sd->scrollto.x.animator)
- {
- ecore_animator_del(sd->scrollto.x.animator);
- sd->scrollto.x.animator = NULL;
- }
- if (sd->scrollto.y.animator)
- {
- ecore_animator_del(sd->scrollto.y.animator);
- sd->scrollto.y.animator = NULL;
- }
- if (sd->down.bounce_x_animator)
- {
- ecore_animator_del(sd->down.bounce_x_animator);
- sd->down.bounce_x_animator = NULL;
- sd->bouncemex = 0;
- }
- if (sd->down.bounce_y_animator)
+ if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
{
- ecore_animator_del(sd->down.bounce_y_animator);
- sd->down.bounce_y_animator = NULL;
- sd->bouncemey = 0;
+ _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
+ _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
}
- if (sd->down.hold_animator)
- {
- ecore_animator_del(sd->down.hold_animator);
- sd->down.hold_animator = NULL;
- _smart_drag_stop(sd->smart_obj);
- }
- if (sd->down.momentum_animator)
- {
- ecore_animator_del(sd->down.momentum_animator);
- sd->down.momentum_animator = NULL;
- sd->down.bounce_x_hold = 0;
- sd->down.bounce_y_hold = 0;
- sd->down.ax = 0;
- sd->down.ay = 0;
- sd->down.pdx = 0;
- sd->down.pdy = 0;
- }
- x = nx;
- if ((x + pw) > cw) x = cw - pw;
- if (x < minx) x = minx;
- y = ny;
- if ((y + ph) > ch) y = ch - ph;
- if (y < miny) y = miny;
-
- if ((x == px) && (y == py)) return;
- _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
- _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
}
void