123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121(* Contains GridTrack used to represent a single grid track (row/column) during
layout *)openStyleopenStyle.Grid(* Whether a GridTrack represents an actual track or a gutter *)typegrid_track_kind=|Track(* Track is an actual track *)|Gutter(* Track is a gutter (aka grid line) (aka gap) *)(* Internal sizing information for a single grid track (row/column) Gutters
between tracks are sized similarly to actual tracks, so they are also
represented by this struct *)typet={kind:grid_track_kind;(* Whether the track is a full track, a gutter, or a placeholder that has
not yet been initialised *)is_collapsed:bool;(* Whether the track is a collapsed track/gutter. Collapsed tracks are
effectively treated as if they don't exist for the purposes of grid
sizing. Gutters between collapsed tracks are also collapsed *)track_sizing_function:track_sizing_function;(* The track sizing function (contains both min and max) *)mutableoffset:float;(* The distance of the start of the track from the start of the grid
container *)mutablebase_size:float;(* The size (width/height as applicable) of the track *)mutablegrowth_limit:float;(* A temporary scratch value when sizing tracks. Note: can be infinity *)mutablecontent_alignment_adjustment:float;(* A temporary scratch value when sizing tracks. Is used as an additional
amount to add to the estimate for the available space in the opposite
axis when content sizing items *)mutableitem_incurred_increase:float;(* A temporary scratch value when "distributing space" to avoid clobbering
planned increase variable *)mutablebase_size_planned_increase:float;(* A temporary scratch value when "distributing space" to avoid clobbering
the main variable *)mutablegrowth_limit_planned_increase:float;(* A temporary scratch value when "distributing space" to avoid clobbering
the main variable *)mutableinfinitely_growable:bool;(* A temporary scratch value when "distributing space" See:
https://www.w3.org/TR/css3-grid-layout/#infinitely-growable *)}(* GridTrack constructor with all configuration parameters for the other
constructors exposed *)letnew_with_kindkindtrack_sizing_function={kind;is_collapsed=false;track_sizing_function;offset=0.0;base_size=0.0;growth_limit=0.0;content_alignment_adjustment=0.0;item_incurred_increase=0.0;base_size_planned_increase=0.0;growth_limit_planned_increase=0.0;infinitely_growable=false;}(* Create new GridTrack representing an actual track (not a gutter) *)letcreatetrack_sizing_function=new_with_kindTracktrack_sizing_function(* Create a new GridTrack representing a gutter *)letgutter(size:length_percentage)=(* For gutters, both min and max track sizing functions are the same
length_percentage *)letsizing_fn=Style.Grid.Track_sizing_function.from_length_percentagesizeinnew_with_kindGuttersizing_fn(* Mark a GridTrack as collapsed. Also sets both of the track's sizing functions
to fixed zero-sized sizing functions *)letcollapset={twithis_collapsed=true;track_sizing_function=Track_sizing_function.zero;}(* Returns true if the track is flexible (has a Flex MaxTrackSizingFunction),
else false *)letis_flexiblet=Track_sizing_function.Max.is_frt.track_sizing_function(* Returns true if the track uses percentage sizing *)letuses_percentaget=Track_sizing_function.Min.uses_percentaget.track_sizing_function||Track_sizing_function.Max.uses_percentaget.track_sizing_function(* Returns true if the track has an intrinsic min and or max sizing function *)lethas_intrinsic_sizing_functiont=Track_sizing_function.Min.is_intrinsict.track_sizing_function||Track_sizing_function.Max.is_intrinsict.track_sizing_function(* Returns the fit-content limit for the track *)letfit_content_limittaxis_available_grid_space=matchTrack_sizing_function.Max.definite_limitt.track_sizing_functionaxis_available_grid_spacewith|SomelimitwhenTrack_sizing_function.Max.is_fit_contentt.track_sizing_function->limit|_->Float.infinity(* Returns the fit-content limited growth limit *)letfit_content_limited_growth_limittaxis_available_grid_space=Float.mint.growth_limit(fit_content_limittaxis_available_grid_space)(* Returns the track's flex factor if it is a flex track, else 0 *)letflex_factort=ifTrack_sizing_function.Max.is_frt.track_sizing_functionthenTrack_sizing_function.Max.fr_valuet.track_sizing_functionelse0.0