Skip to content

Editor → Widget Kit → layout.h

kit::row_layout

Syntax

class CONJURE_API row_layout

Constructors

AccessSignatureDescription
publicexplicit row_layout( f32 gap = 0.0f, f32 paddingStart = 0.0f, f32 paddingEnd = 0.0f) noexcept;An empty row; negative or non-finite gaps and paddings count as 0.

Variables

AccessNameTypeDefaultDescription
privatemCountusize0
privatemGapf320.0f
privatemPaddingEndf320.0f
privatemPaddingStartf320.0f
privatemSlotsstd::array<slot, MAX_ROW_SLOTS>{}

Functions

Public

add

usize add(
    const slot &value) noexcept;

Appends any slot (the forms above call this).

arrange

[[nodiscard]] row_arrangement arrange(
    f32 origin,
    f32 extent) const noexcept;

Places the slots in the span from origin over extent: the padding, then each slot and a gap between neighbours. The free space (extent less padding, gaps and every slot's size, FILL slots counted at their least size) is shared among the FILL slots by weight on top of their least size; when it is negative every FILL slot keeps its least size and overflow reports the excess. Without FILL slots the free space stays at the end. Positions are exact (no rounding): callers snap to pixels where they draw.

at

[[nodiscard]] const slot &at(
    usize index) const noexcept;

The slot at index, in the order the slots were added. Asserts past the last slot; in a build without asserts it returns the first slot (a default one in an empty row).

empty

[[nodiscard]] bool empty() const noexcept;

True when the row holds no slot.

fill

usize fill(
    f32 weight = 1.0f,
    f32 minimum = 0.0f) noexcept;

Appends a slot that takes weight shares of the free space (weights at or below 0 count as 1), never less than minimum.

fit

usize fit(
    f32 measuredSize) noexcept;

Appends a slot whose size is its measured content (as fixed()).

fixed

usize fixed(
    f32 size) noexcept;

Appends a slot of exactly size (negative or non-finite: 0). Asserts when the row is full; in a build without asserts the slot is dropped. Returns the slot's index.

from_template

[[nodiscard]] static core::result<row_layout> from_template(
    std::string_view tracks,
    f32 gap = 0.0f,
    f32 paddingStart = 0.0f,
    f32 paddingEnd = 0.0f);

Parses a CSS-like track list, the form tables use: lengths in pixels ("150"), fractions ("1fr", "2.5fr") and "fit:<pixels>" for a measured column, separated by spaces, with the given gap and padding. Fails with INVALID_ARGUMENT for an empty list, a track that is none of these forms, a negative or non-finite number or more than MAX_ROW_SLOTS tracks; the message names the offending track and its position.

gap

[[nodiscard]] f32 gap() const noexcept;

The gap between neighbouring slots (0 for a negative or non-finite one given).

minimum_extent

[[nodiscard]] f32 minimum_extent() const noexcept;

The least extent the row needs: padding, gaps and every slot's size (FILL at its least size).

size

[[nodiscard]] usize size() const noexcept;

How many slots the row holds (at most MAX_ROW_SLOTS).