efl/src/lib/elementary/efl_ui_pan.c

198 lines
5.8 KiB
C
Raw Normal View History

scroller: Introducing Efl.Ui.Scroller Summary: scrollable widgets had a interface_scrollable as a mixin so that the widgets had a 'is-a' relation with interface_scrollabe. however, new scroller concept don't have 'is-a' relationship, but 'has-a' relationship. scrollable widgets should have a scroll manager inside them, then scroll manager handles event from user and api implementations. and also we cut the features such as paging because there will be aka 'elm_pager'. we are expecting that the new concept make us to maintain the scroller easier. please excuse for many unorganized code and logics. : ( [contained commit] scrollable: add efl_ui_scroller example scrollable: refactoring for behavior in case of multiple scroller scrollable: remove repetitive scrollbar code. scrollable: combine calculating bounce distance code. scroll_manager: mouse up function refactoring scroll_manager: mouse move function refactoring scroll_manager: warp animator wip scroll_manager: fix denominator value when calculating flicking behavior. Fix to disconnect bounce animator once animation is done gather duplicated animator drop logics gather duplicated conditions Rearrange prototypes and append comment Add manipulate functions for animators scroll_manager: change member_add function. scroll_manger: apply mirroring logic scroll_manager: apply scrollbar apply API to scroller widget scroll_manager: apply scroll event callback Change logics for all about scroll animating efl_ui_pan: add efl_ui_pan scrollable: change content_min_limit to match_content scroll theme: apply overlapped scrollbar + many others! Reviewers: akanad, woohyun, cedric, jpeg Subscribers: jenkins, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5222 Note by @jpeg: Unfortunately this patch comes in a massive single blob, after too many rebase operations. It has now come to a point where I think the API is nice and it works as I'd expect. Now I only wonder how applicable this will be for Efl.Ui.List. As we can see Photocam (legacy and unified API) could be transformed to use this new API.
2017-12-18 04:08:25 -08:00
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_widget_pan.h"
#define MY_CLASS EFL_UI_PAN_CLASS
#define MY_CLASS_NAME "Efl_Ui_Pan"
#define EFL_UI_PAN_DATA_GET(o, sd) \
Efl_Ui_Pan_Data *sd = efl_data_scope_safe_get(o, MY_CLASS)
#define EFL_UI_PAN_DATA_GET_OR_RETURN(o, ptr, ...) \
EFL_UI_PAN_DATA_GET(o, ptr); \
if (EINA_UNLIKELY(!ptr)) \
{ \
CRI("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return __VA_ARGS__; \
}
EOLIAN static void
_efl_ui_pan_efl_gfx_position_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Position2D pos)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
return;
efl_gfx_position_set(efl_super(obj, MY_CLASS), pos);
psd->x = pos.x;
psd->y = pos.y;
evas_object_smart_changed(obj);
}
EOLIAN static void
_efl_ui_pan_efl_gfx_size_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Size2D sz)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
return;
efl_gfx_size_set(efl_super(obj, MY_CLASS), sz);
psd->w = sz.w;
psd->h = sz.h;
evas_object_smart_changed(obj);
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_VIEWPORT_CHANGED, NULL);
}
EOLIAN static void
_efl_ui_pan_efl_gfx_visible_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Bool vis)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
return;
efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);
if (psd->content) efl_gfx_visible_set(psd->content, vis);
}
EOLIAN static void
_efl_ui_pan_pan_position_set(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd, Eina_Position2D pos)
{
if ((pos.x == psd->px) && (pos.y == psd->py)) return;
psd->px = pos.x;
psd->py = pos.y;
evas_object_smart_changed(obj);
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_POSITION_CHANGED, NULL);
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
return EINA_POSITION2D(psd->px, psd->py);
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
Eina_Position2D pos = { 0, 0};
if (psd->w < psd->content_w) pos.x = psd->content_w - psd->w;
if (psd->h < psd->content_h) pos.y = psd->content_h - psd->h;
return pos;
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *_pd EINA_UNUSED)
{
return EINA_POSITION2D(0 ,0);
}
EOLIAN static Eina_Size2D
_efl_ui_pan_content_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
return EINA_SIZE2D(psd->content_w, psd->content_h);
}
EOLIAN static Eo *
_efl_ui_pan_efl_object_constructor(Eo *obj, Efl_Ui_Pan_Data *_pd EINA_UNUSED)
{
efl_canvas_group_clipped_set(obj, EINA_TRUE);
obj = efl_constructor(efl_super(obj, MY_CLASS));
return obj;
}
EOLIAN static void
_efl_ui_pan_efl_object_destructor(Eo *obj, Efl_Ui_Pan_Data *sd EINA_UNUSED)
{
efl_content_set(obj, NULL);
efl_destructor(efl_super(obj, MY_CLASS));
}
static void
_efl_ui_pan_content_del_cb(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *pobj = data;
EFL_UI_PAN_DATA_GET_OR_RETURN(pobj, psd);
psd->content = NULL;
psd->content_w = psd->content_h = psd->px = psd->py = 0;
efl_event_callback_call(pobj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
}
static void
_efl_ui_pan_content_resize_cb(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *pobj = data;
EFL_UI_PAN_DATA_GET_OR_RETURN(pobj, psd);
Eina_Size2D sz = efl_gfx_size_get(psd->content);
if ((sz.w != psd->content_w) || (sz.h != psd->content_h))
{
psd->content_w = sz.w;
psd->content_h = sz.h;
evas_object_smart_changed(pobj);
}
efl_event_callback_call(pobj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
}
EOLIAN static Eina_Bool
_efl_ui_pan_efl_content_content_set(Evas_Object *obj, Efl_Ui_Pan_Data *psd, Evas_Object *content)
{
Eina_Size2D sz;
if (content == psd->content) return EINA_TRUE;
if (psd->content)
{
efl_canvas_group_member_del(obj, psd->content);
evas_object_event_callback_del_full
(psd->content, EVAS_CALLBACK_DEL, _efl_ui_pan_content_del_cb, obj);
evas_object_event_callback_del_full
(psd->content, EVAS_CALLBACK_RESIZE, _efl_ui_pan_content_resize_cb,
obj);
psd->content = NULL;
psd->content_w = psd->content_h = psd->px = psd->py = 0;
}
if (!content) goto end;
psd->content = content;
efl_canvas_group_member_add(obj, content);
sz = efl_gfx_size_get(psd->content);
psd->content_w = sz.w;
psd->content_h = sz.h;
evas_object_event_callback_add
(content, EVAS_CALLBACK_DEL, _efl_ui_pan_content_del_cb, obj);
evas_object_event_callback_add
(content, EVAS_CALLBACK_RESIZE, _efl_ui_pan_content_resize_cb, obj);
if (evas_object_visible_get(obj))
evas_object_show(psd->content);
else
evas_object_hide(psd->content);
evas_object_smart_changed(obj);
end:
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
return EINA_TRUE;
}
EOLIAN static void
_efl_ui_pan_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
efl_gfx_position_set(psd->content, EINA_POSITION2D(psd->x - psd->px, psd->y - psd->py));
}
#include "efl_ui_pan.eo.c"