package bogue
Handle large lists by not displaying all elements at once.
Very quickly, displaying a list of layouts (for instance, listing files in a directory) can run the computer out of memory if it tries to keep in memory the textures of all entries of the list. In these cases you need to use a Long_list
.
See for instance the example 34: `boguex 34` that displays a list of 1 million entries.
Long_lists may contain any type of Layout. They don't need to be all of the same dimension. Instead of providing the list of layouts, one must give a function generate
such that the layout given by generate i
is the i-eth element of the list.
Dependency graph
val create :
w:int ->
h:int ->
length:int ->
?first:int ->
generate:(int -> Layout.t) ->
?height_fn:(int -> int option) ->
?cleanup:(Layout.t -> unit) ->
?max_memory:int ->
?linear:bool ->
?scrollbar_width:int ->
unit ->
Layout.t
Create a long list through the function generate
which maps any index i to the ieth element (layout) of the list. If specified (which is not a good idea), the max_memory
should be at least twice the area (in physical pixels) of the visible part of the list. If the number of elements is large (typically 100000 or more, this depends on your CPU), its is highly advisable to provide a height_fn
, which to an index i gives the height (in logical pixels) of the ieth entry. If some heights are not known in advance, it's ok to return None
. For instance, if all entries have the same height, say 30 pixels, one can define
let height_fn _ = Some 30