/**
A thin D face for Clay (`clay_impl.c`, compiled by ImportC), for the build
benchmark: the calls Clay's C macros expand to, wrapped so a view reads like
the other builders' views — and nothing more between the view and Clay.
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 1 } }) { … }
becomes
with (ui.column(gap: 1)) { … }
which is `Clay__OpenElement(); Clay__ConfigureOpenElement(decl);` at the
`with` and `Clay__CloseElement()` when it ends (the macro's `for` latch). A
keyed element is `Clay__OpenElementWithId(Clay__HashString(key,
Clay_GetOpenElementId()))`, i.e. `CLAY(CLAY_SID_LOCAL(key), …)`.
Leaves are Clay elements with FIXED sizing (the width computed here, as the
other builders compute it) and a background colour, so each leaf emits one
render command at `Clay_EndLayout`. Clay text elements cannot reproduce the
other builders' leaf sizes without a different tree (see README.md).
`Side` = `true` adds the per-leaf side work the sketches' builders do and Clay
does not: every text interned into a `BumpTextPool` (a copy) and every
`ui.on(msg)` copied into an argument arena and a message table, as
`lazystack.Ui.on` does.
*/
module (module) clayuiA thin D face for Clay (clay_impl.c, compiled by ImportC), for the build
benchmark: the calls Clay's C macros expand to, wrapped so a view reads like
the other builders' views — and nothing more between the view and Clay.
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 1 } }) { … }
becomes
with (ui.column(gap: 1)) { … }
which is Clay__OpenElement(); Clay__ConfigureOpenElement(decl); at the
with and Clay__CloseElement() when it ends (the macro's for latch). A
keyed element is Clay__OpenElementWithId(Clay__HashString(key,
Clay_GetOpenElementId())), i.e. CLAY(CLAY_SID_LOCAL(key), …).
Leaves are Clay elements with FIXED sizing (the width computed here, as the
other builders compute it) and a background colour, so each leaf emits one
render command at Clay_EndLayout. Clay text elements cannot reproduce the
other builders' leaf sizes without a different tree (see README.md).
Side = true adds the per-leaf side work the sketches' builders do and Clay
does not: every text interned into a BumpTextPool (a copy) and every
ui.on(msg) copied into an argument arena and a message table, as
lazystack.Ui.on does.
clayui;
import (package) corecore.(module) core.interpolationThis module provides definitions to support D's
interpolated expression sequence literal, sometimes
called string interpolation.
string str;
int num;
// the compiler uses this module to implement the
// i"..." literal used here.
auto a = i"$(str) has $(num) items.";
The variable a is a sequence of expressions:
a[0] == InterpolationHeader()
a[$-1] == InterpolationFooter()
First and last, you see the header and footer, to
clearly indicate where interpolation begins and ends.
Note that there may be nested interpolated sequences too,
each with their own header and footer. Think of them
as a set of balanced parenthesis around the contents.
Inside, you will find three general categories of
content: InterpolatedLiteral!"string" for string
expressions, InterpolatedExpression!"code" for code
expressions, and then the values themselves as their
own type.
In the example:
auto a = i"$(str) has $(num) items.";
We will find:
a[0] == InterpolationHeader()
a[1] == InterpolatedExpression!"str"
a[2] == str
a[3] == InterpolatedLiteral!" has ";
a[4] == InterpolatedExpression!"num";
a[5] == num
a[6] == InterpolatedLiteral!" items.";
a[7] == InterpolationFooter()
a.length == 8;
You can see the correspondence with the original
input: when you write $(expression), the string of the
expression is passed as InterpolatedExpression!ThatString,
(excluding any parenthesis around the expression),
and everything else is passed as InterpolatedLiteral!str,
in the same sequence as they appeared in the source.
After an InterpolatedExpression!..., you will find the
actual value(s) in the tuple. (If the expression expanded
to multiple values - for example, if it was itself a tuple,
there will be multiple values for a single expression.)
Library functions should NOT attempt to mixin the code
from an InterpolatedExpression themselves. Doing so
will fail, since it is coming from a different scope anyway.
The string is provided to you only for informational purposes
and as a sentinel to separate things the user wrote.
Your code should be able to handle an empty code string
in InterpolatedExpression or even an entirely missing
InterpolatedExpression, in case an implementation decides to
not emit these.
The toString members on these return null, except for
the InterpolatedLiteral, which returns the literal string.
This is to ease processing by generic functions like
std.stdio.write or std.conv.text, making them effectively
transparently skipped.
To extract the string from an InterpolatedLiteral, you can
use an is expression or the .toString method.
To extract the string from a InterpolatedExpression, you can
use an is expression or the .expression member.
None of these structures have runtime state.
interpolation : (struct) core.interpolation.InterpolationFooterditto
InterpolationFooter, (struct) core.interpolation.InterpolationHeaderSentinel values to indicate the beginning and end of an
interpolated expression sequence.
Note that these can nest, so while processing a sequence,
it may be helpful to keep a nesting count if that knowledge
is important to your application.
InterpolationHeader;
import (package) stdstd.(package) std.experimentalexperimental.(package) std.experimental.allocatorallocator.(package) std.experimental.allocator.building_blocksbuilding_blocks.(module) std.experimental.allocator.building_blocks.regionSource
std/experimental/allocator/building_blocks/region.d
region : (alias struct) clayui.InSituRegion = std.experimental.allocator.building_blocks.region.InSituRegion(ulong size, ulong minAlign = platformAlignment)InSituRegion is a convenient region that carries its storage within itself
(in the form of a statically-sized array).
The first template argument is the size of the region and the second is the
needed alignment. Depending on the alignment requested and platform details,
the actual available storage may be smaller than the compile-time parameter. To
make sure that at least n bytes are available in the region, use
``InSituRegion!(n + a - 1, a).
Given that the most frequent use of InSituRegion is as a stack allocator, it
allocates starting at the end on systems where stack grows downwards, such that
hot memory is used first.
InSituRegion;
import (package) sparklessparkles.(package) sparkles.basebase.(module) sparkles.base.bufferA @nogc container with Small Buffer Optimization (SBO).
Provides an append-only buffer that stores small amounts of data inline
(avoiding heap allocation) and automatically switches to heap storage
when capacity is exceeded.
Primary use case: appending elements in a temporary scope where GC
allocation is not desired.
buffer : (alias struct) clayui.BoundedSink = sparkles.base.buffer.BoundedSink(T)A bounded output range over storage someone else owns.
Handed out by tryWrite and valid only inside it, so a partially written
destination is never observable: either the whole write fits, or nothing is
kept. Overflow is recorded rather than thrown, which is what lets the entire
sparkles.base.text.writers family compose inside one attempt.
BoundedSink, (alias template) clayui.InlineBuffer = sparkles.base.buffer.InlineBuffer(T, ulong N, Storage extra = Storage.none) if (!(extra & ~Storage.unique))A buffer that never allocates: the elements live in the inline T[N] and
nowhere else.
The policy with a guarantee no other has. Because there is no union, a slice of
the storage is provably a reference to the enclosing frame, so -dip1000
rejects returning one from a @safe function — the property CString is built
on. It also has no destructor, so it is plain data: copyable, comparable, and
usable as a field in an aggregate that must stay POD.
It is deliberately not an output range: put promises to accept what it is
given, and this cannot. Write into it with tryWrite.
Pass Storage.unique as extra for the move-only form, which is what prevents
an accidental copy of a large one.
InlineBuffer;
import (package) sparklessparkles.(package) sparkles.basebase.(package) sparkles.base.texttext.(module) sparkles.base.text.writers@nogc-compatible text writing utilities for output ranges.
Provides functions for writing integers, floats, escaped characters/strings,
and ANSI escape sequences to output ranges without GC allocation.
writers : (alias template) clayui.writeText = sparkles.base.text.writers.writeText(Writer, Args...)(ref Writer w, InterpolationHeader, Args args, InterpolationFooter)Writes an interpolated sequence to an output range, verbatim.
SharedBuffer!(char, 128) buf;
buf.writeText(i"pid $(pid) exited with $(status)");
Plain, not styled. Literals are copied through and interpolated values go
via writeValue; nothing is parsed. That is the difference from
sparkles.base.styled_template.writeStyled, which reads {red …} as markup —
and the reason to reach for this one whenever the text is not a style template.
Interpolating a value that may contain a brace (a file path, a user's input)
through the styled writer silently eats it as a style block; here a brace is a
brace.
The @nogc half of the pair. std.conv.text already renders an
interpolated sequence to a string, so use that where a GC allocation is fine;
this is for the paths where it is not, and it inherits Writer's attributes the
way every template in this module does.
writeText;
import (module) benchtextThe benchmark's frame text store, used by all three builders under
version (Bench): a bump arena with TextPool's intern/withText/release
surface. TextPool cannot be sized for a 100 000-row frame on a test worker's
512 KiB stack: its compact keeps a uint[slots] on the stack (2 MiB at 2^19
slots), and the frame is reserved on every intern that may compact.
benchtext : (struct) benchtext.BumpTextPoolBumpTextPool, (alias template) clayui.FrameBuf = benchtext.FrameBuf(T)The frame tables' buffer in the benchmark. By default the sparkles:base
HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a
bare malloc'd array. The mutable Buffer.opIndex/opSlice call
ensureUniqueStorage (not inlined, computing roundedCapacity) on every
access even for Storage.unique, and the top-down builders index their node
table far more than the inside-out one does; RawBuf takes that cost out of
all three, leaving the builders' own work.
FrameBuf;
import (module) treehashThe tree checksum every builder folds its nodes into, in pre-order.
treehash : (alias) clayui.treeHash = ulong treehash.treeHash(ulong h, scope const(char)[] kind, uint w, uint hgt, uint children) pure nothrow @nogc @safetreeHash;
public import (module) clay_implclay_impl;
/// What each element is, for the tree checksum; kept in the declaration's
/// `userData` (Clay copies it into the element, at no extra cost). Names as
/// in the other builders' `Kind`.
enum (enum) clayui.KindWhat each element is, for the tree checksum; kept in the declaration's
userData (Clay copies it into the element, at no extra cost). Names as
in the other builders' Kind.
Kind : ubyte { (enum value) clayui.Kind.column = cast(ubyte)0ucolumn, (enum value) clayui.Kind.row = 1row, (enum value) clayui.Kind.label = 2label, (enum value) clayui.Kind.toggle = 3toggle, (enum value) clayui.Kind.numberField = 4numberField, (enum value) clayui.Kind.keyValue = 5keyValue }
private immutable (alias) object.string = stringstring[6] (immutable global) immutable(string[6]) clayui.kindNamekindName = ["column", "row", "label", "toggle", "numberField", "keyValue"];
/// `Density`, as the other builders' `Env` carries it.
enum (enum) clayui.DensityDensity, as the other builders' Env carries it.
Density : ubyte { (enum value) clayui.Density.compact = cast(ubyte)0ucompact, (enum value) clayui.Density.comfortable = 1comfortable }
private extern (C) void clayui.countErrorcountError(Clay_ErrorData (parameter) Clay_ErrorData ee) nothrow @nogc
{
auto _error_ countscounts = cast(uint*) e.userData;
counts[e.errorType == CLAY_ERROR_TYPE_DUPLICATE_ID ? 1 : 0]++;
}
/// One message, as `lazystack.MsgRec`: its type key and its bytes in the arena.
private struct (struct) clayui.MsgRecOne message, as lazystack.MsgRec``: its type key and its bytes in the arena.
MsgRec { ulong (field) ulong clayui.MsgRec.typeKeytypeKey; const(void)[] (field) const(void)[] clayui.MsgRec.valuevalue; }
private ulong ulong clayui.fnv(scope const(char)[] s) pure nothrow @nogc @safefnv(scope const(char)[] (parameter) const(char)[] ss) @safe pure nothrow @nogc
{
ulong (local variable) ulong hh = 0xcbf29ce484222325;
foreach ((parameter) const(char) cc; (parameter) const(char)[] ss)
(local variable) ulong hh = ((local variable) ulong hh ^ (local variable) const(char) cc) * 0x100000001b3;
return (local variable) ulong hh;
}
/// A handle to a message, as the other builders' `MsgRef`.
struct (struct) clayui.MsgRefA handle to a message, as the other builders' MsgRef.
MsgRef { uint (field) uint clayui.MsgRef.indexindex = uint.(constant) uint uint.max = 4294967295umax; }
/**
One Clay context, sized for `maxElements` elements, owned (malloc'd) by this
struct. Clay's context is a global (`Clay__currentContext`): `begin` makes
this one current.
*/
struct (struct) clayui.ClayUi(bool Side = false)One Clay context, sized for maxElements elements, owned (malloc'd) by this
struct. Clay's context is a global (Clay__currentContext): begin makes
this one current.
ClayUi(bool Side = false)
{
private void* _error_ memorymemory;
private Clay_Context* _error_ ctxctx;
private uint[2] _error_ errorserrors; // [other, duplicate id]
(unresolved type) DensityDensity _error_ densitydensity = Density.Density.comfortablecomfortable;
private InlineBuffer!(char, 1024) _error_ scratchscratch;
static if (Side)
{
private BumpTextPool texts;
private FrameBuf!MsgRec msgs;
private InSituRegion!(8 << 20) argArena;
}
@disable this(this);
/// Allocates and initialises the context. The layout root is huge so that
/// nothing is shrunk to fit or culled.
void void setup(int maxElements) nothrow @nogc @trustedAllocates and initialises the context. The layout root is huge so that
nothing is shrunk to fit or culled.
setup(int (parameter) int maxElementsmaxElements) @trusted nothrow @nogc
{
import core.stdc.stdlib : malloc;
Clay_SetCurrentContext(null); // the defaults below apply to a new context only
Clay_SetMaxElementCount(maxElements);
const _error_ sizesize = Clay_MinMemorySize();
memory = malloc(size);
assert(memory !is null, "out of memory");
auto _error_ arenaarena = Clay_CreateArenaWithCapacityAndMemory(size, memory);
ctx = Clay_Initialize(arena, Clay_Dimensions(1e9, 1e9),
Clay_ErrorHandler(&countError, &errors[0]));
assert(ctx !is null, "Clay_Initialize failed");
Clay_SetMeasureTextFunction(&measureCells, null);
}
~this() @trusted nothrow @nogc
{
import core.stdc.stdlib : free;
if (Clay_GetCurrentContext() is ctx)
Clay_SetCurrentContext(null);
free(memory);
}
/// Bytes Clay asked for.
size_t size_t memorySize() const nothrow @nogc @trustedBytes Clay asked for.
memorySize() const @trusted nothrow @nogc => ctx.internalArena.capacity;
/// `Clay_BeginLayout` on this context.
void void begin() nothrow @nogc @trustedClay_BeginLayout on this context.
begin() @trusted nothrow @nogc
{
Clay_SetCurrentContext(ctx);
Clay_BeginLayout();
}
/// `Clay_EndLayout`: the remaining layout passes and the render commands.
Clay_RenderCommandArray Clay_RenderCommandArray end() nothrow @nogc @trustedClay_EndLayout: the remaining layout passes and the render commands.
end() @trusted nothrow @nogc => Clay_EndLayout(0);
/// Errors Clay reported, other than duplicate ids (which it resolves).
uint uint errorCount() const nothrow @nogc @safeErrors Clay reported, other than duplicate ids (which it resolves).
errorCount() const @safe nothrow @nogc => errors[0];
/// Duplicate-id reports (auto ids are 32-bit hashes; see README.md).
uint uint duplicateIds() const nothrow @nogc @safeDuplicate-id reports (auto ids are 32-bit hashes; see README.md).
duplicateIds() const @safe nothrow @nogc => errors[1];
/// Drops the frame's side tables, keeping the storage.
void void reset() nothrow @nogc @trustedDrops the frame's side tables, keeping the storage.
reset() @trusted nothrow @nogc
{
scratch.clear();
static if (Side)
{
texts.clearAll();
msgs.clear(releaseStorage: false);
argArena.deallocateAll();
}
}
/// Formats an IES into the frame's scratch, as `lazystack.Ui.text`.
const(char)[] const(char)[] text(InterpolationHeader header, Args args, InterpolationFooter footer) returntext(Args...)((unresolved type) InterpolationHeaderInterpolationHeader (parameter) InterpolationHeader headerheader, Args (parameter) Args argsargs,
(unresolved type) InterpolationFooterInterpolationFooter (parameter) InterpolationFooter footerfooter) return
{
const _error_ startstart = scratch.length;
const _error_ fitsfits = scratch.tryWrite((scope ref BoundedSink!char (parameter) BoundedSink!char ww) {
w.w.writeTextwriteText(header, args, footer);
});
assert(fits, "the frame's text scratch is full");
return scratch[start .. scratch.length];
}
/// A message handle. Without `Side`, nothing is stored (Clay has no
/// message table; an app would check `Clay_PointerOver(id)` instead).
MsgRef MsgRef on(M value)on(M)(M (parameter) M valuevalue)
{
static if (Side)
{
static assert(__traits(isPOD, M), "a message is plain data: it is copied as bytes");
const block = () @trusted {
auto b = argArena.allocate(M.sizeof);
if (b !is null)
b[] = (cast(const(void)*) &value)[0 .. M.sizeof];
return b;
}();
assert(block !is null, "the frame's argument arena is full");
const self = MsgRef(cast(uint) msgs.length);
msgs ~= MsgRec(fnv(M.mangleof), block);
return self;
}
else
return MsgRef.init;
}
pragma(inline, true)
private void void keep(scope const(char)[] s) pure nothrow @nogc @safekeep(scope const(char)[] (parameter) const(char)[] ss) @safe pure nothrow @nogc
{
static if (Side)
if (s.length)
cast(void) texts.intern(s);
}
// ── the tree, read back from Clay's own element storage ────────────────
/// The view's root: the first element opened after Clay's root container.
enum int (constant) int viewRoot = 1The view's root: the first element opened after Clay's root container.
viewRoot = 1;
/// Elements Clay holds this frame (its root container included).
size_t size_t elementCount() const nothrow @nogc @trustedElements Clay holds this frame (its root container included).
elementCount() const @trusted nothrow @nogc => ctx.layoutElements.length;
/// Pre-order checksum of the subtree under element `i`, read from
/// `layoutElements[i]`: `dimensions` (the fit size `Clay__CloseElement`
/// computed), `children.elements[0 .. children.length]`, and the kind in
/// `config.userData`.
void void checksum(int i, ref ulong h, ref size_t count) const nothrow @nogc @trustedPre-order checksum of the subtree under element i, read from
layoutElements[i]: dimensions (the fit size Clay__CloseElement
computed), children.elements[0 .. children.length], and the kind in
config.userData.
checksum(int (parameter) int ii, ref ulong (parameter) ulong hh, ref size_t (parameter) size_t countcount) const @trusted nothrow @nogc
{
const _error_ ee = &ctx.layoutElements.internalArray[i];
assert(!e.isTextElement, "this bench declares no text elements");
const _error_ kindkind = cast(size_t) e.config.userData - 1;
h = treeHash(h, kindName[kind], cast(uint) e.dimensions.width,
cast(uint) e.dimensions.height, e.children.length);
count++;
foreach ((parameter) cc; e.children.elements[0 .. e.children.length])
checksum(c, h, count);
}
}
/// `Clay_String` over a D slice; `isStaticallyAllocated` as the macros set it
/// for literals (the bench's strings outlive every frame).
pragma(inline, true)
Clay_String clayui.clayStringClay_String over a D slice; isStaticallyAllocated as the macros set it
for literals (the bench's strings outlive every frame).
clayString(const(char)[] (parameter) const(char)[] ss) @trusted pure nothrow @nogc
=> Clay_String(true, cast(int) s.length, s.ptr);
private extern (C) Clay_Dimensions clayui.measureCellsmeasureCells(Clay_StringSlice (parameter) Clay_StringSlice texttext,
Clay_TextElementConfig* config, void* userData) nothrow @nogc
=> Clay_Dimensions(cells(text.chars[0 .. text.length]), 1);
/// Display width of UTF-8 text: one cell per code point (as `lazystack.cells`).
uint uint clayui.cells(scope const(char)[] s) pure nothrow @nogc @safeDisplay width of UTF-8 text: one cell per code point (as lazystack.cells``).
cells(scope const(char)[] (parameter) const(char)[] ss) @safe pure nothrow @nogc
{
uint (local variable) uint nn;
foreach ((parameter) const(char) cc; (parameter) const(char)[] ss)
(local variable) uint nn += ((local variable) const(char) cc & 0xC0) != 0x80;
return (local variable) uint nn;
}
/// Decimal digits of `v` (as `lazystack.digits`).
uint uint clayui.digits(int v) pure nothrow @nogc @safeDecimal digits of v (as lazystack.digits``).
digits(int (parameter) int vv) @safe pure nothrow @nogc
{
uint (local variable) uint nn = (parameter) int vv < 0 ? 2 : 1;
for ((parameter) int vv /= 10; v; v /= 10)
(local variable) uint nn++;
return (local variable) uint nn;
}
// ── containers: `with (ui.column(gap: 1)) { … }` ─────────────────────────
/// Closes the element it was returned for when the `with` scope ends.
struct (struct) clayui.OpenCloses the element it was returned for when the with scope ends.
Open
{
private bool (field) bool clayui.Open.livelive;
@disable this(this);
pragma(inline, true)
~this() @trusted nothrow @nogc
{
if ((field) bool clayui.Open.livelive)
Clay__CloseElement();
}
}
pragma(inline, true)
private (struct) clayui.OpenCloses the element it was returned for when the with scope ends.
Open clayui.containercontainer((enum) clayui.KindWhat each element is, for the tree checksum; kept in the declaration's
userData (Clay copies it into the element, at no extra cost). Names as
in the other builders' Kind.
Kind (parameter) Kind kindkind, Clay_LayoutDirection dir, int (parameter) int gapgap) @trusted nothrow @nogc
{
Clay__OpenElement();
Clay_ElementDeclaration _error_ dd; // all FIT, no padding: Clay's defaults
d.layout.layoutDirection = dir;
d.layout.childGap = cast(ushort) gap;
d.userData = cast(void*) (kind + 1);
Clay__ConfigureOpenElement(d);
return Open(true);
}
/// A vertical stack: `CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = gap } })`.
pragma(inline, true)
Open Open column(U)(ref U ui, int gap = 0)A vertical stack: CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = gap } }).
column(U)(ref U (parameter) U uiui, int (parameter) int gapgap = 0) => container(Kind.Kind.columncolumn, CLAY_TOP_TO_BOTTOM, gap);
/// A horizontal stack.
pragma(inline, true)
Open Open row(U)(ref U ui, int gap = 0)A horizontal stack.
row(U)(ref U (parameter) U uiui, int (parameter) int gapgap = 0) => container(Kind.Kind.rowrow, CLAY_LEFT_TO_RIGHT, gap);
// ── leaves: fixed-size elements ────────────────────────────────────────────
pragma(inline, true)
private void void clayui.configureLeaf(clayui.Kind kind, uint w) nothrow @nogc @trustedconfigureLeaf((enum) clayui.KindWhat each element is, for the tree checksum; kept in the declaration's
userData (Clay copies it into the element, at no extra cost). Names as
in the other builders' Kind.
Kind (parameter) clayui.Kind kindkind, uint (parameter) uint ww) @trusted nothrow @nogc
{
Clay_ElementDeclaration (local variable) _error_ dd;
d.layout.sizing.width.(field) _error_ d.layout.sizing.width.sizesize.minMax = Clay_SizingMinMax(w, w);
d.layout.sizing.width.type = CLAY__SIZING_TYPE_FIXED;
d.layout.sizing.height.(field) _error_ d.layout.sizing.height.sizesize.minMax = Clay_SizingMinMax(1, 1);
d.layout.sizing.height.type = CLAY__SIZING_TYPE_FIXED;
d.backgroundColor = Clay_Color(40, 40, 48, 255);
d.userData = cast(void*) (kind + 1);
Clay__ConfigureOpenElement(d);
}
pragma(inline, true)
private void void clayui.leaf(clayui.Kind kind, uint w) nothrow @nogc @trustedleaf((enum) clayui.KindWhat each element is, for the tree checksum; kept in the declaration's
userData (Clay copies it into the element, at no extra cost). Names as
in the other builders' Kind.
Kind (parameter) clayui.Kind kindkind, uint (parameter) uint ww) @trusted nothrow @nogc
{
Clay__OpenElement();
void clayui.configureLeaf(clayui.Kind kind, uint w) nothrow @nogc @trustedconfigureLeaf((parameter) clayui.Kind kindkind, (parameter) uint ww);
Clay__CloseElement();
}
/// One run of text.
pragma(inline, true)
void void label(U)(ref U ui, scope const(char)[] text)One run of text.
label(U)(ref U (parameter) U uiui, scope const(char)[] (parameter) const(char)[] texttext)
{
ui.ui.keepkeep(text);
leaf(Kind.Kind.labellabel, text.text.cellscells);
}
/// A switch.
pragma(inline, true)
void void toggle(U)(ref U ui, bool on, scope const(char)[] label, MsgRef onPress)A switch.
toggle(U)(ref U (parameter) U uiui, bool (parameter) bool onon, scope const(char)[] (parameter) const(char)[] labellabel, (unresolved type) MsgRefMsgRef (parameter) MsgRef onPressonPress)
{
ui.ui.keepkeep(label);
leaf(Kind.Kind.toggletoggle, label.label.cellscells + 4);
}
/// A number field.
pragma(inline, true)
void void numberField(U)(ref U ui, int value, scope const(char)[] unit, MsgRef onChange)A number field.
numberField(U)(ref U (parameter) U uiui, int (parameter) int valuevalue, scope const(char)[] (parameter) const(char)[] unitunit, (unresolved type) MsgRefMsgRef (parameter) MsgRef onChangeonChange)
{
ui.ui.keepkeep(unit);
leaf(Kind.Kind.numberFieldnumberField, value.value.digitsdigits + 1 + unit.unit.cellscells);
}
/// A name and its value, keyed: its id is `CLAY_SID_LOCAL(key)`.
pragma(inline, true)
void void keyValue(U)(ref U ui, scope const(char)[] key, scope const(char)[] name, scope const(char)[] value, MsgRef onPress)A name and its value, keyed: its id is CLAY_SID_LOCAL(key).
keyValue(U)(ref U (parameter) U uiui, scope const(char)[] (parameter) const(char)[] keykey, scope const(char)[] (parameter) const(char)[] namename,
scope const(char)[] (parameter) const(char)[] valuevalue, (unresolved type) MsgRefMsgRef (parameter) MsgRef onPressonPress)
{
ui.ui.keepkeep(name);
ui.ui.keepkeep(value);
() @trusted {
Clay__OpenElementWithId(Clay__HashString(clayString(key), Clay_GetOpenElementId()));
configureLeaf(Kind.Kind.keyValuekeyValue, name.name.cellscells + 1 + value.value.cellscells);
Clay__CloseElement();
}();
}