struct _Widget_Data
{
+ Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */
Evas_Object *scr;
Evas_Object *content;
const char *widget_name, *widget_base;
static void
_show_region_hook(void *data, Evas_Object *obj)
{
- Widget_Data *wd = elm_widget_data_get(data);
Evas_Coord x, y, w, h;
- if (!wd) return;
elm_widget_show_region_get(obj, &x, &y, &w, &h);
- if (wd->scr)
- elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
+ elm_scroller_region_show(data, x, y, w, h);
}
static void
_focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (wd->scr)
- elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
+ elm_scroller_region_show(obj, x, y, w, h);
}
static void
if ((maxw > 0) && (w > maxw)) w = maxw;
if ((maxh > 0) && (h > maxh)) h = maxh;
evas_object_size_hint_min_set(obj, w, h);
+ elm_smart_scroller_child_region_show(wd->scr, wd->wx, wd->wy, wd->ww, wd->wh);
}
}
if (!wd) return;
if (wd->content == content) return;
if (wd->content) evas_object_del(wd->content);
+ wd->wx = wd->wh = wd->ww = wd->wy = 0;
+
wd->content = content;
if (content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->scr)) return;
+ wd->wx = x;
+ wd->wh = h;
+ wd->ww = w;
+ wd->wy = y;
+
elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
}
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->scr)) return;
+ wd->wx = x;
+ wd->wh = h;
+ wd->ww = w;
+ wd->wy = y;
elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
}
struct _Smart_Data
{
Evas_Coord x, y, w, h;
+ Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */
Evas_Object *smart_obj;
Evas_Object *child_obj;
}
sd->child_obj = child;
+ sd->wx = sd->wy = sd->ww = sd->wh = 0;
if (!child) return;
if (!sd->pan_obj)
elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
x = pos_x;
- elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
+ elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
return;
}
t = ecore_loop_time_get();
sd->scrollto.x.t_end = t + t_in;
elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
- elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
+ elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
if (!sd->scrollto.x.animator)
{
if (!sd->scrollto.y.animator)
elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
y = pos_y;
- elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
+ elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
return;
}
t = ecore_loop_time_get();
sd->scrollto.y.t_end = t + t_in;
elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h);
- elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
+ elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
if (!sd->scrollto.y.animator)
{
if (!sd->scrollto.x.animator)
x = _smart_page_x_get(sd, 0);
y = _smart_page_y_get(sd, 0);
- elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h);
+ elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h);
}
static Eina_Bool
sd->pan_func.get(sd->pan_obj, x, y);
}
-void
-elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
+/* "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)
{
Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0;
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 ((nx == px) && (ny == py)) return;
+// if ((nx == px) && (ny == py)) return;
+ if (!internal_call)
+ {
+ sd->wx = x;
+ sd->wy = y;
+ sd->ww = w;
+ sd->wh = h;
+ if ((nx == px) && (ny == py)) return;
+ }
if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) ||
(sd->scrollto.x.animator) || (sd->scrollto.y.animator))
{
sd->new.pos_job = ecore_idler_add(_smart_pos_set, sd);
}
+/* Set should be used for calculated positions, for example, when we move
+ * because of an animation or because this is the correct position after
+ * constraints. */
+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);
+}
+
+/* Set should be used for setting the wanted position, for example a user scroll
+ * or moving the cursor in an entry. */
+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);
+}
+
void
elm_smart_scroller_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
{
x += ev->z * sd->step.x;
if ((!sd->hold) && (!sd->freeze))
- elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
+ {
+ sd->wx = x;
+ sd->wy = y;
+ elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
+ }
}
static void
}
}
elm_smart_scroller_child_pos_set(sd->smart_obj, ox, oy);
+ sd->wx = ox;
+ sd->wy = oy;
return ECORE_CALLBACK_RENEW;
}
sd->down.now = 0;
elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y);
elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
+ sd->wx = x;
+ sd->wy = y;
if (!_smart_do_page(sd))
bounce_eval(sd);
}
}
elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
+ sd->wx = x;
+ sd->wy = y;
// printf("scroll %i %i\n", sd->down.hold_x, sd->down.hold_y);
}
sd->down.onhold_tlast = t;
#ifdef SCROLLDBG
printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
#endif
+ sd->wx = ev->cur.canvas.x;
+ sd->wy = ev->cur.canvas.y;
memmove(&(sd->down.history[1]), &(sd->down.history[0]),
sizeof(sd->down.history[0]) * 19);
#ifdef EVTIME
sd->w = w;
sd->h = h;
_smart_reconfigure(sd);
+ elm_smart_scroller_child_region_set(obj, sd->wx, sd->wy, sd->ww, sd->h);
}
static void