Skip to content

v0.1.4

Choose a tag to compare

@rizukirr rizukirr released this 07 Oct 05:57
· 22 commits to main since this release

Builds on v0.1.3.

This release contains a breaking layout change. A Box with two or more children now layers them instead of flowing them top to bottom. See Migration below.

Breaking: Box is a z-stack

Up to v0.1.3 Box mapped to CLAY_TOP_TO_BOTTOM, the same as Column. Children were only layered when each one set .floating, which Text and the progress components do not accept.

Box now layers its children in declaration order, with the last one on top. .layout.padding and .layout.childAlignment apply to every layer.

Box("Timer",
    .layout = {.sizing = {Fixed(200), Fixed(200)},
               .childAlignment = {.x = CC_ALIGN_X_CENTER,
                                  .y = CC_ALIGN_Y_CENTER}}) {
  CircularProgress(0.75f, .sizing = {Grow(), Grow()});
  Text("24:59", .fontSize = 40); // centered over the ring
}

Clay has no z-stack layout mode, so Box builds one. The first child stays in normal flow, and every later child is wrapped in a floating layer the size of the box.

  • A Fit() box takes its size from its first child. Put the largest layer first, or give the box an explicit size.
  • Layers let the pointer through, so a Button under a later layer still gets its hover and click.
  • A child that sets its own .floating is left alone, for a custom attach point, offset or zIndex.
  • .layout.childGap has no effect on a Box.

Migration

  • A Box with zero or one child needs no change.
  • A Box whose children all set .floating needs no change.
  • A Box that relied on its children flowing top to bottom becomes a Column.
  • Draw keeps its top-to-bottom children. It is now built on Column.

Other changes

  • Text expands to a call to CC__Text instead of calling Clay__OpenTextElement directly. Call sites are unchanged.
  • New headless test ccompose_box_test.

Using it

FetchContent_Declare(ccompose
    GIT_REPOSITORY https://github.com/rizukirr/ccompose.git
    GIT_TAG        v0.1.4
    GIT_SHALLOW    TRUE
)