template <Layout L>
nxt::tui::Slot class

A live hole in the layout tree.

Slot<L> satisfies the Layout concept by forwarding to whichever L value was most recently published into it. The slot is a shared handle: copies share the same cell, so the layout tree can copy a slot by value each frame while a coroutine elsewhere keeps publishing fresh layouts into the same cell.

Publishing is lock-free (atomic shared_ptr swap) and invokes an optional on-publish callback — typically UIRuntime::signal_damage.

Constructors, destructors, conversion operators

Slot(L initial, std::function<void()> on_publish = {}) explicit

Public functions

auto height_hint() const →  HeightHint
void publish(L layout) const
Replace the current layout. Thread-safe.
void render(RasterView& raster, Size size) const
void set_on_publish(std::function<void()> fn) const
auto width_hint() const →  WidthHint

Function documentation

template <Layout L>
nxt::tui::Slot::Slot(L initial, std::function<void()> on_publish = {}) explicit

Construct a slot showing initial. on_publish is invoked after every successful publish(); it is intended to wake the render loop (e.g. [&rt]{ rt.signal_damage(); }). It can also be set later via set_on_publish for cases where the runtime is not available at construction time.

template <Layout L>
void nxt::tui::Slot::set_on_publish(std::function<void()> fn) const

Install or replace the on-publish callback. Not thread-safe; call before any coroutine starts publishing.