From aa7376a7bbddb690a052a23d8de5beda9240fba5 Mon Sep 17 00:00:00 2001 From: godlytalias14573465 Date: Mon, 9 Dec 2019 18:02:47 +0530 Subject: [PATCH] Genlist: Loop feature implementation for genlist Change-Id: I9338ad4f2b70a779db520e2dc81f6edea335894e Signed-off-by: godlytalias14573465 --- src/lib/elementary/elm_genlist.c | 18 +++++ src/lib/elementary/elm_genlist_eo.c | 6 ++ src/lib/elementary/elm_interface_scrollable.c | 98 ++++++++++++++++++++++++++- src/lib/elementary/elm_interface_scrollable.h | 3 + src/lib/elementary/elm_widget_genlist.h | 4 ++ src/lib/elementary_tizen/elm_genlist.c | 78 +++++++++++++++++++-- src/lib/elementary_tizen/elm_widget_genlist.h | 4 ++ 7 files changed, 201 insertions(+), 10 deletions(-) diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index 13c5d93..e4a22a2 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -8226,6 +8226,24 @@ elm_genlist_bounce_get(const Evas_Object *obj, (obj, h_bounce, v_bounce); } + +//TIZEN_ONLY(20191209): Genlist looping implementation +EOLIAN static void +_elm_genlist_elm_interface_scrollable_content_loop_set(Eo *obj, Elm_Genlist_Data *sd, Eina_Bool loop_h, Eina_Bool loop_v) +{ + sd->loop_h = !!loop_h; + sd->loop_v = !!loop_v; + elm_interface_scrollable_content_loop_set(efl_super(obj, MY_CLASS), sd->loop_h, sd->loop_v); +} + +EOLIAN static void +_elm_genlist_elm_interface_scrollable_content_loop_get(Eo *obj, Elm_Genlist_Data *sd, Eina_Bool *loop_h, Eina_Bool *loop_v) +{ + if (loop_h) *loop_h = sd->loop_h; + if (loop_v) *loop_v = sd->loop_v; +} +// + EOLIAN static void _elm_genlist_elm_interface_scrollable_bounce_allow_get(const Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, Eina_Bool *h_bounce, Eina_Bool *v_bounce) { diff --git a/src/lib/elementary/elm_genlist_eo.c b/src/lib/elementary/elm_genlist_eo.c index 11800b6..79ebe21 100644 --- a/src/lib/elementary/elm_genlist_eo.c +++ b/src/lib/elementary/elm_genlist_eo.c @@ -504,6 +504,9 @@ void _elm_genlist_elm_interface_scrollable_item_loop_enabled_set(Eo *obj, Elm_Ge Eina_Bool _elm_genlist_elm_interface_scrollable_item_loop_enabled_get(const Eo *obj, Elm_Genlist_Data *pd); +//TIZEN_ONLY(20191209): Genlist looping implementation +void _elm_genlist_elm_interface_scrollable_content_loop_set(Eo *obj, Elm_Genlist_Data *pd, Eina_Bool loop_h, Eina_Bool loop_v); +// void _elm_genlist_elm_interface_scrollable_bounce_allow_set(Eo *obj, Elm_Genlist_Data *pd, Eina_Bool horiz, Eina_Bool vert); @@ -645,6 +648,9 @@ _elm_genlist_class_initializer(Efl_Class *klass) EFL_OBJECT_OP_FUNC(efl_ui_widget_screen_reader, _elm_genlist_efl_ui_widget_screen_reader), EFL_OBJECT_OP_FUNC(elm_interface_scrollable_item_loop_enabled_set, _elm_genlist_elm_interface_scrollable_item_loop_enabled_set), EFL_OBJECT_OP_FUNC(elm_interface_scrollable_item_loop_enabled_get, _elm_genlist_elm_interface_scrollable_item_loop_enabled_get), +//TIZEN_ONLY(20191209): Genlist looping implementation + EFL_OBJECT_OP_FUNC(elm_interface_scrollable_content_loop_set, _elm_genlist_elm_interface_scrollable_content_loop_set), +// EFL_OBJECT_OP_FUNC(elm_interface_scrollable_bounce_allow_set, _elm_genlist_elm_interface_scrollable_bounce_allow_set), EFL_OBJECT_OP_FUNC(elm_interface_scrollable_bounce_allow_get, _elm_genlist_elm_interface_scrollable_bounce_allow_get), EFL_OBJECT_OP_FUNC(elm_interface_scrollable_policy_set, _elm_genlist_elm_interface_scrollable_policy_set), diff --git a/src/lib/elementary/elm_interface_scrollable.c b/src/lib/elementary/elm_interface_scrollable.c index 53d9126..3444300 100644 --- a/src/lib/elementary/elm_interface_scrollable.c +++ b/src/lib/elementary/elm_interface_scrollable.c @@ -2747,6 +2747,11 @@ _elm_scroll_momentum_animator(void *data, const Efl_Event *event EINA_UNUSED) sid->down.by = sid->down.by0 - dy + sid->down.b0y; y = py; } + //TIZEN_ONLY(20191209): Genlist looping implementation + if (sid->loop_v && y < 0) + y = sid->content_info.h + y; + // + elm_interface_scrollable_content_pos_set(sid->obj, x, y, EINA_TRUE); _elm_scroll_wanted_coordinates_update(sid, x, y); elm_obj_pan_pos_max_get(sid->pan_obj, &maxx, &maxy); @@ -2933,8 +2938,34 @@ _elm_scroll_scroll_to_y_animator(void *data, const Efl_Event *event EINA_UNUSED) tt = 1.0 - tt; tt = 1.0 - (tt * tt); elm_obj_pan_pos_get(sid->pan_obj, &px, &py); - py = (sid->scrollto.y.start * (1.0 - tt)) + - (sid->scrollto.y.end * tt); + //TIZEN_ONLY(20191209): Genlist looping implementation + if (!sid->loop_v) + py = (sid->scrollto.y.start * (1.0 - tt)) + + (sid->scrollto.y.end * tt); + else + { + Evas_Coord ch = 0; + elm_obj_pan_content_size_get(sid->pan_obj, NULL, &ch); + if (sid->y_forward_scroll) + { + if(sid->scrollto.y.start > sid->scrollto.y.end) + { + py = (sid->scrollto.y.start * (1.0 - tt)) + + (ch + sid->scrollto.y.end)*tt;//works for neg value of y_end also becuase in looping case neg value starts from bottom + if (py > ch) py %= ch; //needed when y_end is positive + } + else + { + py = ((ch + sid->scrollto.y.start) * (1.0 - tt)) + + (sid->scrollto.y.end)*tt; + if (py > ch) py %= ch; + } + } + else + 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; @@ -2942,6 +2973,9 @@ _elm_scroll_scroll_to_y_animator(void *data, const Efl_Event *event EINA_UNUSED) sid->down.sy = py; sid->down.y = sid->down.history[0].y; sid->down.pdy = 0; + //TIZEN_ONLY(20191209): Genlist looping implementation + sid->y_forward_scroll = EINA_FALSE; + // _elm_scroll_wanted_coordinates_update(sid, px, py); if ((!sid->scrollto.x.animator) && (!sid->down.bounce_x_animator)) _elm_scroll_anim_stop(sid); @@ -2983,6 +3017,22 @@ _elm_scroll_scroll_to_y(Elm_Scrollable_Smart_Interface_Data *sid, sid->scrollto.y.end = pos_y; sid->scrollto.y.t_start = t; sid->scrollto.y.t_end = t + t_in; + //TIZEN_ONLY(20191209): Genlist looping implementation + if (sid->loop_v) + { + Evas_Coord ch = 0, for_dist = 0, back_dist = 0; + elm_obj_pan_content_size_get(sid->pan_obj, NULL, &ch); + back_dist = abs(sid->scrollto.y.end - sid->scrollto.y.start); + if (sid->scrollto.y.end < 0) + for_dist = abs((ch + sid->scrollto.y.end) - sid->scrollto.y.start); + else + for_dist = ch - abs(sid->scrollto.y.start - sid->scrollto.y.end); + if (for_dist <= back_dist) + sid->y_forward_scroll = EINA_TRUE; + else + sid->y_forward_scroll = EINA_FALSE; + } + // if (!sid->scrollto.y.animator) { ELM_ANIMATOR_CONNECT(sid->obj, sid->scrollto.y.animator, _elm_scroll_scroll_to_y_animator, sid); @@ -3286,8 +3336,50 @@ _elm_scroll_mouse_up_event_cb(void *data, pos_x = _round(pos_x * (_elm_config->thumbscroll_momentum_friction), 0); pos_y = _round(pos_y * (_elm_config->thumbscroll_momentum_friction), 0); + //TIZEN_ONLY(20191209): Genlist looping implementation + if (pos_x < 0) + { + if ((px - pos_x) > mx) + pos_x = px - mx; + } + else + { + if ((px - pos_x) < minx) + pos_x = px - minx; + } + if (!sid->loop_v) + { + if (pos_y < 0) + { + if ((py - pos_y) > my) + pos_y = py - my; + } + else + { + if ((py - pos_y) < miny) + pos_y = py - miny; + } + } + //scroll distance have to be less than content size + else if (sid->loop_v && abs(pos_y) > sid->content_info.h) + { + Evas_Coord final_pos_y = pos_y % sid->content_info.h; + if (pos_y > 0) + pos_y = final_pos_y; + else + pos_y = -final_pos_y; + } + // elm_obj_pan_pos_adjust(sid->pan_obj, &pos_x, &pos_y); - + //TIZEN_ONLY(20191209): Genlist looping implementation + if (sid->loop_v) + { + if (pos_y > 0 && dy < 0) + pos_y = pos_y - sid->content_info.h; + else if (pos_y < 0 && dy > 0) + pos_y = sid->content_info.h + pos_y; + } + // // adjusted position using to _elm_scroll_momentum_animator() sid->down.dx = pos_x; sid->down.dy = pos_y; diff --git a/src/lib/elementary/elm_interface_scrollable.h b/src/lib/elementary/elm_interface_scrollable.h index 0549fc3..7d075b3 100644 --- a/src/lib/elementary/elm_interface_scrollable.h +++ b/src/lib/elementary/elm_interface_scrollable.h @@ -238,6 +238,9 @@ struct _Elm_Scrollable_Smart_Interface_Data void *manager; /* Efl_Ui_Focus_Manager */ + //TIZEN_ONLY(20191209): Genlist looping implementation + Eina_Bool y_forward_scroll : 1; + // //TIZEN_ONLY(20180118): Modify logics to make scroller stable on tizen struct { diff --git a/src/lib/elementary/elm_widget_genlist.h b/src/lib/elementary/elm_widget_genlist.h index 41d9366..d513a29 100644 --- a/src/lib/elementary/elm_widget_genlist.h +++ b/src/lib/elementary/elm_widget_genlist.h @@ -185,6 +185,10 @@ struct _Elm_Genlist_Data Eina_Bool highlight : 1; Eina_Bool h_bounce : 1; Eina_Bool v_bounce : 1; + //TIZEN_ONLY(20191209): Genlist looping implementation + Eina_Bool loop_h : 1; + Eina_Bool loop_v : 1; + // Eina_Bool bring_in : 1; /* a flag to * describe the * scroll diff --git a/src/lib/elementary_tizen/elm_genlist.c b/src/lib/elementary_tizen/elm_genlist.c index b0bb287..b4f7896 100644 --- a/src/lib/elementary_tizen/elm_genlist.c +++ b/src/lib/elementary_tizen/elm_genlist.c @@ -400,11 +400,14 @@ _elm_genlist_pos_adjust_xy_item_get(const Evas_Object *obj, ELM_GENLIST_CHECK(obj) NULL; ELM_GENLIST_DATA_GET(obj, sd); + Evas_Coord oh; + evas_object_geometry_get(obj, NULL, NULL, NULL, &oh); EINA_INLIST_FOREACH(sd->blocks, itb) { Eina_List *l = NULL; Elm_Gen_Item *it; + if (!ELM_RECTS_INTERSECT(itb->x, itb->y, sd->minw, itb->minh, x, y, 1, 1)) continue; @@ -472,7 +475,7 @@ _adjust_item_align(Elm_Gen_Item *it) if (adjust_item) { //Adjusted item must be aligned center position, so last item cannot be adjusted item. - if (adjust_item == last) + if (!sd->loop_v && adjust_item == last) adjust_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(adjust_item)->prev); return adjust_item; } @@ -507,7 +510,7 @@ _adjust_item_align(Elm_Gen_Item *it) adjust_item = it; //Adjusted item must be aligned center position, so last item cannot be adjusted item. - if (adjust_item == last) + if (!sd->loop_v && adjust_item == last) adjust_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(adjust_item)->prev); return adjust_item; @@ -536,8 +539,11 @@ _elm_genlist_pan_elm_pan_pos_adjust(Eo *obj EINA_UNUSED, Elm_Genlist_Pan_Data *p elm_interface_scrollable_content_viewport_geometry_get(sd->obj, NULL, NULL, &vw, &vh); yy = sd->pan_y - yy; - if (yy > maxy) yy = maxy; - if (yy < miny) yy = miny; + if (!sd->loop_v) + { + if (yy > maxy) yy = maxy; + if (yy < miny) yy = miny; + } if (!strcmp(wd->scroll_item_valign, "center")) { @@ -545,6 +551,17 @@ _elm_genlist_pan_elm_pan_pos_adjust(Eo *obj EINA_UNUSED, Elm_Genlist_Pan_Data *p cy = yy + (vh / 2); } + //TIZEN_ONLY(20181511): Pan pos calculation for looping cases + if (sd->loop_v && (cy > maxy)) + { + cy = (cy % maxy) + miny; + } + else if (sd->loop_v && (cy < miny)) + { + cy = (maxy - abs(cy) + miny); + } + // + sd->adjusted_item = _elm_genlist_pos_adjust_xy_item_get(sd->obj, cx, cy); if ((abs(*y) > FLICK_GAP) && (sd->adjusted_item == sd->aligned_item)) @@ -560,6 +577,8 @@ _elm_genlist_pan_elm_pan_pos_adjust(Eo *obj EINA_UNUSED, Elm_Genlist_Pan_Data *p } sd->adjusted_item = _adjust_item_align(sd->adjusted_item); if (!sd->adjusted_item) return; + //TIZEN_ONLY(20191209): Genlist looping implementation + if(!(GL_IT(sd->adjusted_item)->block)) return; it_y = sd->adjusted_item->y + GL_IT(sd->adjusted_item)->block->y; it_h = GL_IT(sd->adjusted_item)->h; @@ -598,7 +617,14 @@ _elm_genlist_pan_elm_pan_pos_max_get(const Eo *obj, Elm_Genlist_Pan_Data *psd, E evas_object_geometry_get(obj, NULL, NULL, &ow, &oh); ow = psd->wsd->minw - ow; if (ow < 0) ow = 0; - oh = psd->wsd->minh - oh; + //TIZEN_ONLY(20191209): Genlist looping implementation + //oh = psd->wsd->minh - oh; + if (psd->wsd->loop_v) + oh = psd->wsd->minh; + else + oh = psd->wsd->minh - oh; + // + if (oh < 0) oh = 0; if (x) *x = ow; if (y) *y = oh; @@ -2313,6 +2339,11 @@ _item_block_realize(Item_Block *itb, Eina_Bool force) } GL_IT(it)->scrl_x = it->x + itb->x - sd->pan_x + ox; GL_IT(it)->scrl_y = it->y + itb->y - sd->pan_y + oy; + + //TIZEN_ONLY(20191209): Genlist looping implementation + if (sd->loop_v && GL_IT(it)->scrl_y < 0 && (sd->pan_y > (sd->minh - cvh))) + GL_IT(it)->scrl_y = it->y + itb->y - (sd->pan_y - sd->minh) + oy; + // GL_IT(it)->w = sd->minw; GL_IT(it)->h = GL_IT(it)->minh; @@ -2456,7 +2487,8 @@ _elm_genlist_pan_efl_canvas_group_group_calculate(Eo *obj, Elm_Genlist_Pan_Data Eina_Inlist *start = NULL; Eina_List *realized_new = NULL; Eina_Bool flag = EINA_FALSE; - if ((psd->wsd->blocks_realized) && (psd->wsd->dir == -1) && + + if (!psd->wsd->loop_v && (psd->wsd->blocks_realized) && (psd->wsd->dir == -1) && (!_elm_config->access_mode) && (!_elm_atspi_enabled())) { start = EINA_INLIST_GET((Item_Block *)eina_list_data_get @@ -2483,7 +2515,7 @@ _elm_genlist_pan_efl_canvas_group_group_calculate(Eo *obj, Elm_Genlist_Pan_Data } } } - else if ((psd->wsd->blocks_realized) && (psd->wsd->dir == 1) && + else if (!psd->wsd->loop_v && (psd->wsd->blocks_realized) && (psd->wsd->dir == 1) && (!_elm_config->access_mode) && (!_elm_atspi_enabled())) { start = EINA_INLIST_GET((Item_Block *)eina_list_data_get @@ -2528,6 +2560,21 @@ _elm_genlist_pan_efl_canvas_group_group_calculate(Eo *obj, Elm_Genlist_Pan_Data realized_new = eina_list_append(realized_new, itb); _item_block_realize(itb, EINA_FALSE); } + //TIZEN_ONLY(20191209): Genlist looping implementation + else if (psd->wsd->loop_v && psd->wsd->pan_y > (psd->wsd->minh - cvh)) + { + itb_y = itb->y - (psd->wsd->pan_y - psd->wsd->minh) + oy; + if (ELM_RECTS_INTERSECT(itb_x, itb_y, itb_w, itb_h, + cvx, cvy, cvw, cvh)) + { + flag = EINA_TRUE; + realized_new = eina_list_append(realized_new, itb); + _item_block_realize(itb, EINA_FALSE); + } + else + _item_block_unrealize(itb); + } + // else { _item_block_unrealize(itb); @@ -8670,6 +8717,23 @@ _elm_genlist_elm_interface_scrollable_bounce_allow_get(const Eo *obj EINA_UNUSED if (v_bounce) *v_bounce = sd->v_bounce; } +//TIZEN_ONLY(20191209): Genlist looping implementation +EOLIAN static void +_elm_genlist_elm_interface_scrollable_content_loop_set(Eo *obj, Elm_Genlist_Data *sd, Eina_Bool loop_h, Eina_Bool loop_v) +{ + sd->loop_h = !!loop_h; + sd->loop_v = !!loop_v; + elm_interface_scrollable_content_loop_set(efl_super(obj, MY_CLASS), sd->loop_h, sd->loop_v); +} + +EOLIAN static void +_elm_genlist_elm_interface_scrollable_content_loop_get(Eo *obj, Elm_Genlist_Data *sd, Eina_Bool *loop_h, Eina_Bool *loop_v) +{ + if (loop_h) *loop_h = sd->loop_h; + if (loop_v) *loop_v = sd->loop_v; +} +// + EOLIAN static void _elm_genlist_homogeneous_set(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, Eina_Bool homogeneous) { diff --git a/src/lib/elementary_tizen/elm_widget_genlist.h b/src/lib/elementary_tizen/elm_widget_genlist.h index 8d012c5..2c08be3 100644 --- a/src/lib/elementary_tizen/elm_widget_genlist.h +++ b/src/lib/elementary_tizen/elm_widget_genlist.h @@ -261,6 +261,10 @@ struct _Elm_Genlist_Data Eina_Bool highlight : 1; Eina_Bool h_bounce : 1; Eina_Bool v_bounce : 1; + //TIZEN_ONLY(20191209): Genlist looping implementation + Eina_Bool loop_h : 1; + Eina_Bool loop_v : 1; + // Eina_Bool bring_in : 1; /* a flag to * describe the * scroll -- 2.7.4