Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
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
.
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 m 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