2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2018-05-16 10:30:28 -07:00
|
|
|
#define EFL_UI_WIDGET_FOCUS_MANAGER_PROTECTED
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
#include "elm_priv.h"
|
|
|
|
#include "elm_interface_scrollable.h"
|
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_PAN_CLASS ELM_PAN_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_PAN_CLASS_NAME "Elm_Pan"
|
|
|
|
#define MY_PAN_CLASS_NAME_LEGACY "elm_pan"
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-02-18 21:06:11 -08:00
|
|
|
#define ELM_PAN_DATA_GET_OR_RETURN(o, ptr) \
|
2016-08-15 06:44:41 -07:00
|
|
|
Elm_Pan_Smart_Data *ptr = efl_data_scope_get(o, MY_PAN_CLASS); \
|
2013-02-18 21:06:11 -08:00
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("No smart data for object %p (%s)", \
|
2013-02-18 21:06:11 -08:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return; \
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2013-02-18 21:06:11 -08:00
|
|
|
#define ELM_PAN_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
2016-08-15 06:44:41 -07:00
|
|
|
Elm_Pan_Smart_Data *ptr = efl_data_scope_get(o, MY_PAN_CLASS); \
|
2013-02-18 21:06:11 -08:00
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("No smart data for object %p (%s)", \
|
2013-02-18 21:06:11 -08:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return val; \
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2016-01-26 15:51:49 -08:00
|
|
|
#define ELM_ANIMATOR_CONNECT(Obj, Bool, Callback, Data) \
|
2019-02-21 12:50:35 -08:00
|
|
|
efl_event_callback_del(Obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, Callback, Data); \
|
|
|
|
efl_event_callback_add(Obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, Callback, Data); \
|
2016-01-26 15:51:49 -08:00
|
|
|
Bool = 1;
|
|
|
|
|
|
|
|
#define ELM_ANIMATOR_DISCONNECT(Obj, Bool, Callback, Data) \
|
2019-02-21 12:50:35 -08:00
|
|
|
efl_event_callback_del(Obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, Callback, Data); \
|
2016-01-26 15:51:49 -08:00
|
|
|
Bool = 0;
|
|
|
|
|
2018-08-28 23:58:10 -07:00
|
|
|
#ifndef CLAMP
|
|
|
|
# define CLAMP(x, min, \
|
|
|
|
max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
|
|
|
|
#endif
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static const char SIG_CHANGED[] = "changed";
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_CHANGED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void _elm_pan_content_set(Evas_Object *, Evas_Object *);
|
2014-01-13 23:56:52 -08:00
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_to_x(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
double t_in,
|
|
|
|
Evas_Coord pos_x);
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_to_y(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
double t_in,
|
|
|
|
Evas_Coord pos_y);
|
2014-04-20 22:17:43 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_wanted_coordinates_update(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
Evas_Coord x,
|
|
|
|
Evas_Coord y);
|
2016-01-26 15:51:49 -08:00
|
|
|
|
2016-08-30 05:34:10 -07:00
|
|
|
static void _elm_scroll_hold_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_on_hold_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_scroll_to_y_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_scroll_to_x_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_bounce_y_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_bounce_x_animator(void *data, const Efl_Event *event);
|
|
|
|
static void _elm_scroll_momentum_animator(void *data, const Efl_Event *event);
|
2016-01-26 15:51:49 -08:00
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
static const char iface_scr_legacy_dragable_hbar[] = "elm.dragable.hbar";
|
|
|
|
static const char iface_scr_legacy_dragable_vbar[] = "elm.dragable.vbar";
|
|
|
|
static const char iface_scr_efl_ui_dragable_hbar[] = "efl.dragable.hbar";
|
|
|
|
static const char iface_scr_efl_ui_dragable_vbar[] = "efl.dragable.vbar";
|
|
|
|
|
2013-04-10 04:25:35 -07:00
|
|
|
static double
|
|
|
|
_round(double value, int pos)
|
|
|
|
{
|
|
|
|
double temp;
|
|
|
|
|
|
|
|
temp = value * pow( 10, pos );
|
|
|
|
temp = floor( temp + 0.5 );
|
|
|
|
temp *= pow( 10, -pos );
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_pan_update(Elm_Pan_Smart_Data *psd)
|
|
|
|
{
|
2018-01-15 22:12:49 -08:00
|
|
|
if (psd->content)
|
2018-11-22 06:47:52 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *manager;
|
|
|
|
|
|
|
|
manager = psd->interface_object;
|
|
|
|
|
|
|
|
efl_ui_focus_manager_dirty_logic_freeze(manager);
|
|
|
|
evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
|
|
|
|
efl_ui_focus_manager_dirty_logic_unfreeze(manager);
|
2018-11-26 03:40:17 -08:00
|
|
|
//XXX: hack, right now there is no api in efl_ui_focus_manager_sub.eo to mark it dirty
|
|
|
|
// If we have moved the content, then emit this event, in order to ensure that the focus_manager_sub
|
|
|
|
// logic tries to fetch the viewport again
|
|
|
|
efl_event_callback_call(manager, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL);
|
2018-11-22 06:47:52 -08:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_pan_efl_canvas_group_group_add(Eo *obj, Elm_Pan_Smart_Data *priv)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_PAN_CLASS));
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
priv->self = obj;
|
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_pan_efl_canvas_group_group_del(Eo *obj, Elm_Pan_Smart_Data *_pd EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
_elm_pan_content_set(obj, NULL);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_PAN_CLASS));
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_elm_pan_efl_gfx_entity_position_set(Eo *obj, Elm_Pan_Smart_Data *psd, Eina_Position2D pos)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2017-09-14 20:14:32 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
|
2016-10-10 20:39:05 -07:00
|
|
|
return;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_position_set(efl_super(obj, MY_PAN_CLASS), pos);
|
2016-10-10 20:39:05 -07:00
|
|
|
|
2017-09-14 20:14:32 -07:00
|
|
|
psd->x = pos.x;
|
|
|
|
psd->y = pos.y;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
_elm_pan_update(psd);
|
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_elm_pan_efl_gfx_entity_size_set(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Eina_Size2D sz)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
|
evas/elm: Remove function group_resize
This is an override of efl_gfx_size_set. Same as before, the
order of operations matter so it is possible that a corner
case will break. In particular, legacy code was:
- intercept
- smart resize (do stuff), super, super, super
- evas object resize
The new code is more like:
- intercept
- super, super, super, evas object resize
- do stuff
But unfortunately this broke elm_widget (read: all widgets) as
the internal resize was done before the object resize. So,
inside the resize event cb, the resize_obj size would not match
the smart object size. >_<
2016-10-11 00:54:31 -07:00
|
|
|
return;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(efl_super(obj, MY_PAN_CLASS), sz);
|
evas/elm: Remove function group_resize
This is an override of efl_gfx_size_set. Same as before, the
order of operations matter so it is possible that a corner
case will break. In particular, legacy code was:
- intercept
- smart resize (do stuff), super, super, super
- evas object resize
The new code is more like:
- intercept
- super, super, super, evas object resize
- do stuff
But unfortunately this broke elm_widget (read: all widgets) as
the internal resize was done before the object resize. So,
inside the resize event cb, the resize_obj size would not match
the smart object size. >_<
2016-10-11 00:54:31 -07:00
|
|
|
|
2017-09-15 02:37:25 -07:00
|
|
|
psd->w = sz.w;
|
|
|
|
psd->h = sz.h;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
_elm_pan_update(psd);
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_elm_pan_efl_gfx_entity_visible_set(Eo *obj, Elm_Pan_Smart_Data *psd, Eina_Bool vis)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-10-10 02:59:42 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
|
|
|
|
return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_visible_set(efl_super(obj, MY_PAN_CLASS), vis);
|
|
|
|
if (psd->content) efl_gfx_entity_visible_set(psd->content, vis);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_pan_pos_set(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coord x, Evas_Coord y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if ((x == psd->px) && (y == psd->py)) return;
|
|
|
|
psd->px = x;
|
|
|
|
psd->py = y;
|
|
|
|
|
|
|
|
_elm_pan_update(psd);
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_pan_pos_get(const Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x) *x = psd->px;
|
|
|
|
if (y) *y = psd->py;
|
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_pan_pos_max_get(const Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
{
|
|
|
|
if (psd->w < psd->content_w) *x = psd->content_w - psd->w;
|
|
|
|
else *x = 0;
|
|
|
|
}
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
if (psd->h < psd->content_h) *y = psd->content_h - psd->h;
|
|
|
|
else *y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_pan_pos_min_get(const Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
*x = 0;
|
|
|
|
if (y)
|
|
|
|
*y = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_pan_content_size_get(const Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coord *w, Evas_Coord *h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (w) *w = psd->content_w;
|
|
|
|
if (h) *h = psd->content_h;
|
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_elm_pan_add(Evas *evas)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2018-01-23 22:50:58 -08:00
|
|
|
return elm_legacy_add(MY_PAN_CLASS, evas);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_pan_efl_object_constructor(Eo *obj, Elm_Pan_Smart_Data *_pd EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2017-09-05 20:13:58 -07:00
|
|
|
efl_canvas_group_clipped_set(obj, EINA_TRUE);
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_PAN_CLASS));
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_PAN_CLASS_NAME_LEGACY);
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_pan_content_del_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Pan_Smart_Data *psd;
|
|
|
|
|
|
|
|
psd = data;
|
|
|
|
psd->content = NULL;
|
2016-09-21 04:44:53 -07:00
|
|
|
psd->content_w = psd->content_h = psd->px = psd->py = 0;
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_pan_content_resize_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Pan_Smart_Data *psd;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
psd = data;
|
|
|
|
evas_object_geometry_get(psd->content, NULL, NULL, &w, &h);
|
|
|
|
if ((w != psd->content_w) || (h != psd->content_h))
|
|
|
|
{
|
|
|
|
psd->content_w = w;
|
|
|
|
psd->content_h = h;
|
|
|
|
_elm_pan_update(psd);
|
|
|
|
}
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_pan_content_set(Evas_Object *obj,
|
|
|
|
Evas_Object *content)
|
|
|
|
{
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
2012-12-09 22:59:46 -08:00
|
|
|
ELM_PAN_DATA_GET_OR_RETURN(obj, psd);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (content == psd->content) return;
|
|
|
|
if (psd->content)
|
|
|
|
{
|
|
|
|
evas_object_smart_member_del(psd->content);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(psd->content, EVAS_CALLBACK_DEL, _elm_pan_content_del_cb, psd);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(psd->content, EVAS_CALLBACK_RESIZE, _elm_pan_content_resize_cb,
|
|
|
|
psd);
|
|
|
|
psd->content = NULL;
|
|
|
|
}
|
|
|
|
if (!content) goto end;
|
|
|
|
|
|
|
|
psd->content = content;
|
|
|
|
evas_object_smart_member_add(psd->content, psd->self);
|
|
|
|
evas_object_geometry_get(psd->content, NULL, NULL, &w, &h);
|
|
|
|
psd->content_w = w;
|
|
|
|
psd->content_h = h;
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(content, EVAS_CALLBACK_DEL, _elm_pan_content_del_cb, psd);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(content, EVAS_CALLBACK_RESIZE, _elm_pan_content_resize_cb, psd);
|
|
|
|
|
|
|
|
if (evas_object_visible_get(psd->self))
|
|
|
|
evas_object_show(psd->content);
|
|
|
|
else
|
|
|
|
evas_object_hide(psd->content);
|
|
|
|
|
|
|
|
_elm_pan_update(psd);
|
|
|
|
|
|
|
|
end:
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 06:52:41 -07:00
|
|
|
EOLIAN static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_pan_class_constructor(Efl_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_PAN_CLASS_NAME_LEGACY, klass);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
/* pan smart object on top, scroller interface on bottom */
|
|
|
|
/* ============================================================ */
|
|
|
|
|
2014-06-30 13:37:04 -07:00
|
|
|
#define MY_SCROLLABLE_INTERFACE ELM_INTERFACE_SCROLLABLE_MIXIN
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 06:29:38 -08:00
|
|
|
#define MY_SCROLLABLE_INTERFACE_NAME "Elm_Interface_Scrollable"
|
|
|
|
#define MY_SCROLLABLE_INTERFACE_NAME_LEGACY "elm_interface_scrollable"
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
#define ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(o, ptr) \
|
2013-10-13 22:40:35 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *ptr = \
|
2016-08-15 06:44:41 -07:00
|
|
|
(!efl_isa(o, MY_SCROLLABLE_INTERFACE) ? NULL : \
|
|
|
|
efl_data_scope_get(o, MY_SCROLLABLE_INTERFACE)); \
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("No interface data for object %p (%s)", \
|
2012-07-04 14:41:01 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ELM_SCROLL_IFACE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
2013-10-13 22:40:35 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *ptr = \
|
2016-08-15 06:44:41 -07:00
|
|
|
(!efl_isa(o, MY_SCROLLABLE_INTERFACE) ? NULL : \
|
|
|
|
efl_data_scope_get(o, MY_SCROLLABLE_INTERFACE)); \
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("No interface data for object %p (%s)", \
|
2012-07-04 14:41:01 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return val; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _elm_scroll_scroll_bar_size_adjust(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *);
|
|
|
|
static void _elm_scroll_wanted_region_set(Evas_Object *);
|
2013-04-09 21:36:04 -07:00
|
|
|
static Eina_Bool _paging_is_enabled(Elm_Scrollable_Smart_Interface_Data *sid);
|
|
|
|
static Evas_Coord _elm_scroll_page_x_get(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid, int offset, Eina_Bool limit);
|
|
|
|
static Evas_Coord _elm_scroll_page_y_get(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid, int offset, Eina_Bool limit);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2012-07-06 10:04:48 -07:00
|
|
|
#define LEFT 0
|
|
|
|
#define RIGHT 1
|
|
|
|
#define UP 2
|
|
|
|
#define DOWN 3
|
2012-07-04 14:41:01 -07:00
|
|
|
//#define SCROLLDBG 1
|
2012-07-06 10:04:48 -07:00
|
|
|
/* smoothness debug calls - for debugging how much smooth your app is */
|
|
|
|
#define SMOOTHDBG 1
|
|
|
|
|
|
|
|
#ifdef SMOOTHDBG
|
|
|
|
#define SMOOTH_DEBUG_COUNT 100
|
|
|
|
|
|
|
|
#define FPS 1 / 60
|
|
|
|
typedef struct _smooth_debug_info smooth_debug_info;
|
|
|
|
struct _smooth_debug_info
|
|
|
|
{
|
|
|
|
double t;
|
|
|
|
double dt;
|
|
|
|
Evas_Coord pos;
|
|
|
|
Evas_Coord dpos;
|
|
|
|
double vpos;
|
|
|
|
};
|
|
|
|
|
|
|
|
static smooth_debug_info smooth_x_history[SMOOTH_DEBUG_COUNT];
|
|
|
|
static smooth_debug_info smooth_y_history[SMOOTH_DEBUG_COUNT];
|
|
|
|
static int smooth_info_x_count = 0;
|
|
|
|
static int smooth_info_y_count = 0;
|
|
|
|
static double start_time = 0;
|
|
|
|
static int _elm_scroll_smooth_debug = 0;
|
|
|
|
|
|
|
|
void
|
|
|
|
_elm_scroll_smooth_debug_init(void)
|
|
|
|
{
|
|
|
|
start_time = ecore_time_get();
|
|
|
|
smooth_info_x_count = 0;
|
|
|
|
smooth_info_y_count = 0;
|
|
|
|
|
|
|
|
memset(&(smooth_x_history[0]), 0,
|
|
|
|
sizeof(smooth_x_history[0]) * SMOOTH_DEBUG_COUNT);
|
|
|
|
memset(&(smooth_y_history[0]), 0,
|
|
|
|
sizeof(smooth_y_history[0]) * SMOOTH_DEBUG_COUNT);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_elm_scroll_smooth_debug_shutdown(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int info_x_count = 0;
|
|
|
|
int info_y_count = 0;
|
|
|
|
double x_ave = 0, y_ave = 0;
|
|
|
|
double x_sum = 0, y_sum = 0;
|
|
|
|
double x_dev = 0, y_dev = 0;
|
|
|
|
double x_dev_sum = 0, y_dev_sum = 0;
|
|
|
|
|
|
|
|
if (smooth_info_x_count >= SMOOTH_DEBUG_COUNT)
|
|
|
|
info_x_count = SMOOTH_DEBUG_COUNT;
|
|
|
|
else
|
|
|
|
info_x_count = smooth_info_x_count;
|
|
|
|
|
|
|
|
if (smooth_info_y_count >= SMOOTH_DEBUG_COUNT)
|
|
|
|
info_y_count = SMOOTH_DEBUG_COUNT;
|
|
|
|
else
|
|
|
|
info_y_count = smooth_info_y_count;
|
|
|
|
|
|
|
|
DBG("\n\n<<< X-axis Smoothness >>>\n");
|
|
|
|
DBG("| Num | t(time) | dt | x | dx |vx(dx/1fps) |\n");
|
|
|
|
|
|
|
|
for (i = info_x_count - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
DBG("| %4d | %1.6f | %1.6f | %4d | %4d | %9.3f |\n", info_x_count - i,
|
|
|
|
smooth_x_history[i].t,
|
|
|
|
smooth_x_history[i].dt,
|
|
|
|
smooth_x_history[i].pos,
|
|
|
|
smooth_x_history[i].dpos,
|
|
|
|
smooth_x_history[i].vpos);
|
|
|
|
if (i == info_x_count - 1) continue;
|
|
|
|
x_sum += smooth_x_history[i].vpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
x_ave = x_sum / (info_x_count - 1);
|
|
|
|
for (i = 0; i < info_x_count - 1; i++)
|
|
|
|
{
|
|
|
|
x_dev_sum += (smooth_x_history[i].vpos - x_ave) *
|
|
|
|
(smooth_x_history[i].vpos - x_ave);
|
|
|
|
}
|
|
|
|
x_dev = x_dev_sum / (info_x_count - 1);
|
2012-07-25 07:55:04 -07:00
|
|
|
DBG(" Standard deviation of X-axis velocity: %9.3f\n", sqrt(x_dev));
|
2012-07-06 10:04:48 -07:00
|
|
|
|
|
|
|
DBG("\n\n<<< Y-axis Smoothness >>>\n");
|
|
|
|
DBG("| Num | t(time) | dt | y | dy |vy(dy/1fps) |\n");
|
|
|
|
for (i = info_y_count - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
DBG("| %4d | %1.6f | %1.6f | %4d | %4d | %9.3f |\n", info_y_count - i,
|
|
|
|
smooth_y_history[i].t,
|
|
|
|
smooth_y_history[i].dt,
|
|
|
|
smooth_y_history[i].pos,
|
|
|
|
smooth_y_history[i].dpos,
|
|
|
|
smooth_y_history[i].vpos);
|
|
|
|
if (i == info_y_count - 1) continue;
|
|
|
|
y_sum += smooth_y_history[i].vpos;
|
|
|
|
}
|
|
|
|
y_ave = y_sum / (info_y_count - 1);
|
|
|
|
for (i = 0; i < info_y_count - 1; i++)
|
|
|
|
{
|
|
|
|
y_dev_sum += (smooth_y_history[i].vpos - y_ave) *
|
|
|
|
(smooth_y_history[i].vpos - y_ave);
|
|
|
|
}
|
|
|
|
y_dev = y_dev_sum / (info_y_count - 1);
|
|
|
|
|
2012-07-25 07:55:04 -07:00
|
|
|
DBG(" Standard deviation of Y-axis velocity: %9.3f\n", sqrt(y_dev));
|
2012-07-06 10:04:48 -07:00
|
|
|
}
|
|
|
|
|
2012-08-07 03:20:30 -07:00
|
|
|
static void
|
|
|
|
_elm_direction_arrows_eval(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
Eina_Bool go_left = EINA_TRUE, go_right = EINA_TRUE;
|
|
|
|
Eina_Bool go_up = EINA_TRUE, go_down = EINA_TRUE;
|
|
|
|
Evas_Coord x = 0, y = 0, mx = 0, my = 0, minx = 0, miny = 0;
|
2013-09-30 03:21:31 -07:00
|
|
|
|
2012-08-07 03:20:30 -07:00
|
|
|
if (!sid->edje_obj || !sid->pan_obj) return;
|
2013-09-30 03:21:31 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &x, &y);
|
2012-08-07 03:20:30 -07:00
|
|
|
|
|
|
|
if (x == minx) go_left = EINA_FALSE;
|
|
|
|
if (x == (mx + minx)) go_right = EINA_FALSE;
|
|
|
|
if (y == miny) go_up = EINA_FALSE;
|
|
|
|
if (y == (my + miny)) go_down = EINA_FALSE;
|
|
|
|
if (go_left != sid->go_left)
|
|
|
|
{
|
|
|
|
if (go_left)
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,show,left", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,left", "elm");
|
|
|
|
sid->go_left = go_left;
|
|
|
|
}
|
|
|
|
if (go_right != sid->go_right)
|
|
|
|
{
|
|
|
|
if (go_right)
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,show,right", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,right", "elm");
|
|
|
|
sid->go_right= go_right;
|
|
|
|
}
|
|
|
|
if (go_up != sid->go_up)
|
|
|
|
{
|
|
|
|
if (go_up)
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,show,up", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,up", "elm");
|
|
|
|
sid->go_up = go_up;
|
|
|
|
}
|
|
|
|
if (go_down != sid->go_down)
|
|
|
|
{
|
|
|
|
if (go_down)
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,show,down", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,down", "elm");
|
|
|
|
sid->go_down= go_down;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-06 10:04:48 -07:00
|
|
|
void
|
|
|
|
_elm_scroll_smooth_debug_movetime_add(int x,
|
|
|
|
int y)
|
|
|
|
{
|
|
|
|
double tim = 0;
|
|
|
|
static int bx = 0;
|
|
|
|
static int by = 0;
|
|
|
|
|
|
|
|
tim = ecore_time_get();
|
|
|
|
|
|
|
|
if (bx != x)
|
|
|
|
{
|
|
|
|
smooth_info_x_count++;
|
|
|
|
memmove(&(smooth_x_history[1]), &(smooth_x_history[0]),
|
|
|
|
sizeof(smooth_x_history[0]) * (SMOOTH_DEBUG_COUNT - 1));
|
|
|
|
smooth_x_history[0].t = tim - start_time;
|
|
|
|
smooth_x_history[0].dt = smooth_x_history[0].t - smooth_x_history[1].t;
|
|
|
|
smooth_x_history[0].pos = x;
|
|
|
|
smooth_x_history[0].dpos =
|
|
|
|
smooth_x_history[0].pos - smooth_x_history[1].pos;
|
|
|
|
|
|
|
|
if (smooth_x_history[0].dpos >= 0)
|
|
|
|
smooth_x_history[0].vpos = (double)(smooth_x_history[0].dpos) /
|
|
|
|
smooth_x_history[0].dt * FPS;
|
|
|
|
else
|
|
|
|
smooth_x_history[0].vpos = -((double)(smooth_x_history[0].dpos) /
|
|
|
|
smooth_x_history[0].dt * FPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (by != y)
|
|
|
|
{
|
|
|
|
smooth_info_y_count++;
|
|
|
|
memmove(&(smooth_y_history[1]), &(smooth_y_history[0]),
|
|
|
|
sizeof(smooth_y_history[0]) * (SMOOTH_DEBUG_COUNT - 1));
|
|
|
|
smooth_y_history[0].t = tim - start_time;
|
|
|
|
smooth_y_history[0].dt = smooth_y_history[0].t - smooth_y_history[1].t;
|
|
|
|
smooth_y_history[0].pos = y;
|
|
|
|
smooth_y_history[0].dpos = smooth_y_history[0].pos -
|
|
|
|
smooth_y_history[1].pos;
|
|
|
|
|
|
|
|
if (smooth_y_history[0].dpos >= 0)
|
|
|
|
smooth_y_history[0].vpos = (double)(smooth_y_history[0].dpos) /
|
|
|
|
smooth_y_history[0].dt * FPS;
|
|
|
|
else
|
|
|
|
smooth_y_history[0].vpos = -((double)(smooth_y_history[0].dpos) /
|
|
|
|
smooth_y_history[0].dt * FPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
bx = x;
|
|
|
|
by = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2014-02-12 03:39:39 -08:00
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_h_visibility_apply(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if (sid->hbar_flags != ELM_SCROLLER_POLICY_OFF)
|
|
|
|
{
|
|
|
|
if (sid->hbar_visible)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show,hbar", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,hide,hbar", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,hbar", "elm");
|
|
|
|
edje_object_message_signal_process(sid->edje_obj);
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
if (sid->cb_func.content_min_limit)
|
|
|
|
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_apply(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if (sid->vbar_flags != ELM_SCROLLER_POLICY_OFF)
|
|
|
|
{
|
|
|
|
if (sid->vbar_visible)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show,vbar", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,hide,vbar", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,hide,vbar", "elm");
|
|
|
|
edje_object_message_signal_process(sid->edje_obj);
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
if (sid->cb_func.content_min_limit)
|
|
|
|
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static int
|
|
|
|
_elm_scroll_scroll_bar_h_visibility_adjust(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
int scroll_h_vis_change = 0;
|
|
|
|
Evas_Coord w, vw = 0, vh = 0;
|
|
|
|
|
|
|
|
if (!sid->edje_obj) return 0;
|
|
|
|
|
|
|
|
w = sid->content_info.w;
|
|
|
|
if (sid->pan_obj)
|
|
|
|
evas_object_geometry_get(sid->pan_obj, NULL, NULL, &vw, &vh);
|
|
|
|
if (sid->hbar_visible)
|
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (sid->min_w)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sid->hbar_flags == ELM_SCROLLER_POLICY_AUTO)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if ((sid->content) || (sid->extern_pan))
|
|
|
|
{
|
|
|
|
if (w <= vw)
|
|
|
|
{
|
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-07-17 23:59:16 -07:00
|
|
|
else if (sid->hbar_flags == ELM_SCROLLER_POLICY_OFF)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (!sid->min_w)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (sid->hbar_flags == ELM_SCROLLER_POLICY_AUTO)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if ((sid->content) || (sid->extern_pan))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (w > vw)
|
|
|
|
{
|
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_TRUE;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 23:59:16 -07:00
|
|
|
else if (sid->hbar_flags == ELM_SCROLLER_POLICY_ON)
|
|
|
|
{
|
|
|
|
scroll_h_vis_change = 1;
|
|
|
|
sid->hbar_visible = EINA_TRUE;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 03:39:39 -08:00
|
|
|
|
|
|
|
if (scroll_h_vis_change) _elm_scroll_scroll_bar_h_visibility_apply(sid);
|
2013-09-30 03:21:31 -07:00
|
|
|
|
2012-08-07 03:20:30 -07:00
|
|
|
_elm_direction_arrows_eval(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
return scroll_h_vis_change;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_adjust(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
int scroll_v_vis_change = 0;
|
|
|
|
Evas_Coord h, vw = 0, vh = 0;
|
|
|
|
|
|
|
|
if (!sid->edje_obj) return 0;
|
|
|
|
|
|
|
|
h = sid->content_info.h;
|
|
|
|
if (sid->pan_obj)
|
|
|
|
evas_object_geometry_get(sid->pan_obj, NULL, NULL, &vw, &vh);
|
|
|
|
if (sid->vbar_visible)
|
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (sid->min_h)
|
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (sid->vbar_flags == ELM_SCROLLER_POLICY_AUTO)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if ((sid->content) || (sid->extern_pan))
|
|
|
|
{
|
|
|
|
if (h <= vh)
|
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-07-17 23:59:16 -07:00
|
|
|
else if (sid->vbar_flags == ELM_SCROLLER_POLICY_OFF)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (!sid->min_h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (sid->vbar_flags == ELM_SCROLLER_POLICY_AUTO)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if ((sid->content) || (sid->extern_pan))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (h > vh)
|
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_TRUE;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 23:59:16 -07:00
|
|
|
else if (sid->vbar_flags == ELM_SCROLLER_POLICY_ON)
|
|
|
|
{
|
|
|
|
scroll_v_vis_change = 1;
|
|
|
|
sid->vbar_visible = EINA_TRUE;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 03:39:39 -08:00
|
|
|
if (scroll_v_vis_change) _elm_scroll_scroll_bar_v_visibility_apply(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2012-08-07 03:20:30 -07:00
|
|
|
_elm_direction_arrows_eval(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
return scroll_v_vis_change;
|
|
|
|
}
|
|
|
|
|
2016-10-26 04:11:10 -07:00
|
|
|
static inline void
|
|
|
|
_elm_scroll_scroll_bar_auto_visibility_adjust(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
Eina_Size2D sz;
|
|
|
|
int w, h;
|
2016-10-26 04:11:10 -07:00
|
|
|
|
|
|
|
if ((sid->vbar_flags != ELM_SCROLLER_POLICY_AUTO) ||
|
|
|
|
(sid->hbar_flags != ELM_SCROLLER_POLICY_AUTO) ||
|
|
|
|
!sid->hbar_visible || !sid->vbar_visible) return;
|
|
|
|
|
|
|
|
if (!sid->content && !sid->extern_pan) return;
|
|
|
|
|
|
|
|
w = sid->content_info.w;
|
|
|
|
h = sid->content_info.h;
|
2018-04-05 01:47:26 -07:00
|
|
|
sz = efl_gfx_entity_size_get(sid->edje_obj);
|
2016-10-26 04:11:10 -07:00
|
|
|
|
|
|
|
// Adjust when the content may fit but the bars are visible. The if() test
|
|
|
|
// does not guarantee that the content will fit (offsets & margins depend
|
|
|
|
// on the theme).
|
2017-09-15 02:37:25 -07:00
|
|
|
if ((w <= sz.w) && (h <= sz.h))
|
2016-10-26 04:11:10 -07:00
|
|
|
{
|
|
|
|
sid->hbar_visible = EINA_FALSE;
|
|
|
|
sid->vbar_visible = EINA_FALSE;
|
|
|
|
_elm_scroll_scroll_bar_h_visibility_apply(sid);
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_apply(sid);
|
|
|
|
_elm_scroll_scroll_bar_h_visibility_adjust(sid);
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_adjust(sid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_visibility_adjust(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
int changed = 0;
|
|
|
|
|
|
|
|
changed |= _elm_scroll_scroll_bar_h_visibility_adjust(sid);
|
|
|
|
changed |= _elm_scroll_scroll_bar_v_visibility_adjust(sid);
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
_elm_scroll_scroll_bar_h_visibility_adjust(sid);
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_adjust(sid);
|
|
|
|
}
|
2016-10-26 04:11:10 -07:00
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_auto_visibility_adjust(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
static inline EINA_PURE Eina_Bool
|
|
|
|
_elm_scroll_has_bars(const Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
|
|
|
}
|
|
|
|
return edje_object_part_exists(sid->edje_obj, iface_scr_dragable_hbar) ||
|
|
|
|
edje_object_part_exists(sid->edje_obj, iface_scr_dragable_vbar);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if (!sid->pan_obj || !sid->edje_obj) return;
|
2018-05-07 16:12:10 -07:00
|
|
|
if (efl_invalidated_get(sid->pan_obj) || efl_invalidated_get(sid->edje_obj)) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-11-26 02:32:35 -08:00
|
|
|
if (sid->size_adjust_recurse_abort) return;
|
|
|
|
if (sid->size_adjust_recurse > 20)
|
|
|
|
{
|
|
|
|
sid->size_adjust_recurse_abort = EINA_TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sid->size_adjust_recurse++;
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((sid->content) || (sid->extern_pan))
|
|
|
|
{
|
2017-11-24 06:52:08 -08:00
|
|
|
Evas_Coord x, y, w, h, mx = 0, my = 0, vw = 0, vh = 0,
|
|
|
|
px = 0, py = 0, minx = 0, miny = 0;
|
|
|
|
double vx = 0.0, vy = 0.0, size;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-15 11:49:48 -07:00
|
|
|
edje_object_calc_force(sid->edje_obj);
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
edje_object_part_geometry_get
|
|
|
|
(sid->edje_obj, "elm.swallow.content", NULL, NULL, &vw, &vh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_part_geometry_get
|
|
|
|
(sid->edje_obj, "efl.content", NULL, NULL, &vw, &vh);
|
|
|
|
}
|
2018-06-21 15:51:43 -07:00
|
|
|
|
|
|
|
if (!_elm_scroll_has_bars(sid))
|
|
|
|
goto skip_bars;
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
w = sid->content_info.w;
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
size = (double)vw / (double)w;
|
|
|
|
|
|
|
|
if (size > 1.0)
|
|
|
|
{
|
|
|
|
size = 1.0;
|
|
|
|
edje_object_part_drag_value_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, 0.0, 0.0);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
edje_object_part_drag_size_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, size, 1.0);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
h = sid->content_info.h;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
size = (double)vh / (double)h;
|
|
|
|
if (size > 1.0)
|
|
|
|
{
|
|
|
|
size = 1.0;
|
|
|
|
edje_object_part_drag_value_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0, 0.0);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
edje_object_part_drag_size_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 1.0, size);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
edje_object_part_drag_value_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, &vx, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
edje_object_part_drag_value_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, NULL, &vy);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
x = vx * mx + minx;
|
|
|
|
y = vy * my + miny;
|
|
|
|
|
|
|
|
edje_object_part_drag_step_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, (double)sid->step.x /
|
2012-07-04 14:41:01 -07:00
|
|
|
(double)w, 0.0);
|
|
|
|
edje_object_part_drag_step_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0, (double)sid->step.y /
|
2012-07-04 14:41:01 -07:00
|
|
|
(double)h);
|
|
|
|
if (sid->page.x > 0)
|
|
|
|
edje_object_part_drag_page_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, (double)sid->page.x /
|
2012-07-04 14:41:01 -07:00
|
|
|
(double)w, 0.0);
|
|
|
|
else
|
|
|
|
edje_object_part_drag_page_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
-((double)sid->page.x * ((double)vw / (double)w)) / 100.0, 0.0);
|
|
|
|
if (sid->page.y > 0)
|
|
|
|
edje_object_part_drag_page_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0,
|
2012-07-04 14:41:01 -07:00
|
|
|
(double)sid->page.y / (double)h);
|
|
|
|
else
|
|
|
|
edje_object_part_drag_page_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0,
|
2012-07-04 14:41:01 -07:00
|
|
|
-((double)sid->page.y * ((double)vh / (double)h)) / 100.0);
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (vx != mx) x = px;
|
|
|
|
if (vy != my) y = py;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_set(sid->pan_obj, x, y);
|
2015-04-26 21:55:10 -07:00
|
|
|
|
|
|
|
if (mx > 0) vx = (double)(x - minx) / (double)mx;
|
|
|
|
else vx = 0.0;
|
|
|
|
|
|
|
|
if (vx < 0.0) vx = 0.0;
|
|
|
|
else if (vx > 1.0)
|
|
|
|
vx = 1.0;
|
|
|
|
|
|
|
|
if (my > 0) vy = (double)(y - miny) / (double)my;
|
|
|
|
else vy = 0.0;
|
|
|
|
|
|
|
|
if (vy < 0.0) vy = 0.0;
|
|
|
|
else if (vy > 1.0)
|
|
|
|
vy = 1.0;
|
|
|
|
|
|
|
|
edje_object_part_drag_value_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0, vy);
|
2015-04-26 21:55:10 -07:00
|
|
|
edje_object_part_drag_value_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, vx, 0.0);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
|
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
if (_elm_scroll_has_bars(sid))
|
|
|
|
{
|
|
|
|
edje_object_part_drag_size_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 1.0, 1.0);
|
|
|
|
edje_object_part_drag_size_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, 1.0, 1.0);
|
|
|
|
}
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
|
|
|
elm_obj_pan_pos_set(sid->pan_obj, minx, miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((px != minx) || (py != miny))
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
|
|
|
|
}
|
2018-06-21 15:51:43 -07:00
|
|
|
|
|
|
|
skip_bars:
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_scroll_bar_visibility_adjust(sid);
|
2013-11-26 02:32:35 -08:00
|
|
|
sid->size_adjust_recurse--;
|
|
|
|
if (sid->size_adjust_recurse <= 0)
|
|
|
|
{
|
|
|
|
sid->size_adjust_recurse = 0;
|
|
|
|
sid->size_adjust_recurse_abort = EINA_FALSE;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2013-11-25 04:22:11 -08:00
|
|
|
Evas_Coord x, y, mx = 0, my = 0, minx = 0, miny = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
double vx, vy;
|
|
|
|
|
|
|
|
if (!sid->edje_obj || !sid->pan_obj) return;
|
|
|
|
|
|
|
|
if ((sid->down.dragged) || (sid->down.bounce_x_animator)
|
|
|
|
|| (sid->down.bounce_y_animator) || (sid->down.momentum_animator)
|
|
|
|
|| (sid->scrollto.x.animator) || (sid->scrollto.y.animator))
|
|
|
|
return;
|
2018-06-21 15:51:43 -07:00
|
|
|
if (!_elm_scroll_has_bars(sid)) return;
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
edje_object_part_drag_value_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, NULL, &vy);
|
2012-07-04 14:41:01 -07:00
|
|
|
edje_object_part_drag_value_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, &vx, NULL);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2013-04-10 04:25:35 -07:00
|
|
|
x = _round(vx * (double)mx + minx, 1);
|
|
|
|
y = _round(vy * (double)my + miny, 1);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2014-04-20 22:17:43 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, x, y);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_drag_start(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2013-05-15 14:56:04 -07:00
|
|
|
sid->current_page.x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
sid->current_page.y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->cb_func.drag_start)
|
|
|
|
sid->cb_func.drag_start(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_drag_stop(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2013-05-15 14:56:04 -07:00
|
|
|
Evas_Coord x, y;
|
|
|
|
|
|
|
|
if (!(sid->down.bounce_x_animator) && !(sid->down.bounce_y_animator) &&
|
|
|
|
!(sid->scrollto.x.animator) && !(sid->scrollto.y.animator))
|
|
|
|
{
|
|
|
|
x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
if (sid->cb_func.page_change &&
|
|
|
|
((x != sid->current_page.x) || (y != sid->current_page.y)))
|
|
|
|
sid->cb_func.page_change(sid->obj, NULL);
|
interface_scrollable: delete unnecessary smart callback call.
Summary:
When _elm_interface_scrollable_page_bring_in is called, page is not changed yet.
So "page,changed" smart callback is unnecessary.
Sometimes "page,changed" smart callback is called twice.
Because "drag,stop" and "anim,stop"is called it.
So I add updating current page code.
Test Plan:
elementary_test -> scroller
1. using wheel.
2. using "prev page" and "next page".
3. draging sceen
Reviewers: Hermet, singh.amitesh, cedric, raster, jaehwan, seoz
Differential Revision: https://phab.enlightenment.org/D3260
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-03 12:29:05 -08:00
|
|
|
sid->current_page.x = x;
|
|
|
|
sid->current_page.y = y;
|
2013-05-15 14:56:04 -07:00
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->cb_func.drag_stop)
|
|
|
|
sid->cb_func.drag_stop(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_anim_start(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
interface_scrollable: delete unnecessary smart callback call.
Summary:
When _elm_interface_scrollable_page_bring_in is called, page is not changed yet.
So "page,changed" smart callback is unnecessary.
Sometimes "page,changed" smart callback is called twice.
Because "drag,stop" and "anim,stop"is called it.
So I add updating current page code.
Test Plan:
elementary_test -> scroller
1. using wheel.
2. using "prev page" and "next page".
3. draging sceen
Reviewers: Hermet, singh.amitesh, cedric, raster, jaehwan, seoz
Differential Revision: https://phab.enlightenment.org/D3260
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-03 12:29:05 -08:00
|
|
|
sid->current_page.x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
sid->current_page.y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->cb_func.animate_start)
|
|
|
|
sid->cb_func.animate_start(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_anim_stop(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2013-05-15 14:56:04 -07:00
|
|
|
Evas_Coord x, y;
|
|
|
|
|
|
|
|
if (sid->cb_func.page_change)
|
|
|
|
{
|
|
|
|
x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
if ((x != sid->current_page.x) || (y != sid->current_page.y))
|
|
|
|
sid->cb_func.page_change(sid->obj, NULL);
|
interface_scrollable: delete unnecessary smart callback call.
Summary:
When _elm_interface_scrollable_page_bring_in is called, page is not changed yet.
So "page,changed" smart callback is unnecessary.
Sometimes "page,changed" smart callback is called twice.
Because "drag,stop" and "anim,stop"is called it.
So I add updating current page code.
Test Plan:
elementary_test -> scroller
1. using wheel.
2. using "prev page" and "next page".
3. draging sceen
Reviewers: Hermet, singh.amitesh, cedric, raster, jaehwan, seoz
Differential Revision: https://phab.enlightenment.org/D3260
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-03 12:29:05 -08:00
|
|
|
sid->current_page.x = x;
|
|
|
|
sid->current_page.y = y;
|
2013-05-15 14:56:04 -07:00
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->cb_func.animate_stop)
|
|
|
|
sid->cb_func.animate_stop(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
2013-04-15 21:27:55 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_policy_signal_emit(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if (sid->hbar_flags == ELM_SCROLLER_POLICY_ON)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show_always,hbar", "elm");
|
|
|
|
else if (sid->hbar_flags == ELM_SCROLLER_POLICY_OFF)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,hide,hbar", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show_notalways,hbar", "elm");
|
|
|
|
if (sid->vbar_flags == ELM_SCROLLER_POLICY_ON)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show_always,vbar", "elm");
|
|
|
|
else if (sid->vbar_flags == ELM_SCROLLER_POLICY_OFF)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,hide,vbar", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(sid->edje_obj, "elm,action,show_notalways,vbar", "elm");
|
|
|
|
edje_object_message_signal_process(sid->edje_obj);
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_reload_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2013-04-15 21:27:55 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
_elm_scroll_policy_signal_emit(sid);
|
2014-02-12 03:39:39 -08:00
|
|
|
_elm_scroll_scroll_bar_h_visibility_apply(sid);
|
|
|
|
_elm_scroll_scroll_bar_v_visibility_apply(sid);
|
2013-04-15 21:27:55 -07:00
|
|
|
}
|
|
|
|
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
static void
|
|
|
|
_elm_scroll_vbar_drag_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.vbar_drag)
|
|
|
|
sid->cb_func.vbar_drag(sid->obj, NULL);
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_vbar_press_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.vbar_press)
|
|
|
|
sid->cb_func.vbar_press(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_vbar_unpress_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.vbar_unpress)
|
|
|
|
sid->cb_func.vbar_unpress(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_v_start_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
_elm_scroll_drag_start(sid);
|
|
|
|
sid->freeze = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_v_stop_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
_elm_scroll_drag_stop(sid);
|
scroller: Fix freeze after dragging bars
The freeze property is a set() only but could internally
be reset to false, after dragging a vertical or horizontal slider.
Test scenario:
elementary_test -to scroller
Click Freeze, test the mouse wheel (can't do anything), drag a
scroller side bar, test the mouse wheel again.
Before this patch, the scroller would scroll. After the patch, the
scroller remains fixed, respecting the value of freeze.
FIXME: It is possible that the proper fix would be to disable
bars drag during freeze, but that is not the case currently.
NOTE: freeze, hold, movement_block, lock_x/y have very similar
meanings. The doc really needs clarification here, and some
property might be removed. Also, freeze and hold have no
getter, only a setter. drag_lock_x/y is part of elm_widget,
and not specific to scrollers.
2017-04-11 23:02:42 -07:00
|
|
|
sid->freeze = sid->freeze_want;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_v_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
}
|
|
|
|
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
static void
|
|
|
|
_elm_scroll_hbar_drag_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.hbar_drag)
|
|
|
|
sid->cb_func.hbar_drag(sid->obj, NULL);
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_hbar_press_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.hbar_press)
|
|
|
|
sid->cb_func.hbar_press(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_hbar_unpress_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.hbar_unpress)
|
|
|
|
sid->cb_func.hbar_unpress(sid->obj, NULL);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_h_start_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
_elm_scroll_drag_start(sid);
|
|
|
|
sid->freeze = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_h_stop_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
_elm_scroll_drag_stop(sid);
|
scroller: Fix freeze after dragging bars
The freeze property is a set() only but could internally
be reset to false, after dragging a vertical or horizontal slider.
Test scenario:
elementary_test -to scroller
Click Freeze, test the mouse wheel (can't do anything), drag a
scroller side bar, test the mouse wheel again.
Before this patch, the scroller would scroll. After the patch, the
scroller remains fixed, respecting the value of freeze.
FIXME: It is possible that the proper fix would be to disable
bars drag during freeze, but that is not the case currently.
NOTE: freeze, hold, movement_block, lock_x/y have very similar
meanings. The doc really needs clarification here, and some
property might be removed. Also, freeze and hold have no
getter, only a setter. drag_lock_x/y is part of elm_widget,
and not specific to scrollers.
2017-04-11 23:02:42 -07:00
|
|
|
sid->freeze = sid->freeze_want;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_edje_drag_h_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_read_and_update(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_size_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord *w, Evas_Coord *h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_viewport_geometry_get(const Eo *obj EINA_UNUSED,
|
entry: wrong viewport value calculation issue fix
Summary:
Issue: As entire scroller edje co-ordinates was being taken instead of the actual viewport value,
if in scroller edje more parts are added apart from just "elm.swallow.content", then the viewport value
set will be wrong. hence the selection handlers will not hide when they have to hide.
solution: Instead of taking scroller edje's geometry, get the actual viewport values.
To get viewport x,y a new scrollable interface is also added.
signed-off by: Shilpa Singh <shilpa.singh@samsung.com>
@fix
Test Plan: Selection handlers have to hide correctly when the text is scrolled in a scrolled entry, if the scroller edc of entry has more parts added other than elm.swallow.content, then when we scroll the selection handlers are not hidden correctly.
Reviewers: jaehwan, woohyun, seoz, Hermet, raster
CC: govi, rajeshps, thiepha
Differential Revision: https://phab.enlightenment.org/D674
2014-04-20 20:31:49 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
Evas_Coord *x,
|
|
|
|
Evas_Coord *y,
|
|
|
|
Evas_Coord *w,
|
|
|
|
Evas_Coord *h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (!sid->pan_obj || !sid->edje_obj) return;
|
|
|
|
|
|
|
|
edje_object_calc_force(sid->edje_obj);
|
entry: wrong viewport value calculation issue fix
Summary:
Issue: As entire scroller edje co-ordinates was being taken instead of the actual viewport value,
if in scroller edje more parts are added apart from just "elm.swallow.content", then the viewport value
set will be wrong. hence the selection handlers will not hide when they have to hide.
solution: Instead of taking scroller edje's geometry, get the actual viewport values.
To get viewport x,y a new scrollable interface is also added.
signed-off by: Shilpa Singh <shilpa.singh@samsung.com>
@fix
Test Plan: Selection handlers have to hide correctly when the text is scrolled in a scrolled entry, if the scroller edc of entry has more parts added other than elm.swallow.content, then when we scroll the selection handlers are not hidden correctly.
Reviewers: jaehwan, woohyun, seoz, Hermet, raster
CC: govi, rajeshps, thiepha
Differential Revision: https://phab.enlightenment.org/D674
2014-04-20 20:31:49 -07:00
|
|
|
evas_object_geometry_get(sid->pan_obj, x, y, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_min_limit(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool w, Eina_Bool h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-07-17 23:59:16 -07:00
|
|
|
if (!sid->edje_obj) return;
|
2012-07-18 10:09:51 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->cb_func.content_min_limit)
|
|
|
|
{
|
|
|
|
ERR("Content minimim size limiting is unimplemented -- you "
|
|
|
|
"must provide it yourself\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 23:59:16 -07:00
|
|
|
sid->min_w = !!w;
|
|
|
|
sid->min_h = !!h;
|
2012-07-18 10:09:51 -07:00
|
|
|
sid->cb_func.content_min_limit(sid->obj, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Coord
|
|
|
|
_elm_scroll_x_mirrored_get(const Evas_Object *obj,
|
|
|
|
Evas_Coord x)
|
|
|
|
{
|
elm_interface_scrollable: fix wrong mirrored calculation
Summary:
This Patch is regarding D2553, but funtionally independent patch.
D2557 is also related with this patch, so to test working fine,
need to install those all three patches.
1. _elm_interface_scrollable_content_region_show store wx
into scroll_interface_data without coverting mirrored_x.
fix to store wx to mirror-converted x if is_mirrored.
2. _elm_scroll_x_mirrored_get return mirroed_x after compare zero not minx.
so current mirrored_x couldn't be less then 0.
fix to check min not 0 for set return value.
3. _elm_scroll_x_mirrored_get calculation need to consider start position of scroller.
some scroller(e.g. gengrid) start from non-zero position, so calculation need to change
like below.
ret = (cw - (x + w - min));
@fix
Test Plan: You can test this after merge D2553 patch and D2557 and test gengrid2.
Reviewers: raster, Hermet, seoz, jaehwan, tanwar.umesh07, cedric
Subscribers: tanwar.umesh07, Jaehyun, anand.km, eagleeye, singh.amitesh
Differential Revision: https://phab.enlightenment.org/D2558
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-06-25 07:44:41 -07:00
|
|
|
Evas_Coord cw = 0, w = 0, min = 0, ret;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN_VAL(obj, sid, x);
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return 0;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &min, NULL);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
((Eo *)obj, NULL, NULL, &w, NULL);
|
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, NULL);
|
elm_interface_scrollable: fix wrong mirrored calculation
Summary:
This Patch is regarding D2553, but funtionally independent patch.
D2557 is also related with this patch, so to test working fine,
need to install those all three patches.
1. _elm_interface_scrollable_content_region_show store wx
into scroll_interface_data without coverting mirrored_x.
fix to store wx to mirror-converted x if is_mirrored.
2. _elm_scroll_x_mirrored_get return mirroed_x after compare zero not minx.
so current mirrored_x couldn't be less then 0.
fix to check min not 0 for set return value.
3. _elm_scroll_x_mirrored_get calculation need to consider start position of scroller.
some scroller(e.g. gengrid) start from non-zero position, so calculation need to change
like below.
ret = (cw - (x + w - min));
@fix
Test Plan: You can test this after merge D2553 patch and D2557 and test gengrid2.
Reviewers: raster, Hermet, seoz, jaehwan, tanwar.umesh07, cedric
Subscribers: tanwar.umesh07, Jaehyun, anand.km, eagleeye, singh.amitesh
Differential Revision: https://phab.enlightenment.org/D2558
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-06-25 07:44:41 -07:00
|
|
|
ret = cw - w - x + min + min;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
elm_interface_scrollable: fix wrong mirrored calculation
Summary:
This Patch is regarding D2553, but funtionally independent patch.
D2557 is also related with this patch, so to test working fine,
need to install those all three patches.
1. _elm_interface_scrollable_content_region_show store wx
into scroll_interface_data without coverting mirrored_x.
fix to store wx to mirror-converted x if is_mirrored.
2. _elm_scroll_x_mirrored_get return mirroed_x after compare zero not minx.
so current mirrored_x couldn't be less then 0.
fix to check min not 0 for set return value.
3. _elm_scroll_x_mirrored_get calculation need to consider start position of scroller.
some scroller(e.g. gengrid) start from non-zero position, so calculation need to change
like below.
ret = (cw - (x + w - min));
@fix
Test Plan: You can test this after merge D2553 patch and D2557 and test gengrid2.
Reviewers: raster, Hermet, seoz, jaehwan, tanwar.umesh07, cedric
Subscribers: tanwar.umesh07, Jaehyun, anand.km, eagleeye, singh.amitesh
Differential Revision: https://phab.enlightenment.org/D2558
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-06-25 07:44:41 -07:00
|
|
|
return (ret >= min) ? ret : min;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the wanted coordinates according to the x, y passed
|
|
|
|
* widget directionality, content size and etc. */
|
|
|
|
static void
|
|
|
|
_elm_scroll_wanted_coordinates_update(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
Evas_Coord x,
|
|
|
|
Evas_Coord y)
|
|
|
|
{
|
elm_interface_scrollable: fix wanted coordinate calculation
Summary:
boundary check of _elm_scroll_wanted_coordinates_update() is wrong.
boundary was checked with assumption that 0, 0 is top, left
however, 0, 0 could be different according to usages, in case of gengrid, 0, 0 was center left not top left)
Do not assume the min/max value, but use pan min/max value for boundary check
Fixes T1092
Test Plan: elementary_test -> grid -> uncheck multi select mode -> select first item -> click bring in -> resize window
Reviewers: raster, woohyun, seoz, zmike
CC: seoz
Maniphest Tasks: T1092
Differential Revision: https://phab.enlightenment.org/D720
2014-04-20 23:06:28 -07:00
|
|
|
Evas_Coord mx = 0, my = 0, minx = 0, miny = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
/* Update wx/y/w/h - and if the requested positions aren't legal
|
|
|
|
* adjust a bit. */
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &sid->ww, &sid->wh);
|
elm_interface_scrollable: fix wanted coordinate calculation
Summary:
boundary check of _elm_scroll_wanted_coordinates_update() is wrong.
boundary was checked with assumption that 0, 0 is top, left
however, 0, 0 could be different according to usages, in case of gengrid, 0, 0 was center left not top left)
Do not assume the min/max value, but use pan min/max value for boundary check
Fixes T1092
Test Plan: elementary_test -> grid -> uncheck multi select mode -> select first item -> click bring in -> resize window
Reviewers: raster, woohyun, seoz, zmike
CC: seoz
Maniphest Tasks: T1092
Differential Revision: https://phab.enlightenment.org/D720
2014-04-20 23:06:28 -07:00
|
|
|
|
2015-04-21 19:41:41 -07:00
|
|
|
if (x < minx && !sid->is_mirrored)
|
2015-01-23 19:01:03 -08:00
|
|
|
{
|
|
|
|
if (!sid->loop_h) sid->wx = minx;
|
|
|
|
else sid->wx = mx;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
else if (sid->is_mirrored)
|
|
|
|
sid->wx = _elm_scroll_x_mirrored_get(sid->obj, x);
|
2015-04-21 19:41:41 -07:00
|
|
|
else if (!sid->loop_h && (x > mx)) sid->wx = mx;
|
2017-04-12 00:59:14 -07:00
|
|
|
else if (sid->loop_h && x >= (sid->ww + mx)) sid->wx = minx;
|
elm_interface_scrollable: fix wanted coordinate calculation
Summary:
boundary check of _elm_scroll_wanted_coordinates_update() is wrong.
boundary was checked with assumption that 0, 0 is top, left
however, 0, 0 could be different according to usages, in case of gengrid, 0, 0 was center left not top left)
Do not assume the min/max value, but use pan min/max value for boundary check
Fixes T1092
Test Plan: elementary_test -> grid -> uncheck multi select mode -> select first item -> click bring in -> resize window
Reviewers: raster, woohyun, seoz, zmike
CC: seoz
Maniphest Tasks: T1092
Differential Revision: https://phab.enlightenment.org/D720
2014-04-20 23:06:28 -07:00
|
|
|
else sid->wx = x;
|
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
if (y < miny)
|
|
|
|
{
|
|
|
|
if (!sid->loop_v) sid->wy = miny;
|
|
|
|
else sid->wy = my;
|
|
|
|
}
|
|
|
|
else if (!sid->loop_v && (y > my)) sid->wy = my;
|
2017-04-12 00:59:14 -07:00
|
|
|
else if (sid->loop_v && y >= (sid->wh + my)) sid->wy = miny;
|
2012-07-04 14:41:01 -07:00
|
|
|
else sid->wy = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_momentum_end(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator)) return;
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord px = 0, py = 0;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, px, py);
|
|
|
|
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.bounce_x_hold = EINA_FALSE;
|
|
|
|
sid->down.bounce_y_hold = EINA_FALSE;
|
|
|
|
sid->down.ax = 0;
|
|
|
|
sid->down.ay = 0;
|
|
|
|
sid->down.dx = 0;
|
|
|
|
sid->down.dy = 0;
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->down.pdy = 0;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_bounce_x_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-06-20 07:31:31 -07:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(data, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
Evas_Coord x, y, dx, w, odx, ed, md;
|
|
|
|
double t, p, dt, pd, r;
|
|
|
|
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
dt = t - sid->down.anim_start2;
|
|
|
|
if (dt >= 0.0)
|
|
|
|
{
|
|
|
|
dt = dt / _elm_config->thumbscroll_bounce_friction;
|
|
|
|
odx = sid->down.b2x - sid->down.bx;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->down.momentum_animator && (w > abs(odx)))
|
|
|
|
{
|
|
|
|
pd = (double)odx / (double)w;
|
|
|
|
pd = (pd > 0) ? pd : -pd;
|
|
|
|
pd = 1.0 - ((1.0 - pd) * (1.0 - pd));
|
|
|
|
dt = dt / pd;
|
|
|
|
}
|
|
|
|
if (dt > 1.0) dt = 1.0;
|
|
|
|
p = 1.0 - ((1.0 - dt) * (1.0 - dt));
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
dx = (odx * p);
|
|
|
|
r = 1.0;
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2018-08-28 23:58:10 -07:00
|
|
|
ed = abs((int)(sid->down.dx * _elm_config->thumbscroll_momentum_friction - sid->down.b0x));
|
|
|
|
md = abs((int)(_elm_config->thumbscroll_momentum_friction * 5 * w));
|
2012-07-04 14:41:01 -07:00
|
|
|
if (ed > md) r = (double)(md) / (double)ed;
|
|
|
|
}
|
|
|
|
x = sid->down.b2x + (int)((double)(dx - odx) * r);
|
|
|
|
if (!sid->down.cancelled)
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (dt >= 1.0)
|
|
|
|
{
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
sid->down.bounce_x_hold = EINA_TRUE;
|
|
|
|
if ((!sid->down.bounce_y_animator) &&
|
|
|
|
(!sid->scrollto.y.animator))
|
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
_elm_scroll_momentum_end(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_bounce_y_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-06-20 07:31:31 -07:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(data, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
Evas_Coord x, y, dy, h, ody, ed, md;
|
|
|
|
double t, p, dt, pd, r;
|
|
|
|
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
dt = t - sid->down.anim_start3;
|
|
|
|
if (dt >= 0.0)
|
|
|
|
{
|
|
|
|
dt = dt / _elm_config->thumbscroll_bounce_friction;
|
|
|
|
ody = sid->down.b2y - sid->down.by;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, NULL, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->down.momentum_animator && (h > abs(ody)))
|
|
|
|
{
|
|
|
|
pd = (double)ody / (double)h;
|
|
|
|
pd = (pd > 0) ? pd : -pd;
|
|
|
|
pd = 1.0 - ((1.0 - pd) * (1.0 - pd));
|
|
|
|
dt = dt / pd;
|
|
|
|
}
|
|
|
|
if (dt > 1.0) dt = 1.0;
|
|
|
|
p = 1.0 - ((1.0 - dt) * (1.0 - dt));
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
dy = (ody * p);
|
|
|
|
r = 1.0;
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2018-08-28 23:58:10 -07:00
|
|
|
ed = abs((int)(sid->down.dy * _elm_config->thumbscroll_momentum_friction - sid->down.b0y));
|
|
|
|
md = abs((int)(_elm_config->thumbscroll_momentum_friction * 5 * h));
|
2012-07-04 14:41:01 -07:00
|
|
|
if (ed > md) r = (double)(md) / (double)ed;
|
|
|
|
}
|
|
|
|
y = sid->down.b2y + (int)((double)(dy - ody) * r);
|
|
|
|
if (!sid->down.cancelled)
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (dt >= 1.0)
|
|
|
|
{
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
sid->down.bounce_y_hold = EINA_TRUE;
|
|
|
|
if ((!sid->down.bounce_x_animator) &&
|
|
|
|
(!sid->scrollto.y.animator))
|
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
sid->down.pdy = 0;
|
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
_elm_scroll_momentum_end(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_bounce_eval(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord mx = 0, my = 0, px = 0, py = 0, bx, by, b2x, b2y, minx = 0, miny = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
|
|
|
if (sid->freeze) return;
|
|
|
|
if ((!sid->bouncemex) && (!sid->bouncemey)) return;
|
|
|
|
if (sid->down.now) return; // down bounce while still held down
|
|
|
|
if (sid->down.onhold_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2013-10-24 19:59:55 -07:00
|
|
|
if (sid->down.hold_animator)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2014-01-21 16:55:58 -08:00
|
|
|
ELM_SAFE_FREE(sid->down.hold_enterer, ecore_idle_enterer_del);
|
2013-10-24 20:36:28 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
bx = px;
|
|
|
|
by = py;
|
|
|
|
if (px < minx) px = minx;
|
|
|
|
if ((px - minx) > mx) px = mx + minx;
|
|
|
|
if (py < miny) py = miny;
|
|
|
|
if ((py - miny) > my) py = my + miny;
|
|
|
|
b2x = px;
|
|
|
|
b2y = py;
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if ((!sid->down.bounce_x_animator) && (!sid->bounce_animator_disabled))
|
|
|
|
{
|
|
|
|
if (sid->bouncemex)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.anim_start2 = ecore_loop_time_get();
|
|
|
|
sid->down.bx = bx;
|
|
|
|
sid->down.bx0 = bx;
|
|
|
|
sid->down.b2x = b2x;
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
sid->down.b0x = sid->down.ax;
|
|
|
|
else sid->down.b0x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if ((!sid->down.bounce_y_animator) && (!sid->bounce_animator_disabled))
|
|
|
|
{
|
|
|
|
if (sid->bouncemey)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.anim_start3 = ecore_loop_time_get();
|
|
|
|
sid->down.by = by;
|
|
|
|
sid->down.by0 = by;
|
|
|
|
sid->down.b2y = b2y;
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
sid->down.b0y = sid->down.ay;
|
|
|
|
else sid->down.b0y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_pos_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, x, y);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y, Eina_Bool sig)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-02-28 01:27:21 -08:00
|
|
|
Evas_Coord mx = 0, my = 0, px = 0, py = 0, spx = 0, spy = 0, minx = 0, miny = 0;
|
2015-01-23 19:01:03 -08:00
|
|
|
Evas_Coord cw = 0, ch = 0, pw = 0, ph = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
double vx, vy;
|
|
|
|
|
|
|
|
|
|
|
|
if (!sid->edje_obj || !sid->pan_obj) return;
|
|
|
|
|
|
|
|
// FIXME: allow for bounce outside of range
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2015-01-23 19:01:03 -08:00
|
|
|
evas_object_geometry_get(sid->pan_obj, NULL, NULL, &pw, &ph);
|
2013-05-17 07:30:42 -07:00
|
|
|
|
2013-10-09 07:29:35 -07:00
|
|
|
if (_paging_is_enabled(sid))
|
2013-05-17 07:30:42 -07:00
|
|
|
{
|
2017-04-12 00:59:14 -07:00
|
|
|
if (sid->page_snap_horiz && !sid->loop_h)
|
2013-10-09 07:29:35 -07:00
|
|
|
{
|
|
|
|
//we passed one page to the right
|
|
|
|
if (x > sid->current_page.x + sid->pagesize_h)
|
|
|
|
x = sid->current_page.x + sid->pagesize_h;
|
|
|
|
//we passed one page to the left
|
|
|
|
if (x < sid->current_page.x - sid->pagesize_h)
|
|
|
|
x = sid->current_page.x - sid->pagesize_h;
|
|
|
|
}
|
2017-04-12 00:59:14 -07:00
|
|
|
if (sid->page_snap_vert && !sid->loop_v)
|
2013-10-09 07:29:35 -07:00
|
|
|
{
|
|
|
|
//we passed one page to the bottom
|
|
|
|
if (y > sid->current_page.y + sid->pagesize_v)
|
|
|
|
y = sid->current_page.y + sid->pagesize_v;
|
|
|
|
//we passed one page to the top
|
|
|
|
if (y < sid->current_page.y - sid->pagesize_v)
|
|
|
|
y = sid->current_page.y - sid->pagesize_v;
|
|
|
|
}
|
2013-05-17 07:30:42 -07:00
|
|
|
}
|
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
if (sid->loop_h && cw > 0)
|
|
|
|
{
|
2015-08-28 02:08:14 -07:00
|
|
|
if (x < 0) x = cw + (x % cw);
|
|
|
|
else if (x >= cw) x = (x % cw);
|
2015-01-23 19:01:03 -08:00
|
|
|
}
|
|
|
|
if (sid->loop_v && ch > 0)
|
|
|
|
{
|
2015-08-28 02:08:14 -07:00
|
|
|
if (y < 0) y = ch + (y % ch);
|
|
|
|
else if (y >= ch) y = (y % ch);
|
2015-01-23 19:01:03 -08:00
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!_elm_config->thumbscroll_bounce_enable)
|
|
|
|
{
|
2013-05-17 07:30:42 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (x < minx) x = minx;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && (x - minx) > mx) x = mx + minx;
|
2012-07-04 14:41:01 -07:00
|
|
|
if (y < miny) y = miny;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v && (y - miny) > my) y = my + miny;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!sid->bounce_horiz)
|
|
|
|
{
|
|
|
|
if (x < minx) x = minx;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && (x - minx) > mx) x = mx + minx;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
if (!sid->bounce_vert)
|
|
|
|
{
|
|
|
|
if (y < miny) y = miny;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v && (y - miny) > my) y = my + miny;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_set(sid->pan_obj, x, y);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &spx, &spy);
|
2013-02-28 01:27:21 -08:00
|
|
|
|
|
|
|
if (mx > 0) vx = (double)(spx - minx) / (double)mx;
|
|
|
|
else vx = 0.0;
|
|
|
|
|
|
|
|
if (vx < 0.0) vx = 0.0;
|
|
|
|
else if (vx > 1.0)
|
|
|
|
vx = 1.0;
|
|
|
|
|
|
|
|
if (my > 0) vy = (double)(spy - miny) / (double)my;
|
|
|
|
else vy = 0.0;
|
|
|
|
|
|
|
|
if (vy < 0.0) vy = 0.0;
|
|
|
|
else if (vy > 1.0)
|
|
|
|
vy = 1.0;
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
|
|
|
}
|
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
if (_elm_scroll_has_bars(sid))
|
|
|
|
{
|
|
|
|
edje_object_part_drag_value_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0, vy);
|
|
|
|
edje_object_part_drag_value_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, vx, 0.0);
|
|
|
|
}
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && !sid->down.bounce_x_animator)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (((x < minx) && (0 <= sid->down.dx)) ||
|
|
|
|
((x > (mx + minx)) && (0 >= sid->down.dx)))
|
|
|
|
{
|
|
|
|
sid->bouncemex = EINA_TRUE;
|
|
|
|
_elm_scroll_bounce_eval(sid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
}
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v && !sid->down.bounce_y_animator)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (((y < miny) && (0 <= sid->down.dy)) ||
|
|
|
|
((y > (my + miny)) && (0 >= sid->down.dy)))
|
|
|
|
{
|
|
|
|
sid->bouncemey = EINA_TRUE;
|
|
|
|
_elm_scroll_bounce_eval(sid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-27 22:18:51 -08:00
|
|
|
if (sig)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-03-15 02:53:17 -07:00
|
|
|
if ((x != px) || (y != py))
|
|
|
|
{
|
|
|
|
if (sid->cb_func.scroll)
|
|
|
|
sid->cb_func.scroll(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
|
|
|
|
if (x < px)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.scroll_left)
|
|
|
|
sid->cb_func.scroll_left(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll,left", "elm");
|
|
|
|
}
|
|
|
|
if (x > px)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.scroll_right)
|
|
|
|
sid->cb_func.scroll_right(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll,right", "elm");
|
|
|
|
}
|
|
|
|
if (y < py)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.scroll_up)
|
|
|
|
sid->cb_func.scroll_up(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll,up", "elm");
|
|
|
|
}
|
|
|
|
if (y > py)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.scroll_down)
|
|
|
|
sid->cb_func.scroll_down(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll,down", "elm");
|
|
|
|
}
|
|
|
|
}
|
2013-02-27 22:18:51 -08:00
|
|
|
if (x != px)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-02-27 22:18:51 -08:00
|
|
|
if (x == minx)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.edge_left)
|
|
|
|
sid->cb_func.edge_left(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,edge,left", "elm");
|
|
|
|
}
|
|
|
|
if (x == (mx + minx))
|
|
|
|
{
|
|
|
|
if (sid->cb_func.edge_right)
|
|
|
|
sid->cb_func.edge_right(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,edge,right", "elm");
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-02-27 22:18:51 -08:00
|
|
|
if (y != py)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-02-27 22:18:51 -08:00
|
|
|
if (y == miny)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.edge_top)
|
|
|
|
sid->cb_func.edge_top(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,edge,top", "elm");
|
|
|
|
}
|
|
|
|
if (y == my + miny)
|
|
|
|
{
|
|
|
|
if (sid->cb_func.edge_bottom)
|
|
|
|
sid->cb_func.edge_bottom(obj, NULL);
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,edge,bottom", "elm");
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2013-02-27 22:18:51 -08:00
|
|
|
|
2012-08-07 03:20:30 -07:00
|
|
|
_elm_direction_arrows_eval(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-12-21 14:13:40 -08:00
|
|
|
_elm_interface_scrollable_efl_ui_i18n_mirrored_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool mirrored)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Evas_Coord wx;
|
|
|
|
|
2017-06-06 23:17:45 -07:00
|
|
|
if (!sid->edje_obj) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
mirrored = !!mirrored;
|
|
|
|
|
2017-06-06 23:17:45 -07:00
|
|
|
if (sid->is_mirrored == mirrored)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sid->is_mirrored = mirrored;
|
|
|
|
edje_object_mirrored_set(sid->edje_obj, mirrored);
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->is_mirrored)
|
|
|
|
wx = _elm_scroll_x_mirrored_get(sid->obj, sid->wx);
|
|
|
|
else
|
|
|
|
wx = sid->wx;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, wx, sid->wy, EINA_FALSE);
|
2018-02-14 18:14:52 -08:00
|
|
|
efl_ui_mirrored_set(efl_super(obj, ELM_INTERFACE_SCROLLABLE_MIXIN), mirrored);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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_scroll_content_region_show_internal(Evas_Object *obj,
|
|
|
|
Evas_Coord *_x,
|
|
|
|
Evas_Coord *_y,
|
|
|
|
Evas_Coord w,
|
|
|
|
Evas_Coord h)
|
|
|
|
{
|
2016-12-16 15:25:18 -08:00
|
|
|
Evas_Coord cw = 0, ch = 0, px = 0, py = 0, nx, ny,
|
2012-07-04 14:41:01 -07:00
|
|
|
minx = 0, miny = 0, pw = 0, ph = 0, x = *_x, y = *_y;
|
|
|
|
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN_VAL(obj, sid, EINA_FALSE);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return EINA_FALSE;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
evas_object_geometry_get(sid->pan_obj, NULL, NULL, &pw, &ph);
|
|
|
|
|
2016-12-16 15:25:18 -08:00
|
|
|
nx = x;
|
|
|
|
if ((x > px) && (w < pw))
|
|
|
|
{
|
|
|
|
if ((px + pw) < (x + w)) nx = x - pw + w;
|
|
|
|
else nx = px;
|
|
|
|
}
|
|
|
|
ny = y;
|
|
|
|
if ((y > py) && (h < ph))
|
|
|
|
{
|
|
|
|
if ((py + ph) < (y + h)) ny = y - ph + h;
|
|
|
|
else ny = py;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator) ||
|
|
|
|
(sid->scrollto.x.animator) || (sid->scrollto.y.animator))
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2014-01-09 22:42:12 -08:00
|
|
|
if (sid->down.bounce_x_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2014-01-09 22:42:12 -08:00
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
if (sid->down.bounce_y_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2014-01-09 22:42:12 -08:00
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
}
|
2013-10-24 19:59:55 -07:00
|
|
|
if (sid->down.hold_animator)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_drag_stop(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2014-01-21 16:55:58 -08:00
|
|
|
ELM_SAFE_FREE(sid->down.hold_enterer, ecore_idle_enterer_del);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.bounce_x_hold = EINA_FALSE;
|
|
|
|
sid->down.bounce_y_hold = EINA_FALSE;
|
|
|
|
sid->down.ax = 0;
|
|
|
|
sid->down.ay = 0;
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->down.pdy = 0;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
|
2013-04-07 21:44:39 -07:00
|
|
|
if (_paging_is_enabled(sid))
|
|
|
|
{
|
2013-04-09 19:22:52 -07:00
|
|
|
x = _elm_scroll_page_x_get(sid, nx - px, EINA_FALSE);
|
|
|
|
y = _elm_scroll_page_y_get(sid, ny - py, EINA_FALSE);
|
2013-04-07 21:44:39 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = nx;
|
|
|
|
y = ny;
|
|
|
|
}
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h)
|
|
|
|
{
|
|
|
|
if ((x + pw) > cw) x = cw - pw;
|
|
|
|
if (x < minx) x = minx;
|
|
|
|
}
|
|
|
|
if (!sid->loop_v)
|
|
|
|
{
|
|
|
|
if ((y + ph) > ch) y = ch - ph;
|
|
|
|
if (y < miny) y = miny;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if ((x == px) && (y == py)) return EINA_FALSE;
|
|
|
|
*_x = x;
|
|
|
|
*_y = y;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_region_get(const Eo *obj, Elm_Scrollable_Smart_Interface_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
2013-05-24 06:23:28 -07:00
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(obj, x, y);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(obj, NULL, NULL, w, h);
|
2013-05-24 06:23:28 -07:00
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
/* 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. */
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_region_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(obj, x, y, EINA_FALSE);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.sx = x;
|
|
|
|
sid->down.sy = y;
|
|
|
|
sid->down.x = sid->down.history[0].x;
|
|
|
|
sid->down.y = sid->down.history[0].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set should be used for setting the wanted position, for example a
|
|
|
|
* user scroll or moving the cursor in an entry. */
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_region_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
elm_interface_scrollable: fix wrong mirrored calculation
Summary:
This Patch is regarding D2553, but funtionally independent patch.
D2557 is also related with this patch, so to test working fine,
need to install those all three patches.
1. _elm_interface_scrollable_content_region_show store wx
into scroll_interface_data without coverting mirrored_x.
fix to store wx to mirror-converted x if is_mirrored.
2. _elm_scroll_x_mirrored_get return mirroed_x after compare zero not minx.
so current mirrored_x couldn't be less then 0.
fix to check min not 0 for set return value.
3. _elm_scroll_x_mirrored_get calculation need to consider start position of scroller.
some scroller(e.g. gengrid) start from non-zero position, so calculation need to change
like below.
ret = (cw - (x + w - min));
@fix
Test Plan: You can test this after merge D2553 patch and D2557 and test gengrid2.
Reviewers: raster, Hermet, seoz, jaehwan, tanwar.umesh07, cedric
Subscribers: tanwar.umesh07, Jaehyun, anand.km, eagleeye, singh.amitesh
Differential Revision: https://phab.enlightenment.org/D2558
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-06-25 07:44:41 -07:00
|
|
|
sid->wx = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->wy = y;
|
|
|
|
sid->ww = w;
|
|
|
|
sid->wh = h;
|
|
|
|
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.sx = x;
|
|
|
|
sid->down.sy = y;
|
|
|
|
sid->down.x = sid->down.history[0].x;
|
|
|
|
sid->down.y = sid->down.history[0].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_wanted_region_set(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Coord ww, wh, wx;
|
2017-02-19 18:31:12 -08:00
|
|
|
Evas_Coord mx = 0, my = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
wx = sid->wx;
|
|
|
|
|
|
|
|
if (sid->down.now || sid->down.momentum_animator ||
|
|
|
|
sid->down.bounce_x_animator || sid->down.bounce_y_animator ||
|
2013-10-24 19:59:55 -07:00
|
|
|
sid->down.hold_animator || sid->down.onhold_animator ||
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->scrollto.x.animator || sid->scrollto.y.animator)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sid->content_info.resized = EINA_FALSE;
|
|
|
|
|
|
|
|
/* Flip to RTL cords only if init in RTL mode */
|
|
|
|
if (sid->is_mirrored)
|
|
|
|
wx = _elm_scroll_x_mirrored_get(obj, sid->wx);
|
|
|
|
|
|
|
|
if (sid->ww == -1)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(obj, NULL, NULL, &ww, &wh);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ww = sid->ww;
|
|
|
|
wh = sid->wh;
|
|
|
|
}
|
|
|
|
|
2017-02-19 18:31:12 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
|
|
|
|
wx += (mx - sid->prev_cw) * sid->gravity_x;
|
|
|
|
sid->wy += (my - sid->prev_ch) * sid->gravity_y;
|
2016-09-21 04:44:53 -07:00
|
|
|
|
2017-02-19 18:31:12 -08:00
|
|
|
sid->prev_cw = mx;
|
|
|
|
sid->prev_ch = my;
|
2016-09-21 04:44:53 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_region_set(obj, wx, sid->wy, ww, wh);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2017-12-11 11:46:33 -08:00
|
|
|
static Eina_Value
|
|
|
|
_scroll_wheel_post_event_job(void *data, const Eina_Value v,
|
|
|
|
const Eina_Future *dead EINA_UNUSED)
|
2017-04-11 22:17:09 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
2017-04-12 00:59:14 -07:00
|
|
|
// Animations are disabled if we are here
|
2017-04-11 22:17:09 -07:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, sid->wx, sid->wy, EINA_TRUE);
|
2017-04-12 00:59:14 -07:00
|
|
|
if (_paging_is_enabled(sid))
|
|
|
|
{
|
|
|
|
sid->current_page.x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
sid->current_page.y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
}
|
2017-12-11 11:46:33 -08:00
|
|
|
return v;
|
2017-04-11 22:17:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_scroll_wheel_post_event_go(Elm_Scrollable_Smart_Interface_Data *sid, int x, int y)
|
|
|
|
{
|
|
|
|
if (sid->hold || sid->freeze) return;
|
|
|
|
_elm_scroll_wanted_coordinates_update(sid, x, y);
|
|
|
|
if (_elm_config->scroll_animation_disable)
|
|
|
|
{
|
2017-12-11 11:46:33 -08:00
|
|
|
Eina_Future *f;
|
|
|
|
|
2017-12-11 13:51:52 -08:00
|
|
|
f = eina_future_then(efl_loop_job(efl_loop_get(sid->obj)),
|
2018-11-07 06:52:41 -08:00
|
|
|
_scroll_wheel_post_event_job, sid, NULL);
|
2018-11-21 17:33:10 -08:00
|
|
|
efl_future_then(sid->obj, f);
|
2017-04-11 22:17:09 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x);
|
|
|
|
_elm_scroll_scroll_to_y(sid, _elm_config->bring_in_scroll_friction, y);
|
|
|
|
}
|
|
|
|
}
|
2015-08-07 01:27:30 -07:00
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_scroll_wheel_post_event_cb(void *data, Evas *e EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-08-07 01:27:30 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Event_Mouse_Wheel *ev = sid->event_info;
|
|
|
|
|
2012-12-06 17:37:04 -08:00
|
|
|
Evas_Coord x = 0, y = 0, vw = 0, vh = 0, cw = 0, ch = 0;
|
2014-01-13 23:56:52 -08:00
|
|
|
int pagenumber_h = 0, pagenumber_v = 0;
|
2015-02-12 20:14:07 -08:00
|
|
|
int mx = 0, my = 0, minx = 0, miny = 0;
|
2017-04-11 19:31:21 -07:00
|
|
|
Eina_Bool hold = EINA_FALSE;
|
2015-07-07 03:35:48 -07:00
|
|
|
Evas_Coord pwx, pwy;
|
|
|
|
double t;
|
2015-08-07 01:27:30 -07:00
|
|
|
int direction;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2017-04-11 19:31:21 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ev, EINA_TRUE);
|
|
|
|
|
|
|
|
sid->event_info = NULL;
|
2012-07-04 14:41:01 -07:00
|
|
|
direction = ev->direction;
|
2013-05-09 12:26:29 -07:00
|
|
|
|
2015-07-07 03:35:48 -07:00
|
|
|
pwx = sid->wx;
|
|
|
|
pwy = sid->wy;
|
2013-05-09 12:26:29 -07:00
|
|
|
|
2017-04-11 19:31:21 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
2015-08-07 01:27:30 -07:00
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
2012-12-06 00:25:53 -08:00
|
|
|
direction = !direction;
|
2015-08-07 01:27:30 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2015-02-12 20:14:07 -08:00
|
|
|
if (sid->scrollto.x.animator) x = sid->scrollto.x.end;
|
|
|
|
if (sid->scrollto.y.animator) y = sid->scrollto.y.end;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2015-02-12 20:14:07 -08:00
|
|
|
if (x < minx) x = minx;
|
|
|
|
if (x > mx) x = mx;
|
|
|
|
if (y < miny) y = miny;
|
|
|
|
if (y > my) y = my;
|
|
|
|
|
2015-07-07 03:35:48 -07:00
|
|
|
t = ecore_loop_time_get();
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator) ||
|
|
|
|
(sid->scrollto.x.animator) || (sid->scrollto.y.animator))
|
|
|
|
{
|
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
}
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->down.bounce_x_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
if (sid->down.bounce_y_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &vw, &vh);
|
2013-03-22 21:27:21 -07:00
|
|
|
if (sid->pan_obj)
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
2014-01-13 23:56:52 -08:00
|
|
|
if (!_paging_is_enabled(sid))
|
2012-12-06 17:37:04 -08:00
|
|
|
{
|
2015-02-12 20:14:07 -08:00
|
|
|
int d = ev->z;
|
|
|
|
double delta_t = (double)(ev->timestamp - sid->last_wheel) / 1000.0;
|
|
|
|
double mul;
|
|
|
|
|
2016-08-02 01:30:34 -07:00
|
|
|
if (delta_t > 0.2) sid->last_wheel_mul = 0.0;
|
|
|
|
if (delta_t > 0.2) delta_t = 0.2;
|
2016-02-18 09:44:43 -08:00
|
|
|
mul = 1.0 + (_elm_config->scroll_accel_factor * ((0.2 - delta_t) / 0.2));
|
2016-08-02 01:30:34 -07:00
|
|
|
mul = mul * (1.0 + (0.15 * sid->last_wheel_mul));
|
|
|
|
d *= mul;
|
2015-02-12 20:14:07 -08:00
|
|
|
sid->last_wheel = ev->timestamp;
|
2016-08-02 01:30:34 -07:00
|
|
|
sid->last_wheel_mul = mul;
|
2017-04-11 22:17:09 -07:00
|
|
|
|
2014-01-13 23:56:52 -08:00
|
|
|
if (!direction)
|
|
|
|
{
|
2017-04-11 22:17:09 -07:00
|
|
|
if ((ch > vh) || (cw <= vw))
|
|
|
|
y += d * sid->step.y;
|
2017-04-11 19:31:21 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
x += d * sid->step.x;
|
|
|
|
direction = 1;
|
|
|
|
}
|
2014-01-13 23:56:52 -08:00
|
|
|
}
|
2017-04-11 19:31:21 -07:00
|
|
|
else
|
2014-01-13 23:56:52 -08:00
|
|
|
{
|
2017-04-11 22:17:09 -07:00
|
|
|
if ((cw > vw) || (ch <= vh))
|
|
|
|
x += d * sid->step.x;
|
2017-04-11 19:31:21 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
y += d * sid->step.y;
|
|
|
|
direction = 0;
|
|
|
|
}
|
2014-01-13 23:56:52 -08:00
|
|
|
}
|
2017-04-11 22:17:09 -07:00
|
|
|
_scroll_wheel_post_event_go(sid, x, y);
|
2012-12-06 17:37:04 -08:00
|
|
|
}
|
2014-01-13 23:56:52 -08:00
|
|
|
else
|
2012-12-06 17:37:04 -08:00
|
|
|
{
|
2017-04-12 00:59:14 -07:00
|
|
|
int wx = x, wy = y;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_current_page_get(sid->obj, &pagenumber_h, &pagenumber_v);
|
2014-01-13 23:56:52 -08:00
|
|
|
if (!direction)
|
|
|
|
{
|
2017-04-11 22:17:09 -07:00
|
|
|
if ((ch > vh) || (cw <= vw))
|
2017-04-12 00:59:14 -07:00
|
|
|
wy = (pagenumber_v + (1 * ev->z)) * sid->pagesize_v;
|
2014-01-13 23:56:52 -08:00
|
|
|
else
|
2017-04-11 22:17:09 -07:00
|
|
|
{
|
2017-04-12 00:59:14 -07:00
|
|
|
wx = (pagenumber_h + (1 * ev->z)) * sid->pagesize_h;
|
2017-04-11 22:17:09 -07:00
|
|
|
direction = 1;
|
|
|
|
}
|
2014-01-13 23:56:52 -08:00
|
|
|
}
|
2017-04-11 19:31:21 -07:00
|
|
|
else
|
2014-01-13 23:56:52 -08:00
|
|
|
{
|
2017-04-11 22:17:09 -07:00
|
|
|
if ((cw > vw) || (ch <= vh))
|
2017-04-12 00:59:14 -07:00
|
|
|
wx = (pagenumber_h + (1 * ev->z)) * sid->pagesize_h;
|
2014-01-13 23:56:52 -08:00
|
|
|
else
|
2017-04-11 22:17:09 -07:00
|
|
|
{
|
2017-04-12 00:59:14 -07:00
|
|
|
wy = (pagenumber_v + (1 * ev->z)) * sid->pagesize_v;
|
2017-04-11 22:17:09 -07:00
|
|
|
direction = 0;
|
|
|
|
}
|
2014-01-13 23:56:52 -08:00
|
|
|
}
|
2017-04-12 00:59:14 -07:00
|
|
|
|
|
|
|
// Snap to first or last page before looping if not smooth
|
|
|
|
if (_elm_config->scroll_animation_disable)
|
|
|
|
{
|
|
|
|
if (direction && sid->loop_h)
|
|
|
|
{
|
|
|
|
if (sid->page_snap_horiz)
|
|
|
|
{
|
|
|
|
if ((x == mx) && (wx > mx)) wx = minx;
|
|
|
|
else if ((x == minx) && (wx < minx)) wx = mx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((x < mx) && (wx > mx)) wx = mx;
|
|
|
|
else if ((x > minx) && (wx < minx)) wx = minx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!direction && sid->loop_v)
|
|
|
|
{
|
|
|
|
if (sid->page_snap_vert)
|
|
|
|
{
|
|
|
|
if ((y == my) && (wy > my)) wy = miny;
|
|
|
|
else if ((y == miny) && (wy < miny)) wy = my;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((y < my) && (wy > my)) wy = my;
|
|
|
|
else if ((y > miny) && (wy < miny)) wy = miny;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_scroll_wheel_post_event_go(sid, wx, wy);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2015-07-07 03:35:48 -07:00
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
if ((pwx != sid->wx) ||
|
|
|
|
(((t - sid->down.last_time_x_wheel) < 0.5) &&
|
|
|
|
(sid->down.last_hold_x_wheel)))
|
|
|
|
{
|
|
|
|
sid->down.last_hold_x_wheel = EINA_TRUE;
|
2017-04-11 19:31:21 -07:00
|
|
|
hold = EINA_TRUE;
|
2015-07-07 03:35:48 -07:00
|
|
|
}
|
|
|
|
else sid->down.last_hold_x_wheel = EINA_FALSE;
|
|
|
|
sid->down.last_time_x_wheel = t;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((pwy != sid->wy) ||
|
|
|
|
(((t - sid->down.last_time_y_wheel) < 0.5) &&
|
|
|
|
(sid->down.last_hold_y_wheel)))
|
|
|
|
{
|
|
|
|
sid->down.last_hold_y_wheel = EINA_TRUE;
|
2017-04-11 19:31:21 -07:00
|
|
|
hold = EINA_TRUE;
|
2015-07-07 03:35:48 -07:00
|
|
|
}
|
|
|
|
else sid->down.last_hold_y_wheel = EINA_FALSE;
|
|
|
|
sid->down.last_time_y_wheel = t;
|
|
|
|
}
|
2015-08-07 01:27:30 -07:00
|
|
|
|
2017-04-11 19:31:21 -07:00
|
|
|
return !hold;
|
2015-08-07 01:27:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_wheel_event_cb(void *data,
|
|
|
|
Evas *e,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid;
|
|
|
|
Evas_Event_Mouse_Wheel *ev;
|
|
|
|
int direction;
|
|
|
|
|
|
|
|
sid = data;
|
|
|
|
ev = event_info;
|
|
|
|
sid->event_info = event_info;
|
|
|
|
direction = ev->direction;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
|
|
|
if ((evas_key_modifier_is_set(ev->modifiers, "Control")) ||
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Alt")) ||
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Meta")) ||
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Hyper")) ||
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Super")))
|
|
|
|
return;
|
|
|
|
if (direction)
|
|
|
|
{
|
2017-08-29 01:49:38 -07:00
|
|
|
if (sid->block & EFL_UI_SCROLL_BLOCK_HORIZONTAL) return;
|
2015-08-07 01:27:30 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-29 01:49:38 -07:00
|
|
|
if (sid->block & EFL_UI_SCROLL_BLOCK_VERTICAL) return;
|
2015-08-07 01:27:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
evas_post_event_callback_push(e, _scroll_wheel_post_event_cb, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_scroll_post_event_up(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->obj)
|
|
|
|
{
|
2018-05-25 10:04:49 -07:00
|
|
|
elm_widget_scroll_lock_set(sid->obj, EFL_UI_SCROLL_BLOCK_NONE);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2018-05-25 10:04:49 -07:00
|
|
|
return EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_paging_is_enabled(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
if ((sid->pagerel_h == 0.0) && (!sid->pagesize_h) &&
|
|
|
|
(sid->pagerel_v == 0.0) && (!sid->pagesize_v))
|
|
|
|
return EINA_FALSE;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_momentum_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2018-08-29 10:20:53 -07:00
|
|
|
double t, dt, p;
|
2012-07-04 14:41:01 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Coord x, y, dx, dy, px, py, maxx, maxy, minx, miny;
|
|
|
|
Eina_Bool no_bounce_x_end = EINA_FALSE, no_bounce_y_end = EINA_FALSE;
|
|
|
|
|
2013-12-03 04:40:09 -08:00
|
|
|
if (!sid->pan_obj)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2013-12-03 04:40:09 -08:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
t = ecore_loop_time_get();
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
if (sid->down.anim_dur == 0) dt = 1.0;
|
|
|
|
else dt = (t - sid->down.anim_start) / sid->down.anim_dur;
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (dt >= 0.0)
|
|
|
|
{
|
|
|
|
if (dt > 1.0) dt = 1.0;
|
|
|
|
p = 1.0 - ((1.0 - dt) * (1.0 - dt));
|
2018-08-28 23:58:10 -07:00
|
|
|
dx = sid->down.dx * p;
|
|
|
|
dy = sid->down.dy * p;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.ax = dx;
|
|
|
|
sid->down.ay = dy;
|
|
|
|
x = sid->down.sx - dx;
|
|
|
|
y = sid->down.sy - dy;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((sid->down.bounce_x_animator) ||
|
|
|
|
(sid->down.bounce_x_hold))
|
|
|
|
{
|
|
|
|
sid->down.bx = sid->down.bx0 - dx + sid->down.b0x;
|
|
|
|
x = px;
|
|
|
|
}
|
|
|
|
if ((sid->down.bounce_y_animator) ||
|
|
|
|
(sid->down.bounce_y_hold))
|
|
|
|
{
|
|
|
|
sid->down.by = sid->down.by0 - dy + sid->down.b0y;
|
|
|
|
y = py;
|
|
|
|
}
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, x, y);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &maxx, &maxy);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2013-04-07 16:40:24 -07:00
|
|
|
|
|
|
|
if (!_elm_config->thumbscroll_bounce_enable || !sid->bounce_horiz)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x <= minx) no_bounce_x_end = EINA_TRUE;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && (x - minx) >= maxx) no_bounce_x_end = EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-04-07 16:40:24 -07:00
|
|
|
if (!_elm_config->thumbscroll_bounce_enable || !sid->bounce_vert)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (y <= miny) no_bounce_y_end = EINA_TRUE;
|
2015-06-03 05:30:49 -07:00
|
|
|
if (!sid->loop_v && (y - miny) >= maxy) no_bounce_y_end = EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
if ((dt >= 1.0) ||
|
|
|
|
((sid->down.bounce_x_hold) && (sid->down.bounce_y_hold)) ||
|
|
|
|
(no_bounce_x_end && no_bounce_y_end))
|
|
|
|
{
|
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.bounce_x_hold = EINA_FALSE;
|
|
|
|
sid->down.bounce_y_hold = EINA_FALSE;
|
|
|
|
sid->down.ax = 0;
|
|
|
|
sid->down.ay = 0;
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->down.pdy = 0;
|
2018-08-28 23:58:10 -07:00
|
|
|
sid->down.anim_dur = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Coord
|
|
|
|
_elm_scroll_page_x_get(Elm_Scrollable_Smart_Interface_Data *sid,
|
2013-04-09 19:22:52 -07:00
|
|
|
int offset, Eina_Bool limit)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-04-05 21:06:43 -07:00
|
|
|
Evas_Coord x, y, w, h, dx, cw, ch, minx = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return 0;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (sid->pagerel_h > 0.0)
|
|
|
|
sid->pagesize_h = w * sid->pagerel_h;
|
2013-04-05 21:06:43 -07:00
|
|
|
|
2013-04-09 19:22:52 -07:00
|
|
|
if (!limit)
|
|
|
|
x += offset;
|
2013-04-05 21:06:43 -07:00
|
|
|
else
|
2013-04-09 19:22:52 -07:00
|
|
|
{
|
|
|
|
dx = (sid->pagesize_h * ((double)sid->page_limit_h - 0.5));
|
|
|
|
|
|
|
|
if (offset > 0)
|
|
|
|
x += (abs(offset) < dx ? offset : dx);
|
|
|
|
else
|
2013-12-03 06:49:30 -08:00
|
|
|
x += (abs(offset) < dx ? offset : -(dx + 1));
|
2013-04-09 19:22:52 -07:00
|
|
|
}
|
2013-04-05 21:06:43 -07:00
|
|
|
|
2017-01-15 21:20:04 -08:00
|
|
|
if (sid->is_mirrored) x += w;
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->pagesize_h > 0)
|
|
|
|
{
|
2015-08-28 05:12:30 -07:00
|
|
|
if (x >= 0)
|
|
|
|
x = x + (sid->pagesize_h * 0.5);
|
|
|
|
else if (x < 0 && sid->loop_h)
|
|
|
|
x = x - (sid->pagesize_h * 0.5);
|
2012-07-04 14:41:01 -07:00
|
|
|
x = x / (sid->pagesize_h);
|
|
|
|
x = x * (sid->pagesize_h);
|
|
|
|
}
|
2017-01-15 21:20:04 -08:00
|
|
|
if (sid->is_mirrored) x -= w;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h)
|
|
|
|
{
|
|
|
|
if ((x + w) > cw) x = cw - w;
|
|
|
|
if (x < minx) x = minx;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Coord
|
|
|
|
_elm_scroll_page_y_get(Elm_Scrollable_Smart_Interface_Data *sid,
|
2013-04-09 19:22:52 -07:00
|
|
|
int offset, Eina_Bool limit)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord x, y, w = 0, h = 0, dy, cw = 0, ch = 0, miny = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return 0;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, NULL, &miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (sid->pagerel_v > 0.0)
|
|
|
|
sid->pagesize_v = h * sid->pagerel_v;
|
2013-04-05 21:06:43 -07:00
|
|
|
|
2013-04-09 19:22:52 -07:00
|
|
|
if (!limit)
|
|
|
|
y += offset;
|
2013-04-05 21:06:43 -07:00
|
|
|
else
|
2013-04-09 19:22:52 -07:00
|
|
|
{
|
|
|
|
dy = (sid->pagesize_v * ((double)sid->page_limit_v - 0.5));
|
|
|
|
|
|
|
|
if (offset > 0)
|
|
|
|
y += (abs(offset) < dy ? offset : dy);
|
|
|
|
else
|
2013-12-03 06:49:30 -08:00
|
|
|
y += (abs(offset) < dy ? offset : -(dy + 1));
|
2013-04-09 19:22:52 -07:00
|
|
|
}
|
2013-04-05 21:06:43 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->pagesize_v > 0)
|
|
|
|
{
|
2015-08-28 05:12:30 -07:00
|
|
|
if (y >= 0)
|
|
|
|
y = y + (sid->pagesize_v * 0.5);
|
|
|
|
else if (y < 0 && sid->loop_v)
|
|
|
|
y = y - (sid->pagesize_v * 0.5);
|
2012-07-04 14:41:01 -07:00
|
|
|
y = y / (sid->pagesize_v);
|
|
|
|
y = y * (sid->pagesize_v);
|
|
|
|
}
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v)
|
|
|
|
{
|
|
|
|
if ((y + h) > ch) y = ch - h;
|
|
|
|
if (y < miny) y = miny;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_scroll_to_x_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Coord px, py;
|
|
|
|
double t, tt;
|
|
|
|
|
2016-01-26 15:51:49 -08:00
|
|
|
if (!sid->pan_obj) goto on_end;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
tt = (t - sid->scrollto.x.t_start) /
|
|
|
|
(sid->scrollto.x.t_end - sid->scrollto.x.t_start);
|
|
|
|
tt = 1.0 - tt;
|
|
|
|
tt = 1.0 - (tt * tt);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
px = (sid->scrollto.x.start * (1.0 - tt)) +
|
|
|
|
(sid->scrollto.x.end * tt);
|
|
|
|
if (t >= sid->scrollto.x.t_end)
|
|
|
|
{
|
|
|
|
px = sid->scrollto.x.end;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, px, py, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.sx = px;
|
|
|
|
sid->down.x = sid->down.history[0].x;
|
2013-02-21 01:36:14 -08:00
|
|
|
sid->down.pdx = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, px, py);
|
|
|
|
if ((!sid->scrollto.y.animator) && (!sid->down.bounce_y_animator))
|
|
|
|
_elm_scroll_anim_stop(sid);
|
2016-01-26 15:51:49 -08:00
|
|
|
goto on_end;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, px, py, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, px, py);
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2016-01-26 15:51:49 -08:00
|
|
|
|
|
|
|
on_end:
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_scroll_to_y_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Coord px, py;
|
|
|
|
double t, tt;
|
|
|
|
|
2016-01-26 15:51:49 -08:00
|
|
|
if (!sid->pan_obj) goto on_end;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
tt = (t - sid->scrollto.y.t_start) /
|
|
|
|
(sid->scrollto.y.t_end - sid->scrollto.y.t_start);
|
|
|
|
tt = 1.0 - tt;
|
|
|
|
tt = 1.0 - (tt * tt);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
py = (sid->scrollto.y.start * (1.0 - tt)) +
|
|
|
|
(sid->scrollto.y.end * tt);
|
|
|
|
if (t >= sid->scrollto.y.t_end)
|
|
|
|
{
|
|
|
|
py = sid->scrollto.y.end;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, px, py, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.sy = py;
|
|
|
|
sid->down.y = sid->down.history[0].y;
|
2013-02-21 01:36:14 -08:00
|
|
|
sid->down.pdy = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, px, py);
|
|
|
|
if ((!sid->scrollto.x.animator) && (!sid->down.bounce_x_animator))
|
|
|
|
_elm_scroll_anim_stop(sid);
|
2016-01-26 15:51:49 -08:00
|
|
|
goto on_end;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, px, py, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, px, py);
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2016-01-26 15:51:49 -08:00
|
|
|
|
|
|
|
on_end:
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_to_y(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
double t_in,
|
|
|
|
Evas_Coord pos_y)
|
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord px = 0, py = 0, x, y, w, h;
|
2012-07-04 14:41:01 -07:00
|
|
|
double t;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
|
|
|
if (sid->freeze) return;
|
|
|
|
if (t_in <= 0.0)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
y = pos_y;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_region_set(sid->obj, x, y, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
t = ecore_loop_time_get();
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2016-07-29 01:28:27 -07:00
|
|
|
if (py == pos_y) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->scrollto.y.start = py;
|
|
|
|
sid->scrollto.y.end = pos_y;
|
|
|
|
sid->scrollto.y.t_start = t;
|
|
|
|
sid->scrollto.y.t_end = t + t_in;
|
|
|
|
if (!sid->scrollto.y.animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->scrollto.x.animator)
|
|
|
|
_elm_scroll_anim_start(sid);
|
|
|
|
}
|
|
|
|
if (sid->down.bounce_y_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_momentum_end(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_to_x(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
double t_in,
|
|
|
|
Evas_Coord pos_x)
|
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord px = 0, py = 0, x, y, w, h;
|
2012-07-04 14:41:01 -07:00
|
|
|
double t;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
|
|
|
if (sid->freeze) return;
|
|
|
|
if (t_in <= 0.0)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
x = pos_x;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_region_set
|
|
|
|
(sid->obj, x, y, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
t = ecore_loop_time_get();
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2016-07-29 01:28:27 -07:00
|
|
|
if (px == pos_x) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->scrollto.x.start = px;
|
|
|
|
sid->scrollto.x.end = pos_x;
|
|
|
|
sid->scrollto.x.t_start = t;
|
|
|
|
sid->scrollto.x.t_end = t + t_in;
|
|
|
|
if (!sid->scrollto.x.animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->scrollto.y.animator)
|
|
|
|
_elm_scroll_anim_start(sid);
|
|
|
|
}
|
|
|
|
if (sid->down.bounce_x_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_momentum_end(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2018-08-28 23:58:10 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_scroll_running_momentum_speed_get(Elm_Scrollable_Smart_Interface_Data *sid, double *vx, double *vy)
|
|
|
|
{
|
|
|
|
double p = 0;
|
|
|
|
int remain_x = 0, remain_y = 0;
|
|
|
|
double remain_dur = 0;
|
|
|
|
|
|
|
|
p = (ecore_loop_time_get() - sid->down.anim_start) / sid->down.anim_dur;
|
|
|
|
|
|
|
|
// if momentum animation is not running now
|
|
|
|
if ( p > 1.0 || p < 0)
|
|
|
|
{
|
2018-08-31 01:46:25 -07:00
|
|
|
if (vx) *vx = 0;
|
elm_interface_scrollable: fix using wrong variable.
Summary:
vy isn't initialized when p >1.0 or p<0.
this function is for finding out a current animating speed of momentum scrolling.
and a caller of this function calls this function by reference(vx, vy)
so that if progress ratio is not between 0 and 1, vx, vy must be zero.
The issue was detected by coverity check.
It may not discovered any issues yet, but the typo is too obvious, so need to fix the right value.
Test Plan: This is coverity issue.
Reviewers: akanad, Hermet, SanghyeonLee
Subscribers: segfaultxavi, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D7114
2018-09-27 23:44:58 -07:00
|
|
|
if (vy) *vy = 0;
|
2018-08-28 23:58:10 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate current velecity from remain distance and time
|
|
|
|
remain_x = sid->down.dx - sid->down.dx * p;
|
|
|
|
remain_y = sid->down.dy - sid->down.dy * p;
|
|
|
|
remain_dur = sid->down.anim_dur - sid->down.anim_dur * p;
|
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (vx) *vx = remain_x / remain_dur;
|
|
|
|
if (vy) *vy = remain_y / remain_dur;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_scroll_momentum_calc(int dx, int dy, double dt, double *vx, double *vy, int *dist_x, int *dist_y, double *dur)
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
double vel = 0, vel_x = 0, vel_y = 0;
|
|
|
|
double fvel = 0, fvel_x = 0, fvel_y = 0;
|
|
|
|
int distance_x = 0 , distance_y = 0;
|
|
|
|
int sign_dx = 0, sign_dy = 0;
|
|
|
|
int sign_vx = 0, sign_vy = 0;
|
|
|
|
|
|
|
|
|
|
|
|
double r = _elm_config->thumbscroll_momentum_friction;
|
|
|
|
const int min_px = 3;
|
|
|
|
|
|
|
|
if ( dt == 0 ) return EINA_FALSE;
|
|
|
|
|
|
|
|
// store sign value of distance
|
|
|
|
sign_dx = (dx > 0) - (dx < 0);
|
|
|
|
sign_dy = (dy > 0) - (dy < 0);
|
|
|
|
|
2018-08-30 20:31:55 -07:00
|
|
|
if (vx) sign_vx = (*vx > 0) - (*vx < 0);
|
|
|
|
if (vy) sign_vy = (*vy > 0) - (*vy < 0);
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
// scale factor must be below 1.0
|
|
|
|
if ( r >= 1 ) r = 0.99;
|
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (vx && (sign_dx == sign_vx)) vel_x = *vx;
|
|
|
|
if (vy && (sign_dy == sign_vy)) vel_y = *vy;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
// calculate time based velecity (unit : px/second)
|
|
|
|
vel_x += dx / dt;
|
|
|
|
vel_y += dy / dt;
|
|
|
|
|
|
|
|
vel_x *= _elm_config->thumbscroll_sensitivity_friction;
|
|
|
|
vel_y *= _elm_config->thumbscroll_sensitivity_friction;
|
|
|
|
|
|
|
|
vel = sqrt((vel_x * vel_x) + (vel_y * vel_y));
|
|
|
|
|
|
|
|
// calculate frame based velecity (unit : px/frame)
|
|
|
|
fvel_x = vel_x * (1/60.0);
|
|
|
|
fvel_y = vel_y * (1/60.0);
|
|
|
|
fvel = vel * (1/60.0);
|
|
|
|
|
2018-12-18 04:01:34 -08:00
|
|
|
if (abs((int) fvel) < _elm_config->thumbscroll_threshold ) return EINA_FALSE;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
// calculate a number of frames to reach min_px when it follows a geometric sequence with scale factor r
|
|
|
|
n = log(min_px/fvel) / log(r);
|
|
|
|
|
|
|
|
distance_x = fvel_x * (( 1 - pow(r, n)) / (1 - r));
|
|
|
|
distance_y = fvel_y * (( 1 - pow(r, n)) / (1 - r));
|
|
|
|
|
|
|
|
// remove sign of distance
|
|
|
|
distance_x = abs(distance_x);
|
|
|
|
distance_y = abs(distance_y);
|
|
|
|
|
|
|
|
// clamp distance by thumbscroll_momentum_distance_max
|
|
|
|
distance_x = CLAMP(distance_x, 0, _elm_config->thumbscroll_momentum_distance_max);
|
|
|
|
distance_y = CLAMP(distance_y, 0, _elm_config->thumbscroll_momentum_distance_max);
|
|
|
|
|
|
|
|
// restore sign
|
|
|
|
distance_x *= sign_dx;
|
|
|
|
distance_y *= sign_dy;
|
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (dist_x) *dist_x = distance_x;
|
|
|
|
if (dist_y) *dist_y = distance_y;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (vx) *vx = vel_x;
|
|
|
|
if (vy) *vy = vel_y;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
// convert to time based animation duration
|
2018-08-31 01:46:25 -07:00
|
|
|
if (dur) *dur = CLAMP((n / 60.0), _elm_config->thumbscroll_momentum_animation_duration_min_limit, _elm_config->thumbscroll_momentum_animation_duration_max_limit);
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_mouse_up_event_cb(void *data,
|
|
|
|
Evas *e,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-07-04 14:41:01 -07:00
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Coord x = 0, y = 0, ox = 0, oy = 0;
|
2013-12-02 06:54:46 -08:00
|
|
|
Evas_Event_Mouse_Up *ev;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
2017-08-29 01:49:38 -07:00
|
|
|
if ((sid->block & EFL_UI_SCROLL_BLOCK_VERTICAL) &&
|
|
|
|
(sid->block & EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
return;
|
|
|
|
|
2012-07-06 10:04:48 -07:00
|
|
|
#ifdef SMOOTHDBG
|
|
|
|
if (_elm_scroll_smooth_debug) _elm_scroll_smooth_debug_shutdown();
|
|
|
|
#endif
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
ev = event_info;
|
|
|
|
sid->down.hold_parent = EINA_FALSE;
|
|
|
|
sid->down.dx = 0;
|
|
|
|
sid->down.dy = 0;
|
|
|
|
evas_post_event_callback_push(e, _elm_scroll_post_event_up, sid);
|
|
|
|
|
|
|
|
// FIXME: respect elm_widget_scroll_hold_get of parent container
|
|
|
|
if (!_elm_config->thumbscroll_enable) return;
|
|
|
|
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
|
|
|
if (sid->down.onhold_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
x = ev->canvas.x - sid->down.x;
|
|
|
|
y = ev->canvas.y - sid->down.y;
|
|
|
|
if (sid->down.dragged)
|
|
|
|
{
|
|
|
|
_elm_scroll_drag_stop(sid);
|
|
|
|
if ((!sid->hold) && (!sid->freeze))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
double t, at, dt;
|
|
|
|
Evas_Coord ax, ay, dx, dy, vel;
|
|
|
|
|
2018-08-28 23:58:10 -07:00
|
|
|
double vel_x, vel_y, dur;
|
|
|
|
Evas_Coord dist_x, dist_y;
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
t = ev->timestamp / 1000.0;
|
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
ax = ev->canvas.x;
|
|
|
|
ay = ev->canvas.y;
|
|
|
|
at = 0.0;
|
|
|
|
#ifdef SCROLLDBG
|
|
|
|
DBG("------ %i %i\n", ev->canvas.x, ev->canvas.y);
|
|
|
|
#endif
|
|
|
|
for (i = 0; i < 60; i++)
|
|
|
|
{
|
|
|
|
dt = t - sid->down.history[i].timestamp;
|
|
|
|
if (dt > 0.2) break;
|
|
|
|
#ifdef SCROLLDBG
|
|
|
|
DBG("H: %i %i @ %1.3f\n",
|
|
|
|
sid->down.history[i].x,
|
|
|
|
sid->down.history[i].y, dt);
|
|
|
|
#endif
|
|
|
|
at += dt;
|
|
|
|
ax += sid->down.history[i].x;
|
|
|
|
ay += sid->down.history[i].y;
|
|
|
|
}
|
|
|
|
ax /= (i + 1);
|
|
|
|
ay /= (i + 1);
|
|
|
|
at /= (i + 1);
|
2018-08-28 23:58:10 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
dx = ev->canvas.x - ax;
|
|
|
|
dy = ev->canvas.y - ay;
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
_elm_scroll_running_momentum_speed_get(sid, &vel_x, &vel_y);
|
|
|
|
|
|
|
|
if (at > 0 && _elm_scroll_momentum_calc(dx, dy, at, &vel_x, &vel_y, &dist_x, &dist_y, &dur))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2018-08-28 23:58:10 -07:00
|
|
|
vel = sqrt((vel_x * vel_x) + (vel_y * vel_y));
|
|
|
|
|
|
|
|
if ((_elm_config->thumbscroll_momentum_friction > 0.0) &&
|
2012-07-04 14:41:01 -07:00
|
|
|
(vel > _elm_config->thumbscroll_momentum_threshold))
|
|
|
|
{
|
|
|
|
int minx, miny, mx, my, px, py;
|
2018-08-29 10:20:53 -07:00
|
|
|
double dtt = 0.0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get
|
|
|
|
(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_max_get
|
|
|
|
(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2018-08-28 23:58:10 -07:00
|
|
|
|
|
|
|
sid->down.dx = dist_x;
|
|
|
|
sid->down.dy = dist_y;
|
|
|
|
sid->down.anim_dur = dur;
|
2013-03-31 22:02:23 -07:00
|
|
|
|
2013-04-17 05:46:21 -07:00
|
|
|
if (abs(sid->down.dx) > _elm_config->thumbscroll_acceleration_threshold &&
|
|
|
|
(dtt < _elm_config->thumbscroll_acceleration_time_limit) &&
|
2013-03-31 22:02:23 -07:00
|
|
|
(((sid->down.dx > 0) && (sid->down.pdx > 0)) ||
|
|
|
|
((sid->down.dx < 0) && (sid->down.pdx < 0))))
|
|
|
|
if (px > minx && px < mx)
|
2013-04-17 05:46:21 -07:00
|
|
|
sid->down.dx += (double)sid->down.pdx * _elm_config->thumbscroll_acceleration_weight;
|
|
|
|
if (abs(sid->down.dy) > _elm_config->thumbscroll_acceleration_threshold &&
|
|
|
|
(dtt < _elm_config->thumbscroll_acceleration_time_limit) &&
|
2013-03-31 22:02:23 -07:00
|
|
|
(((sid->down.dy > 0) && (sid->down.pdy > 0)) ||
|
|
|
|
((sid->down.dy < 0) && (sid->down.pdy < 0))))
|
|
|
|
if (py > miny && py < my)
|
2013-04-17 05:46:21 -07:00
|
|
|
{
|
|
|
|
sid->down.dy += (double)sid->down.pdy * _elm_config->thumbscroll_acceleration_weight;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.pdx = sid->down.dx;
|
|
|
|
sid->down.pdy = sid->down.dy;
|
|
|
|
ox = -sid->down.dx;
|
|
|
|
oy = -sid->down.dy;
|
|
|
|
if (!_paging_is_enabled(sid))
|
|
|
|
{
|
|
|
|
if ((!sid->down.momentum_animator) &&
|
|
|
|
(!sid->momentum_animator_disabled) &&
|
|
|
|
(sid->obj) &&
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get
|
2012-07-04 14:41:01 -07:00
|
|
|
(sid->obj)))
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
ev->event_flags |=
|
|
|
|
EVAS_EVENT_FLAG_ON_SCROLL;
|
|
|
|
_elm_scroll_anim_start(sid);
|
|
|
|
}
|
|
|
|
sid->down.anim_start = ecore_loop_time_get();
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->down.sx = x;
|
|
|
|
sid->down.sy = y;
|
|
|
|
sid->down.b0x = 0;
|
|
|
|
sid->down.b0y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->down.pdy = 0;
|
|
|
|
}
|
|
|
|
evas_event_feed_hold(e, 0, ev->timestamp, ev->data);
|
|
|
|
if (_paging_is_enabled(sid))
|
|
|
|
{
|
|
|
|
Evas_Coord pgx, pgy;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get
|
|
|
|
(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get
|
2012-07-04 14:41:01 -07:00
|
|
|
(sid->obj)))
|
|
|
|
{
|
2013-04-09 19:22:52 -07:00
|
|
|
pgx = _elm_scroll_page_x_get(sid, ox, EINA_TRUE);
|
2013-05-09 12:26:29 -07:00
|
|
|
if (pgx != x &&
|
|
|
|
!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
|
|
|
|
_elm_scroll_scroll_to_x
|
|
|
|
(sid, _elm_config->page_scroll_friction, pgx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get
|
2012-07-04 14:41:01 -07:00
|
|
|
(sid->obj)))
|
|
|
|
{
|
2013-04-09 19:22:52 -07:00
|
|
|
pgy = _elm_scroll_page_y_get(sid, oy, EINA_TRUE);
|
2013-05-09 12:26:29 -07:00
|
|
|
if (pgy != y &&
|
|
|
|
!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
|
|
|
|
_elm_scroll_scroll_to_y
|
|
|
|
(sid, _elm_config->page_scroll_friction, pgy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sid->down.pdx = 0;
|
|
|
|
sid->down.pdy = 0;
|
|
|
|
if (_paging_is_enabled(sid))
|
|
|
|
{
|
|
|
|
Evas_Coord pgx, pgy;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get
|
|
|
|
(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get
|
2012-07-04 14:41:01 -07:00
|
|
|
(sid->obj)))
|
|
|
|
{
|
2013-04-09 19:22:52 -07:00
|
|
|
pgx = _elm_scroll_page_x_get(sid, ox, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (pgx != x)
|
|
|
|
_elm_scroll_scroll_to_x
|
|
|
|
(sid, _elm_config->page_scroll_friction, pgx);
|
|
|
|
}
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get
|
2012-07-04 14:41:01 -07:00
|
|
|
(sid->obj)))
|
|
|
|
{
|
2013-04-09 19:22:52 -07:00
|
|
|
pgy = _elm_scroll_page_y_get(sid, oy, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (pgy != y)
|
|
|
|
_elm_scroll_scroll_to_y
|
|
|
|
(sid, _elm_config->page_scroll_friction, pgy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-24 19:59:55 -07:00
|
|
|
if (sid->down.hold_animator)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2014-01-21 16:55:58 -08:00
|
|
|
ELM_SAFE_FREE(sid->down.hold_enterer, ecore_idle_enterer_del);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->down.scroll)
|
|
|
|
{
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL;
|
|
|
|
sid->down.scroll = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (sid->down.hold)
|
|
|
|
{
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
sid->down.hold = EINA_FALSE;
|
|
|
|
}
|
|
|
|
sid->down.dragged_began = EINA_FALSE;
|
|
|
|
sid->down.dir_x = EINA_FALSE;
|
|
|
|
sid->down.dir_y = EINA_FALSE;
|
|
|
|
sid->down.want_dragged = EINA_FALSE;
|
|
|
|
sid->down.dragged = EINA_FALSE;
|
|
|
|
sid->down.now = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_coordinates_update(sid, x, y);
|
|
|
|
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
|
|
|
|
if (!_paging_is_enabled(sid))
|
|
|
|
_elm_scroll_bounce_eval(sid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_mouse_down_event_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-07-04 14:41:01 -07:00
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid;
|
|
|
|
Evas_Event_Mouse_Down *ev;
|
|
|
|
Evas_Coord x = 0, y = 0;
|
|
|
|
|
|
|
|
sid = data;
|
|
|
|
ev = event_info;
|
|
|
|
|
2017-08-29 01:49:38 -07:00
|
|
|
if ((sid->block & EFL_UI_SCROLL_BLOCK_VERTICAL) &&
|
|
|
|
(sid->block & EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
return;
|
|
|
|
|
2012-07-06 10:04:48 -07:00
|
|
|
#ifdef SMOOTHDBG
|
|
|
|
if (getenv("ELS_SCROLLER_SMOOTH_DEBUG")) _elm_scroll_smooth_debug = 1;
|
|
|
|
if (_elm_scroll_smooth_debug) _elm_scroll_smooth_debug_init();
|
|
|
|
#endif
|
|
|
|
|
2013-03-21 11:32:36 -07:00
|
|
|
if (!_elm_config->thumbscroll_enable) return;
|
|
|
|
|
|
|
|
sid->down.hold = EINA_FALSE;
|
|
|
|
if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator) ||
|
|
|
|
(sid->down.momentum_animator) || (sid->scrollto.x.animator) ||
|
|
|
|
(sid->scrollto.y.animator))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-03-21 11:32:36 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_SCROLL |
|
|
|
|
EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
sid->down.scroll = EINA_TRUE;
|
|
|
|
sid->down.hold = EINA_TRUE;
|
|
|
|
_elm_scroll_anim_stop(sid);
|
|
|
|
}
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2013-03-21 11:32:36 -07:00
|
|
|
if (sid->down.bounce_x_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->bouncemex = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
if (sid->down.bounce_y_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->bouncemey = EINA_FALSE;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2013-10-24 19:59:55 -07:00
|
|
|
if (sid->down.hold_animator)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
2013-03-21 11:32:36 -07:00
|
|
|
_elm_scroll_drag_stop(sid);
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
2014-01-21 16:55:58 -08:00
|
|
|
ELM_SAFE_FREE(sid->down.hold_enterer, ecore_idle_enterer_del);
|
2013-03-21 11:32:36 -07:00
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->down.bounce_x_hold = EINA_FALSE;
|
|
|
|
sid->down.bounce_y_hold = EINA_FALSE;
|
|
|
|
sid->down.ax = 0;
|
|
|
|
sid->down.ay = 0;
|
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
2018-08-29 05:38:20 -07:00
|
|
|
sid->down.est_timestamp_diff =
|
2013-03-21 11:32:36 -07:00
|
|
|
ecore_loop_time_get() - ((double)ev->timestamp / 1000.0);
|
|
|
|
sid->down.now = EINA_TRUE;
|
|
|
|
sid->down.dragged = EINA_FALSE;
|
|
|
|
sid->down.dir_x = EINA_FALSE;
|
|
|
|
sid->down.dir_y = EINA_FALSE;
|
|
|
|
sid->down.x = ev->canvas.x;
|
|
|
|
sid->down.y = ev->canvas.y;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->down.sx = x;
|
|
|
|
sid->down.sy = y;
|
|
|
|
sid->down.locked = EINA_FALSE;
|
|
|
|
memset(&(sid->down.history[0]), 0,
|
|
|
|
sizeof(sid->down.history[0]) * 60);
|
|
|
|
sid->down.history[0].timestamp = ev->timestamp / 1000.0;
|
2013-04-30 00:46:59 -07:00
|
|
|
sid->down.dragged_began_timestamp = sid->down.history[0].timestamp;
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->down.history[0].x = ev->canvas.x;
|
|
|
|
sid->down.history[0].y = ev->canvas.y;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-03-21 11:32:36 -07:00
|
|
|
sid->down.dragged_began = EINA_FALSE;
|
|
|
|
sid->down.hold_parent = EINA_FALSE;
|
|
|
|
sid->down.cancelled = EINA_FALSE;
|
|
|
|
if (sid->hold || sid->freeze)
|
|
|
|
sid->down.want_reset = EINA_TRUE;
|
|
|
|
else
|
|
|
|
sid->down.want_reset = EINA_FALSE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_scroll_can_scroll(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
int dir)
|
|
|
|
{
|
|
|
|
Evas_Coord mx = 0, my = 0, px = 0, py = 0, minx = 0, miny = 0;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return EINA_FALSE;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
2012-07-04 14:41:01 -07:00
|
|
|
switch (dir)
|
|
|
|
{
|
|
|
|
case LEFT:
|
|
|
|
if (px > minx) return EINA_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIGHT:
|
|
|
|
if ((px - minx) < mx) return EINA_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UP:
|
|
|
|
if (py > miny) return EINA_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DOWN:
|
|
|
|
if ((py - miny) < my) return EINA_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2017-08-17 07:26:34 -07:00
|
|
|
static inline void
|
|
|
|
_elm_widget_parents_bounce_get(Eo *obj, Eina_Bool *horiz, Eina_Bool *vert)
|
|
|
|
{
|
|
|
|
Evas_Object *parent_obj = obj;
|
|
|
|
Eina_Bool h = EINA_FALSE, v = EINA_FALSE;
|
|
|
|
|
|
|
|
*horiz = EINA_FALSE;
|
|
|
|
*vert = EINA_FALSE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
parent_obj = elm_widget_parent_get(parent_obj);
|
2018-01-07 20:55:35 -08:00
|
|
|
if ((!parent_obj) || (!efl_isa(parent_obj, EFL_UI_WIDGET_CLASS))) break;
|
2017-08-17 07:26:34 -07:00
|
|
|
|
|
|
|
if (efl_isa(parent_obj, ELM_INTERFACE_SCROLLABLE_MIXIN))
|
|
|
|
{
|
|
|
|
elm_interface_scrollable_bounce_allow_get(parent_obj, &h, &v);
|
|
|
|
if (h) *horiz = EINA_TRUE;
|
|
|
|
if (v) *vert = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (parent_obj);
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_scroll_post_event_move(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
2017-08-29 02:15:33 -07:00
|
|
|
Efl_Ui_Scroll_Block block;
|
2013-06-18 00:28:06 -07:00
|
|
|
Eina_Bool horiz, vert;
|
2013-03-25 13:56:22 -07:00
|
|
|
int start = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-03-25 13:56:22 -07:00
|
|
|
if (!sid->down.want_dragged) return EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2017-08-29 02:15:33 -07:00
|
|
|
block = elm_widget_scroll_lock_get(sid->obj);
|
2017-08-17 07:26:34 -07:00
|
|
|
_elm_widget_parents_bounce_get(sid->obj, &horiz, &vert);
|
2013-03-25 13:56:22 -07:00
|
|
|
if (sid->down.hold_parent)
|
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
if ((sid->down.dir_x) && (horiz || !sid->bounce_horiz) &&
|
2013-03-25 13:56:22 -07:00
|
|
|
!_elm_scroll_can_scroll(sid, sid->down.hdir))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-03-25 13:56:22 -07:00
|
|
|
sid->down.dir_x = EINA_FALSE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2015-06-03 06:08:38 -07:00
|
|
|
if ((sid->down.dir_y) && (vert || !sid->bounce_vert) &&
|
2013-03-25 13:56:22 -07:00
|
|
|
!_elm_scroll_can_scroll(sid, sid->down.vdir))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-03-25 13:56:22 -07:00
|
|
|
sid->down.dir_y = EINA_FALSE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2015-06-03 06:08:38 -07:00
|
|
|
sid->down.dragged_began = EINA_TRUE;
|
2013-03-25 13:56:22 -07:00
|
|
|
}
|
|
|
|
if (sid->down.dir_x)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
if (sid->down.dragged_began)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
sid->down.want_dragged = EINA_FALSE;
|
|
|
|
sid->down.dragged = EINA_TRUE;
|
|
|
|
if (sid->obj)
|
|
|
|
{
|
2017-08-29 02:15:33 -07:00
|
|
|
block |= EFL_UI_SCROLL_BLOCK_HORIZONTAL;
|
|
|
|
elm_widget_scroll_lock_set(sid->obj, block);
|
2015-06-03 06:08:38 -07:00
|
|
|
}
|
|
|
|
start = 1;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2013-03-25 13:56:22 -07:00
|
|
|
else
|
2015-06-03 06:08:38 -07:00
|
|
|
{
|
|
|
|
sid->down.dragged_began = EINA_TRUE;
|
|
|
|
sid->down.dir_x = EINA_FALSE;
|
|
|
|
}
|
2013-03-25 13:56:22 -07:00
|
|
|
}
|
|
|
|
if (sid->down.dir_y)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
if (sid->down.dragged_began)
|
2013-03-25 13:56:22 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
sid->down.want_dragged = EINA_FALSE;
|
|
|
|
sid->down.dragged = EINA_TRUE;
|
|
|
|
if (sid->obj)
|
|
|
|
{
|
2017-08-29 02:15:33 -07:00
|
|
|
block |= EFL_UI_SCROLL_BLOCK_VERTICAL;
|
|
|
|
elm_widget_scroll_lock_set(sid->obj, block);
|
2015-06-03 06:08:38 -07:00
|
|
|
}
|
|
|
|
start = 1;
|
2013-03-25 13:56:22 -07:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-03-25 13:56:22 -07:00
|
|
|
else
|
2015-06-03 06:08:38 -07:00
|
|
|
{
|
|
|
|
sid->down.dragged_began = EINA_TRUE;
|
|
|
|
sid->down.dir_y = EINA_FALSE;
|
|
|
|
}
|
2013-03-25 13:56:22 -07:00
|
|
|
}
|
|
|
|
if ((!sid->down.dir_x) && (!sid->down.dir_y))
|
|
|
|
{
|
|
|
|
sid->down.cancelled = EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-03-25 13:56:22 -07:00
|
|
|
if (start) _elm_scroll_drag_start(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2018-05-25 10:04:49 -07:00
|
|
|
return EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_down_coord_eval(Elm_Scrollable_Smart_Interface_Data *sid,
|
|
|
|
Evas_Coord *x,
|
|
|
|
Evas_Coord *y)
|
|
|
|
{
|
|
|
|
Evas_Coord minx, miny;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
|
|
|
if (sid->down.dir_x) *x = sid->down.sx - (*x - sid->down.x);
|
|
|
|
else *x = sid->down.sx;
|
|
|
|
if (sid->down.dir_y) *y = sid->down.sy - (*y - sid->down.y);
|
|
|
|
else *y = sid->down.sy;
|
|
|
|
|
|
|
|
if ((sid->down.dir_x) || (sid->down.dir_y))
|
|
|
|
{
|
|
|
|
if (!((sid->down.dir_x) && (sid->down.dir_y)))
|
|
|
|
{
|
|
|
|
if (sid->down.dir_x) *y = sid->down.locked_y;
|
|
|
|
else *x = sid->down.locked_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && *x < minx)
|
2012-07-04 14:41:01 -07:00
|
|
|
*x += (minx - *x) * _elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_h && sid->content_info.w <= sid->w)
|
2012-07-04 14:41:01 -07:00
|
|
|
*x += (sid->down.sx - *x) * _elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_h && (sid->content_info.w - sid->w + minx) < *x)
|
2012-07-04 14:41:01 -07:00
|
|
|
*x += (sid->content_info.w - sid->w + minx - *x) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v && *y < miny)
|
2012-07-04 14:41:01 -07:00
|
|
|
*y += (miny - *y) * _elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_v && sid->content_info.h <= sid->h)
|
2012-07-04 14:41:01 -07:00
|
|
|
*y += (sid->down.sy - *y) * _elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_v && (sid->content_info.h - sid->h + miny) < *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
*y += (sid->content_info.h - sid->h + miny - *y) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
|
|
|
}
|
|
|
|
|
2013-10-24 19:59:55 -07:00
|
|
|
static Eina_Bool
|
2013-10-24 20:36:28 -07:00
|
|
|
_elm_scroll_hold_enterer(void *data)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Coord ox = 0, oy = 0, fx = 0, fy = 0;
|
2015-09-13 22:45:19 -07:00
|
|
|
// Evas_Coord fy2;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-10-24 20:36:28 -07:00
|
|
|
sid->down.hold_enterer = NULL;
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
fx = sid->down.hold_x;
|
|
|
|
fy = sid->down.hold_y;
|
2015-09-13 22:45:19 -07:00
|
|
|
// fy2 = fy;
|
2015-09-11 07:24:51 -07:00
|
|
|
if ((_elm_config->scroll_smooth_amount > 0.0) &&
|
|
|
|
(_elm_config->scroll_smooth_time_window > 0.0))
|
2013-02-05 22:54:30 -08:00
|
|
|
{
|
|
|
|
int i, count = 0;
|
|
|
|
Evas_Coord basex = 0, basey = 0, x, y;
|
2015-09-13 22:45:19 -07:00
|
|
|
double dt, tdiff, tnow, twin, ttot;
|
2015-09-11 07:24:51 -07:00
|
|
|
double xx, yy, tot;
|
2012-07-04 14:41:01 -07:00
|
|
|
struct
|
2013-02-05 22:54:30 -08:00
|
|
|
{
|
2015-09-13 22:45:19 -07:00
|
|
|
Evas_Coord x, y;
|
|
|
|
double t;
|
|
|
|
} pos[100];
|
2013-02-05 22:54:30 -08:00
|
|
|
|
2018-08-29 05:38:20 -07:00
|
|
|
tdiff = sid->down.est_timestamp_diff;
|
2015-09-11 07:24:51 -07:00
|
|
|
tnow = ecore_loop_time_get();
|
2013-02-05 22:54:30 -08:00
|
|
|
twin = _elm_config->scroll_smooth_time_window;
|
|
|
|
for (i = 0; i < 60; i++)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-09-11 07:24:51 -07:00
|
|
|
if ((sid->down.history[i].timestamp - tdiff) > tnow)
|
2015-09-13 22:45:19 -07:00
|
|
|
continue;
|
2015-09-11 07:24:51 -07:00
|
|
|
if ((sid->down.history[i].timestamp >
|
|
|
|
sid->down.dragged_began_timestamp) || (count == 0))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-04-30 00:46:59 -07:00
|
|
|
x = sid->down.history[i].x;
|
|
|
|
y = sid->down.history[i].y;
|
2015-09-13 22:45:19 -07:00
|
|
|
_elm_scroll_down_coord_eval(sid, &x, &y);
|
|
|
|
if (count == 0)
|
2013-04-30 00:46:59 -07:00
|
|
|
{
|
|
|
|
basex = x;
|
|
|
|
basey = y;
|
|
|
|
}
|
2015-09-13 22:45:19 -07:00
|
|
|
dt = (tnow + tdiff) - sid->down.history[i].timestamp;
|
2015-09-11 07:24:51 -07:00
|
|
|
if ((dt > twin) && (count > 0)) break;
|
2015-09-13 22:45:19 -07:00
|
|
|
if ((dt > 0.0) && (count == 0))
|
|
|
|
{
|
|
|
|
pos[count].x = x - basex;
|
|
|
|
pos[count].y = y - basey;
|
|
|
|
pos[count].t = 0.0;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
pos[count].x = x - basex;
|
|
|
|
pos[count].y = y - basey;
|
|
|
|
pos[count].t = dt;
|
2013-04-30 00:46:59 -07:00
|
|
|
count++;
|
2012-07-06 10:04:48 -07:00
|
|
|
}
|
2013-04-30 00:46:59 -07:00
|
|
|
}
|
2015-09-11 07:24:51 -07:00
|
|
|
if (count > 0)
|
2013-02-05 22:54:30 -08:00
|
|
|
{
|
2015-09-11 07:24:51 -07:00
|
|
|
xx = 0.0;
|
|
|
|
yy = 0.0;
|
|
|
|
tot = 0.0;
|
2015-09-13 22:45:19 -07:00
|
|
|
ttot = pos[count - 1].t;
|
2015-09-11 07:24:51 -07:00
|
|
|
for (i = 0; i < count; i++)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2015-09-13 22:45:19 -07:00
|
|
|
double wt;
|
|
|
|
|
|
|
|
if (ttot > 0.0)
|
|
|
|
{
|
|
|
|
if (i < (count - 1))
|
|
|
|
wt = (ttot - pos[i].t) * (pos[i + 1].t - pos[i].t);
|
|
|
|
else
|
|
|
|
wt = 0.0;
|
|
|
|
}
|
|
|
|
else wt = 1.0;
|
2015-09-11 07:24:51 -07:00
|
|
|
|
|
|
|
xx += ((double)(pos[i].x)) * wt;
|
|
|
|
yy += ((double)(pos[i].y)) * wt;
|
|
|
|
tot += wt;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2015-09-11 07:24:51 -07:00
|
|
|
if (tot > 0.0)
|
2013-06-05 15:14:59 -07:00
|
|
|
{
|
2015-09-11 07:24:51 -07:00
|
|
|
xx = basex + (xx / tot);
|
|
|
|
yy = basey + (yy / tot);
|
|
|
|
fx =
|
|
|
|
(_elm_config->scroll_smooth_amount * xx) +
|
|
|
|
((1.0 - _elm_config->scroll_smooth_amount) * fx);
|
|
|
|
fy =
|
|
|
|
(_elm_config->scroll_smooth_amount * yy) +
|
|
|
|
((1.0 - _elm_config->scroll_smooth_amount) * fy);
|
2013-06-05 15:14:59 -07:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2015-09-13 22:45:19 -07:00
|
|
|
// printf("%1.5f %i %i\n",
|
|
|
|
// ecore_loop_time_get() - sid->down.dragged_began_timestamp,
|
|
|
|
// fy, fy2);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &ox, &oy);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->down.dir_x)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
ox = fx;
|
|
|
|
}
|
|
|
|
if (sid->down.dir_y)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
oy = fy;
|
|
|
|
}
|
|
|
|
|
2012-07-06 10:04:48 -07:00
|
|
|
#ifdef SMOOTHDBG
|
|
|
|
if (_elm_scroll_smooth_debug)
|
|
|
|
_elm_scroll_smooth_debug_movetime_add(ox, oy);
|
|
|
|
#endif
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, ox, oy, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-10-24 20:36:28 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_hold_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2013-10-24 20:36:28 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
2014-01-21 16:55:58 -08:00
|
|
|
ecore_idle_enterer_del(sid->down.hold_enterer);
|
2013-10-24 20:36:28 -07:00
|
|
|
sid->down.hold_enterer =
|
|
|
|
ecore_idle_enterer_before_add(_elm_scroll_hold_enterer, sid);
|
2013-10-22 03:01:00 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_on_hold_animator(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
double t, td;
|
|
|
|
double vx, vy;
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord x, y, ox = 0, oy = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid;
|
|
|
|
|
|
|
|
sid = data;
|
|
|
|
t = ecore_loop_time_get();
|
|
|
|
if (sid->down.onhold_tlast > 0.0)
|
|
|
|
{
|
|
|
|
td = t - sid->down.onhold_tlast;
|
|
|
|
vx = sid->down.onhold_vx * td *
|
2013-03-07 01:13:15 -08:00
|
|
|
(double)_elm_config->thumbscroll_hold_threshold * 2.0;
|
2012-07-04 14:41:01 -07:00
|
|
|
vy = sid->down.onhold_vy * td *
|
2013-03-07 01:13:15 -08:00
|
|
|
(double)_elm_config->thumbscroll_hold_threshold * 2.0;
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &ox, &oy);
|
2012-07-04 14:41:01 -07:00
|
|
|
x = ox;
|
|
|
|
y = oy;
|
|
|
|
|
|
|
|
if (sid->down.dir_x)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_x_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->down.onhold_vxe += vx;
|
|
|
|
x = ox + (int)sid->down.onhold_vxe;
|
|
|
|
sid->down.onhold_vxe -= (int)sid->down.onhold_vxe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sid->down.dir_y)
|
|
|
|
{
|
|
|
|
if ((!sid->obj) ||
|
2017-08-29 00:49:43 -07:00
|
|
|
(!elm_widget_scroll_child_locked_y_get(sid->obj)))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->down.onhold_vye += vy;
|
|
|
|
y = oy + (int)sid->down.onhold_vye;
|
|
|
|
sid->down.onhold_vye -= (int)sid->down.onhold_vye;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
sid->down.onhold_tlast = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_mouse_move_event_cb(void *data,
|
|
|
|
Evas *e,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-07-04 14:41:01 -07:00
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
Evas_Event_Mouse_Move *ev;
|
|
|
|
Evas_Coord x = 0, y = 0;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
2017-08-29 01:49:38 -07:00
|
|
|
if ((sid->block & EFL_UI_SCROLL_BLOCK_VERTICAL) &&
|
|
|
|
(sid->block & EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
return;
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
ev = event_info;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
|
|
|
sid->down.hold_parent = EINA_TRUE;
|
|
|
|
evas_post_event_callback_push(e, _elm_scroll_post_event_move, sid);
|
|
|
|
|
|
|
|
// FIXME: respect elm_widget_scroll_hold_get of parent container
|
2013-03-21 11:32:36 -07:00
|
|
|
if (!_elm_config->thumbscroll_enable)
|
|
|
|
return;
|
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
if (!sid->down.now) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-05-09 12:26:29 -07:00
|
|
|
if ((sid->scrollto.x.animator) && (!sid->hold) && (!sid->freeze) &&
|
2017-08-29 01:49:38 -07:00
|
|
|
!(sid->block & EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-03-22 14:38:50 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord px = 0;
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, NULL);
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.sx = px;
|
|
|
|
sid->down.x = sid->down.history[0].x;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-05-09 12:26:29 -07:00
|
|
|
if ((sid->scrollto.y.animator) && (!sid->hold) && (!sid->freeze) &&
|
2017-08-29 01:49:38 -07:00
|
|
|
!(sid->block & EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2013-03-22 14:38:50 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord py = 0;
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, NULL, &py);
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.sy = py;
|
|
|
|
sid->down.y = sid->down.history[0].y;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
#ifdef SCROLLDBG
|
2013-03-22 14:38:50 -07:00
|
|
|
DBG("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y);
|
2012-07-04 14:41:01 -07:00
|
|
|
#endif
|
2013-03-22 14:38:50 -07:00
|
|
|
memmove(&(sid->down.history[1]), &(sid->down.history[0]),
|
|
|
|
sizeof(sid->down.history[0]) * (60 - 1));
|
|
|
|
sid->down.history[0].timestamp = ev->timestamp / 1000.0;
|
|
|
|
sid->down.history[0].x = ev->cur.canvas.x;
|
|
|
|
sid->down.history[0].y = ev->cur.canvas.y;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
if (!sid->down.dragged_began)
|
|
|
|
{
|
|
|
|
x = ev->cur.canvas.x - sid->down.x;
|
|
|
|
y = ev->cur.canvas.y - sid->down.y;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.hdir = -1;
|
|
|
|
sid->down.vdir = -1;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
if (x > 0) sid->down.hdir = LEFT;
|
|
|
|
else if (x < 0)
|
|
|
|
sid->down.hdir = RIGHT;
|
|
|
|
if (y > 0) sid->down.vdir = UP;
|
|
|
|
else if (y < 0)
|
|
|
|
sid->down.vdir = DOWN;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
if (x < 0) x = -x;
|
|
|
|
if (y < 0) y = -y;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-04-10 04:06:41 -07:00
|
|
|
if (sid->one_direction_at_a_time)
|
2013-03-22 14:38:50 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
if (((x * x) + (y * y)) >
|
|
|
|
(_elm_config->thumbscroll_threshold *
|
|
|
|
_elm_config->thumbscroll_threshold))
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-04-10 04:06:41 -07:00
|
|
|
if (sid->one_direction_at_a_time ==
|
|
|
|
ELM_SCROLLER_SINGLE_DIRECTION_SOFT)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-04-10 04:06:41 -07:00
|
|
|
int dodir = 0;
|
|
|
|
if (x > (y * 2))
|
|
|
|
{
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_TRUE;
|
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
sid->down.dir_y = EINA_FALSE;
|
|
|
|
dodir++;
|
|
|
|
}
|
|
|
|
if (y > (x * 2))
|
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_FALSE;
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_y = EINA_TRUE;
|
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
dodir++;
|
|
|
|
}
|
|
|
|
if (!dodir)
|
|
|
|
{
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_y = EINA_TRUE;
|
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
else if (sid->one_direction_at_a_time ==
|
|
|
|
ELM_SCROLLER_SINGLE_DIRECTION_HARD)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-04-10 04:06:41 -07:00
|
|
|
if (x > y)
|
|
|
|
{
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_TRUE;
|
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
sid->down.dir_y = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (y > x)
|
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_FALSE;
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_y = EINA_TRUE;
|
|
|
|
}
|
2013-04-10 04:06:41 -07:00
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
else
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-05-09 12:26:29 -07:00
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_HORIZONTAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_x = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (!(sid->block &
|
2017-08-29 01:49:38 -07:00
|
|
|
EFL_UI_SCROLL_BLOCK_VERTICAL))
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->down.dir_y = EINA_TRUE;
|
|
|
|
}
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
}
|
|
|
|
if ((!sid->hold) && (!sid->freeze))
|
|
|
|
{
|
|
|
|
if ((sid->down.dragged) ||
|
|
|
|
(((x * x) + (y * y)) >
|
|
|
|
(_elm_config->thumbscroll_threshold *
|
2013-04-30 00:46:59 -07:00
|
|
|
_elm_config->thumbscroll_threshold)))
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-04-30 00:46:59 -07:00
|
|
|
if (!sid->down.dragged_began &&
|
|
|
|
_elm_config->scroll_smooth_start_enable)
|
|
|
|
{
|
|
|
|
sid->down.x = ev->cur.canvas.x;
|
|
|
|
sid->down.y = ev->cur.canvas.y;
|
|
|
|
sid->down.dragged_began_timestamp = ev->timestamp / 1000.0;
|
|
|
|
}
|
2015-06-03 06:08:38 -07:00
|
|
|
|
2013-03-22 14:38:50 -07:00
|
|
|
if (!sid->down.dragged)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.want_dragged = EINA_TRUE;
|
2015-06-03 06:08:38 -07:00
|
|
|
}
|
|
|
|
if ((((_elm_scroll_can_scroll(sid, LEFT) || _elm_scroll_can_scroll(sid, RIGHT)) && sid->down.dir_x) ||
|
|
|
|
((_elm_scroll_can_scroll(sid, UP) || _elm_scroll_can_scroll(sid, DOWN)) && sid->down.dir_y)) &&
|
|
|
|
!sid->down.dragged_began)
|
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2015-06-03 06:08:38 -07:00
|
|
|
sid->down.dragged_began = EINA_TRUE;
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2015-06-03 06:08:38 -07:00
|
|
|
else if (sid->down.dragged_began)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
if (sid->down.dir_x)
|
|
|
|
x = sid->down.sx - (ev->cur.canvas.x - sid->down.x);
|
|
|
|
else
|
|
|
|
x = sid->down.sx;
|
|
|
|
if (sid->down.dir_y)
|
|
|
|
y = sid->down.sy - (ev->cur.canvas.y - sid->down.y);
|
|
|
|
else
|
|
|
|
y = sid->down.sy;
|
|
|
|
if (sid->down.want_reset)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.x = ev->cur.canvas.x;
|
|
|
|
sid->down.y = ev->cur.canvas.y;
|
|
|
|
sid->down.want_reset = EINA_FALSE;
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
if ((sid->down.dir_x) || (sid->down.dir_y))
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
if (!sid->down.locked)
|
|
|
|
{
|
|
|
|
sid->down.locked_x = x;
|
|
|
|
sid->down.locked_y = y;
|
|
|
|
sid->down.locked = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (!((sid->down.dir_x) && (sid->down.dir_y)))
|
|
|
|
{
|
|
|
|
if (sid->down.dir_x) y = sid->down.locked_y;
|
|
|
|
else x = sid->down.locked_x;
|
|
|
|
}
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord minx = 0, miny = 0, mx, my;
|
2013-03-22 14:38:50 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_v && y < miny)
|
2013-03-22 14:38:50 -07:00
|
|
|
y += (miny - y) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_v && my <= 0)
|
2013-03-22 14:38:50 -07:00
|
|
|
y += (sid->down.sy - y) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_v && (my + miny) < y)
|
2013-03-22 14:38:50 -07:00
|
|
|
y += (my + miny - y) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
if (!sid->loop_h && x < minx)
|
2013-03-22 14:38:50 -07:00
|
|
|
x += (minx - x) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_h && mx <= 0)
|
2013-03-22 14:38:50 -07:00
|
|
|
x += (sid->down.sx - x) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
2015-01-23 19:01:03 -08:00
|
|
|
else if (!sid->loop_h && (mx + minx) < x)
|
2013-03-22 14:38:50 -07:00
|
|
|
x += (mx + minx - x) *
|
|
|
|
_elm_config->thumbscroll_border_friction;
|
|
|
|
}
|
|
|
|
|
|
|
|
sid->down.hold_x = x;
|
|
|
|
sid->down.hold_y = y;
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
2013-03-22 14:38:50 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sid->down.dragged_began)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2015-06-03 06:08:38 -07:00
|
|
|
if ((_elm_scroll_can_scroll(sid, sid->down.hdir) && sid->down.dir_x) ||
|
|
|
|
(_elm_scroll_can_scroll(sid, sid->down.vdir) && sid->down.dir_y))
|
|
|
|
{
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
if (!sid->down.hold)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.hold = EINA_TRUE;
|
|
|
|
evas_event_feed_hold
|
|
|
|
(e, 1, ev->timestamp, ev->data);
|
2013-03-21 11:32:36 -07:00
|
|
|
}
|
|
|
|
}
|
2013-03-22 14:38:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!sid->freeze)
|
|
|
|
{
|
|
|
|
double vx = 0.0, vy = 0.0;
|
|
|
|
|
|
|
|
x = ev->cur.canvas.x - sid->x;
|
|
|
|
y = ev->cur.canvas.y - sid->y;
|
|
|
|
if (x < _elm_config->thumbscroll_hold_threshold)
|
|
|
|
{
|
|
|
|
if (_elm_config->thumbscroll_hold_threshold > 0.0)
|
|
|
|
vx = -(double)(_elm_config->thumbscroll_hold_threshold - x)
|
|
|
|
/ _elm_config->thumbscroll_hold_threshold;
|
|
|
|
else
|
|
|
|
vx = -1.0;
|
|
|
|
}
|
|
|
|
else if (x > (sid->w - _elm_config->thumbscroll_hold_threshold))
|
|
|
|
{
|
|
|
|
if (_elm_config->thumbscroll_hold_threshold > 0.0)
|
|
|
|
vx = (double)(_elm_config->thumbscroll_hold_threshold -
|
|
|
|
(sid->w - x)) /
|
|
|
|
_elm_config->thumbscroll_hold_threshold;
|
|
|
|
else
|
|
|
|
vx = 1.0;
|
|
|
|
}
|
|
|
|
if (y < _elm_config->thumbscroll_hold_threshold)
|
|
|
|
{
|
|
|
|
if (_elm_config->thumbscroll_hold_threshold > 0.0)
|
|
|
|
vy = -(double)(_elm_config->thumbscroll_hold_threshold - y)
|
|
|
|
/ _elm_config->thumbscroll_hold_threshold;
|
2013-03-21 11:32:36 -07:00
|
|
|
else
|
2013-03-22 14:38:50 -07:00
|
|
|
vy = -1.0;
|
|
|
|
}
|
|
|
|
else if (y > (sid->h - _elm_config->thumbscroll_hold_threshold))
|
|
|
|
{
|
|
|
|
if (_elm_config->thumbscroll_hold_threshold > 0.0)
|
|
|
|
vy = (double)(_elm_config->thumbscroll_hold_threshold -
|
|
|
|
(sid->h - y)) /
|
|
|
|
_elm_config->thumbscroll_hold_threshold;
|
|
|
|
else
|
|
|
|
vy = 1.0;
|
|
|
|
}
|
|
|
|
if ((vx != 0.0) || (vy != 0.0))
|
|
|
|
{
|
|
|
|
sid->down.onhold_vx = vx;
|
|
|
|
sid->down.onhold_vy = vy;
|
|
|
|
if (!sid->down.onhold_animator)
|
2013-03-21 11:32:36 -07:00
|
|
|
{
|
2013-03-22 14:38:50 -07:00
|
|
|
sid->down.onhold_vxe = 0.0;
|
|
|
|
sid->down.onhold_vye = 0.0;
|
|
|
|
sid->down.onhold_tlast = 0.0;
|
2016-01-26 15:51:49 -08:00
|
|
|
|
|
|
|
ELM_ANIMATOR_CONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
2013-03-22 14:38:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sid->down.onhold_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
2013-03-22 14:38:50 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_page_adjust(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
|
|
|
|
if (!_paging_is_enabled(sid)) return;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-04-09 19:22:52 -07:00
|
|
|
x = _elm_scroll_page_x_get(sid, 0, EINA_TRUE);
|
|
|
|
y = _elm_scroll_page_y_get(sid, 0, EINA_TRUE);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_region_set(sid->obj, x, y, w, h);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_reconfigure(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
_elm_scroll_page_adjust(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_edje_move(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
2012-07-04 14:41:01 -07:00
|
|
|
Evas_Object *edje_obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
evas_object_geometry_get(edje_obj, &x, &y, NULL, NULL);
|
|
|
|
|
|
|
|
sid->x = x;
|
|
|
|
sid->y = y;
|
|
|
|
|
|
|
|
_elm_scroll_reconfigure(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_edje_resize(void *data,
|
2014-02-14 00:29:11 -08:00
|
|
|
Evas *e,
|
2012-07-04 14:41:01 -07:00
|
|
|
Evas_Object *edje_obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
2014-02-14 00:29:11 -08:00
|
|
|
Evas_Coord w, h;
|
|
|
|
int current_calc;
|
|
|
|
Eina_Bool reconf_ok = EINA_TRUE;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
evas_object_geometry_get(edje_obj, NULL, NULL, &w, &h);
|
|
|
|
|
|
|
|
sid->w = w;
|
|
|
|
sid->h = h;
|
|
|
|
|
2014-02-14 00:29:11 -08:00
|
|
|
current_calc = evas_smart_objects_calculate_count_get(e);
|
|
|
|
if (current_calc == sid->current_calc)
|
|
|
|
{
|
|
|
|
sid->size_count++;
|
|
|
|
if (sid->size_count > 3) reconf_ok = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sid->current_calc = current_calc;
|
|
|
|
sid->size_count = 0;
|
|
|
|
}
|
|
|
|
if (reconf_ok) _elm_scroll_reconfigure(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-30 15:34:57 -07:00
|
|
|
_scroll_edje_object_attach(Evas_Object *obj)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->edje_obj, EVAS_CALLBACK_RESIZE, _on_edje_resize, sid);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->edje_obj, EVAS_CALLBACK_MOVE, _on_edje_move, sid);
|
|
|
|
|
2013-04-15 21:27:55 -07:00
|
|
|
edje_object_signal_callback_add
|
|
|
|
(sid->edje_obj, "reload", "elm", _elm_scroll_reload_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
if (!_elm_scroll_has_bars(sid))
|
|
|
|
return;
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
else
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
2012-07-04 14:41:01 -07:00
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag", iface_scr_dragable_vbar, _elm_scroll_vbar_drag_cb,
|
2012-07-04 14:41:01 -07:00
|
|
|
sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,set", iface_scr_dragable_vbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,start", iface_scr_dragable_vbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_v_start_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,stop", iface_scr_dragable_vbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_v_stop_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,step", iface_scr_dragable_vbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,page", iface_scr_dragable_vbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
edje_object_signal_callback_add
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
(sid->edje_obj, "elm,vbar,press", "elm",
|
|
|
|
_elm_scroll_vbar_press_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(sid->edje_obj, "elm,vbar,unpress", "elm",
|
|
|
|
_elm_scroll_vbar_unpress_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
else
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag", iface_scr_dragable_hbar, _elm_scroll_hbar_drag_cb,
|
2012-07-04 14:41:01 -07:00
|
|
|
sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,set", iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,start", iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_h_start_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,stop", iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_h_stop_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,step", iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,page", iface_scr_dragable_hbar,
|
2012-07-04 14:41:01 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
edje_object_signal_callback_add
|
|
|
|
(sid->edje_obj, "elm,hbar,press", "elm",
|
|
|
|
_elm_scroll_hbar_press_cb, sid);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(sid->edje_obj, "elm,hbar,unpress", "elm",
|
|
|
|
_elm_scroll_hbar_unpress_cb, sid);
|
2012-07-30 15:34:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scroll_event_object_attach(Evas_Object *obj)
|
|
|
|
{
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_WHEEL, _elm_scroll_wheel_event_cb,
|
|
|
|
sid);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_elm_scroll_mouse_down_event_cb, sid);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_elm_scroll_mouse_up_event_cb, sid);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_elm_scroll_mouse_move_event_cb, sid);
|
|
|
|
}
|
|
|
|
|
2012-07-30 15:34:57 -07:00
|
|
|
static void
|
|
|
|
_scroll_edje_object_detach(Evas_Object *obj)
|
|
|
|
{
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
|
2012-07-30 15:34:57 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->edje_obj, EVAS_CALLBACK_RESIZE, _on_edje_resize, sid);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->edje_obj, EVAS_CALLBACK_MOVE, _on_edje_move, sid);
|
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
if (!_elm_scroll_has_bars(sid))
|
|
|
|
return;
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
else
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
2012-07-30 15:34:57 -07:00
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag", iface_scr_dragable_vbar, _elm_scroll_vbar_drag_cb,
|
2012-07-30 15:34:57 -07:00
|
|
|
sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,set", iface_scr_dragable_vbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,start", iface_scr_dragable_vbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_v_start_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,stop", iface_scr_dragable_vbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_v_stop_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,step", iface_scr_dragable_vbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,page", iface_scr_dragable_vbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_v_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
2012-07-30 15:34:57 -07:00
|
|
|
edje_object_signal_callback_del_full
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
(sid->edje_obj, "elm,vbar,press", "elm",
|
|
|
|
_elm_scroll_vbar_press_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
|
|
|
(sid->edje_obj, "elm,vbar,unpress", "elm",
|
|
|
|
_elm_scroll_vbar_unpress_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
else
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag", iface_scr_dragable_hbar, _elm_scroll_hbar_drag_cb,
|
2012-07-30 15:34:57 -07:00
|
|
|
sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,set", iface_scr_dragable_hbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,start", iface_scr_dragable_hbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_h_start_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,stop", iface_scr_dragable_hbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_h_stop_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,step", iface_scr_dragable_hbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
2018-04-26 03:27:43 -07:00
|
|
|
(sid->edje_obj, "drag,page", iface_scr_dragable_hbar,
|
2012-07-30 15:34:57 -07:00
|
|
|
_elm_scroll_edje_drag_h_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
edje_object_signal_callback_del_full
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
(sid->edje_obj, "elm,hbar,press", "elm",
|
|
|
|
_elm_scroll_hbar_press_cb, sid);
|
|
|
|
edje_object_signal_callback_del_full
|
|
|
|
(sid->edje_obj, "elm,hbar,unpress", "elm",
|
|
|
|
_elm_scroll_hbar_unpress_cb, sid);
|
2012-07-30 15:34:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scroll_event_object_detach(Evas_Object *obj)
|
|
|
|
{
|
2012-12-09 23:24:48 -08:00
|
|
|
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
|
2012-07-30 15:34:57 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_WHEEL, _elm_scroll_wheel_event_cb,
|
|
|
|
sid);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_elm_scroll_mouse_down_event_cb, sid);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_elm_scroll_mouse_up_event_cb, sid);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_elm_scroll_mouse_move_event_cb, sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_objects_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Object *edje_object, Evas_Object *hit_rectangle)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Evas_Coord mw, mh;
|
|
|
|
|
2012-07-30 15:34:57 -07:00
|
|
|
if (!edje_object || !hit_rectangle) return;
|
|
|
|
|
|
|
|
if (sid->edje_obj)
|
2013-04-15 23:50:58 -07:00
|
|
|
_scroll_edje_object_detach(obj);
|
2012-07-30 15:34:57 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->edje_obj = edje_object;
|
|
|
|
|
2012-07-30 15:34:57 -07:00
|
|
|
if (sid->event_rect)
|
2013-04-15 23:50:58 -07:00
|
|
|
_scroll_event_object_detach(obj);
|
2012-07-30 15:34:57 -07:00
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->event_rect = hit_rectangle;
|
|
|
|
evas_object_repeat_events_set(hit_rectangle, EINA_TRUE);
|
|
|
|
|
2012-07-30 15:34:57 -07:00
|
|
|
_scroll_edje_object_attach(obj);
|
|
|
|
_scroll_event_object_attach(obj);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
mw = mh = -1;
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
if (edje_object_part_exists(sid->edje_obj, "elm.scrollbar.base"))
|
|
|
|
{
|
|
|
|
Evas_Object *base;
|
|
|
|
|
|
|
|
base = edje_object_part_swallow_get
|
|
|
|
(sid->edje_obj, "elm.scrollbar.base");
|
|
|
|
if (!base)
|
|
|
|
{
|
|
|
|
base = evas_object_rectangle_add
|
|
|
|
(evas_object_evas_get(sid->edje_obj));
|
|
|
|
evas_object_color_set(base, 0, 0, 0, 0);
|
|
|
|
edje_object_part_swallow
|
|
|
|
(sid->edje_obj, "elm.scrollbar.base", base);
|
|
|
|
}
|
|
|
|
if (!_elm_config->thumbscroll_enable)
|
|
|
|
evas_object_size_hint_min_set(base, mw, mh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (edje_object_part_exists(sid->edje_obj, "efl.scrollbar.base"))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
Evas_Object *base;
|
|
|
|
|
|
|
|
base = edje_object_part_swallow_get
|
|
|
|
(sid->edje_obj, "efl.scrollbar.base");
|
|
|
|
if (!base)
|
|
|
|
{
|
|
|
|
base = evas_object_rectangle_add
|
|
|
|
(evas_object_evas_get(sid->edje_obj));
|
|
|
|
evas_object_color_set(base, 0, 0, 0, 0);
|
|
|
|
edje_object_part_swallow
|
|
|
|
(sid->edje_obj, "efl.scrollbar.base", base);
|
|
|
|
}
|
|
|
|
if (!_elm_config->thumbscroll_enable)
|
|
|
|
evas_object_size_hint_min_set(base, mw, mh);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_visibility_adjust(sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_scroll_bar_reset(Elm_Scrollable_Smart_Interface_Data *sid)
|
|
|
|
{
|
|
|
|
Evas_Coord px = 0, py = 0, minx = 0, miny = 0;
|
|
|
|
|
2018-05-07 16:12:10 -07:00
|
|
|
if (!sid->edje_obj || efl_invalidated_get(sid->edje_obj)) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
const char *iface_scr_dragable_hbar = NULL;
|
|
|
|
const char *iface_scr_dragable_vbar = NULL;
|
|
|
|
if (elm_widget_is_legacy(sid->obj))
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_legacy_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_legacy_dragable_vbar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iface_scr_dragable_hbar = iface_scr_efl_ui_dragable_hbar;
|
|
|
|
iface_scr_dragable_vbar = iface_scr_efl_ui_dragable_vbar;
|
|
|
|
}
|
|
|
|
|
2018-06-21 15:51:43 -07:00
|
|
|
if (_elm_scroll_has_bars(sid))
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2018-06-21 15:51:43 -07:00
|
|
|
edje_object_part_drag_value_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 0.0, 0.0);
|
|
|
|
edje_object_part_drag_value_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, 0.0, 0.0);
|
|
|
|
if ((!sid->content) && (!sid->extern_pan))
|
|
|
|
{
|
|
|
|
edje_object_part_drag_size_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_vbar, 1.0, 1.0);
|
|
|
|
edje_object_part_drag_size_set
|
|
|
|
(sid->edje_obj, iface_scr_dragable_hbar, 1.0, 1.0);
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
if (sid->pan_obj)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
|
|
|
|
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
|
|
|
|
elm_obj_pan_pos_set(sid->pan_obj, minx, miny);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
if ((px != minx) || (py != miny))
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
|
2012-08-07 03:20:30 -07:00
|
|
|
_elm_direction_arrows_eval(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2013-07-01 04:17:30 -07:00
|
|
|
static void
|
|
|
|
_elm_scroll_pan_resized_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2013-07-01 04:17:30 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord w = 0, h = 0;
|
2013-07-01 04:17:30 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
if (sid->cb_func.content_viewport_resize)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2013-07-01 04:17:30 -07:00
|
|
|
sid->cb_func.content_viewport_resize(sid->obj, w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
/* even external pan objects get this */
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_elm_scroll_pan_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord w = 0, h = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
if (!sid->pan_obj) return;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &w, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
if ((w != sid->content_info.w) || (h != sid->content_info.h))
|
|
|
|
{
|
|
|
|
sid->content_info.w = w;
|
|
|
|
sid->content_info.h = h;
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
|
|
|
|
evas_object_size_hint_min_set
|
|
|
|
(sid->edje_obj, sid->content_info.w, sid->content_info.h);
|
|
|
|
sid->content_info.resized = EINA_TRUE;
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_scroll_content_del_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Elm_Scrollable_Smart_Interface_Data *sid = data;
|
|
|
|
|
|
|
|
sid->content = NULL;
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
_elm_scroll_scroll_bar_reset(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2017-12-19 22:23:23 -08:00
|
|
|
_elm_interface_scrollable_scrollable_content_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Object *content)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord w = 0, h = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
if (!sid->edje_obj) return;
|
|
|
|
|
|
|
|
if (sid->content)
|
|
|
|
{
|
|
|
|
/* if we had content, for sure we had a pan object */
|
|
|
|
_elm_pan_content_set(sid->pan_obj, NULL);
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->content, EVAS_CALLBACK_DEL, _elm_scroll_content_del_cb, sid);
|
|
|
|
}
|
|
|
|
|
|
|
|
sid->content = content;
|
|
|
|
sid->wx = sid->wy = 0;
|
|
|
|
/* (-1) means want viewports size */
|
|
|
|
sid->ww = sid->wh = -1;
|
|
|
|
if (!content) return;
|
|
|
|
|
|
|
|
if (!sid->pan_obj)
|
|
|
|
{
|
|
|
|
o = _elm_pan_add(evas_object_evas_get(obj));
|
2018-11-22 06:47:52 -08:00
|
|
|
ELM_PAN_DATA_GET_OR_RETURN(o, pd);
|
|
|
|
pd->interface_object = obj;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->pan_obj = o;
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add
|
2016-03-02 04:10:48 -08:00
|
|
|
(o, ELM_PAN_EVENT_CHANGED, _elm_scroll_pan_changed_cb, sid);
|
2013-07-01 04:17:30 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_scroll_pan_resized_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
edje_object_part_swallow(sid->edje_obj, "elm.swallow.content", o);
|
|
|
|
else
|
|
|
|
edje_object_part_swallow(sid->edje_obj, "efl.content", o);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(content, EVAS_CALLBACK_DEL, _elm_scroll_content_del_cb, sid);
|
|
|
|
|
|
|
|
_elm_pan_content_set(sid->pan_obj, content);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &w, &h);
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->content_info.w = w;
|
|
|
|
sid->content_info.h = h;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
_elm_scroll_scroll_bar_reset(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_extern_pan_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Object *pan)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (!sid->edje_obj) return;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_set(obj, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
if (sid->pan_obj)
|
|
|
|
{
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_del(sid->pan_obj, ELM_PAN_EVENT_CHANGED, _elm_scroll_pan_changed_cb, sid);
|
2013-07-01 04:17:30 -07:00
|
|
|
evas_object_event_callback_del(sid->pan_obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_scroll_pan_resized_cb);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sid->extern_pan)
|
|
|
|
{
|
|
|
|
if (sid->pan_obj)
|
|
|
|
{
|
|
|
|
/* not owned by scroller, just leave (was external already) */
|
|
|
|
edje_object_part_unswallow(sid->edje_obj, sid->pan_obj);
|
|
|
|
sid->pan_obj = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(sid->pan_obj, evas_object_del);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
if (!pan)
|
|
|
|
{
|
|
|
|
sid->extern_pan = EINA_FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sid->pan_obj = pan;
|
|
|
|
|
|
|
|
sid->extern_pan = EINA_TRUE;
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add
|
2016-03-02 04:10:48 -08:00
|
|
|
(sid->pan_obj, ELM_PAN_EVENT_CHANGED, _elm_scroll_pan_changed_cb, sid);
|
2013-07-01 04:17:30 -07:00
|
|
|
evas_object_event_callback_add(sid->pan_obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_scroll_pan_resized_cb, sid);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
{
|
|
|
|
edje_object_part_swallow
|
|
|
|
(sid->edje_obj, "elm.swallow.content", sid->pan_obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_part_swallow
|
|
|
|
(sid->edje_obj, "efl.content", sid->pan_obj);
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_drag_start_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb drag_start_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.drag_start = drag_start_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_drag_stop_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb drag_stop_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.drag_stop = drag_stop_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_animate_start_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb animate_start_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.animate_start = animate_start_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_animate_stop_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb animate_stop_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.animate_stop = animate_stop_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_change_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb page_change_cb EINA_UNUSED)
|
2013-05-15 14:56:04 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.page_change = page_change_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_scroll_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb scroll_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.scroll = scroll_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_scroll_left_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb scroll_left_cb)
|
2013-03-15 02:53:17 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.scroll_left = scroll_left_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_scroll_right_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb scroll_right_cb)
|
2013-03-15 02:53:17 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.scroll_right = scroll_right_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_scroll_up_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb scroll_up_cb)
|
2013-03-15 02:53:17 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.scroll_up = scroll_up_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_scroll_down_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb scroll_down_cb)
|
2013-03-15 02:53:17 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.scroll_down = scroll_down_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_edge_left_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb edje_left_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
sid->cb_func.edge_left = edje_left_cb;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_edge_right_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb edje_right_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
sid->cb_func.edge_right = edje_right_cb;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_edge_top_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb edje_top_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
sid->cb_func.edge_top = edje_top_cb;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_edge_bottom_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb edje_bottom_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
sid->cb_func.edge_bottom = edje_bottom_cb;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_vbar_drag_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb vbar_drag_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.vbar_drag = vbar_drag_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_vbar_press_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb vbar_press_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.vbar_press = vbar_press_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_vbar_unpress_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb vbar_unpress_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.vbar_unpress = vbar_unpress_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_hbar_drag_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb hbar_drag_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.hbar_drag = hbar_drag_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_hbar_press_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb hbar_press_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.hbar_press = hbar_press_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_hbar_unpress_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Cb hbar_unpress_cb)
|
Add smart callback signals of a scroller. "vbar,drag", "vbar,press", "vbar,unpress", "hbar,drag", "hbar,press", "hbar,unpress".
SVN revision: 83703
2013-02-06 22:13:31 -08:00
|
|
|
{
|
|
|
|
sid->cb_func.hbar_unpress = hbar_unpress_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_min_limit_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Min_Limit_Cb min_limit_cb)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
sid->cb_func.content_min_limit = min_limit_cb;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_content_viewport_resize_cb_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Interface_Scrollable_Resize_Cb viewport_resize_cb)
|
2013-06-29 22:42:34 -07:00
|
|
|
{
|
|
|
|
sid->cb_func.content_viewport_resize = viewport_resize_cb;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_momentum_animator_disabled_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
return sid->momentum_animator_disabled;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_momentum_animator_disabled_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool disabled)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->momentum_animator_disabled = disabled;
|
|
|
|
if (sid->momentum_animator_disabled)
|
|
|
|
{
|
|
|
|
if (sid->down.momentum_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_bounce_animator_disabled_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
return sid->bounce_animator_disabled;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_bounce_animator_disabled_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool disabled)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->bounce_animator_disabled = disabled;
|
|
|
|
if (sid->bounce_animator_disabled)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_wheel_disabled_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
return sid->wheel_disabled;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_wheel_disabled_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool disabled)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (!sid->event_rect) return;
|
|
|
|
|
|
|
|
if ((!sid->wheel_disabled) && (disabled))
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_elm_scroll_wheel_event_cb, sid);
|
|
|
|
else if ((sid->wheel_disabled) && (!disabled))
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sid->event_rect, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_elm_scroll_wheel_event_cb, sid);
|
|
|
|
sid->wheel_disabled = disabled;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_step_size_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x < 1) x = 1;
|
|
|
|
if (y < 1) y = 1;
|
|
|
|
sid->step.x = x;
|
|
|
|
sid->step.y = y;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_step_size_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x) *x = sid->step.x;
|
|
|
|
if (y) *y = sid->step.y;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_size_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->page.x = x;
|
|
|
|
sid->page.y = y;
|
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_size_adjust(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_page_size_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord *x, Evas_Coord *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (x) *x = sid->page.x;
|
|
|
|
if (y) *y = sid->page.y;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_policy_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Scroller_Policy hbar, Elm_Scroller_Policy vbar)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (!sid->edje_obj) return;
|
|
|
|
|
|
|
|
if ((sid->hbar_flags == hbar) && (sid->vbar_flags == vbar)) return;
|
|
|
|
|
|
|
|
sid->hbar_flags = hbar;
|
|
|
|
sid->vbar_flags = vbar;
|
2013-04-15 21:27:55 -07:00
|
|
|
_elm_scroll_policy_signal_emit(sid);
|
2012-07-18 10:09:51 -07:00
|
|
|
if (sid->cb_func.content_min_limit)
|
|
|
|
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
|
2012-08-07 03:20:30 -07:00
|
|
|
_elm_direction_arrows_eval(sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_policy_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Scroller_Policy *hbar, Elm_Scroller_Policy *vbar)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (hbar) *hbar = sid->hbar_flags;
|
|
|
|
if (vbar) *vbar = sid->vbar_flags;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_single_direction_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Elm_Scroller_Single_Direction single_dir)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->one_direction_at_a_time = single_dir;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static Elm_Scroller_Single_Direction
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_single_direction_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
return sid->one_direction_at_a_time;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-02-14 18:14:52 -08:00
|
|
|
_elm_interface_scrollable_content_events_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool repeat_events)
|
2013-04-01 01:13:32 -07:00
|
|
|
{
|
|
|
|
if (sid->event_rect)
|
2013-04-01 05:14:43 -07:00
|
|
|
evas_object_repeat_events_set(sid->event_rect, repeat_events);
|
2013-04-01 01:13:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_events_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2013-04-01 01:13:32 -07:00
|
|
|
{
|
|
|
|
if (sid->event_rect)
|
2014-03-17 04:44:40 -07:00
|
|
|
return evas_object_repeat_events_get(sid->event_rect);
|
2013-04-01 01:13:32 -07:00
|
|
|
else
|
2014-03-17 04:44:40 -07:00
|
|
|
return EINA_TRUE;
|
2013-04-01 01:13:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_hold_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool hold)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->hold = hold;
|
|
|
|
}
|
2013-04-01 01:13:32 -07:00
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_freeze_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool freeze)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->freeze = freeze;
|
scroller: Fix freeze after dragging bars
The freeze property is a set() only but could internally
be reset to false, after dragging a vertical or horizontal slider.
Test scenario:
elementary_test -to scroller
Click Freeze, test the mouse wheel (can't do anything), drag a
scroller side bar, test the mouse wheel again.
Before this patch, the scroller would scroll. After the patch, the
scroller remains fixed, respecting the value of freeze.
FIXME: It is possible that the proper fix would be to disable
bars drag during freeze, but that is not the case currently.
NOTE: freeze, hold, movement_block, lock_x/y have very similar
meanings. The doc really needs clarification here, and some
property might be removed. Also, freeze and hold have no
getter, only a setter. drag_lock_x/y is part of elm_widget,
and not specific to scrollers.
2017-04-11 23:02:42 -07:00
|
|
|
sid->freeze_want = freeze;
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->freeze)
|
|
|
|
{
|
|
|
|
if (sid->down.onhold_animator)
|
|
|
|
{
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->content_info.resized)
|
|
|
|
_elm_scroll_wanted_region_set(sid->obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_elm_scroll_bounce_eval(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_snap_allow_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool horiz, Eina_Bool vert)
|
2013-05-17 07:30:42 -07:00
|
|
|
{
|
|
|
|
sid->page_snap_horiz = !!horiz;
|
|
|
|
sid->page_snap_vert = !!vert;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_page_snap_allow_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool *horiz, Eina_Bool *vert)
|
2013-05-17 07:30:42 -07:00
|
|
|
{
|
|
|
|
if (horiz) *horiz = sid->page_snap_horiz;
|
|
|
|
if (vert) *vert = sid->page_snap_vert;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_bounce_allow_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool horiz, Eina_Bool vert)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->bounce_horiz = !!horiz;
|
|
|
|
sid->bounce_vert = !!vert;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_bounce_allow_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool *horiz, Eina_Bool *vert)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (horiz) *horiz = sid->bounce_horiz;
|
|
|
|
if (vert) *vert = sid->bounce_vert;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_paging_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double pagerel_h, double pagerel_v, Evas_Coord pagesize_h, Evas_Coord pagesize_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
sid->pagerel_h = pagerel_h;
|
|
|
|
sid->pagerel_v = pagerel_v;
|
|
|
|
sid->pagesize_h = pagesize_h;
|
|
|
|
sid->pagesize_v = pagesize_v;
|
|
|
|
|
|
|
|
_elm_scroll_page_adjust(sid);
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_paging_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double *pagerel_h, double *pagerel_v, Evas_Coord *pagesize_h, Evas_Coord *pagesize_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (pagerel_h) *pagerel_h = sid->pagerel_h;
|
|
|
|
if (pagerel_v) *pagerel_v = sid->pagerel_v;
|
|
|
|
if (pagesize_h) *pagesize_h = sid->pagesize_h;
|
|
|
|
if (pagesize_v) *pagesize_v = sid->pagesize_v;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_relative_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *_pd EINA_UNUSED, double h_pagerel, double v_pagerel)
|
2013-05-24 06:23:28 -07:00
|
|
|
{
|
|
|
|
Evas_Coord pagesize_h, pagesize_v;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_paging_get(obj, NULL, NULL, &pagesize_h, &pagesize_v);
|
2013-05-24 06:23:28 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_paging_set(obj, h_pagerel, v_pagerel, pagesize_h, pagesize_v);
|
2013-05-24 06:23:28 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_scroll_limit_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, int page_limit_h, int page_limit_v)
|
2013-04-05 21:06:43 -07:00
|
|
|
{
|
|
|
|
sid->page_limit_h = page_limit_h;
|
|
|
|
sid->page_limit_v = page_limit_v;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_page_scroll_limit_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, int *page_limit_h, int *page_limit_v)
|
2013-04-05 21:06:43 -07:00
|
|
|
{
|
|
|
|
if (page_limit_h) *page_limit_h = sid->page_limit_h;
|
|
|
|
if (page_limit_v) *page_limit_v = sid->page_limit_v;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_current_page_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, int *pagenumber_h, int *pagenumber_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Evas_Coord x, y;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (pagenumber_h)
|
|
|
|
{
|
2017-01-15 21:20:04 -08:00
|
|
|
if (sid->is_mirrored)
|
|
|
|
x = _elm_scroll_x_mirrored_get(sid->obj, x);
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (sid->pagesize_h > 0)
|
2013-06-17 09:23:45 -07:00
|
|
|
{
|
|
|
|
double result = (double)x / (double)sid->pagesize_h;
|
|
|
|
double rest = result - (x / sid->pagesize_h);
|
|
|
|
if (rest >= 0.5)
|
|
|
|
*pagenumber_h = result + 1;
|
|
|
|
else
|
|
|
|
*pagenumber_h = result;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
else
|
|
|
|
*pagenumber_h = 0;
|
|
|
|
}
|
|
|
|
if (pagenumber_v)
|
|
|
|
{
|
|
|
|
if (sid->pagesize_v > 0)
|
2013-06-17 09:23:45 -07:00
|
|
|
{
|
|
|
|
double result = (double)y / (double)sid->pagesize_v;
|
|
|
|
double rest = result - (y / sid->pagesize_v);
|
|
|
|
if (rest >= 0.5)
|
|
|
|
*pagenumber_v = result + 1;
|
|
|
|
else
|
|
|
|
*pagenumber_v = result;
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
else
|
|
|
|
*pagenumber_v = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_last_page_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, int *pagenumber_h, int *pagenumber_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
Evas_Coord cw, ch;
|
|
|
|
|
|
|
|
if (!sid->pan_obj) return;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (pagenumber_h)
|
|
|
|
{
|
2015-01-11 18:51:41 -08:00
|
|
|
if ((sid->pagesize_h > 0) && (cw > sid->pagesize_h))
|
2016-12-05 20:30:43 -08:00
|
|
|
*pagenumber_h = ceil((double)cw / (double)sid->pagesize_h) - 1;
|
2012-07-04 14:41:01 -07:00
|
|
|
else
|
|
|
|
*pagenumber_h = 0;
|
|
|
|
}
|
|
|
|
if (pagenumber_v)
|
|
|
|
{
|
2015-01-11 18:51:41 -08:00
|
|
|
if ((sid->pagesize_v > 0) && (ch > sid->pagesize_v))
|
2016-12-05 20:30:43 -08:00
|
|
|
*pagenumber_v = ceil((double)ch / (double)sid->pagesize_v) - 1;
|
2012-07-04 14:41:01 -07:00
|
|
|
else
|
|
|
|
*pagenumber_v = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, int pagenumber_h, int pagenumber_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord w = 0, h = 0;
|
2012-11-30 02:08:23 -08:00
|
|
|
Evas_Coord x = 0;
|
|
|
|
Evas_Coord y = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2013-05-15 14:56:04 -07:00
|
|
|
sid->current_page.x = _elm_scroll_page_x_get(sid, 0, EINA_FALSE);
|
|
|
|
sid->current_page.y = _elm_scroll_page_y_get(sid, 0, EINA_FALSE);
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2015-08-28 05:12:30 -07:00
|
|
|
x = sid->pagesize_h * pagenumber_h;
|
2017-01-15 21:20:04 -08:00
|
|
|
x = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
|
2015-08-28 05:12:30 -07:00
|
|
|
y = sid->pagesize_v * pagenumber_v;
|
2013-06-19 07:31:36 -07:00
|
|
|
|
2017-01-15 21:20:04 -08:00
|
|
|
sid->wx = x;
|
2013-06-19 07:31:36 -07:00
|
|
|
sid->wy = y;
|
|
|
|
sid->ww = w;
|
|
|
|
sid->wh = h;
|
|
|
|
|
2012-07-04 14:41:01 -07:00
|
|
|
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_pos_set(obj, x, y, EINA_TRUE);
|
2013-05-15 14:56:04 -07:00
|
|
|
|
|
|
|
if ((sid->current_page.x != x) || (sid->current_page.y != y))
|
|
|
|
{
|
|
|
|
if (sid->cb_func.page_change)
|
|
|
|
sid->cb_func.page_change(sid->obj, NULL);
|
|
|
|
}
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_page_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, int pagenumber_h, int pagenumber_v)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2014-04-03 08:23:51 -07:00
|
|
|
Evas_Coord w = 0, h = 0;
|
2012-11-30 02:08:23 -08:00
|
|
|
Evas_Coord x = 0;
|
|
|
|
Evas_Coord y = 0;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_viewport_geometry_get
|
|
|
|
(sid->obj, NULL, NULL, &w, &h);
|
2015-08-28 05:12:30 -07:00
|
|
|
x = sid->pagesize_h * pagenumber_h;
|
2017-01-15 21:20:04 -08:00
|
|
|
x = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
|
2015-08-28 05:12:30 -07:00
|
|
|
y = sid->pagesize_v * pagenumber_v;
|
2012-07-04 14:41:01 -07:00
|
|
|
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
|
|
|
{
|
|
|
|
_elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x);
|
|
|
|
_elm_scroll_scroll_to_y(sid, _elm_config->bring_in_scroll_friction, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_region_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
|
|
|
{
|
|
|
|
_elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x);
|
|
|
|
_elm_scroll_scroll_to_y(sid, _elm_config->bring_in_scroll_friction, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_gravity_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double x, double y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-09-21 04:44:53 -07:00
|
|
|
sid->gravity_x = x;
|
|
|
|
sid->gravity_y = y;
|
2017-02-19 18:31:12 -08:00
|
|
|
elm_obj_pan_pos_max_get(sid->pan_obj, &sid->prev_cw, &sid->prev_ch);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_gravity_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double *x, double *y)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2016-09-21 04:44:53 -07:00
|
|
|
if (x) *x = sid->gravity_x;
|
|
|
|
if (y) *y = sid->gravity_y;
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2017-08-29 01:49:38 -07:00
|
|
|
_elm_interface_scrollable_movement_block_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Efl_Ui_Scroll_Block block)
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
|
|
|
sid->block = block;
|
|
|
|
}
|
|
|
|
|
2017-08-29 01:49:38 -07:00
|
|
|
EOLIAN static Efl_Ui_Scroll_Block
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_movement_block_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid)
|
2013-05-09 12:26:29 -07:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
return sid->block;
|
2013-05-09 12:26:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-23 19:01:03 -08:00
|
|
|
EOLIAN static void
|
2018-02-14 18:14:52 -08:00
|
|
|
_elm_interface_scrollable_content_loop_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool loop_h, Eina_Bool loop_v)
|
2015-01-23 19:01:03 -08:00
|
|
|
{
|
|
|
|
if (sid->loop_h == loop_h && sid->loop_v == loop_v) return;
|
|
|
|
|
|
|
|
sid->loop_h = loop_h;
|
|
|
|
sid->loop_v = loop_v;
|
2015-08-28 04:40:43 -07:00
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (sid->loop_h)
|
2015-08-28 04:40:43 -07:00
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,loop_x,set", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,loop_x,unset", "elm");
|
|
|
|
|
2018-08-31 01:46:25 -07:00
|
|
|
if (sid->loop_v)
|
2015-08-28 04:40:43 -07:00
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,loop_y,set", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sid->edje_obj, "elm,loop_y,unset", "elm");
|
2015-01-23 19:01:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_content_loop_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, Eina_Bool *loop_h, Eina_Bool *loop_v)
|
2015-01-23 19:01:03 -08:00
|
|
|
{
|
|
|
|
*loop_h = sid->loop_h;
|
|
|
|
*loop_v = sid->loop_v;
|
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_interface_scrollable_efl_canvas_group_group_add(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
|
|
|
memset(sid, 0, sizeof(*sid));
|
|
|
|
|
|
|
|
sid->obj = obj;
|
|
|
|
|
|
|
|
sid->x = 0;
|
|
|
|
sid->y = 0;
|
|
|
|
sid->w = 0;
|
|
|
|
sid->h = 0;
|
2016-02-18 10:37:13 -08:00
|
|
|
sid->step.x = 32 * elm_config_scale_get();
|
|
|
|
sid->step.y = 32 * elm_config_scale_get();
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->page.x = -50;
|
|
|
|
sid->page.y = -50;
|
2013-04-05 21:06:43 -07:00
|
|
|
sid->page_limit_h = 9999;
|
|
|
|
sid->page_limit_v = 9999;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->hbar_flags = ELM_SCROLLER_POLICY_AUTO;
|
|
|
|
sid->vbar_flags = ELM_SCROLLER_POLICY_AUTO;
|
|
|
|
sid->hbar_visible = EINA_TRUE;
|
|
|
|
sid->vbar_visible = EINA_TRUE;
|
2015-01-23 19:01:03 -08:00
|
|
|
sid->loop_h = EINA_FALSE;
|
|
|
|
sid->loop_v = EINA_FALSE;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
sid->bounce_horiz = EINA_TRUE;
|
|
|
|
sid->bounce_vert = EINA_TRUE;
|
|
|
|
|
2013-04-10 04:06:41 -07:00
|
|
|
sid->one_direction_at_a_time = ELM_SCROLLER_SINGLE_DIRECTION_SOFT;
|
2012-07-04 14:41:01 -07:00
|
|
|
sid->momentum_animator_disabled = EINA_FALSE;
|
|
|
|
sid->bounce_animator_disabled = EINA_FALSE;
|
2017-08-29 01:49:38 -07:00
|
|
|
sid->block = EFL_UI_SCROLL_BLOCK_NONE;
|
2012-07-04 14:41:01 -07:00
|
|
|
|
|
|
|
_elm_scroll_scroll_bar_reset(sid);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_SCROLLABLE_INTERFACE));
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_interface_scrollable_efl_canvas_group_group_del(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid)
|
2012-07-04 14:41:01 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_SCROLLABLE_INTERFACE));
|
2012-07-04 14:41:01 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_scrollable_content_set(obj, NULL);
|
2012-07-04 14:41:01 -07:00
|
|
|
if (!sid->extern_pan) evas_object_del(sid->pan_obj);
|
|
|
|
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_idle_enterer_del(sid->down.hold_enterer);
|
2016-01-26 15:51:49 -08:00
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.hold_animator, _elm_scroll_hold_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.onhold_animator, _elm_scroll_on_hold_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.momentum_animator, _elm_scroll_momentum_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_x_animator, _elm_scroll_bounce_x_animator, sid->obj);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->down.bounce_y_animator, _elm_scroll_bounce_y_animator, sid->obj);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.x.animator, _elm_scroll_scroll_to_x_animator, sid);
|
|
|
|
ELM_ANIMATOR_DISCONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid);
|
2012-07-04 14:41:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
EOLIAN static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_interface_scrollable_class_constructor(Efl_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-17 04:44:40 -07:00
|
|
|
evas_smart_legacy_type_register(MY_SCROLLABLE_INTERFACE_NAME_LEGACY, klass);
|
|
|
|
}
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2016-12-20 08:25:57 -08:00
|
|
|
|
2017-02-22 22:32:17 -08:00
|
|
|
/* Legacy ABI compatibility - APIs never worked and were hidden behind
|
|
|
|
* EFL_EO_API_SUPPORT (from elm_interface.h) or inside internal headers.
|
|
|
|
* Removed between 1.18 and 1.19. The symbols are kept purely for ABI
|
|
|
|
* compatibility reasons.
|
|
|
|
*/
|
|
|
|
EAPI void elm_pan_gravity_set(Elm_Pan *obj EINA_UNUSED, double x EINA_UNUSED, double y EINA_UNUSED) {}
|
|
|
|
EAPI void elm_pan_gravity_get(const Elm_Pan *obj EINA_UNUSED, double *x EINA_UNUSED, double *y EINA_UNUSED) {}
|
|
|
|
|
2017-06-08 14:52:37 -07:00
|
|
|
EOLIAN static Efl_Ui_Focus_Manager*
|
2018-05-16 10:30:28 -07:00
|
|
|
_elm_interface_scrollable_efl_ui_widget_focus_manager_focus_manager_create(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root)
|
2017-06-08 14:52:37 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Focus_Manager *manager;
|
|
|
|
|
2018-03-15 04:46:47 -07:00
|
|
|
manager = efl_add(EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS, obj,
|
2017-06-08 14:52:37 -07:00
|
|
|
efl_ui_focus_manager_root_set(efl_added, root)
|
|
|
|
);
|
|
|
|
|
|
|
|
return manager;
|
|
|
|
}
|
|
|
|
|
2016-12-20 08:25:57 -08:00
|
|
|
EOLIAN static Efl_Object*
|
|
|
|
_elm_interface_scrollable_efl_object_constructor(Eo *obj, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED)
|
|
|
|
{
|
2018-03-27 02:34:14 -07:00
|
|
|
Eo *o = efl_constructor(efl_super(obj, MY_SCROLLABLE_INTERFACE));
|
2016-12-20 09:21:58 -08:00
|
|
|
|
2018-03-27 02:34:14 -07:00
|
|
|
return o;
|
2016-12-20 08:25:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_filter_cb(const void *iterator EINA_UNUSED, void *data, void *fdata)
|
|
|
|
{
|
2017-10-10 12:35:27 -07:00
|
|
|
Eina_Rect geom;
|
2018-04-25 05:01:48 -07:00
|
|
|
int min_x, max_x, min_y, max_y;
|
2016-12-20 08:25:57 -08:00
|
|
|
|
2017-10-10 12:35:27 -07:00
|
|
|
geom = efl_ui_focus_object_focus_geometry_get(data);
|
2016-12-20 08:25:57 -08:00
|
|
|
|
2018-04-25 05:01:48 -07:00
|
|
|
min_x = geom.rect.x;
|
|
|
|
min_y = geom.rect.y;
|
|
|
|
max_x = eina_rectangle_max_x(&geom.rect);
|
|
|
|
max_y = eina_rectangle_max_y(&geom.rect);
|
|
|
|
|
|
|
|
Eina_Bool inside = eina_rectangle_coords_inside(fdata, min_x, min_y) ||
|
|
|
|
eina_rectangle_coords_inside(fdata, min_x, max_y) ||
|
|
|
|
eina_rectangle_coords_inside(fdata, max_x, min_y) ||
|
|
|
|
eina_rectangle_coords_inside(fdata, max_x, max_y);
|
|
|
|
|
|
|
|
return inside;
|
2016-12-20 08:25:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Iterator*
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_efl_ui_focus_manager_border_elements_get(const Eo *obj, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED)
|
2016-12-20 08:25:57 -08:00
|
|
|
{
|
|
|
|
Eina_Iterator *border_elements;
|
|
|
|
Eina_Rectangle *rect = calloc(1, sizeof(Eina_Rectangle));
|
|
|
|
|
|
|
|
border_elements = efl_ui_focus_manager_border_elements_get(efl_super(obj, MY_SCROLLABLE_INTERFACE));
|
|
|
|
elm_interface_scrollable_content_viewport_geometry_get(obj, &rect->x, &rect->y, &rect->w, &rect->h);
|
|
|
|
|
|
|
|
return eina_iterator_filter_new(border_elements, _filter_cb, free, rect);
|
|
|
|
}
|
|
|
|
|
2017-08-30 00:15:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_interface_scrollable_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED, Eina_Bool enable EINA_UNUSED)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_interface_scrollable_item_loop_enabled_get(const Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED)
|
2017-08-30 00:15:34 -07:00
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define ELM_PAN_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_pan)
|
|
|
|
|
|
|
|
#define ELM_INTERFACE_SCROLLABLE_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_interface_scrollable)
|
|
|
|
|
2014-03-17 04:44:40 -07:00
|
|
|
#include "elm_interface_scrollable.eo.c"
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "elm_pan_eo.c"
|