Skip to main content

Module timeline_layout

Module timeline_layout 

Source
Expand description

Timeline layout helpers shared by time-vs-event UI (tick placement and lane packing).

StructsΒ§

IndexedInterval πŸ”’
TimelineGeometry
Layout + viewport inputs for a timeline (pixels and milliseconds; zoom/pan_ms are clamped by the math).
TimelineMetrics
Derived pixel/time geometry for one render of a timeline.
TimelineViewport
A timeline viewport: the committed pan offset and zoom factor.

ConstantsΒ§

DEFAULT_TARGET_PIXELS_PER_TICK
Target pixel gap between adjacent ticks when no caller preference is set.
FALLBACK_STEP_MS πŸ”’
NICE_STEPS_MS πŸ”’

FunctionsΒ§

assign_timeline_lanes
Pack (start, end) intervals into non-overlapping lanes via greedy scheduling, returning lanes in input order.
clamp πŸ”’
compute_timeline_metrics
Derive all pixel/time geometry (including axis ticks) for one timeline render; the source of truth for px<->ms.
compute_timeline_ticks
Pick β€œnice” tick positions (ms) inside [0, duration_ms] for a timeline axis.
normalized_interval πŸ”’
pan_timeline_by
Compute the new viewport after dragging the track by delta_px pixels (zoom unchanged).
reserve_lane πŸ”’
zoom_timeline_at
Compute the new viewport after a cursor-anchored zoom step (local_x pixels from the track left, cursor time fixed).