38using Key = std::variant<std::int64_t, std::string>;
88template <
typename From,
typename To>
90 !(std::is_same_v<std::remove_cv_t<To>,
bool> && std::is_pointer_v<std::decay_t<From>>) &&
91 !(std::is_integral_v<To> && std::is_floating_point_v<std::remove_cvref_t<From>>) &&
110 requires std::default_initializable<T>
111 : _value{std::in_place_index<0>} {}
122 template <
typename U>
123 requires(!std::invocable<U&>) && detail::ConstantConvertible<U, T>
127 : _value{std::in_place_index<0>,
static_cast<T
>(std::forward<U>(value))} {}
136 template <
typename F>
137 requires std::invocable<F&> && std::convertible_to<std::invoke_result_t<F&>, T>
138 Prop(F
binding) : _value{std::in_place_index<1>, Slot{.id = std::nullopt, .read = std::move(
binding)}} {
146 template <
typename F>
147 requires std::invocable<F&> && std::convertible_to<std::invoke_result_t<F&>, T>
149 : _value{std::in_place_index<1>, Slot{.id =
binding.id, .read = std::move(
binding.read)}} {
155 [[nodiscard]]
bool isBound() const noexcept {
return _value.index() == 1; }
160 [[nodiscard]] T
const&
constant()
const {
return std::get<0>(_value); }
165 [[nodiscard]] std::function<T()>
const&
binding()
const {
return std::get<1>(_value).read; }
169 [[nodiscard]] std::optional<SlotId>
slotId() const noexcept {
170 Slot
const*
const bound = std::get_if<1>(&_value);
171 return bound ==
nullptr ? std::nullopt : bound->id;
176 [[nodiscard]] T
evaluate()
const {
return isBound() ? std::get<1>(_value).read() : std::get<0>(_value); }
182 std::optional<SlotId> id;
184 std::function<T()> read;
189 void refuseEmpty()
const {
190 if (!std::get<1>(_value).read) {
191 throw std::invalid_argument{
"ui::Prop: a binding must not be empty"};
195 std::variant<T, Slot> _value;
222enum class Axis : std::uint8_t {
240enum class Tone : std::uint8_t {
249enum class Side : std::uint8_t {
272 enum class Kind : std::uint8_t {
403using Node = std::shared_ptr<NodeData const>;
587 std::optional<Prop<std::optional<Tone>>>
tone;
723 virtual ~RowSlot() =
default;
724 RowSlot(RowSlot
const&) =
delete;
725 RowSlot& operator=(RowSlot
const&) =
delete;
726 RowSlot(RowSlot&&) =
delete;
727 RowSlot& operator=(RowSlot&&) =
delete;
731 virtual void assign(std::size_t index) = 0;
739class ForEachSession {
741 ForEachSession() =
default;
742 virtual ~ForEachSession() =
default;
743 ForEachSession(ForEachSession
const&) =
delete;
744 ForEachSession& operator=(ForEachSession
const&) =
delete;
745 ForEachSession(ForEachSession&&) =
delete;
746 ForEachSession& operator=(ForEachSession&&) =
delete;
751 [[nodiscard]]
virtual std::vector<Key>
pull() = 0;
756 [[nodiscard]]
virtual std::unique_ptr<RowSlot>
makeRow(std::size_t index) = 0;
762 ForEachModel() =
default;
763 virtual ~ForEachModel() =
default;
764 ForEachModel(ForEachModel
const&) =
delete;
765 ForEachModel& operator=(ForEachModel
const&) =
delete;
766 ForEachModel(ForEachModel&&) =
delete;
767 ForEachModel& operator=(ForEachModel&&) =
delete;
778template <
typename RowT>
787 : _rows{nonEmpty(std::move(rows))},
788 _keyOf{nonEmpty(std::move(
keyOf))},
789 _rowView{nonEmpty(std::move(rowView))} {}
792 return std::make_unique<Session>(runtime, *
this);
796 template <
typename F>
797 [[nodiscard]]
static F nonEmpty(F function) {
799 throw std::invalid_argument{
"ui::forEach: the rows, the key function and the row view must not be empty"};
804 class Slot final :
public RowSlot {
806 Slot(reactive::Runtime& runtime, std::vector<RowT>
const& snapshot, std::size_t index,
808 : _snapshot{&snapshot}, _row{runtime, snapshot.at(index)}, _view{model._rowView(_row)} {}
810 void assign(std::size_t index)
override { _row.set(_snapshot->at(index)); }
811 [[nodiscard]]
Node view()
const override {
return _view; }
814 std::vector<RowT>
const* _snapshot;
815 reactive::Signal<RowT> _row;
819 class Session final :
public ForEachSession {
821 Session(reactive::Runtime& runtime,
TypedForEach const& model) : _rt{&runtime}, _model{&model} {}
823 [[nodiscard]] std::vector<Key>
pull()
override {
824 _snapshot = _model->_rows();
825 std::vector<Key> keys;
826 keys.reserve(_snapshot.size());
827 for (RowT
const& entry : _snapshot) {
828 keys.push_back(_model->_keyOf(entry));
833 [[nodiscard]] std::unique_ptr<RowSlot> makeRow(std::size_t index)
override {
834 return std::make_unique<Slot>(*_rt, _snapshot, index, *_model);
838 reactive::Runtime* _rt;
840 std::vector<RowT> _snapshot;
843 std::function<std::vector<RowT>()> _rows;
844 std::function<
Key(RowT
const&)> _keyOf;
845 std::function<
Node(reactive::Signal<RowT>
const&)> _rowView;
866 std::shared_ptr<detail::ForEachModel const>
model;
892 std::shared_ptr<detail::ForEachModel const>
rows;
918 std::function<void(std::optional<morph::time::Timestamp>)>
onChange;
1136 std::function<void(std::vector<std::string>)>
onDrop;
1166 std::function<void(std::string event, std::string payload)>
onEvent;
1172 std::variant<
Text,
Button,
TextInput,
Checkbox,
Select,
Menu,
Column,
Row,
Grid,
Spacer,
Panel,
Scroll,
Switch,
1173 Tabs,
Dialog,
Busy,
ForEach,
Table,
DateTimeInput,
Slider,
FilePicker,
Banner,
Badge,
Progress,
Steps,
1184template <
typename Kind>
1186 return std::make_shared<NodeData const>(
NodeData{.kind = std::move(spec)});
1239[[nodiscard]]
inline Node spacer(
Spacer spec = {}) {
return detail::makeNode(std::move(spec)); }
1348 throw std::invalid_argument{
"morph::ui::custom: the fallback of a custom node is null"};
1363template <
typename E>
1364 requires std::is_enum_v<E>
1365[[nodiscard]]
Node switchOn(std::function<E()> selector, std::vector<std::pair<E, Node>> cases,
Node fallback = {}) {
1367 throw std::invalid_argument{
"ui::switchOn: the selector must not be empty"};
1369 std::vector<SwitchCase> keyed;
1370 keyed.reserve(cases.size());
1371 for (
auto& [value, node] : cases) {
1372 keyed.push_back(
SwitchCase{.key =
Key{
static_cast<std::int64_t
>(value)}, .node = std::move(node)});
1375 .selector = [current = std::move(selector)] {
return Key{
static_cast<std::int64_t
>(current())}; },
1376 .cases = std::move(keyed),
1378 spec.
fallback = std::move(fallback);
1395template <
typename RowT>
1396[[nodiscard]]
Node forEach(std::function<std::vector<RowT>()> rows, std::function<
Key(RowT
const&)> keyOf,
1401 std::make_shared<detail::TypedForEach<RowT>
const>(std::move(rows), std::move(keyOf), std::move(rowView)),
1416template <
typename RowT>
1420 return forEach<RowT>([&rows] {
return rows.get(); }, std::move(keyOf), std::move(rowView), axis, gap);
1446 std::optional<Prop<std::optional<Tone>>>
tone;
1463template <
typename RowT>
1464[[nodiscard]]
Node table(std::vector<TableColumn> columns, std::function<std::vector<RowT>()> rows,
1465 std::function<
Key(RowT
const&)> keyOf,
1468 if (!rows || !keyOf || !cells) {
1469 throw std::invalid_argument{
"ui::table: the rows, the key function and the cells must not be empty"};
1471 std::function<
TableRowView(reactive::Signal<RowT>
const&)> rowView =
1472 [cellsOf = std::move(cells)](reactive::Signal<RowT>
const& entry) {
1473 return TableRowView{.cells = cellsOf(entry), .tone = std::nullopt};
1475 return table<RowT>(std::move(columns), std::move(rows), std::move(keyOf), std::move(rowView), std::move(options));
1491template <
typename RowT>
1492[[nodiscard]]
Node table(std::vector<TableColumn> columns, std::function<std::vector<RowT>()> rows,
1493 std::function<
Key(RowT
const&)> keyOf,
1496 if (!rows || !keyOf || !rowView) {
1497 throw std::invalid_argument{
"ui::table: the rows, the key function and the row view must not be empty"};
1499 std::function<
Node(reactive::Signal<RowT>
const&)> rowNode =
1500 [viewOf = std::move(rowView),
count = columns.size()](reactive::Signal<RowT>
const& entry) {
1502 if (made.cells.size() != count ||
1503 std::ranges::any_of(made.cells, [](
Node const& cell) { return cell == nullptr; })) {
1504 throw std::invalid_argument{
"ui::table: a row needs exactly one non-null cell per column"};
1506 return row(
Row{.children = std::move(made.cells), .tone = std::move(made.tone)});
1510 std::make_shared<detail::TypedForEach<RowT>
const>(std::move(rows), std::move(keyOf), std::move(rowNode)),
1511 .showHeader = options.showHeader,
1512 .virtualize = options.virtualize,
1513 .selectionMode = options.selectionMode,
1515 spec.
columns = std::move(columns);
1516 spec.selection = std::move(options.selection);
1517 spec.onSelectionChange = std::move(options.onSelectionChange);
1518 spec.onActivate = std::move(options.onActivate);
1519 spec.common = std::move(options.common);
morph::ui::Align and morph::ui::Justify: where a container places its children across its axis and al...
Justify
Where a stack places its spare length along its axis, while no shown child stretches.
@ Start
Packed at the start.
Align
Where a child is placed across its container's axis: a column's horizontally, a row's vertically,...
@ End
At the end: right in a column, bottom in a row or grid.
@ Start
At the start: left in a column, top in a row or grid.
@ Stretch
A content child fills the cross extent; one its maximum stops sits at the start.
Handle< std::int64_t > count(AnyHandle const &list)
count: a list's length.
The owner of a signal graph: every node takes one, and every operation runs on its owner.
A source value. Reading it with get() inside a tracked run subscribes that run.
A node property: a constant, or a slot — a reactive read, with a stable id when it was given one.
T const & constant() const
The constant. Only valid when !isBound().
Prop(SlotBinding< F > binding)
A slot with an id, as ui::slot makes it.
std::optional< SlotId > slotId() const noexcept
The slot's id.
std::function< T()> const & binding() const
The slot's read. Only valid when isBound().
bool isBound() const noexcept
Whether this is a slot.
Prop(F binding)
A slot without an id.
T evaluate() const
The current value: the constant, or the slot read once.
Prop(U &&value)
A constant.
Prop()
The value-initialised constant.
virtual std::unique_ptr< ForEachSession > open(reactive::Runtime &runtime) const =0
Starts one mount's session.
virtual std::unique_ptr< RowSlot > makeRow(std::size_t index)=0
Makes the slot for one snapshot entry, building its view. The mount calls it untracked.
virtual std::vector< Key > pull()=0
Reads the rows (tracked, inside the mount's Effect), keeps them as the snapshot, and returns their ke...
virtual void assign(std::size_t index)=0
Sets the row's signal to an entry of its session's latest snapshot; an equal row notifies nobody.
virtual Node view() const =0
The view built for this row when the slot was made.
std::unique_ptr< ForEachSession > open(reactive::Runtime &runtime) const override
Starts one mount's session.
TypedForEach(std::function< std::vector< RowT >()> rows, std::function< Key(RowT const &)> keyOf, std::function< Node(reactive::Signal< RowT > const &)> rowView)
Whether From may become a constant Prop<To>: an implicit conversion that does not silently change the...
UTC timestamps for morph actions.
@ Pending
{"pending": "q"}: whether a query or mutation is in flight.
@ Save
Run the screen's save, and close it only if it is then clean.
Key keyOf(Value const &value)
A value as a view key: an int or a string as itself, anything else as its JSON text.
morph::reactive::Runtime: the owner, batching and flush scheduling of a signal graph.
Signal<T>, Computed<T> and Effect: the nodes of a reactive graph.
What assistive technology announces for a node.
Prop< std::string > name
The accessible name; empty leaves the widget's own text as its name.
std::string role
The role, such as "heading"; empty leaves the kind's own role. Set once.
A row of buttons in the footer of the dialog or drawer whose content holds it: what a document's over...
Common common
Visibility, enablement, layout, drag-and-drop of the row.
std::vector< Node > children
The buttons, in order; a null child is skipped.
A short label marking a state, such as a count or a status.
Prop< std::string > text
The label.
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< Tone > tone
What the mark conveys.
std::string icon
The name of an icon in the theme's icon map; empty shows none. Set once.
A message across the top of a region, with an optional action and an optional dismissal.
Prop< std::string > text
The message.
bool dismissible
Whether the user can dismiss it; set once.
ActionButton action
The button beside the message; an empty label shows none.
Common common
Visibility, enablement, layout, drag-and-drop.
Action onDismiss
Called when the user dismisses it. The banner stays shown until the application hides it.
Prop< Tone > tone
What the message conveys.
Prop< std::string > label
A caption beside it.
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< bool > active
Whether it animates.
Common common
Visibility, enablement, layout, drag-and-drop.
std::function< void(bool)> onToggle
Called with the new state when the user toggles it.
Prop< std::string > label
The caption.
Prop< bool > checked
Whether it is checked.
FieldState field
Read-only, required, errors and stale.
A titled section the user opens and closes. Its header stays usable while it is closed.
Common common
Visibility, enablement, layout, drag-and-drop.
Node header
Shown beside the title, open or closed; may be null.
Prop< bool > open
Whether the content is shown.
std::function< void(bool)> onToggle
Called with the state the user asked for.
Node child
The content; may be null. Mounted once, and hidden while closed.
Prop< std::string > title
The title.
Children stacked top to bottom.
Align align
Where the children sit across the column (horizontally); set once.
Justify justify
Where the spare height goes while no shown child stretches; set once.
int gap
Space between children: a spacing step, 0 to kMaxSpacingStep.
std::vector< Node > children
The children, in order; a null child is skipped.
Common common
Visibility, enablement, layout, drag-and-drop.
The part every node carries: visibility, enablement, layout, drag-and-drop, accessibility,...
Prop< std::string > tooltip
Text shown while the pointer rests on the widget; empty shows none.
Prop< std::optional< Key > > dragKey
Engaged: the widget can be dragged, and a drop delivers this key.
Accessibility a11y
The accessible name and role.
std::vector< KeyBinding > keys
Chords handled while focus is inside the node; the innermost node declaring a chord takes it....
bool autofocus
Whether the widget takes keyboard focus when the content it is part of mounts; the first such widget ...
LayoutHints layout
The size request; set once.
std::function< void(Key)> onDrop
Set: the widget is a drop target, called with the dropped key.
std::string surface
The named token set of the theme that styles this node and everything inside it; empty is the theme's...
std::string testId
The stable identifier an automated test finds the widget by; empty means none. Set once.
std::function< bool(Key const &)> accepts
Whether a drop of a key is accepted; empty accepts every key. Used only when onDrop is set.
std::string focusId
The name a focus request after mount finds the widget by (Mounted::focus), such as a document element...
Prop< bool > enabled
Whether the widget accepts input.
Prop< bool > visible
Whether the widget is shown.
One prop a loaded custom component is given.
std::variant< Prop< std::string >, Prop< bool >, Prop< double > > value
Its value: text for string, int, exact and json, which cross as text so that no value loses precision...
std::string name
The prop's name, as the component declares it.
A component the backend may load (spec 5 §10), with the built-in nodes shown when it does not.
int minVersion
The lowest version of a host component that will do.
Node fallback
The built-in nodes shown in its place; never null.
std::string name
The component's name, as the document's components declares it.
std::function< void(std::string event, std::string payload)> onEvent
Called with an event a loaded component raises: its name and its payload as the backend reports it.
std::vector< CustomProp > props
The props a loaded component is given, bound as any other property is.
A modal overlay; its content is mounted only while it is open.
Common common
Visibility, enablement, layout, drag-and-drop.
Action onDismiss
Called when the user dismisses it (Esc on the TUI).
Node child
The content; may be null.
Prop< bool > open
Whether it is shown.
Prop< std::string > title
The title.
A panel that slides in from one edge over the content: a Dialog with a side, and the same rules.
Side side
The edge it slides in from; set once.
Node child
The content; may be null.
Prop< bool > open
Whether it is shown.
Action onDismiss
Called when the user dismisses it (Esc on the TUI).
Prop< std::string > title
The title.
Common common
Visibility, enablement, layout, drag-and-drop.
A region that takes files dropped from the operating system.
Common common
Visibility, enablement, layout, drag-and-drop.
std::vector< std::string > accept
The extensions it takes, such as ".csv", compared without regard to case; empty takes every file....
bool multiple
Whether a drop may carry more than one file; set once.
std::function< void(std::vector< std::string >)> onDrop
Called with the paths of a drop it took. A drop with a file outside accept, or with several files whe...
Node child
The content shown inside the region; may be null.
What a region shows when it has nothing to show: a title, an explanation and an optional action.
Prop< std::string > title
The title.
std::string icon
The name of an icon in the theme's icon map; empty shows none. Set once.
Prop< std::string > text
The explanation.
ActionButton action
The button below the text; an empty label shows none.
Common common
Visibility, enablement, layout, drag-and-drop.
The state of a value a user edits or reads: whether it may be changed, must be given,...
Prop< bool > required
Whether the field is marked as one that must be given. Only a mark: whether a value is missing is the...
Prop< std::vector< std::string > > errors
The messages shown with the field, in order; empty shows none. Which errors show, and when,...
Prop< bool > readonly
Whether the user may not change the value. A read-only field shows its value and can take focus and h...
Prop< bool > stale
Whether the value shown is the last known one while a newer one is computed.
A file path, typed or chosen in the platform's file dialog.
FieldState field
Read-only, required, errors and stale.
Common common
Visibility, enablement, layout, drag-and-drop.
std::function< void(std::string)> onPicked
Called with the path the user picked.
Prop< std::string > path
The path shown.
FilePickerMode mode
Open an existing file or name one to save; set once.
One widget per row of a keyed collection, updated in place when a row with the same key changes.
std::shared_ptr< detail::ForEachModel const > model
The rows, the key function and the row view, type-erased; null shows no rows.
Axis axis
The direction rows are stacked in; set once.
int gap
Space between rows: a spacing step, 0 to kMaxSpacingStep.
Common common
Visibility, enablement, layout, drag-and-drop of the row container.
Node node
The cell's content; a null node leaves no cell.
int span
How many columns it spans.
Cells laid out row-major in a fixed number of columns.
Align align
Where each cell's content sits vertically in its row; set once. A grid's columns share its width,...
std::vector< GridCell > cells
The cells, row-major.
Common common
Visibility, enablement, layout, drag-and-drop.
int gap
Space between cells: a spacing step, 0 to kMaxSpacingStep.
int columns
The column count.
A keyboard chord a node handles while focus is inside it.
Action onPress
Called when the chord is pressed.
std::string chord
The chord: modifiers (Ctrl, Shift, Alt, Meta) joined to a key name, such as "Ctrl+S".
One row of a KeyValue list.
bool operator==(KeyValueItem const &) const =default
Memberwise equality.
std::string label
The caption.
std::string value
The value, as text.
Captions beside their values, one pair per row.
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< std::vector< KeyValueItem > > items
The pairs, in order.
A widget's size request in both dimensions, and the bounds its extent is clamped into.
Sizing height
Along the vertical axis.
std::optional< int > minHeight
The least height, in backend units; nullopt for none.
std::optional< int > minWidth
The least width, in backend units; nullopt for none.
std::optional< int > maxWidth
The most width, in backend units; nullopt for none.
std::optional< int > maxHeight
The most height, in backend units; nullopt for none.
std::optional< Align > alignSelf
Where the node sits across its row's, column's or grid row's axis; nullopt takes the container's alig...
bool operator==(LayoutHints const &) const =default
Memberwise equality.
Sizing width
Along the horizontal axis.
What a Node points at: exactly one node kind.
std::variant< Text, Button, TextInput, Checkbox, Select, Menu, Column, Row, Grid, Spacer, Panel, Scroll, Switch, Tabs, Dialog, Busy, ForEach, Table, DateTimeInput, Slider, FilePicker, Banner, Badge, Progress, Steps, KeyValue, EmptyState, Drawer, Splitter, Collapsible, DropZone, Custom, ActionBar > kind
The node.
A titled frame around one child; a collapsible one is an accordion section.
Node child
The content; may be null.
int padding
Space between frame and child: a spacing step, 0 to kMaxSpacingStep.
Prop< std::string > title
The title.
Prop< bool > collapsed
Whether it is collapsed; used only when collapsible.
Node header
Shown beside the title, collapsed or not; may be null.
Common common
Visibility, enablement, layout, drag-and-drop.
bool collapsible
Whether the user can collapse it; set once.
std::function< void(bool)> onToggle
Called with the collapsed state the user asked for; used only when collapsible.
Prop< std::string > label
A caption beside the bar.
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< std::optional< double > > value
How far along, from 0 to 1; a value outside is shown at the nearer end. nullopt: indeterminate.
Children laid out left to right.
int gap
Space between children: a spacing step, 0 to kMaxSpacingStep.
Justify justify
Where the spare width goes while no shown child stretches; set once.
std::vector< Node > children
The children, in order; a null child is skipped.
std::optional< Prop< std::optional< Tone > > > tone
A table row's tone: disengaged when none was given; an engaged Prop whose value is nullopt has no ton...
Align align
Where the children sit across the row (vertically); set once.
Common common
Visibility, enablement, layout, drag-and-drop.
Key key
The option's identity.
std::string label
The caption.
bool operator==(SelectOption const &) const =default
Memberwise equality.
Action onOpen
Called when the user opens the dropdown, whether or not it has options to show; a radio group is neve...
Prop< std::optional< Key > > selected
The selected key, or none. A key outside options shows no selection.
bool showLabel
Whether the input draws label as a visible caption itself; set once. A form leaves it false,...
SelectStyle style
Dropdown or radio; set once.
Prop< std::string > label
The field's label: its visible caption while showLabel; a form's cell draws it otherwise,...
FieldState field
Read-only, required, errors and stale.
Prop< std::vector< SelectOption > > options
The options, in order.
Common common
Visibility, enablement, layout, drag-and-drop.
std::function< void(Key)> onSelect
Called with the key the user chose.
How much space a widget asks for along one dimension, in backend units (a character cell on the TUI).
static constexpr Sizing content() noexcept
Size to the content.
bool operator==(Sizing const &) const =default
Memberwise equality.
static constexpr Sizing stretch(int weight=1) noexcept
A share of the leftover space.
static constexpr Sizing fixed(int units) noexcept
A fixed size.
int amount
Units for Fixed, weight for Stretch, unused for Content.
@ Fixed
Exactly amount units.
@ Content
As much as the content needs.
@ Stretch
A share of the leftover space, weighted by amount.
An integer chosen on a range.
Prop< std::int64_t > value
The value shown.
std::function< void(std::int64_t)> onChange
Called with the value the user moved to.
std::int64_t minimum
The smallest value; set once.
Common common
Visibility, enablement, layout, drag-and-drop.
FieldState field
Read-only, required, errors and stale.
std::function< void(std::int64_t)> onCommit
Called with the value a finished move ended on: a release after a drag, a key step,...
std::int64_t step
The increment between neighbouring values; set once.
std::int64_t maximum
The largest value; set once.
A slot's read together with its id, as ui::slot makes it; a Prop made from it is a slot with that id.
F read
Reads the slot's value; every signal it reads is a dependency.
Empty space that takes what its layout hints ask for.
Common common
Visibility, enablement, layout, drag-and-drop.
Panes side by side, or stacked, with handles the user drags to share the space between them.
Common common
Visibility, enablement, layout, drag-and-drop.
Axis orientation
The axis the panes are laid out along; set once.
std::vector< Node > children
The panes, in order; a null child is skipped.
Prop< std::vector< int > > sizes
Each pane's size, in backend units, in order; empty shares the space equally. A list whose length dif...
std::function< void(std::vector< int >)> onResize
Called with every pane's size after the user dragged a handle.
One step of a Steps indicator.
StepState state
Where it stands.
bool operator==(Step const &) const =default
Memberwise equality.
std::string label
The caption.
The steps of a process in order, each with its state.
Prop< std::vector< Step > > items
The steps.
Prop< std::optional< std::size_t > > current
The step to highlight, by position; nullopt or a position past the last highlights none.
Common common
Visibility, enablement, layout, drag-and-drop.
Key key
The selector value this case answers.
Node node
The content; may be null.
Shows the case whose key the selector yields; remounts only when that key changes.
std::vector< SwitchCase > cases
The cases; the first one with the selected key wins.
Prop< Key > selector
Which case to show.
Node fallback
Shown when no case matches; may be null, and then nothing is shown.
Common common
Visibility, enablement, layout, drag-and-drop.
std::string label
The tab's caption; set once.
Node node
The page content, mounted the first time the tab is selected.
Sizing width
The column's width request.
TextRole role
The text style of this column's default cell; Normal renders unchanged. Has no effect on a column wit...
std::string label
The header caption.
Everything about a table beyond its columns and rows.
bool showHeader
Whether the header row is drawn.
Virtualization virtualize
The row count and margin above which a row's widget is realized only near the visible range.
Common common
Visibility, enablement, layout, drag-and-drop of the table.
SelectionMode selectionMode
How many rows the user can select.
std::function< void(std::vector< Key >)> onSelectionChange
Called with the keys the user selected.
Prop< std::vector< Key > > selection
The selected rows' keys.
std::function< void(Key)> onActivate
Called with a row's key when the user activates it.
What a table's row view builds for one row: its cells, one per column, and its tone.
std::optional< Prop< std::optional< Tone > > > tone
The row's tone, bound in the row's own scope; disengaged for none.
std::vector< Node > cells
The cells, one non-null node per column.
Keyed rows of cells under column headers. Each row's view is a Row whose children are the cells,...
std::shared_ptr< detail::ForEachModel const > rows
The rows, the key function and the row view, type-erased; null shows no rows.
SelectionMode selectionMode
How many rows the user can select; set once.
Common common
Visibility, enablement, layout, drag-and-drop.
bool showHeader
Whether the header row is drawn; set once. false suits several tables sharing one header,...
std::function< void(Key)> onActivate
Called with a row's key when the user activates it (Enter or a double click).
std::function< void(std::vector< Key >)> onSelectionChange
Called with the keys the user selected.
Virtualization virtualize
The row count and margin above which a row's widget is realized only near the visible range; set once...
std::vector< TableColumn > columns
The columns, in order; set once.
Prop< std::vector< Key > > selection
The selected rows' keys. A key with no row selects nothing until such a row appears.
Common common
Visibility, enablement, layout, drag-and-drop.
std::vector< Tab > tabs
The pages, in order; set once.
Prop< std::size_t > selected
The selected page's index; an index past the last page shows none.
std::function< void(std::size_t)> onSelect
Called with the index the user picked, and with the page still shown when a picked page fails to moun...
An editable text field. The backend never reports its own setText back through onChange.
Prop< std::string > unit
The unit the input shows beside its text, such as kg; empty shows none. Only a single-line or passwor...
int decimals
The fraction digits a number is entered with, for a backend or a kit to read; -1 when the input does ...
bool showLabel
Whether the input draws label as a visible caption itself; set once. A form leaves it false,...
FieldState field
Read-only, required, errors and stale.
std::string icon
The name of an icon in the theme's icon set, drawn at the field's leading edge; empty shows none....
std::function< void(std::string)> onSubmit
Called with the text when the user submits (Enter in single-line mode).
TextInputMode mode
Single-line, multiline or password; set once.
std::function< void(std::string)> onCommit
Called with the text when the user commits it: Enter in single-line mode, or focus leaving the field ...
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< std::string > placeholder
Shown while the field is empty.
std::function< void(std::string)> onChange
Called with the new text after every user edit.
Prop< std::string > value
The text the field shows.
Prop< std::string > label
The field's label: its visible caption while showLabel; a form's cell draws it otherwise,...
Common common
Visibility, enablement, layout, drag-and-drop.
Prop< TextRole > role
The style.
FieldState field
Read-only, required, errors and stale.
Prop< std::string > text
The text, UTF-8.
When a keyed row list realizes a widget only for the rows in or near the visible range,...
std::size_t overscan
How many rows beyond the visible range, on each side, keep a realized widget so a small scroll does n...
std::size_t threshold
Below this many rows, every row's widget is realized regardless of scroll position,...
Whether a type is a SlotBinding: false here, true for the specialisation below.
Tone
What a message or a mark conveys, mapped to the theme's colours.
@ Warn
Something to check.
@ Neutral
Nothing in particular.
Node actionBar(ActionBar spec)
An action bar node.
Node panel(Panel spec)
A titled frame, optionally collapsible.
Node collapsible(Collapsible spec)
A titled section the user opens and closes.
TextInputMode
How a TextInput edits.
@ SingleLine
One line; Enter submits.
@ Password
One line, masked.
Node keyValue(KeyValue spec)
Captions beside their values.
TextRole
How a Text is styled; each backend maps a role to its theme.
@ Heading
A section heading.
DateMode
What a DateTimeInput edits.
@ DateTime
A date and a time of day.
Node grid(Grid spec)
Cells in a fixed number of columns.
Node forEach(std::function< std::vector< RowT >()> rows, std::function< Key(RowT const &)> keyOf, std::function< Node(reactive::Signal< RowT > const &)> rowView, Axis axis=Axis::Vertical, int gap=0)
One widget per row of a keyed collection read through a binding (a Query's value() included).
Node slider(Slider spec)
An integer on a range.
Node badge(Badge spec)
A short label marking a state.
std::function< void()> Action
A widget event handler taking no arguments.
Node banner(Banner spec)
A message across the top of a region.
Node textInput(TextInput spec)
An editable text field.
Node column(Column spec)
Children stacked top to bottom.
Node dateTimeInput(DateTimeInput spec)
A date or date-and-time field.
Node custom(Custom spec)
A component loaded by name, mounted by Mounted as its fallback.
Node dropZone(DropZone spec)
A region that takes dropped files.
Node busy(Busy spec)
A progress indicator.
constexpr int kMaxSpacingStep
The largest spacing step: a gap or padding names a step from 0 (none) to this, which each backend map...
SelectionMode
How many rows of a Table the user can select.
@ None
Rows can be activated, not selected.
Node menu(Menu spec)
A list of commands.
Node switchOn(std::function< E()> selector, std::vector< std::pair< E, Node > > cases, Node fallback={})
A Switch over an enumeration: each enumerator becomes the int64 key of its case.
Node filePicker(FilePicker spec)
A file path field.
Node checkbox(Checkbox spec)
A labelled check box.
Node emptyState(EmptyState spec)
What a region shows when it has nothing to show.
Node spacer(Spacer spec={})
Empty space.
Side
The edge a Drawer slides in from, in reading direction.
@ End
The right edge in a left-to-right layout.
FilePickerMode
Whether a FilePicker chooses an existing file or a file to write.
Node switchOf(Switch spec)
Shows the case the selector picks. Spelled switchOf because switch is a keyword.
Node text(Text spec)
Static or bound text.
Node select(Select spec)
A choice of one option.
SelectStyle
How a Select presents its options.
@ Radio
Every option visible, one marked.
@ Dropdown
A closed field that opens a list.
Node splitter(Splitter spec)
Panes with handles the user drags.
constexpr int spacingStep(int value) noexcept
A gap or padding as the spacing step a backend receives.
Node progress(Progress spec)
A progress bar.
std::shared_ptr< NodeData const > Node
A view-tree node: immutable, shared data.
Node drawer(Drawer spec)
A panel that slides in from one edge.
Node row(Row spec)
Children laid out left to right.
std::variant< std::int64_t, std::string > Key
The identity of a Switch case, a Select option, a ForEach or Table row and a drag payload.
Node table(std::vector< TableColumn > columns, std::function< std::vector< RowT >()> rows, std::function< Key(RowT const &)> keyOf, std::function< std::vector< Node >(reactive::Signal< RowT > const &)> cells, TableOptions options={})
A table of keyed rows: one Row of cells per row, under the column headers.
Node steps(Steps spec)
The steps of a process.
Node tabs(Tabs spec)
A tab bar over pages.
Axis
The direction a stack arranges, or a scroll area scrolls, its content.
@ Horizontal
Left to right.
Node dialog(Dialog spec)
A modal overlay.
std::uint32_t SlotId
The stable identity of a slot: a bound property a renderer can refer to by number.
Node scroll(Scroll spec)
A scrollable viewport.
StepState
Where one step of a Steps indicator stands.
Node makeNode(Kind spec)
Wraps one node aggregate into a shared node.
Node button(Button spec)
A push button.
SlotBinding< std::decay_t< F > > slot(SlotId slotId, F &&read)
A slot with an id.