Elementary els_scroller: Merge region_show and region_bring_in codes.

They are 99.99% the same, no reason why not to merge them.

SVN revision: 59077
This commit is contained in:
Tom Hacohen 2011-05-01 09:40:30 +00:00
parent f93bfb1222
commit 25e4d80217
1 changed files with 22 additions and 87 deletions

View File

@ -1007,14 +1007,14 @@ elm_smart_scroller_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
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);
@ -1027,13 +1027,6 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord x, E
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))
@ -1087,8 +1080,10 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord x, E
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
@ -1097,7 +1092,8 @@ _elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord x, E
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
@ -1105,7 +1101,13 @@ elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y
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
@ -1299,79 +1301,12 @@ elm_smart_scroller_paging_get(Evas_Object *obj, double *pagerel_h, double *pager
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))
if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h))
{
_smart_anim_stop(sd->smart_obj);
_smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x);
_smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y);
}
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)
{
ecore_animator_del(sd->down.bounce_y_animator);
sd->down.bounce_y_animator = NULL;
sd->bouncemey = 0;
}
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