Feat: Align layout primitives and terminal geometry semantics with SwiftUI#71
Open
phranck wants to merge 15 commits into
Open
Feat: Align layout primitives and terminal geometry semantics with SwiftUI#71phranck wants to merge 15 commits into
phranck wants to merge 15 commits into
Conversation
- Reshape HorizontalAlignment and VerticalAlignment into SwiftUI's extensible structs with AlignmentID identities and a cell-based ViewDimensions context - Add the TerminalGeometry quantization policy: sizes and spacing round half away from zero, alignment offsets floor (preserving established centering), infinity fills, NaN and negatives degrade deterministically - Replace every alignment switch in the renderers with guide-based cell offsets, so custom guides work everywhere alignment is consumed - Cover identity equality, built-in and custom guide offsets, clamping, and the quantization policy with tests
- Reshape Edge into the enum with a nested Edge.Set option set - Move EdgeInsets to CGFloat sides; the renderer quantizes through TerminalGeometry with negative values degrading to zero - Align padding with SwiftUI: padding(_:) with CGFloat, and padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) where nil means the one-cell terminal default
- HStack, VStack, LazyVStack, LazyHStack, and Spacer take CGFloat? spacing/minLength like SwiftUI; nil selects the established terminal defaults and values quantize through TerminalGeometry - Internal spacing storage stays in cells; the public Int properties become internal - Lazy stacks accept SwiftUI's pinnedViews option set; pinning takes visual effect with viewport-driven laziness (#25)
…fault - Replace the public FrameDimension enum with CGFloat? maxima where .infinity fills the available space (Int.max cell sentinel internally) - frame(width:height:alignment:) and the flexible overload take CGFloat values quantized through TerminalGeometry; the fixed-frame default alignment matches SwiftUI's .center
- Pin ZStack corner alignments, the SwiftUI center default of fixed frames, explicit frame corner alignment, and nested proposal propagation through frames and padding
- GeometryReader reports the proposed cell size through a CGSize-based proxy and expands to fill its space with top-leading content - ViewThatFits measures candidates against a generous ideal probe in the constrained axes (adaptive children would otherwise always fit), renders the first candidate whose ideal size fits, and falls back to the clipped last candidate - Add the Axis and Axis.Set types backing the axis constraint
- Add SwiftUI's Layout contract (ProposedViewSize, LayoutSubview proxies, cache) as a terminal adaptation: measurement quantizes to cells and placements composite child buffers at floored offsets - Layouts apply like container views through callAsFunction, and AnyLayout erases concrete layouts for structure-preserving switches - Cover a custom diagonal layout and AnyLayout delegation with tests
- Cover CGFloat spacing, custom alignment guides, Edge.Set padding, CGFloat frames, pinned lazy stacks, ViewThatFits, GeometryReader, and the custom layout family
- DocC cannot resolve symbol links to the package-visible TerminalGeometry type
- Drop 51 overrides for removed symbols (closed alignment enums, the Edge option set, Int-based spacing, frame, and inset APIs) - Add 148 overrides for the new surface: AlignmentID guides, ViewDimensions, Edge.Set, CGFloat geometry, PinnedScrollableViews, Axis, GeometryReader, ViewThatFits, and the Layout family - Regenerate the manifest with TUIkitAPICheck against fresh 6.0.3 macOS and Linux snapshots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20.
Summary
HorizontalAlignment/VerticalAlignmentbecome SwiftUI's extensible structs withAlignmentIDidentities and a cell-basedViewDimensionscontext; every renderer alignment switch now resolves guide-based cell offsets, so custom guides work everywhere alignment is consumedTerminalGeometry, package-scoped): one documented, deterministic CGFloat→cell mapping — sizes/spacing round half away from zero, alignment offsets floor (preserving established centering),.infinityfills, NaN and negatives degrade to zero; identical results on macOS and LinuxEdgeis the enum with nestedEdge.Set;EdgeInsetscarries CGFloat sides;padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil)matches SwiftUI with the one-cell terminal defaultCGFloat?spacing/minLength everywhere (nil = established terminal defaults); lazy stacks acceptpinnedViews:(visual effect lands with viewport-driven laziness, [P1-20] Implement true viewport-driven lazy collections #25); no public API exposesIntbecause the renderer uses cells.infinitymaxima fill, and the fixed-frame default alignment matches SwiftUI's.center; theFrameDimensionenum is goneGeometryReader(CGSize proxy, fills its space),ViewThatFits(ideal-probe measurement so adaptive children don't always "fit"), and theLayoutprotocol family withAnyLayout(ProposedViewSize, LayoutSubview proxies, cache, placement compositing) built on the two-pass child infrastructureTest plan
./scripts/test-linux.shverify-compatibility-manifest.shpasses against the regenerated manifest