package toffee

  1. Overview
  2. Docs
CSS layout engine for OCaml (Flexbox, Grid, Block)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/compute_grid/Compute_grid/Grid_track_counts/index.html

Module Compute_grid.Grid_track_countsSource

Track count management and coordinate system conversions for CSS Grid layout.

This module maintains counts of tracks in the implicit and explicit grids and provides conversions between two coordinate systems used internally:

  • OriginZero coordinates: Normalized grid line indices where the left/top edge of the explicit grid is line 0, counting up to the right/down and down to the left/up (negative indices).
  • CellOccupancyMatrix track indices: Zero-based indices into the track occupancy matrix, where 0 is the leftmost track of the implicit grid.

Invariant: The total track count equals negative_implicit + explicit + positive_implicit.

The module also handles conversion to GridTrackVec indices, where even indices represent lines and odd indices represent tracks.

Construction

Sourceval make : negative_implicit:int -> explicit:int -> positive_implicit:int -> t

make ~negative_implicit ~explicit ~positive_implicit creates track counts from raw numbers.

Track Count Queries

Sourceval len : t -> int

len t returns the total number of tracks across implicit and explicit grids.

Sourceval negative_implicit : t -> int

negative_implicit t returns the number of tracks in the negative implicit grid.

Sourceval explicit : t -> int

explicit t returns the number of tracks in the explicit grid.

Sourceval positive_implicit : t -> int

positive_implicit t returns the number of tracks in the positive implicit grid.

Grid Boundaries

Sourceval implicit_start_line : t -> int

implicit_start_line t returns the OriginZero line at the start of the implicit grid. Always negative or zero.

Sourceval implicit_end_line : t -> int

implicit_end_line t returns the OriginZero line at the end of the implicit grid. Always positive or zero.

Coordinate Conversions

Sourceval oz_line_to_next_track : t -> int -> int

oz_line_to_next_track t line converts an OriginZero grid line to the index of the track immediately following it in the CellOccupancyMatrix.

Sourceval oz_line_range_to_track_range : t -> int Geometry.Line.t -> int * int

oz_line_range_to_track_range t range converts a line range in OriginZero coordinates to an exclusive track index range in the CellOccupancyMatrix.

Sourceval track_to_prev_oz_line : t -> int -> int

track_to_prev_oz_line t index converts a CellOccupancyMatrix track index to the OriginZero line immediately preceding it.

Sourceval track_range_to_oz_line_range : t -> (int * int) -> int Geometry.Line.t

track_range_to_oz_line_range t range converts an exclusive track index range from the CellOccupancyMatrix to a line range in OriginZero coordinates.

Sourceval oz_line_to_track : t -> int -> int option

oz_line_to_track t line converts an OriginZero grid line to a GridTrackVec index (even indices). Returns None if the line is outside the implicit grid. The result is doubled to account for interleaved lines and tracks in the GridTrackVec representation.