5#include <portals/detail/ui_value_text.hpp>
6#include <portals/ui_construction.hpp>
7#include <portals/ui_model.hpp>
25 if (
const auto *textError = std::get_if<TextError>(&
value.error())) {
26 failure = detail::textError(parent, *textError);
28 failure.resource = std::get<TextResourceError>(
value.error());
31 return std::expected<Node<T>,
ManagedError>(std::unexpected(failure));
34 if constexpr (std::same_as<T, Button>) {
35 return scene.emplace<T>(parent, std::move(*
value),
style, policy,
38 return scene.emplace<T>(parent, std::move(*
value),
style, policy);
53 return control<Label>(
text, style, policy);
63template <
class Control>
64Description<Control> valueTextControl(ValueText source, ControlStyle style = {},
67 detail::Access::cold<Control>([source = std::move(source), style, policy](
68 ManagedScene &scene, Node<Widget> parent,
69 detail::MountContext &context) -> std::expected<Node<Control>, ManagedError> {
72 return std::unexpected(detail::textError(parent, empty.error()));
76 if constexpr (std::same_as<Control, Button>) {
77 return scene.emplace<Control>(parent, std::move(*empty), style, policy,
80 return scene.emplace<Control>(parent, std::move(*empty), style, policy);
84 return std::unexpected(node.error());
87 detail::ModelAccess::keep(scene, *node, context);
89 auto bound = detail::ValueTextAccess::bind(scene, *node, source, context);
91 return bound ? node : std::unexpected(bound.error());
105template <
class Source>
106 requires std::same_as<Source, ValueText>
108 return detail::valueTextControl<Label>(std::move(source), style, policy);
114concept ValueCaption =
115 std::formattable<std::remove_cvref_t<T>,
char> || std::same_as<std::remove_cvref_t<T>, GraphemeText>;
117template <
class Projection,
class T>
118concept ValueCaptionProjection =
119 std::copy_constructible<std::decay_t<Projection>> && std::invocable<Projection &, const T &> &&
120 (!portals::detail::IS_UNSUPPORTED_DERIVED_EXPECTED<
121 std::remove_cvref_t<std::invoke_result_t<Projection &, const T &>>>) &&
122 ValueCaption<portals::detail::DerivedOutput<Projection, T>>;
124template <
class Control, std::equality_comparable T,
class Projection>
125Description<Control> valueControl(Model<T> source, Projection projection, ControlStyle style, SizePolicy policy) {
127 detail::Access::cold<Control>([source = std::move(source), projection = std::move(projection), style, policy](
128 ManagedScene &scene, Node<Widget> parent,
129 detail::MountContext &context) -> std::expected<Node<Control>, ManagedError> {
132 return std::unexpected(detail::textError(parent, empty.error()));
136 if constexpr (std::same_as<Control, Button>) {
137 return scene.emplace<Control>(parent, std::move(*empty), style, policy,
140 return scene.emplace<Control>(parent, std::move(*empty), style, policy);
144 return std::unexpected(node.error());
147 detail::ModelAccess::keep(scene, *node, context);
150 auto retained = std::make_shared<Projection>(std::move(projection));
151 if (owner.expired()) {
155 auto bound = detail::ValueModelAccess::bindCaption(scene, *node, source, retained, context);
157 return bound ? node : std::unexpected(bound.error());
173template <std::equality_comparable T>
174 requires std::copy_constructible<T> && detail::ValueCaption<T>
176 return detail::valueControl<Label>(std::move(source), std::identity{}, style, policy);
184template <std::equality_comparable T>
185 requires std::copy_constructible<T> && detail::ValueCaption<T>
187 return label(detail::ValueModelAccess::root(value), style, policy);
200template <std::equality_comparable T,
class Projection>
201 requires std::copy_constructible<T> && detail::ValueCaptionProjection<Projection, T>
204 return detail::valueControl<Label>(std::move(source), std::move(projection), style, policy);
214template <std::equality_comparable T,
class Member>
215 requires std::copy_constructible<T> && detail::ValueCaption<Member>
218 return label(detail::ValueModelAccess::root(field), detail::ValueModelAccess::member(field), style, policy);
226template <
class Source>
227 requires std::same_as<Source, ValueText>
229 return detail::valueTextControl<Button>(std::move(source), style, policy);
237template <std::equality_comparable T>
238 requires std::copy_constructible<T> && detail::ValueCaption<T>
240 return detail::valueControl<Button>(std::move(source), std::identity{}, style, policy);
248template <std::equality_comparable T>
249 requires std::copy_constructible<T> && detail::ValueCaption<T>
251 return button(detail::ValueModelAccess::root(value), style, policy);
259template <std::equality_comparable T,
class Projection>
260 requires std::copy_constructible<T> && detail::ValueCaptionProjection<Projection, T>
263 return detail::valueControl<Button>(std::move(source), std::move(projection), style, policy);
271template <std::equality_comparable T,
class Member>
272 requires std::copy_constructible<T> && detail::ValueCaption<Member>
275 return button(detail::ValueModelAccess::root(field), detail::ValueModelAccess::member(field), style, policy);
289Description<T> textControl(TextValue text, ControlStyle style, SizePolicy policy, TextResolver resolver,
291 auto arguments = ControlSettings{.text = std::move(text)};
292 auto description = Access::cold<T>(
293 [style, policy, chrome, resolver = std::move(resolver)](
294 ManagedScene &scene, Node<Widget> parent,
MountContext &context) -> std::expected<Node<T>, ManagedError> {
295 const auto &caption = *context.controlSettings->text;
296 auto value = resolver ? caption.resolve(scene.widthPolicy(), resolver) : caption.resolve(scene.widthPolicy());
299 if (
const auto *failure = std::get_if<TextError>(&value.error())) {
300 return std::unexpected(textError(parent, *failure));
305 failure.resource = std::get<TextResourceError>(value.error());
307 return std::unexpected(failure);
310 if constexpr (std::same_as<T, Button>) {
311 return scene.emplace<T>(parent, std::move(*value), style, policy,
312 context.controlSettings->chrome.value_or(chrome));
314 return scene.emplace<T>(parent, std::move(*value), style, policy);
318 std::move(arguments));
326 auto description = Access::cold<T>(
331 return std::unexpected(admitted.error());
333 auto graph = std::make_shared<Access::ColdGraph>();
334 graph->scene = &scene;
335 context.rollback.push_back([graph] {
338 graph->pending =
true;
339 Access::beginCold(scene);
342 return std::unexpected(textError(parent, empty.error()));
345 if constexpr (std::same_as<T, Button>) {
346 return scene.emplace<T>(parent, std::move(*empty), style, policy,
349 return scene.emplace<T>(parent, std::move(*empty), style, policy);
356 context.root = *node;
358 context.captions.push_back(
359 {*node, Access::captionIdentity(source),
false, [&scene, &context, node = *node, source, graph] {
360 return Access::completeCaption(scene, node, source, context, graph);
362 context.finalize.push_back([&context] {
363 return Access::finishCaptions(context);
370template <CaptionSource Source>
TextSource captionSource(Source &&source) {
371 if constexpr (std::same_as<std::remove_cvref_t<Source>,
TextProperty>) {
372 return source.source();
374 return std::forward<Source>(source);
385template <detail::CaptionSource Source>
387 return detail::liveCaption<Label>(detail::captionSource(std::forward<Source>(source)), style, policy);
396template <detail::CaptionSource Source>
398 return detail::liveCaption<Button>(detail::captionSource(std::forward<Source>(source)), style, policy);
408 TextResolver resolver = {}) {
409 return detail::textControl<Label>(std::move(text), style, policy, std::move(resolver));
418template <
class State>
419 requires(std::same_as<std::remove_cvref_t<State>, ManagedState<std::string>> ||
420 std::same_as<std::remove_cvref_t<State>, ManagedSource<std::string>>)
422 return control<Label>(
"", style, policy).setup([model](ManagedScene &scene, Node<Label> node) {
423 return scene.bindText(node, model);
434 TextResolver resolver = {}) {
435 return detail::textControl<Button>(std::move(text), style, policy, std::move(resolver));
444template <
class State>
445 requires(std::same_as<std::remove_cvref_t<State>, ManagedState<std::string>> ||
446 std::same_as<std::remove_cvref_t<State>, ManagedSource<std::string>>)
448 return control<Button>(
"", style, policy).setup([model](ManagedScene &scene, Node<Button> node) {
449 return scene.bindText(node, model);
461template <
class Caption,
class Callback>
462 requires((std::same_as<std::remove_cvref_t<Caption>, TextValue> ||
463 std::same_as<std::remove_cvref_t<Caption>, ManagedState<std::string>> ||
464 std::same_as<std::remove_cvref_t<Caption>, ManagedSource<std::string>> ||
465 portals::detail::IS_LIVE_TEXT_SOURCE<std::remove_cvref_t<Caption>> ||
467 portals::detail::ManagedAction<Callback, ClickEvent>)
470 return button(std::forward<Caption>(text), style, policy).onClick(std::move(action));
479inline Description<Button> button(std::string_view text, std::function<std::expected<void, TreeError>()> action,
481 return control<Button>(text, style, policy)
482 .setup([action = std::move(action)](ManagedScene &scene, Node<Button> node)
mutable {
483 return scene.onClick(node, std::move(action));
494template <
class Callback>
495 requires portals::detail::ManagedAction<Callback, ClickEvent>
496inline Description<Button> button(std::string_view text, Callback action, ControlStyle style = {},
498 return control<Button>(text, style, policy)
499 .setup([action = std::move(action)](ManagedScene &scene, Node<Button> node)
mutable {
500 return scene.onClick(node, std::move(action));
509template <
class Action>
510 requires std::same_as<Action, ActionRef>
512 return button(
TextValue(
""), style, policy).onClick(std::move(action));
520template <
class Action>
521 requires std::same_as<Action, ActionRef>
524 return button(std::move(action), style, policy).reference(std::move(reference));
535 std::function<std::expected<void, TreeError>(
CheckBoxResult)> changed = {},
541 changed = std::move(changed)](ManagedScene &scene, Node<CheckBox> node,
542 const ControlSettings &settings)
mutable -> std::expected<void, ManagedError> {
547 return scene.bind(node, model, std::move(changed));
559 std::function<std::expected<void, TreeError>(
CheckBoxResult)> changed = {},
566 [initial, changed = std::move(changed)](ManagedScene &scene, Node<CheckBox> node,
573 .and_then([&scene, node, &changed](ManagedState<bool> model) {
574 return scene.bind(node, model, std::move(changed));
588 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
590 CheckBoxOptions options = {}) {
592 control<CheckBox>(text, style, policy),
593 [model, changed = std::move(changed), options](ManagedScene &scene, Node<CheckBox> node,
595 options.cycle = settings.cycle.value_or(options.cycle);
596 return scene.bind(node, model, std::move(changed), options);
609 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
611 CheckBoxOptions options = {}) {
614 {.text =
TextValue(text), .state = initial}),
615 [initial, changed = std::move(changed), options](ManagedScene &scene, Node<CheckBox> node,
617 options.cycle = settings.cycle.value_or(options.cycle);
618 return scene.state(settings.state.value_or(initial))
619 .and_then([&scene, node, &changed, options](ManagedState<CheckState> model) {
620 return scene.bind(node, model, std::move(changed), options);
634 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
637 StyleTarget{.type =
"ThreeState", .control =
true, .baseTypes = {
"CheckBox"}})
638 .setup([model, changed = std::move(changed)](ManagedScene &scene, Node<ThreeState> node)
mutable {
639 return scene.bind(Node<CheckBox>{node}, model, std::move(changed),
653 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
658 StyleTarget{.type =
"ThreeState", .control =
true, .baseTypes = {
"CheckBox"}}),
659 {.text =
TextValue(text), .state = initial}),
660 [initial, changed = std::move(changed)](ManagedScene &scene, Node<ThreeState> node,
662 return scene.state(settings.state.value_or(initial))
663 .and_then([&scene, node, &changed](ManagedState<CheckState> model) {
664 return scene.bind(Node<CheckBox>{node}, model, std::move(changed),
690template <
class Options>
691 requires std::same_as<std::remove_cvref_t<Options>, CheckBoxOptions>
693 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
696 checkbox(text, initial, std::move(changed), style, policy, std::forward<Options>(options)),
697 {.text =
TextValue(text), .state = initial, .cycle = options.cycle});
710template <
class Options>
711 requires std::same_as<std::remove_cvref_t<Options>, CheckBoxOptions>
712inline Description<CheckBox> checkbox(std::string_view text, ManagedState<CheckState> model, Options &&options,
713 std::function<std::expected<void, TreeError>(
CheckStateResult)> changed = {},
716 checkbox(text, model, std::move(changed), style, policy, std::forward<Options>(options)),
717 {.text =
TextValue(text), .cycle = options.cycle});
729inline Description<LineEdit> lineEditRecipe(std::optional<ManagedState<std::string>> external, TextValue initial,
730 LineEditConfig config,
bool inherit, TextResolver resolver = {}) {
731 auto model = std::make_shared<ManagedState<std::string>>(external.value_or(ManagedState<std::string>{}));
733 Access::cold<LineEdit>([initial = std::move(initial), options = config.options, policy = config.policy,
734 resolver = std::move(resolver), model, external = external.has_value()](
735 ManagedScene &scene, Node<Widget> parent,
736 MountContext &context) mutable -> std::expected<Node<LineEdit>, ManagedError> {
737 const ControlSettings empty;
738 const auto &settings = context.controlSettings ? *context.controlSettings : empty;
739 auto effective = controlLineEditOptions(settings, options, scene.widthPolicy(), resolver, parent);
741 return std::unexpected(effective.error());
743 auto placeholder = lineEditPlaceholder(*effective, parent);
745 return std::unexpected(placeholder.error());
748 const auto &
text = settings.text ? *settings.text : initial;
749 auto resolved = resolver ?
text.resolve(scene.widthPolicy(), resolver, effective->limits)
750 :
text.resolve(scene.widthPolicy(), effective->limits);
753 if (
const auto *textError = std::get_if<TextError>(&resolved.error())) {
754 failure.text = *textError;
757 switch (textError->kind) {
768 failure.resource = std::get<TextResourceError>(resolved.error());
770 return std::unexpected(failure);
772 auto state = scene.state(std::string(resolved->bytes()));
774 return std::unexpected(state.error());
778 return scene.emplace<LineEdit>(parent, *effective, policy, std::move(*placeholder));
782 [model, result = std::move(config.result), clipboard = std::move(config.clipboard),
783 validate = std::move(config.validate)](ManagedScene &scene, Node<LineEdit> node,
const ControlSettings &)
mutable {
784 return scene.bind(node, *model, std::move(result), std::move(clipboard), std::move(validate));
793 return detail::lineEditRecipe(model,
TextValue(
""), std::move(config),
false);
798 return detail::lineEditRecipe(model,
TextValue(
""), {},
true);
804inline Description<LineEdit> lineEdit(TextValue initial, LineEditConfig config, TextResolver resolver = {}) {
805 return detail::lineEditRecipe(std::nullopt, std::move(initial), std::move(config),
false, std::move(resolver));
809inline Description<LineEdit> lineEdit(TextValue initial) {
810 auto arguments = ControlSettings{.text = initial};
811 return detail::Access::controlArguments(detail::lineEditRecipe(std::nullopt, std::move(initial), {},
true),
812 std::move(arguments));
818inline Description<LineEdit> lineEdit(std::string_view initial, LineEditConfig config) {
819 return lineEdit(TextValue(initial), std::move(config));
823inline Description<LineEdit> lineEdit(std::string_view initial) {
824 return lineEdit(TextValue(initial));
828inline Description<LineEdit> lineEdit() {
829 return detail::lineEditRecipe(std::nullopt, TextValue(
""), {},
true);
837template <
class Initial,
class Settings>
838 requires std::same_as<std::remove_cvref_t<Settings>, ControlSettings> &&
839 requires(Initial &&initial) { lineEdit(std::forward<Initial>(initial)); }
840inline Description<LineEdit> lineEdit(Initial &&initial, Settings &&patch) {
841 return lineEdit(std::forward<Initial>(initial)).settings(std::forward<Settings>(patch));
848template <
class Settings>
849 requires std::same_as<std::remove_cvref_t<Settings>, ControlSettings>
850inline Description<LineEdit> lineEdit(TextValue initial, Settings &&patch, TextResolver resolver) {
851 auto arguments = ControlSettings{.text = initial};
852 return detail::Access::controlArguments(
853 detail::lineEditRecipe(std::nullopt, std::move(initial), {},
true, std::move(resolver)),
854 std::move(arguments))
855 .settings(std::forward<Settings>(patch));
862inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, TextValue initial, LineEditConfig config,
863 TextResolver resolver = {}) {
864 return lineEdit(std::move(initial), std::move(config), std::move(resolver)).reference(std::move(reference));
870inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, TextValue initial) {
871 return lineEdit(std::move(initial)).reference(std::move(reference));
877inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, std::string_view initial, LineEditConfig config) {
878 return lineEdit(initial, std::move(config)).reference(std::move(reference));
884inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, std::string_view initial) {
885 return lineEdit(initial).reference(std::move(reference));
889inline Description<LineEdit> lineEdit(Ref<LineEdit> reference) {
890 return lineEdit().reference(std::move(reference));
897template <
class Initial,
class Settings>
898 requires std::same_as<std::remove_cvref_t<Settings>, ControlSettings> &&
899 requires(Initial &&initial) { lineEdit(std::forward<Initial>(initial)); }
900inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, Initial &&initial, Settings &&patch) {
901 return lineEdit(std::forward<Initial>(initial), std::forward<Settings>(patch)).reference(std::move(reference));
907inline Description<Button> button(std::string_view text) {
917inline Description<Label> label(Ref<Label> reference, std::string_view text, ControlStyle style = {},
919 return label(text, style, policy).reference(std::move(reference));
929template <std::equality_comparable T>
930 requires std::copy_constructible<T> && detail::ValueCaption<T>
931Description<Label> label(Ref<Label> reference, Model<T> source, ControlStyle style = {},
933 return label(std::move(source), style, policy).reference(std::move(reference));
941template <std::equality_comparable T>
942 requires std::copy_constructible<T> && detail::ValueCaption<T>
943Description<Label> label(Ref<Label> reference, ModelValue<T> value, ControlStyle style = {},
945 return label(std::move(value), style, policy).reference(std::move(reference));
957template <std::equality_comparable T,
class Projection>
958 requires std::copy_constructible<T> && detail::ValueCaptionProjection<Projection, T>
959Description<Label> label(Ref<Label> reference, Model<T> source, Projection projection, ControlStyle style = {},
961 return label(std::move(source), std::move(projection), style, policy).reference(std::move(reference));
970template <std::equality_comparable T,
class Projection>
971 requires std::copy_constructible<T> && detail::ValueCaptionProjection<Projection, T>
972Description<Button> button(Ref<Button> reference, Model<T> source, Projection projection, ControlStyle style = {},
974 return button(std::move(source), std::move(projection), style, policy).reference(std::move(reference));
985template <std::equality_comparable T,
class Member>
986 requires std::copy_constructible<T> && detail::ValueCaption<Member>
987Description<Label> label(Ref<Label> reference, ModelField<T, Member> field, ControlStyle style = {},
989 return label(std::move(field), style, policy).reference(std::move(reference));
998inline Description<Button> button(Ref<Button> reference, std::string_view text, ControlStyle style = {},
1000 return control<Button>(text, style, policy).reference(std::move(reference));
1010template <
class Caption>
1011 requires(std::same_as<std::remove_cvref_t<Caption>, TextValue> ||
1012 std::same_as<std::remove_cvref_t<Caption>, ManagedState<std::string>> ||
1013 std::same_as<std::remove_cvref_t<Caption>, ManagedSource<std::string>> ||
1014 portals::detail::IS_LIVE_TEXT_SOURCE<std::remove_cvref_t<Caption>> ||
1015 std::same_as<std::remove_cvref_t<Caption>, ValueText> || detail::CaptionSource<Caption>)
1016inline Description<Label> label(Ref<Label> reference, Caption &&text, ControlStyle style = {},
1018 return label(std::forward<Caption>(text), style, policy).reference(std::move(reference));
1028template <
class Caption>
1029 requires(std::same_as<std::remove_cvref_t<Caption>, TextValue> ||
1030 std::same_as<std::remove_cvref_t<Caption>, ManagedState<std::string>> ||
1031 std::same_as<std::remove_cvref_t<Caption>, ManagedSource<std::string>> ||
1032 portals::detail::IS_LIVE_TEXT_SOURCE<std::remove_cvref_t<Caption>> ||
1033 std::same_as<std::remove_cvref_t<Caption>, ValueText> || detail::CaptionSource<Caption>)
1034inline Description<Button> button(Ref<Button> reference, Caption &&text, ControlStyle style = {},
1036 return button(std::forward<Caption>(text), style, policy).reference(std::move(reference));
1048template <
class Caption,
class Callback>
1049 requires((std::same_as<std::remove_cvref_t<Caption>, TextValue> ||
1050 std::same_as<std::remove_cvref_t<Caption>, ManagedState<std::string>> ||
1051 std::same_as<std::remove_cvref_t<Caption>, ManagedSource<std::string>> ||
1052 portals::detail::IS_LIVE_TEXT_SOURCE<std::remove_cvref_t<Caption>> ||
1053 std::same_as<std::remove_cvref_t<Caption>, ValueText> || detail::CaptionSource<Caption>) &&
1055inline Description<Button> button(Ref<Button> reference, Caption &&text, Callback action, ControlStyle style = {},
1057 return button(std::forward<Caption>(text), std::move(action), style, policy).reference(std::move(reference));
1068template <
class Callback>
1070Description<Button> button(Ref<Button> reference, std::string_view text, Callback action, ControlStyle style = {},
1072 return button(text, std::move(action), style, policy).reference(std::move(reference));
1083inline Description<CheckBox> checkbox(Ref<CheckBox> reference, std::string_view text, ManagedState<bool> model,
1084 std::function<std::expected<void, TreeError>(CheckBoxResult)> changed = {},
1086 return checkbox(text, model, std::move(changed), style, policy).reference(std::move(reference));
1098inline Description<CheckBox> checkbox(Ref<CheckBox> reference, std::string_view text, ManagedState<CheckState> model,
1099 std::function<std::expected<void, TreeError>(CheckStateResult)> changed = {},
1101 CheckBoxOptions options = {}) {
1102 return checkbox(text, model, std::move(changed), style, policy, options).reference(std::move(reference));
1113inline Description<ThreeState> threeState(Ref<ThreeState> reference, std::string_view text, CheckState initial,
1114 std::function<std::expected<void, TreeError>(CheckStateResult)> changed = {},
1116 return threeState(text, initial, std::move(changed), style, policy).reference(std::move(reference));
1122inline Description<ThreeState> threeState(Ref<ThreeState> reference, std::string_view text) {
1123 return threeState(text).reference(std::move(reference));
1129inline Description<CheckBox> checkbox(Ref<CheckBox> reference, std::string_view text) {
1130 return checkbox(text).reference(std::move(reference));
1141inline Description<ThreeState> threeState(Ref<ThreeState> reference, std::string_view text,
1142 ManagedState<CheckState> model,
1143 std::function<std::expected<void, TreeError>(CheckStateResult)> changed = {},
1145 return threeState(text, model, std::move(changed), style, policy).reference(std::move(reference));
1153inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, ManagedState<std::string> model, LineEditConfig config) {
1154 return lineEdit(model, std::move(config)).reference(std::move(reference));
1160inline Description<LineEdit> lineEdit(Ref<LineEdit> reference, ManagedState<std::string> model) {
1161 return lineEdit(model).reference(std::move(reference));
1172Description<T> control(Ref<T> reference, std::string_view text, ControlStyle style = {},
1174 return control<T>(text, style, policy).reference(std::move(reference));
1187 requires(std::same_as<T, LineEdit> || std::same_as<T, Password> || std::same_as<T, ScrollArea> ||
1188 std::same_as<T, ScrollBar>)
1190 return std::move(description).readOnly(modifier.
enabled);
1197inline ReadOnlyModifier readOnly(
bool enabled =
true) {
1206inline Description<Button> plainButton(std::string_view text, ControlStyle style = {},
1208 return detail::textControl<Button>(TextValue(text), style, policy, {}, ButtonChrome::NONE);
1218template <
class Callback>
1220Description<Button> plainButton(std::string_view text, Callback action, ControlStyle style = {},
1222 return plainButton(text, style, policy).onClick(std::move(action));
1231inline Description<Button> plainButton(Ref<Button> reference, std::string_view text, ControlStyle style = {},
1233 return plainButton(text, style, policy).reference(std::move(reference));
1240 return std::move(description).threeState();
1245inline ThreeStateModifier threeState() {
static std::expected< GraphemeText, TextError > from(std::string_view bytes, WidthPolicy policy={}, TextLimits limits={})
Validate, segment and measure a single logical UTF-8 buffer.
Additive lifecycle owner over one existing Application subtree. UI affine and nonmovable....
Definition managed.hpp:530
Weak UI handle to a scene-owned Property, never an owning alias. Copies and destruction of the handle...
Definition managed.hpp:367
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Owning literal bytes or a resource key, measured only at resolution.
Definition text_value.hpp:42
constexpr TextValue(const TextValue &other)=default
Copy expression bytes and kind into independent storage.
One owning callback and its metadata; construct before checked set admission. Captures and metadata c...
Definition ui_action.hpp:75
Single-use owning construction recipe; no mounted widget ownership.
Definition ui_description.hpp:48
Description && style(StyleTarget target) &&
Definition ui_description.hpp:1288
Description()=default
Construct an empty recipe; mounting it returns INVALID_ARGUMENT.
friend Description< LineEdit > lineEdit(ManagedState< std::string >, LineEditConfig)
Definition ui_controls.hpp:792
friend Description< U > control(std::string_view, ControlStyle, SizePolicy)
Construct a standard text-control recipe with the scene's width policy.
Definition ui_controls.hpp:18
Description && value(double value) &&
Definition ui_description.hpp:290
Owning field descriptor over one scalar root; snapshots never retain a borrowed member reference.
Definition ui_value_model.hpp:520
Weak scalar property observation; assignment publishes a value without rebinding the descriptor.
Definition ui_value_model.hpp:412
Owning cold model declaration; copies share one single-scene registration. Construction does not read...
Definition ui_model.hpp:129
Typed Widget observation; explicit composite specializations reuse their existing weak facades.
Definition ui_ref.hpp:761
Copyable observing text property; copies own their resolver and last-operation result....
Definition ui_ref.hpp:585
Copyable read-only source observing one caption, visible draft or accepted editor model....
Definition ui_ref.hpp:302
Owning cold formatted text with explicit scalar dependencies, separate from its input roots....
Definition ui_value_text.hpp:37
A compact action optionally receives owning event parameters.
Definition managed.hpp:239
Exact deferred caption inputs; literals and bare braces keep their existing overloads.
Definition ui_controls.hpp:322
ui::ValueText text(std::format_string< const ui::detail::TextArgumentValue< Args > &... > pattern, Args &&...args)
Declare live formatted text over explicit scalar roots, fields or value properties.
Definition ui_value_text.hpp:567
std::expected< PropertyUpdate< CheckState >, TreeError > CheckStateResult
Exact typed Property set receipt; successful commits can reject notifications.
Definition controls.hpp:477
CheckState
Explicit checkbox value; MIXED describes an aggregate or an opt-in user choice.
Definition controls.hpp:266
@ MIXED
Partial selection, displayed independently of color.
Definition controls.hpp:269
@ CHECKED
Complete selection.
Definition controls.hpp:268
@ UNCHECKED
No selection.
Definition controls.hpp:267
constexpr SizePolicy DEFAULT_CONTENT_POLICY
Intrinsic content on both axes; explicit policies remain authoritative.
Definition layout.hpp:44
@ BIND
Register a managed callback, binding or presentation adapter.
Definition managed_diagnostics.hpp:51
@ TWO_STATE
Unchecked/checked toggle; mixed activates to checked.
Definition controls.hpp:274
@ THREE_STATE
Unchecked, checked, mixed, then unchecked.
Definition controls.hpp:275
ButtonChrome
Button caption decoration; action routing and identity remain unchanged.
Definition controls.hpp:155
@ BRACKETS
ASCII bracket contour spanning the allocated button width.
Definition controls.hpp:156
@ INPUT_LIMIT
Input length exceeds its configured/representation limit.
Definition text.hpp:73
@ CLUSTER_LIMIT
One whole cluster exceeds its byte limit.
Definition text.hpp:75
@ GRAPHEME_LIMIT
The number of clusters exceeds its limit.
Definition text.hpp:77
@ CELL_LIMIT
Cell accumulation exceeds its configured/int32_t limit.
Definition text.hpp:79
std::expected< PropertyUpdate< bool >, TreeError > CheckBoxResult
Exact Property set outcome; errors mean no commit, successful receipts can reject notifications.
Definition controls.hpp:474
@ CLOSED
The owning tree or source is closed.
Definition widget_types.hpp:31
@ INVALID_ARGUMENT
An option, enum value or operation argument is invalid.
Definition widget_types.hpp:27
Owning paint values; no theme engine or behavior is encoded here.
Definition controls.hpp:24
Original error plus independent runner/restoration and cleanup failures.
Definition managed_diagnostics.hpp:62
Owning independent policies for width and height.
Definition layout.hpp:35
Owning sparse literals only; never contains IDs, models, handlers or live history.
Definition ui_control_context.hpp:391
std::optional< TextValue > text
Caption/value expression, resolved by receiving scene.
Definition ui_control_context.hpp:394
std::optional< ButtonChrome > chrome
Button decoration; absence preserves the receiving factory's chrome.
Definition ui_control_context.hpp:412
Owning optional editor customization and confirmation policy.
Definition ui_description.hpp:34
Owning existing LineEdit/scroll read-only policy stage.
Definition ui_controls.hpp:1178
bool enabled
User-mutation policy; programmatic commands retain their existing behavior.
Definition ui_controls.hpp:1179
Sparse checkbox cycle stage preserving the factory's backing model.
Definition ui_controls.hpp:1237
friend Description< CheckBox > operator|(Description< CheckBox > &&description, ThreeStateModifier)
Definition ui_controls.hpp:1239
static Description< T > controlSetup(Description< T > description, Callback callback)
Attach binding setup after node creation within the mount transaction.
Definition ui_description.hpp:3460
static Description< T > controlArguments(Description< T > description, ControlSettings arguments)
Retain explicit constructor properties above inherited defaults.
Definition ui_description.hpp:3417
static Description< T > intrinsicStyle(Description< T > description, StyleTarget identity)
Definition ui_description.hpp:3471
static std::weak_ptr< const void > lifetime(ManagedScene &scene)
Definition ui_recipe_access.hpp:539
static Description< T > configuredControl(Description< T > description, std::string_view type, bool inherit=true)
Attach a builtin configuration identity to an owning recipe.
Definition ui_description.hpp:3409
static std::expected< void, ManagedError > check(ManagedScene &scene, Node< Widget > node)
Verify a created node remains accessible before publishing references.
Definition ui_recipe_access.hpp:1394
static constexpr std::string_view controlType()
Identify builtin recipe types without allocating runtime metadata.
Definition ui_recipe_access.hpp:808
Stack-owned transaction bookkeeping, discarded after one description mount.
Definition ui_recipe_context.hpp:554
const ControlSettings * controlSettings
Constructor-only borrowed settings; restored before setup/children.
Definition ui_recipe_context.hpp:562