summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorGodly T.Alias <godlytalias@yahoo.co.in>2017-11-01 16:11:30 +0900
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-01 16:11:30 +0900
commit0496b7988ab8df1c20874ebc81c8ff909aee58e1 (patch)
tree244d508c720e66090c6354ccf736f2325f8c279c /src/lib/elementary
parent9d946fa83985df67c8465757aea52509985775ea (diff)
Genlist Item Pin Feature
Summary: **@feature** T6241 This feature enables genlist to pin an item to viewport which will be available always for user to view/select. **Use Case**: In a big list of music, most times when user finds a song which they like, before playing that they may want to go through the entire list to check whether there is some other good songs, but after seeing the entire list user have to again scroll back to the position of item which they liked to play it then. In this case item pinning can be used, so that the item which they want to keep for future selection can be pinned and then it will remain in viewport, finally when user want to do operation on item, it will be readily available in viewport. Signed-off-by: Godly T.Alias <godlytalias@yahoo.co.in> Test Plan: Elementary Test -> Genlist -> Double click on items to enable/disable pinning Reviewers: raster, cedric, prince.dubey, SanghyeonLee Subscribers: rajeshps, jpeg, shilpasingh Tags: #efl Differential Revision: https://phab.enlightenment.org/D5340
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/elm_genlist.c129
-rw-r--r--src/lib/elementary/elm_genlist_item.eo17
-rw-r--r--src/lib/elementary/elm_widget_genlist.h3
3 files changed, 135 insertions, 14 deletions
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index a0706abc2b..19e2a0c02b 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -717,7 +717,7 @@ _item_block_unrealize(Item_Block *itb)
717 dragging = EINA_TRUE; 717 dragging = EINA_TRUE;
718 it->want_unrealize = EINA_TRUE; 718 it->want_unrealize = EINA_TRUE;
719 } 719 }
720 else 720 else if (it != itb->sd->pin_item)
721 _elm_genlist_item_unrealize(it, EINA_FALSE); 721 _elm_genlist_item_unrealize(it, EINA_FALSE);
722 } 722 }
723 } 723 }
@@ -2202,6 +2202,7 @@ _group_items_recalc(void *data)
2202 Eina_List *l; 2202 Eina_List *l;
2203 Elm_Gen_Item *git; 2203 Elm_Gen_Item *git;
2204 Elm_Genlist_Data *sd = data; 2204 Elm_Genlist_Data *sd = data;
2205 Evas_Coord vy;
2205 2206
2206 evas_event_freeze(evas_object_evas_get(sd->obj)); 2207 evas_event_freeze(evas_object_evas_get(sd->obj));
2207 EINA_LIST_FOREACH(sd->group_items, l, git) 2208 EINA_LIST_FOREACH(sd->group_items, l, git)
@@ -2209,6 +2210,22 @@ _group_items_recalc(void *data)
2209 if (git->item->want_realize) 2210 if (git->item->want_realize)
2210 { 2211 {
2211 if (!git->realized) _item_realize(git, git->item->order_num_in, EINA_FALSE); 2212 if (!git->realized) _item_realize(git, git->item->order_num_in, EINA_FALSE);
2213 if (sd->pin_item && git == sd->pin_item->item->group_item &&
2214 sd->pin_item->item->scrl_y <= (git->item->scrl_y + git->item->h))
2215 {
2216 elm_interface_scrollable_content_viewport_geometry_get
2217 (sd->obj, NULL, &vy, NULL, NULL);
2218 if ((git->item->scrl_y + git->item->h) > vy)
2219 {
2220 sd->pin_item->item->scrl_y = git->item->scrl_y + git->item->h;
2221 evas_object_move(VIEW(sd->pin_item),
2222 sd->pin_item->item->scrl_x, sd->pin_item->item->scrl_y);
2223 }
2224 }
2225 else if (sd->pin_item && sd->pin_item_top && git != sd->pin_item->item->group_item &&
2226 (git->item->scrl_y < (sd->pin_item->item->scrl_y + sd->pin_item->item->h)))
2227 git->item->scrl_y = sd->pin_item->item->scrl_y + sd->pin_item->item->h;
2228
2212 evas_object_resize(VIEW(git), sd->minw, git->item->h); 2229 evas_object_resize(VIEW(git), sd->minw, git->item->h);
2213 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y); 2230 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2214 evas_object_stack_above(VIEW(git), sd->stack[1]); 2231 evas_object_stack_above(VIEW(git), sd->stack[1]);
@@ -2321,6 +2338,33 @@ _reorder_item_space_get(Elm_Gen_Item *it)
2321} 2338}
2322 2339
2323static void 2340static void
2341_pin_item_recalc(Elm_Gen_Item *it)
2342{
2343 Evas_Coord vx, vy, vw, vh;
2344 ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
2345
2346 sd->pin_item_top = EINA_FALSE;
2347 elm_interface_scrollable_content_viewport_geometry_get
2348 (sd->obj, &vx, &vy, &vw, &vh);
2349 if (it->item->scrl_x < vx)
2350 it->item->scrl_x = vx;
2351 else if (it->item->scrl_x + it->item->w > vx + vw)
2352 it->item->scrl_x = vx + vw - it->item->w;
2353
2354 if (it->item->scrl_y < vy)
2355 {
2356 sd->pin_item_top = EINA_TRUE;
2357 it->item->scrl_y = vy;
2358 }
2359 else if (it->item->scrl_y + it->item->h > vy + vh)
2360 it->item->scrl_y = vy + vh - it->item->h;
2361
2362 evas_object_resize(VIEW(it), it->item->w, it->item->h);
2363 evas_object_move(VIEW(it), it->item->scrl_x, it->item->scrl_y);
2364 evas_object_show(VIEW(it));
2365}
2366
2367static void
2324_item_block_position(Item_Block *itb, const int blk_idx) 2368_item_block_position(Item_Block *itb, const int blk_idx)
2325{ 2369{
2326 Elm_Gen_Item *it; 2370 Elm_Gen_Item *it;
@@ -2429,7 +2473,7 @@ _item_block_position(Item_Block *itb, const int blk_idx)
2429 } 2473 }
2430 else 2474 else
2431 { 2475 {
2432 if (!sd->tree_effect_animator) 2476 if (!sd->tree_effect_animator && (it != sd->pin_item))
2433 _elm_genlist_item_unrealize(it, EINA_FALSE); 2477 _elm_genlist_item_unrealize(it, EINA_FALSE);
2434 } 2478 }
2435 } 2479 }
@@ -2440,7 +2484,11 @@ _item_block_position(Item_Block *itb, const int blk_idx)
2440 } 2484 }
2441 y += it->item->h; 2485 y += it->item->h;
2442 vis_count++; 2486 vis_count++;
2487
2488 if (it == sd->pin_item)
2489 _pin_item_recalc(it);
2443 } 2490 }
2491
2444 evas_event_thaw(evas_object_evas_get((itb->sd)->obj)); 2492 evas_event_thaw(evas_object_evas_get((itb->sd)->obj));
2445 evas_event_thaw_eval(evas_object_evas_get((itb->sd)->obj)); 2493 evas_event_thaw_eval(evas_object_evas_get((itb->sd)->obj));
2446} 2494}
@@ -2527,6 +2575,15 @@ _elm_genlist_pan_efl_canvas_group_group_calculate(Eo *obj, Elm_Genlist_Pan_Data
2527 else 2575 else
2528 { 2576 {
2529 if (itb->realized) _item_block_unrealize(itb); 2577 if (itb->realized) _item_block_unrealize(itb);
2578 if (sd->pin_item && itb == sd->pin_item->item->block)
2579 {
2580 if (!sd->pin_item->realized)
2581 _item_realize(sd->pin_item, sd->pin_item->item->order_num_in, EINA_FALSE);
2582 sd->pin_item->item->w = itb->w;
2583 sd->pin_item->item->scrl_x = itb->x - sd->pan_x + ox;
2584 sd->pin_item->item->scrl_y = itb->y - sd->pan_y + oy;
2585 _pin_item_recalc(sd->pin_item);
2586 }
2530 } 2587 }
2531 in += itb->vis_count; 2588 in += itb->vis_count;
2532 } 2589 }
@@ -2566,6 +2623,8 @@ _elm_genlist_pan_efl_canvas_group_group_calculate(Eo *obj, Elm_Genlist_Pan_Data
2566 if (git->realized) evas_object_raise(VIEW(git)); 2623 if (git->realized) evas_object_raise(VIEW(git));
2567 } 2624 }
2568 2625
2626 if (sd->pin_item)
2627 evas_object_raise(VIEW(sd->pin_item));
2569 //update item before the render to prevent delayed update by job. 2628 //update item before the render to prevent delayed update by job.
2570 if (sd->update_job) 2629 if (sd->update_job)
2571 { 2630 {
@@ -2746,18 +2805,21 @@ _elm_genlist_item_focused(Elm_Object_Item *eo_it)
2746 (elm_wdg_item_disabled_get(eo_it))) 2805 (elm_wdg_item_disabled_get(eo_it)))
2747 return; 2806 return;
2748 2807
2749 switch (_elm_config->focus_autoscroll_mode) 2808 if (it != sd->pin_item)
2750 { 2809 {
2751 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW: 2810 switch (_elm_config->focus_autoscroll_mode)
2752 elm_genlist_item_show(eo_it, 2811 {
2753 ELM_GENLIST_ITEM_SCROLLTO_IN); 2812 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
2754 break; 2813 elm_genlist_item_show(eo_it,
2755 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN: 2814 ELM_GENLIST_ITEM_SCROLLTO_IN);
2756 elm_genlist_item_bring_in(eo_it, 2815 break;
2757 ELM_GENLIST_ITEM_SCROLLTO_IN); 2816 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
2758 break; 2817 elm_genlist_item_bring_in(eo_it,
2759 default: 2818 ELM_GENLIST_ITEM_SCROLLTO_IN);
2760 break; 2819 break;
2820 default:
2821 break;
2822 }
2761 } 2823 }
2762 2824
2763 sd->focused_item = eo_it; 2825 sd->focused_item = eo_it;
@@ -3438,6 +3500,8 @@ _item_highlight(Elm_Gen_Item *it)
3438 else evas_object_stack_below(VIEW(it), sd->stack[1]); 3500 else evas_object_stack_below(VIEW(it), sd->stack[1]);
3439 if ((it->item->group_item) && (it->item->group_item->realized)) 3501 if ((it->item->group_item) && (it->item->group_item->realized))
3440 evas_object_stack_above(it->item->VIEW(group_item), sd->stack[1]); 3502 evas_object_stack_above(it->item->VIEW(group_item), sd->stack[1]);
3503 if (sd->pin_item && sd->pin_item->realized)
3504 evas_object_stack_above(VIEW(sd->pin_item), sd->stack[1]);
3441 } 3505 }
3442 it->highlighted = EINA_TRUE; 3506 it->highlighted = EINA_TRUE;
3443} 3507}
@@ -3696,6 +3760,7 @@ _item_del(Elm_Gen_Item *it)
3696 } 3760 }
3697 elm_genlist_item_subitems_clear(EO_OBJ(it)); 3761 elm_genlist_item_subitems_clear(EO_OBJ(it));
3698 if (sd->show_item == it) sd->show_item = NULL; 3762 if (sd->show_item == it) sd->show_item = NULL;
3763 if (sd->pin_item == it) sd->pin_item = NULL;
3699 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE); 3764 if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
3700 if (it->item->decorate_all_item_realized) _decorate_all_item_unrealize(it); 3765 if (it->item->decorate_all_item_realized) _decorate_all_item_unrealize(it);
3701 if (it->item->block) _item_block_del(it); 3766 if (it->item->block) _item_block_del(it);
@@ -5587,6 +5652,8 @@ _elm_genlist_efl_canvas_group_group_add(Eo *obj, Elm_Genlist_Data *priv)
5587 priv->item_cache_max = priv->max_items_per_block * 2; 5652 priv->item_cache_max = priv->max_items_per_block * 2;
5588 priv->longpress_timeout = _elm_config->longpress_timeout; 5653 priv->longpress_timeout = _elm_config->longpress_timeout;
5589 priv->highlight = EINA_TRUE; 5654 priv->highlight = EINA_TRUE;
5655 priv->pin_item = NULL;
5656 priv->pin_item_top = EINA_FALSE;
5590 5657
5591 priv->pan_obj = efl_add(MY_PAN_CLASS, evas_object_evas_get(obj)); 5658 priv->pan_obj = efl_add(MY_PAN_CLASS, evas_object_evas_get(obj));
5592 pan_data = efl_data_scope_get(priv->pan_obj, MY_PAN_CLASS); 5659 pan_data = efl_data_scope_get(priv->pan_obj, MY_PAN_CLASS);
@@ -7999,6 +8066,7 @@ _elm_genlist_reorder_mode_set(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, Eina_Bo
7999 Elm_Object_Item *eo_it; 8066 Elm_Object_Item *eo_it;
8000 8067
8001 if (sd->reorder_mode == !!reorder_mode) return; 8068 if (sd->reorder_mode == !!reorder_mode) return;
8069 if (sd->pin_item) elm_genlist_item_pin_set(EO_OBJ(sd->pin_item), EINA_FALSE);
8002 sd->reorder_mode = !!reorder_mode; 8070 sd->reorder_mode = !!reorder_mode;
8003 realized = elm_genlist_realized_items_get(obj); 8071 realized = elm_genlist_realized_items_get(obj);
8004 EINA_LIST_FREE(realized, eo_it) 8072 EINA_LIST_FREE(realized, eo_it)
@@ -8039,6 +8107,41 @@ _elm_genlist_item_type_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
8039 return it->item->type; 8107 return it->item->type;
8040} 8108}
8041 8109
8110EOLIAN static void
8111_elm_genlist_item_pin_set(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it, Eina_Bool pin)
8112{
8113 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it);
8114 ELM_GENLIST_DATA_GET(WIDGET(it), sd);
8115 if (sd->reorder_mode) return;
8116 if (it->item->type & ELM_GENLIST_ITEM_GROUP) return;
8117
8118 if (pin ^ (sd->pin_item == it))
8119 {
8120 if (sd->pin_item)
8121 {
8122 if (sd->pin_item->item->block)
8123 sd->pin_item->item->block->realized = EINA_TRUE;
8124 evas_object_smart_changed(sd->pan_obj);
8125 }
8126 if (pin)
8127 sd->pin_item = it;
8128 else
8129 sd->pin_item = NULL;
8130 }
8131}
8132
8133EOLIAN static Eina_Bool
8134_elm_genlist_item_pin_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
8135{
8136 ELM_GENLIST_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
8137 ELM_GENLIST_DATA_GET(WIDGET(it), sd);
8138
8139 if (sd->pin_item == it)
8140 return EINA_TRUE;
8141 else
8142 return EINA_FALSE;
8143}
8144
8042EAPI Elm_Genlist_Item_Class * 8145EAPI Elm_Genlist_Item_Class *
8043elm_genlist_item_class_new(void) 8146elm_genlist_item_class_new(void)
8044{ 8147{
diff --git a/src/lib/elementary/elm_genlist_item.eo b/src/lib/elementary/elm_genlist_item.eo
index a8076618a6..28a5beaead 100644
--- a/src/lib/elementary/elm_genlist_item.eo
+++ b/src/lib/elementary/elm_genlist_item.eo
@@ -270,6 +270,23 @@ class Elm.Genlist.Item(Elm.Widget.Item)
270 type: Elm.Genlist.Item.Type(Elm.Genlist.Item.Type.max); [[Item type.]] 270 type: Elm.Genlist.Item.Type(Elm.Genlist.Item.Type.max); [[Item type.]]
271 } 271 }
272 } 272 }
273 @property pin {
274 get {
275 [[Get whether a given genlist item is pinned or not.]]
276 }
277 set {
278 [[Set whether a given genlist item is pinned or not
279
280 This sets a genlist item as pinned so that it will be always available in
281 the viewport available for user interaction. Group items cannot be pinned.
282 Also when a new item is pinned, the current pinned item will get unpinned.
283 Item pinning cannot be done in reorder mode too.
284 ]]
285 }
286 values {
287 pin: bool; [[The item pin state state ($true pin item, $false unpin item).]]
288 }
289 }
273 /* init { FIXME 290 /* init { FIXME
274 params { 291 params {
275 Evas_Smart_Cb func; 292 Evas_Smart_Cb func;
diff --git a/src/lib/elementary/elm_widget_genlist.h b/src/lib/elementary/elm_widget_genlist.h
index 5a1f4e8008..5e81cbe8ac 100644
--- a/src/lib/elementary/elm_widget_genlist.h
+++ b/src/lib/elementary/elm_widget_genlist.h
@@ -89,7 +89,7 @@ struct _Elm_Genlist_Data
89 Ecore_Idler *must_recalc_idler; 89 Ecore_Idler *must_recalc_idler;
90 Eina_List *queue; 90 Eina_List *queue;
91 Elm_Gen_Item *show_item, *anchor_item, *mode_item, 91 Elm_Gen_Item *show_item, *anchor_item, *mode_item,
92 *reorder_rel, *expanded_item; 92 *reorder_rel, *expanded_item, *pin_item;
93 Eina_Inlist *item_cache; /* an inlist of 93 Eina_Inlist *item_cache; /* an inlist of
94 * edje object it 94 * edje object it
95 * cache. */ 95 * cache. */
@@ -201,6 +201,7 @@ struct _Elm_Genlist_Data
201 Eina_Bool item_looping_on : 1; 201 Eina_Bool item_looping_on : 1;
202 202
203 Eina_Bool tree_effect_animator : 1; 203 Eina_Bool tree_effect_animator : 1;
204 Eina_Bool pin_item_top : 1;
204}; 205};
205 206
206typedef struct _Item_Block Item_Block; 207typedef struct _Item_Block Item_Block;