Skip to content

ScalarSpec

#include <Layout.hpp>

Represents a single dimension value that can be absolute or percentage-based.

Used for sizing, margins, and positioning. Values can be:

  • Absolute: measured in cells (characters)

  • Percentage: measured as % of parent size

Example Usage:

ScalarSpec width = pct(50); // 50% of parent width
ScalarSpec height = cells(10); // 10 cells tall
ReturnNameDescription
floatvalueThe numeric value.
boolpercentIf true, value is a percentage; if false, it’s in cells.

float value = 0.f

The numeric value.


bool percent =
false

If true, value is a percentage; if false, it’s in cells.

ReturnNameDescription
boolisSet const inlineReturns true if this spec was explicitly set.
intresolve const inlineResolves this spec to an absolute cell count.

const inline

inline bool isSet() const

Returns true if this spec was explicitly set.

True if value > 0


const inline

inline int resolve(int parentSize) const

Resolves this spec to an absolute cell count.

  • parentSize The parent size (used if this is a percentage)

The resolved size in cells