Skip to content

v0.1.3

Choose a tag to compare

@rizukirr rizukirr released this 06 Oct 01:38
71b91aa

Builds on v0.1.2.

This release contains a breaking API change. The float size options on LinearProgress and CircularProgress are removed in favor of .sizing. See Migration below. It is a one-line edit per call site.

Breaking: progress indicators are sized with .sizing

v0.1.2 sized the progress components with bare floats: .length and .thickness on the bar, .size on the ring. A float can only mean fixed pixels, so the ring could not grow with its parent and the bar could not take a percent width or a growing height.

Both components now take .sizing, the same CC_Sizing that containers take in .layout, so Grow(), Fixed(), Percent() and SizingAll() all apply.

LinearProgress(v);                                    // grows wide, 4px high
LinearProgress(v, .sizing = {.height = Fixed(8)});    // grows wide, 8px high
LinearProgress(v, .sizing = {Percent(0.5f), Fixed(6)});

CircularProgress(v);                                  // 40 by 40
CircularProgress(v, .sizing = SizingAll(Fixed(48)));
CircularProgress(v, .sizing = {Grow(), Grow()}, .thickness = 6);

Defaults per axis

Component Width Height
LinearProgress Grow() Fixed(4)
CircularProgress Fixed(40) Fixed(40)

Each axis you leave out gets its default on its own, so setting only .height on a bar keeps its growing width. Fit() counts as left out, because it is the same value as a zeroed axis and a leaf has no content to fit. A Fit with an explicit minimum, such as CLAY_SIZING_FIT(20, 0), is passed through.

What the new sizing allows

  • A ring that fills its parent: .sizing = {Grow(), Grow()} draws the largest circle that fits.
  • A ring in a non-square box still draws a circle. The diameter is the smaller side and the ring sits in the center.
  • A bar with a percent width, or with a height that grows with its parent. The bar stays pill-shaped at any height.

Migration

v0.1.2 v0.1.3
LinearProgress(v, .length = 240) LinearProgress(v, .sizing = {.width = Fixed(240)})
LinearProgress(v, .thickness = 6) LinearProgress(v, .sizing = {.height = Fixed(6)})
CircularProgress(v, .size = 48) CircularProgress(v, .sizing = SizingAll(Fixed(48)))
- LinearProgress(ratio, .length = 240, .thickness = 6);
+ LinearProgress(ratio, .sizing = {Fixed(240), Fixed(6)});

- CircularProgress(ratio, .size = 48, .thickness = 5);
+ CircularProgress(ratio, .sizing = SizingAll(Fixed(48)), .thickness = 5);

.thickness on CircularProgress is unchanged. It is the stroke width and has no sizing equivalent.

Old call sites fail to compile with has no member named 'length' (or size, thickness), so the compiler points at every line that needs the edit. Calls that pass only a value, a color or a track color are unaffected.

Known limits

  • .sizing = {Fit(), Fit()} gives the default size, not a zero-size indicator.
  • A bar with .sizing = {.height = Grow()} in a parent with no bounded height grows as far as layout allows.

Other changes

  • PROJECT_VERSION in CMakeLists.txt is now 0.1.3.
  • ccompose_progress_test gains cases for both axes fixed, only height, only width, percent width, a ring with SizingAll(Fixed(64)), and a ring with only width set.
  • Wiki updated: the Progress page documents .sizing, the per-axis defaults and this migration.

Verification

All 7 CI checks pass on Linux (gcc + clang), macOS, Windows (MSVC), and Emscripten, plus clang-format and cppcheck. Headless ctest suite: 5/5 pass. No automated test covers the ring's pixels or the bar's pill shape. Those were checked from a screenshot.

Consuming via FetchContent

include(FetchContent)
FetchContent_Declare(ccompose
    GIT_REPOSITORY https://github.com/rizukirr/ccompose.git
    GIT_TAG v0.1.3
    GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(ccompose)

target_link_libraries(your_target PRIVATE ccompose)

Full changelog

v0.1.2...v0.1.3