forked from enlightenment/efl
scrollable_interface: fixed gravity_set() API.
Summary: elm_scroller_gravity_set() API is not working. Test Plan: elementary_test -> scroller3 Reviewers: jaehwan, SanghyeonLee, Hermet, jypark, raster, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4252
This commit is contained in:
parent
53095d6fc7
commit
f148296ed1
|
@ -592,6 +592,15 @@ _append_items(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
_timer = ecore_timer_add(0.3, _append_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *sl = data;
|
||||
double val = elm_slider_value_get(obj);
|
||||
elm_scroller_gravity_set(sl, 0.0, val);
|
||||
printf("Gravity change to %lf\n",val);
|
||||
}
|
||||
|
||||
static void
|
||||
_win_del_cb(void *data EINA_UNUSED,
|
||||
Evas *e EINA_UNUSED,
|
||||
|
@ -605,7 +614,7 @@ _win_del_cb(void *data EINA_UNUSED,
|
|||
void
|
||||
test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bt, *bt2, *bt3, *bx, *bx2, *bx3, *bx4, *sc;
|
||||
Evas_Object *win, *bt, *bt2, *bt3, *bx, *bx2, *bx3, *bx4, *sc, *sl;
|
||||
_count = 0;
|
||||
|
||||
win = elm_win_util_standard_add("scroller3", "Scroller 3");
|
||||
|
@ -639,9 +648,20 @@ test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
|
|||
elm_box_pack_end(bx2, bt3);
|
||||
evas_object_show(bt3);
|
||||
|
||||
sl = elm_slider_add(bx);
|
||||
elm_object_text_set(sl, "Gravity");
|
||||
elm_slider_unit_format_set(sl, "%1.1f");
|
||||
elm_slider_indicator_format_set(sl, "%1.1f");
|
||||
elm_slider_min_max_set(sl, 0, 1);
|
||||
elm_slider_value_set(sl, 0.0);
|
||||
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.1);
|
||||
elm_box_pack_end(bx, sl);
|
||||
evas_object_show(sl);
|
||||
|
||||
bx3 = elm_box_add(bx);
|
||||
evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.9);
|
||||
evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.8);
|
||||
elm_box_pack_end(bx, bx3);
|
||||
evas_object_show(bx3);
|
||||
|
||||
|
@ -660,6 +680,7 @@ test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
|
|||
evas_object_smart_callback_add(bt, "clicked", _append_item, bx4);
|
||||
evas_object_smart_callback_add(bt2, "clicked", _prepend_item, bx4);
|
||||
evas_object_smart_callback_add(bt3, "clicked", _append_items, bx4);
|
||||
evas_object_smart_callback_add(sl, "changed", _changed_cb, sc);
|
||||
|
||||
evas_object_resize(win, 500, 500);
|
||||
evas_object_show(win);
|
||||
|
|
|
@ -81,26 +81,8 @@ _round(double value, int pos)
|
|||
|
||||
static void
|
||||
_elm_pan_update(Elm_Pan_Smart_Data *psd)
|
||||
{
|
||||
if (!psd->gravity_x && !psd->gravity_y)
|
||||
{
|
||||
evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!psd->px) && (!psd->py))
|
||||
{
|
||||
psd->px = psd->delta_posx * psd->gravity_x;
|
||||
psd->py = psd->delta_posy * psd->gravity_y;
|
||||
}
|
||||
psd->delta_posx += psd->content_w - psd->prev_cw;
|
||||
psd->prev_cw = psd->content_w;
|
||||
psd->delta_posy += psd->content_h - psd->prev_ch;
|
||||
psd->prev_ch = psd->content_h;
|
||||
|
||||
evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
|
||||
psd->px = psd->delta_posx * psd->gravity_x;
|
||||
psd->py = psd->delta_posy * psd->gravity_y;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -205,24 +187,6 @@ _elm_pan_content_size_get(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coo
|
|||
if (h) *h = psd->content_h;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_pan_gravity_set(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, double x, double y)
|
||||
{
|
||||
psd->gravity_x = x;
|
||||
psd->gravity_y = y;
|
||||
psd->prev_cw = psd->content_w;
|
||||
psd->prev_ch = psd->content_h;
|
||||
psd->delta_posx = 0;
|
||||
psd->delta_posy = 0;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_pan_gravity_get(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, double *x, double *y)
|
||||
{
|
||||
if (x) *x = psd->gravity_x;
|
||||
if (y) *y = psd->gravity_y;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_elm_pan_add(Evas *evas)
|
||||
{
|
||||
|
@ -250,8 +214,7 @@ _elm_pan_content_del_cb(void *data,
|
|||
|
||||
psd = data;
|
||||
psd->content = NULL;
|
||||
psd->content_w = psd->content_h = psd->px = psd->py =
|
||||
psd->prev_cw = psd->prev_ch = psd->delta_posx = psd->delta_posy = 0;
|
||||
psd->content_w = psd->content_h = psd->px = psd->py = 0;
|
||||
efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
|
||||
}
|
||||
|
||||
|
@ -1873,6 +1836,12 @@ _elm_scroll_wanted_region_set(Evas_Object *obj)
|
|||
wh = sid->wh;
|
||||
}
|
||||
|
||||
wx += (sid->content_info.w - sid->prev_cw) * sid->gravity_x;
|
||||
sid->wy += (sid->content_info.h - sid->prev_ch) * sid->gravity_y;
|
||||
|
||||
sid->prev_cw = sid->content_info.w;
|
||||
sid->prev_ch = sid->content_info.h;
|
||||
|
||||
elm_interface_scrollable_content_region_set(obj, wx, sid->wy, ww, wh);
|
||||
}
|
||||
|
||||
|
@ -4427,17 +4396,17 @@ _elm_interface_scrollable_region_bring_in(Eo *obj, Elm_Scrollable_Smart_Interfac
|
|||
EOLIAN static void
|
||||
_elm_interface_scrollable_gravity_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double x, double y)
|
||||
{
|
||||
if (!sid->pan_obj) return;
|
||||
|
||||
elm_obj_pan_gravity_set(sid->pan_obj, x, y);
|
||||
sid->gravity_x = x;
|
||||
sid->gravity_y = y;
|
||||
sid->prev_cw = sid->content_info.w;
|
||||
sid->prev_ch = sid->content_info.h;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_interface_scrollable_gravity_get(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double *x, double *y)
|
||||
{
|
||||
if (!sid->pan_obj) return;
|
||||
|
||||
elm_obj_pan_gravity_get(sid->pan_obj, x, y);
|
||||
if (x) *x = sid->gravity_x;
|
||||
if (y) *y = sid->gravity_y;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
|
|
@ -48,8 +48,6 @@ struct _Elm_Pan_Smart_Data
|
|||
Evas_Object *content;
|
||||
Evas_Coord x, y, w, h;
|
||||
Evas_Coord content_w, content_h, px, py;
|
||||
double gravity_x, gravity_y;
|
||||
Evas_Coord prev_cw, prev_ch, delta_posx, delta_posy;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -209,6 +207,10 @@ struct _Elm_Scrollable_Smart_Interface_Data
|
|||
unsigned char size_adjust_recurse;
|
||||
unsigned char size_count;
|
||||
void *event_info;
|
||||
|
||||
double gravity_x, gravity_y;
|
||||
Evas_Coord prev_cw, prev_ch;
|
||||
|
||||
Eina_Bool size_adjust_recurse_abort : 1;
|
||||
|
||||
Eina_Bool momentum_animator_disabled : 1;
|
||||
|
|
|
@ -5,16 +5,6 @@ class Elm.Pan (Efl.Canvas.Group.Clipped)
|
|||
event_prefix: elm_pan;
|
||||
data: Elm_Pan_Smart_Data;
|
||||
methods {
|
||||
@property gravity {
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
x: double;
|
||||
y: double;
|
||||
}
|
||||
}
|
||||
@property pos {
|
||||
set {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue