axiles / ocaml-efl

An OCaml interface to the Enlightenment Foundation Libraries (EFL) and Elementary
https://forge.ocamlcore.org/projects/ocaml-efl/
Other
27 stars 4 forks source link

elm_gen{,grid,list}: add support for the reusable_content_get callback. #6

Closed adrien-n closed 7 years ago

adrien-n commented 7 years ago

NB: I think this will break on <= 1.17 because of this bit in elm_gen{grid,list}_wrap.c.multi because of the line below but I don't know how to avoid the issue.

c->func.reusable_content_get = ml_Elm_Gen_Item_Reusable_Content_Get_Cb;

Below is the current commit message.

This is a fairly new callback for genlists and gengrids. As far as I can tell it makes it possible to avoid the creation of new item objects by recycling an item that has recently gone of-screen.

I've found it very useful for prepending items to a genlist and I haven't found drawbacks to it yet but I also haven't been able to understand why it needed the flexibility of a callback instead of being always enabled and my callbacks have always been very trivial:

func_reusable_content_get = (fun _obj _part _old -> Some _old);

The callback receives an "old" object and returns an Evas.obj option. If the return value is Some o, the object "o" will be used instead of creating a new item object; if it is None, a new item object will be created.