Skip to content

feat: add padding, align, stack, and decoration layout containers#6

Merged
AsPulse merged 2 commits into
mainfrom
feat/layout-containers
May 24, 2026
Merged

feat: add padding, align, stack, and decoration layout containers#6
AsPulse merged 2 commits into
mainfrom
feat/layout-containers

Conversation

@AsPulse
Copy link
Copy Markdown
Member

@AsPulse AsPulse commented May 24, 2026

Add CSS-Box / Flexbox-style layout containers so scene composition can describe padding, stacking, alignment, and background fills declaratively instead of hand-computing anchor offsets at every call site. The containers preserve the existing "intrinsic-only" view_box() model and ship symmetrically for vector and raster.

  • tellur-core::geometry: EdgeInsets with ZERO / all / symmetric / only constructors and horizontal / vertical / top_left accessors.
  • tellur-core::layout (new): Padding, Align, Stack, DecoratedBox, SizedBox over Box<dyn VectorComponent>. Stack takes an axis, an optional outer size, spacing, plus MainAlign (Start / Center / End / SpaceBetween / SpaceAround / SpaceEvenly) and CrossAlign (Start / Center / End). Align snaps a child's anchor onto the same anchor of a fixed-size parent box. DecoratedBox paints an optional background fill and/or border underneath the child, sized to the child's view_box.
  • tellur-core::layout::raster: same five containers over Box<dyn RasterComponent>. Raster DecoratedBox supports a solid-color background only for now; a small SolidRect rasterizes the fill by buffer-filling. Vector and raster Stack share a compute_stack_layout helper.
  • VectorLayoutExt / RasterLayoutExt: fluent .padding(...), .background(...), .border(...), .align(...).
  • tellur-core::layer: Layer::render's compositing loop extracted into a pub(crate) composite_children(container_size, target, &[(pos, &dyn RasterComponent)]) helper, shared with the raster layout containers.
  • Example: timeline_to_mp4 swaps the four hand-computed Anchor::new(0.5, y_frac).point(scene_size) calls for a Stack { axis: Vertical, size: Some(scene_size), main_align: SpaceEvenly, cross_align: Center, ... }.padding(EdgeInsets::all(100.0)).background(...). BouncingDot still takes scene_width — making it intrinsic-free needs a render_within / Stretch follow-up in a separate PR.

@AsPulse AsPulse merged commit c369d30 into main May 24, 2026
14 checks passed
AsPulse added a commit that referenced this pull request May 24, 2026
Switch the component pipeline to a Flutter / SwiftUI-style
constraint-based layout protocol, and add the painting primitives needed
for effects to work inside layout containers. PR #6's `BouncingDot`
still took `scene_width`; that's gone.

- Trait surface: `view_box()` → `layout(Constraints) -> Vec2` +
`paint_bounds(size) -> Rect` + `render(size [, target])`. `Constraints {
min, max }` with `tight` / `loose` / `tighten_cross` lives in
`tellur-core::geometry` alongside `Axis`.
- Layout containers: `SizeMode { Fill, Hug, Fixed(f32) }`; `Sized` /
`Place` / `Frame` replace `Align`; `CrossAlign::Stretch` propagates a
tight cross-axis constraint so children fill the stack.
- `paint_bounds` propagation: raster containers union the child's paint
rect into their own. `DecoratedBox` keeps the default and acts as a
natural clip boundary. `composite_children` takes `paint_rect: Rect`.
- `#[available]` attribute on a fn argument lets a component opt in to
the parent-assigned size at render time.
- `tellur-renderer::shadow` (new): `DropShadow` with a 3-pass box blur;
`paint_bounds` and padding both expand by `3 * radius`.
- Examples migrated. `BouncingDot` drops `scene_width` and wraps the
circle in a `DropShadow`.
@AsPulse AsPulse deleted the feat/layout-containers branch May 25, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant