Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
ui_ref.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/combo_box.hpp>
6#include <portals/detail/dialog_command_result.hpp>
7#include <portals/detail/quit_command.hpp>
8#include <portals/document_view.hpp>
9#include <portals/find_bar.hpp>
10#include <portals/form_field.hpp>
11#include <portals/help_view.hpp>
12#include <portals/managed.hpp>
13#include <portals/text_value.hpp>
14#include <portals/ui_delivery.hpp>
15
16#include <typeinfo>
17
18namespace portals {
19class PopupMenu;
20template <class> class VirtualRows;
22} // namespace portals
23
24namespace portals::ui {
25class LogSource;
26class DocumentSource;
27class ValueText;
28template <class T> class Description;
29template <class T> class Ref;
30template <class T> class Model;
31template <class T> struct WindowRowsModel;
32class DynamicRef;
33class StyleStage;
35
36namespace detail {
37struct SceneAnchor;
38struct RefTarget;
39
41void reportCaptionModelError(const std::shared_ptr<RefTarget> &target, ManagedError &failure,
42 std::source_location origin, const char *control) noexcept;
44
48 ~LookupSource() = default;
49
50 std::weak_ptr<SceneAnchor> anchor;
51 std::thread::id owner;
52 std::string name = std::string(0, '\0');
53 std::source_location origin;
54 const char *expectedType{"Widget"};
55 std::shared_ptr<RefTarget> observation{};
56};
57
59using LookupPublisher =
60 std::function<std::expected<void, ManagedError>(ManagedScene &, std::expected<Node<Widget>, ManagedError>)>;
61
66std::expected<void, ManagedError> requestLookup(const LookupSource &source, LookupPublisher publish);
67
68struct NamedAccess;
69
71struct RefTarget {
72 const std::thread::id owner = std::this_thread::get_id();
74 std::weak_ptr<const void> lifetime;
77 std::shared_ptr<const ManagedError> failure;
80};
81
82std::expected<void, ManagedError> setLogModel(const std::shared_ptr<RefTarget> &target, Node<LogView> node,
83 const LogSource &source, std::source_location origin);
84
85std::expected<void, ManagedError> setDocumentModel(const std::shared_ptr<RefTarget> &, Node<DocumentView>,
86 const DocumentSource &, std::source_location);
87std::expected<void, ManagedError> seekDocument(const std::shared_ptr<RefTarget> &, Node<DocumentView>, std::uint64_t,
88 bool, std::source_location);
89std::expected<void, ManagedError> navigateDocument(const std::shared_ptr<RefTarget> &,
90 std::shared_ptr<const Node<DocumentView>>,
91 portals::detail::DocumentNavigation, std::int64_t,
92 std::source_location);
93std::expected<void, ManagedError> documentSyntax(const std::shared_ptr<RefTarget> &, Node<DocumentView>,
94 DocumentSyntaxPolicy, std::source_location);
95std::expected<DocumentViewStatus, ManagedError> documentStatus(const std::shared_ptr<RefTarget> &, Node<DocumentView>);
96std::expected<void, ManagedError> documentMode(const std::shared_ptr<RefTarget> &, Node<DocumentView>, DocumentViewMode,
97 std::source_location);
98std::expected<void, ManagedError> documentLanguage(const std::shared_ptr<RefTarget> &, Node<DocumentView>,
99 DocumentLanguage, std::source_location);
100std::expected<void, ManagedError> documentHexOptions(const std::shared_ptr<RefTarget> &, Node<DocumentView>,
101 DocumentHexOptions, std::source_location);
102std::expected<void, ManagedError> documentLineNumbers(const std::shared_ptr<RefTarget> &,
103 std::shared_ptr<const Node<DocumentView>>, std::optional<bool>,
104 std::source_location);
105struct RefAccess;
106std::expected<bool, ManagedError> checkedValue(std::shared_ptr<RefTarget> target,
107 std::shared_ptr<const Node<Switch>> node);
108std::expected<PropertyUpdate<bool>, ManagedError> setChecked(std::shared_ptr<RefTarget> target,
109 std::shared_ptr<const Node<Switch>> node, bool value,
110 std::source_location origin);
111std::expected<PropertyUpdate<bool>, ManagedError> failedChecked(std::shared_ptr<RefTarget> target, ManagedError failure,
112 std::source_location origin);
113using DeliveryCallback = std::function<std::expected<void, TreeError>(std::shared_ptr<const void>)>;
114std::expected<Publisher<portals::detail::UiDeliveryEnvelope>, ManagedError>
115connectDelivery(const std::shared_ptr<RefTarget> &target, DeliveryCallback callback, std::source_location origin);
116EditorCommandResult activateButton(const std::shared_ptr<RefTarget> &target, std::source_location origin);
122std::expected<void, ManagedError> gaugeValue(std::shared_ptr<RefTarget> target, std::shared_ptr<const Node<Gauge>> node,
123 double value, bool relative, std::source_location origin);
124std::expected<double, ManagedError> numericValue(const std::shared_ptr<RefTarget> &,
125 const std::shared_ptr<const Node<Slider>> &);
126std::expected<PropertyUpdate<NumericValue>, ManagedError> numericValue(const std::shared_ptr<RefTarget> &,
127 const std::shared_ptr<const Node<Slider>> &,
128 double, std::source_location);
129std::expected<double, ManagedError> spinBoxValue(const std::shared_ptr<RefTarget> &,
130 const std::shared_ptr<const Node<SpinBox>> &);
131std::expected<SpinBoxResult, ManagedError> spinBoxValue(const std::shared_ptr<RefTarget> &,
132 const std::shared_ptr<const Node<SpinBox>> &, double,
133 std::source_location);
134Ref<LineEdit> spinBoxEditor(const std::shared_ptr<RefTarget> &, const std::shared_ptr<const Node<SpinBox>> &);
135std::expected<FieldValidation, ManagedError> fieldValidation(const std::shared_ptr<RefTarget> &target);
139std::expected<RadioGroupValue, ManagedError> radioValue(const std::shared_ptr<RefTarget> &target,
140 std::shared_ptr<const Node<RadioGroup>> node);
145std::expected<PropertyUpdate<RadioGroupValue>, ManagedError> radioSelect(const std::shared_ptr<RefTarget> &target,
146 std::shared_ptr<const Node<RadioGroup>> node,
147 std::optional<RowId> id,
148 std::source_location origin);
149Ref<LineEdit> fieldEditor(const std::shared_ptr<RefTarget> &target);
150std::expected<bool, ManagedError> validateField(const std::shared_ptr<RefTarget> &target);
151std::expected<void, ManagedError> displayField(const std::shared_ptr<RefTarget> &target, FieldValidation value);
152Ref<LineEdit> findEditor(const std::shared_ptr<RefTarget> &target);
153Ref<LineEdit> choiceEditor(const std::shared_ptr<RefTarget> &target);
154std::expected<ChoiceSelection, ManagedError> choiceSelection(const std::shared_ptr<RefTarget> &target);
155std::expected<bool, ManagedError> choiceOpened(const std::shared_ptr<RefTarget> &target);
156std::expected<void, ManagedError> choiceOpen(const std::shared_ptr<RefTarget> &, bool, std::source_location);
157std::expected<void, ManagedError> choiceSelect(const std::shared_ptr<RefTarget> &, std::uint64_t, std::source_location);
158std::expected<void, ManagedError> choiceSelect(const std::shared_ptr<RefTarget> &, ChoiceSelection,
159 std::source_location);
160std::expected<void, ManagedError> choiceClear(const std::shared_ptr<RefTarget> &, std::source_location);
161std::expected<FindMatch, ManagedError> findNavigate(const std::shared_ptr<RefTarget> &target, FindDirection direction);
162std::expected<FindMatch, ManagedError> findMatch(const std::shared_ptr<RefTarget> &target);
163std::expected<bool, ManagedError> findCurrent(const std::shared_ptr<RefTarget> &target, const FindMatch &match);
164std::expected<void, ManagedError> findDocument(const std::shared_ptr<RefTarget> &target, std::string_view document);
165EditorCommandResult findClear(const std::shared_ptr<RefTarget> &target, std::source_location origin);
166std::pair<std::expected<void, TreeError>, bool> clearFindEditor(ManagedScene &scene, Node<Widget> node,
167 std::source_location origin);
168struct MessageAccess;
169template <class> struct TableRowType;
170
172template <class T> struct TableRowType<VirtualTable<T>> {
173 using Type = T;
174};
175
179std::expected<void, TreeError> displayDataState(std::shared_ptr<RefTarget> target, DataPresentation value,
180 std::source_location origin);
181
190EditorCommandResult editorCommand(std::shared_ptr<RefTarget> target, bool redo, bool stop, std::source_location origin,
191 bool clear = false);
195
196std::expected<HistoryAvailability, TreeError> editorAvailability(std::shared_ptr<RefTarget> target);
197
201std::expected<ManagedScene *, ManagedError> eventScene(const std::shared_ptr<RefTarget> &target);
202
206std::expected<PasswordValue, ManagedError> passwordValue(std::shared_ptr<RefTarget> target,
207 std::source_location origin);
211std::expected<void, ManagedError> setPasswordValue(std::shared_ptr<RefTarget> target, PasswordValue value,
212 std::source_location origin);
216void reportPasswordError(const std::shared_ptr<RefTarget> &target, ManagedError &failure, std::source_location origin);
217
221std::expected<NodeGeometry, ManagedError> geometry(const std::shared_ptr<RefTarget> &target);
222
229std::expected<void, ManagedError> scrollOffset(const std::shared_ptr<RefTarget> &target, ScrollAxis axis,
230 ScrollOffset offset, std::source_location origin);
235std::expected<void, ManagedError> ensureVisible(const std::shared_ptr<RefTarget> &target, std::source_location origin);
236
241void reportEventError(const std::shared_ptr<RefTarget> &target, const ManagedError &error, std::source_location origin);
242
248void reportFocusError(const std::shared_ptr<RefTarget> &target, const ManagedError &error, std::source_location origin);
249
256DialogCommandResult dialogCommand(const std::shared_ptr<RefTarget> &target, bool opening, std::source_location origin);
257DialogCommandResult popupCommand(const std::shared_ptr<RefTarget> &target, const std::shared_ptr<RefTarget> &anchor,
258 bool opening, std::source_location origin);
259std::expected<bool, ManagedError> popupOpened(const std::shared_ptr<RefTarget> &target);
260
261} // namespace detail
262
264using TextResolver = std::function<std::expected<std::string, TextResourceError>(std::string_view)>;
265
266namespace detail {
273std::expected<void, ManagedError> spinnerActive(std::shared_ptr<RefTarget> target,
274 std::shared_ptr<const Node<Spinner>> node, bool active,
275 std::source_location origin);
282std::expected<void, ManagedError> spinnerLabel(std::shared_ptr<RefTarget> target,
283 std::shared_ptr<const Node<Spinner>> node, std::string_view value,
284 std::source_location origin);
292std::expected<void, ManagedError> spinnerLabel(std::shared_ptr<RefTarget> target,
293 std::shared_ptr<const Node<Spinner>> node, const TextValue &value,
294 const TextResolver &resolver, std::source_location origin);
295} // namespace detail
296
302class TextSource {
303public:
308 std::expected<GraphemeText, ManagedError> snapshot() const;
309
310private:
311 template <class T> friend class Ref;
312 friend class portals::ManagedScene;
313 friend struct detail::Access;
314 friend class TextProperty;
315 enum class Kind {
316 CAPTION,
317 DRAFT,
319 };
320
321 TextSource(std::shared_ptr<detail::RefTarget> target, Kind kind) : target_(std::move(target)), kind_(kind) {
322 }
323
324 std::shared_ptr<detail::RefTarget> target_;
325 Kind kind_;
326};
327
334public:
336 NumericProperty(const NumericProperty &other) = default;
339
341 std::expected<double, ManagedError> get() const;
342
346 std::expected<PropertyUpdate<NumericValue>, ManagedError> result() const;
347
353 NumericProperty set(double value, std::source_location origin = std::source_location::current());
354
360
366
367private:
368 template <class> friend class Ref;
369
370 NumericProperty(std::shared_ptr<detail::RefTarget> target, std::shared_ptr<const Node<Slider>> node,
371 std::source_location origin)
372 : target_(std::move(target)), node_(std::move(node)), origin_(origin) {
373 }
374
375 std::shared_ptr<detail::RefTarget> target_;
376 std::shared_ptr<const Node<Slider>> node_;
377 std::source_location origin_;
378 std::optional<std::expected<PropertyUpdate<NumericValue>, ManagedError>> last_;
379};
380
385public:
391 std::expected<double, ManagedError> get() const;
393 std::expected<SpinBoxResult, ManagedError> result() const;
397 SpinBoxNumericProperty set(double value, std::source_location origin = std::source_location::current());
402
403private:
404 template <class> friend class Ref;
405
406 SpinBoxNumericProperty(std::shared_ptr<detail::RefTarget> target, std::shared_ptr<const Node<SpinBox>> node,
407 std::source_location origin)
408 : target_(std::move(target)), node_(std::move(node)), origin_(origin) {
409 }
410
411 std::shared_ptr<detail::RefTarget> target_;
412 std::shared_ptr<const Node<SpinBox>> node_;
413 std::source_location origin_;
414 std::optional<std::expected<SpinBoxResult, ManagedError>> last_;
415};
416
417class TextProperty;
418
423public:
428
433 auto target = target_;
434 auto node = node_;
435 const auto origin = origin_;
436
437 const auto value = source.get();
438
439 auto receipt =
440 value ? detail::setChecked(target, node, *value, origin) : detail::failedChecked(target, value.error(), origin);
441
442 return CheckedProperty(std::move(target), std::move(node), origin, std::move(receipt));
443 }
444
446 std::expected<bool, ManagedError> get() const {
447 return detail::checkedValue(target_, node_);
448 }
449
453 std::expected<PropertyUpdate<bool>, ManagedError> set(bool value,
454 std::source_location origin = std::source_location::current()) {
455 return detail::setChecked(target_, node_, value, origin);
456 }
457
463 auto target = target_;
464 auto node = node_;
465 const auto origin = origin_;
466
467 auto receipt = detail::setChecked(target, node, value, origin);
468
469 return CheckedProperty(std::move(target), std::move(node), origin, std::move(receipt));
470 }
471
474 std::expected<PropertyUpdate<bool>, ManagedError> result() const {
475 return receipt_ ? *receipt_
476 : std::expected<PropertyUpdate<bool>, ManagedError>(
477 std::unexpected(ManagedError{ManagedPhase::BIND, {}, TreeError::INVALID_ARGUMENT, {}, {}}));
478 }
479
480private:
481 template <class> friend class Ref;
482
483 CheckedProperty(std::shared_ptr<detail::RefTarget> target, std::shared_ptr<const Node<Switch>> node,
484 std::source_location origin)
485 : target_(std::move(target)), node_(std::move(node)), origin_(origin) {
486 }
487
488 CheckedProperty(std::shared_ptr<detail::RefTarget> target, std::shared_ptr<const Node<Switch>> node,
489 std::source_location origin, std::expected<PropertyUpdate<bool>, ManagedError> receipt)
490 : target_(std::move(target)), node_(std::move(node)), origin_(origin), receipt_(std::move(receipt)) {
491 }
492
493 std::shared_ptr<detail::RefTarget> target_;
494 std::shared_ptr<const Node<Switch>> node_;
495 std::source_location origin_;
496 std::optional<std::expected<PropertyUpdate<bool>, ManagedError>> receipt_;
497};
498
503template <class T> class VisibleModelSource {
504public:
506 std::expected<VisibleModelSnapshot<T>, VisibleModelError> snapshot() const {
507 auto owner = detail::eventScene(target_);
508
509 if (!owner) {
510 return std::unexpected(owner.error());
511 }
512
513 return (*owner)->visibleModelSnapshot(*node_);
514 }
515
516private:
517 template <class> friend class Ref;
518
519 VisibleModelSource(std::shared_ptr<detail::RefTarget> target, std::shared_ptr<const Node<VirtualTable<T>>> node)
520 : target_(std::move(target)), node_(node) {
521 }
522
523 std::shared_ptr<detail::RefTarget> target_;
524 std::shared_ptr<const Node<VirtualTable<T>>> node_;
525};
526
534class TextResult {
535public:
539 std::expected<GraphemeText, ManagedError> result() const;
540
544 TextResult operator+(const TextProperty &value) const;
545
549 TextResult operator+(std::string_view value) const;
550
554 TextResult operator+(const TextValue &value) const;
555
559 TextResult operator+(const TextResult &value) const;
560
561private:
562 friend class TextProperty;
563 friend struct detail::RefAccess;
564 TextResult(std::expected<GraphemeText, ManagedError> value, std::shared_ptr<TextResolver> resolver,
565 std::source_location origin);
566 TextResult join(std::string_view bytes) const;
567
568 std::expected<GraphemeText, ManagedError> value_;
569 std::shared_ptr<TextResolver> resolver_;
570 std::source_location origin_;
571};
572
586public:
591 return TextSource(target_, (expectedType_ == "LineEdit" || expectedType_ == "FormField" ||
592 expectedType_ == "FindBar" || expectedType_ == "ComboBox")
593 ? TextSource::Kind::DRAFT
594 : TextSource::Kind::CAPTION);
595 }
596
598 TextProperty(const TextProperty &other) = default;
599
601 TextProperty(TextProperty &&other) = default;
602
607
611 std::expected<std::string, ManagedError> get() const;
612
618 std::expected<void, ManagedError> result() const;
619
624 TextProperty set(std::string_view value, std::source_location origin = std::source_location::current());
625
630 TextProperty set(const TextValue &value, std::source_location origin = std::source_location::current());
631
636 TextProperty append(std::string_view value, std::source_location origin = std::source_location::current());
637
642 TextProperty append(const TextValue &value, std::source_location origin = std::source_location::current());
643
647 TextProperty operator=(std::string_view value);
648
653
657 TextProperty operator+=(std::string_view value);
658
663
667 TextProperty operator=(const TextResult &value);
668
672 TextProperty operator+=(const TextResult &value);
673
677 TextResult operator+(const TextProperty &value) const;
678
682 TextResult operator+(std::string_view value) const;
683
687 TextResult operator+(const TextValue &value) const;
688
692 TextResult operator+(const TextResult &value) const;
693
694private:
695 template <class T> friend class Ref;
696 friend class DynamicRef;
697 friend struct detail::RefAccess;
698 friend class TextResult;
699
700 TextProperty(std::shared_ptr<detail::RefTarget> target, TextResolver resolver, std::string_view expectedType,
701
702 std::source_location origin, std::optional<ProgrammaticChange> change = {});
703
704 TextProperty mutate(const TextValue &value, bool append, std::source_location origin);
705 TextProperty mutate(std::string_view value, bool append, std::source_location origin);
706 TextProperty mutate(const TextResult &value, bool append);
707 TextResult readResult() const;
708 void report(const char *operation, std::string_view key, std::source_location origin);
709
710 std::shared_ptr<detail::RefTarget> target_;
711 std::shared_ptr<TextResolver> resolver_;
712 std::string_view expectedType_;
713 std::source_location origin_;
714 std::expected<void, ManagedError> result_;
715 std::optional<ProgrammaticChange> change_;
716};
717
724template <class T> class NodeRef {
725public:
727 NodeRef() : slot_(std::make_shared<Slot>()) {
728 }
729
731 Node<T> node() const noexcept {
732 return slot_ ? slot_->node : Node<T>{};
733 }
734
735private:
736 friend struct detail::NamedAccess;
737 friend class Description<T>;
738 template <class U> friend class Ref;
739
741 struct Slot {
742 Node<T> node;
743 bool pending{};
744 detail::RefTarget target;
745 bool fluent{};
746 };
747
748 std::shared_ptr<Slot> slot_;
749};
750
761template <class T> class Ref : public NodeRef<T> {
762 friend struct detail::MessageAccess;
763
764public:
766 Ref() {
767 this->slot_->fluent = true;
768 }
769
773 CheckedProperty checked(std::source_location origin = std::source_location::current()) const
774 requires std::same_as<T, Switch>
775 {
776 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
777
778 return CheckedProperty(target(), std::move(node), origin);
779 }
780
782 std::expected<RadioGroupValue, ManagedError> value() const
783 requires std::same_as<T, RadioGroup>
784 {
785 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
786 return detail::radioValue(target(), std::move(node));
787 }
788
792 std::expected<PropertyUpdate<RadioGroupValue>, ManagedError>
793 select(std::optional<RowId> id, std::source_location origin = std::source_location::current()) const
794 requires std::same_as<T, RadioGroup>
795 {
796 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
797 return detail::radioSelect(target(), std::move(node), id, origin);
798 }
799
812 template <class Value, class Callback>
813 requires std::copy_constructible<Callback> &&
814 (std::same_as<std::invoke_result_t<Callback &, std::shared_ptr<const Value>>, void> ||
815 std::same_as<std::invoke_result_t<Callback &, std::shared_ptr<const Value>>,
816 std::expected<void, TreeError>>)
817 std::expected<UiEndpoint<Value>, ManagedError>
818 delivery(Callback callback, std::source_location origin = std::source_location::current()) const {
819 auto observation = target();
820 try {
821 auto connected = detail::connectDelivery(
822 observation,
823 [callback =
824 std::move(callback)](std::shared_ptr<const void> payload) mutable -> std::expected<void, TreeError> {
825 if constexpr (std::same_as<std::invoke_result_t<Callback &, std::shared_ptr<const Value>>, void>) {
826 std::invoke(callback, std::static_pointer_cast<const Value>(std::move(payload)));
827 return {};
828 } else {
829 return std::invoke(callback, std::static_pointer_cast<const Value>(std::move(payload)));
830 }
831 },
832 origin);
833 if (!connected) {
834 detail::reportEventError(observation, connected.error(), origin);
835 return std::unexpected(connected.error());
836 }
837
838 return UiEndpoint<Value>(std::move(*connected));
839 } catch (const std::bad_alloc &) {
841 detail::reportEventError(observation, failure, origin);
842 return std::unexpected(failure);
843 } catch (...) {
845 detail::reportEventError(observation, failure, origin);
846 return std::unexpected(failure);
847 }
848 }
849
856 EditorCommandResult activate(std::source_location origin = std::source_location::current()) const
857 requires std::same_as<T, Button>
858 {
859 return detail::activateButton(target(), origin);
860 }
861
867 std::expected<void, ManagedError> value(double value,
868 std::source_location origin = std::source_location::current()) const
869 requires std::same_as<T, Gauge>
870 {
871 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
872
873 return detail::gaugeValue(target(), std::move(node), value, false, origin);
874 }
875
879 NumericProperty value(std::source_location origin = std::source_location::current()) const
880 requires std::same_as<T, Slider>
881 {
882 auto node = this->slot_ ? std::shared_ptr<const Node<Slider>>(this->slot_, &this->slot_->node) : nullptr;
883
884 return NumericProperty(target(), std::move(node), origin);
885 }
886
888 SpinBoxNumericProperty value(std::source_location origin = std::source_location::current()) const
889 requires std::same_as<T, SpinBox>
890 {
891 auto node = this->slot_ ? std::shared_ptr<const Node<SpinBox>>(this->slot_, &this->slot_->node) : nullptr;
892 return SpinBoxNumericProperty(target(), std::move(node), origin);
893 }
894
896 Ref<LineEdit> lineEdit() const
897 requires std::same_as<T, SpinBox>
898 {
899 auto node = this->slot_ ? std::shared_ptr<const Node<SpinBox>>(this->slot_, &this->slot_->node) : nullptr;
900 return detail::spinBoxEditor(target(), std::move(node));
901 }
902
908 std::expected<void, ManagedError> adjust(double delta,
909 std::source_location origin = std::source_location::current()) const
910 requires std::same_as<T, Gauge>
911 {
912 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
913
914 return detail::gaugeValue(target(), std::move(node), delta, true, origin);
915 }
916
920 std::expected<PasswordValue, ManagedError> value(std::source_location origin = std::source_location::current()) const
921 requires std::same_as<T, Password>
922 {
923 return detail::passwordValue(target(), origin);
924 }
925
929 std::expected<void, ManagedError> value(PasswordValue value,
930 std::source_location origin = std::source_location::current()) const
931 requires std::same_as<T, Password>
932 {
933 return detail::setPasswordValue(target(), std::move(value), origin);
934 }
935
941 template <class F>
942 requires(std::same_as<T, Password> && portals::detail::SecretCallback<F> &&
943 std::same_as<std::invoke_result_t<std::decay_t<F> &, SecretView>, void>)
944 std::expected<void, ManagedError> withPlaintext(F &&callback,
945 std::source_location origin = std::source_location::current()) const {
946 auto observation = target();
947 auto selected = detail::passwordValue(observation, origin);
948
949 if (!selected) {
950 return std::unexpected(selected.error());
951 }
952
953 auto accessed = portals::detail::PasswordValueAccess::borrowOwned(std::move(*selected), std::forward<F>(callback));
954
955 if (!accessed) {
956 auto failure =
957 portals::detail::passwordError(ManagedPhase::TEXT, observation->node.id(), std::move(accessed.error()));
958
959 detail::reportPasswordError(observation, failure, origin);
960
961 return std::unexpected(std::move(failure));
962 }
963
964 return {};
965 }
966
970 std::expected<void, ManagedError> start(std::source_location origin = std::source_location::current()) const
971 requires std::same_as<T, Spinner>
972 {
973 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
974 return detail::spinnerActive(target(), std::move(node), true, origin);
975 }
976
980 std::expected<void, ManagedError> stop(std::source_location origin = std::source_location::current()) const
981 requires std::same_as<T, Spinner>
982 {
983 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
984 return detail::spinnerActive(target(), std::move(node), false, origin);
985 }
986
991 std::expected<void, ManagedError> label(std::string_view value,
992 std::source_location origin = std::source_location::current()) const
993 requires std::same_as<T, Spinner>
994 {
995 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
996 return detail::spinnerLabel(target(), std::move(node), value, origin);
997 }
998
1004 std::expected<void, ManagedError> label(const TextValue &value, const TextResolver &resolver = {},
1005 std::source_location origin = std::source_location::current()) const
1006 requires std::same_as<T, Spinner>
1007 {
1008 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1009 return detail::spinnerLabel(target(), std::move(node), value, resolver, origin);
1010 }
1011
1013 std::expected<void, ManagedError> open(std::source_location origin = std::source_location::current()) const
1014 requires std::same_as<T, HelpView>
1015 {
1016 return detail::helpCommand(target(), true, origin);
1017 }
1018
1020 std::expected<void, ManagedError> close(std::source_location origin = std::source_location::current()) const
1021 requires std::same_as<T, HelpView>
1022 {
1023 return detail::helpCommand(target(), false, origin);
1024 }
1025
1031 std::expected<void, ManagedError> setOffset(ScrollAxis axis, ScrollOffset offset,
1032 std::source_location origin = std::source_location::current()) const
1033 requires(std::derived_from<T, ScrollArea> || std::same_as<T, ScrollBar>)
1034 {
1035 return detail::scrollOffset(target(), axis, offset, origin);
1036 }
1037
1041 std::expected<LogAppendReceipt, ManagedError>
1042 appendBatch(std::string_view bytes, std::source_location origin = std::source_location::current()) const
1043 requires std::same_as<T, LogView>
1044 {
1045 const auto observation = target();
1046 const auto owner = detail::eventScene(observation);
1047
1048 if (!owner) {
1049 return std::unexpected(owner.error());
1050 }
1051
1052 auto result = (*owner)->appendLogBatch(this->node(), bytes);
1053
1054 if (!result) {
1055 result.error().registrationOrigin = origin;
1056 }
1057
1058 return result;
1059 }
1060
1064 bool append(std::string_view bytes, std::source_location origin = std::source_location::current()) const
1065 requires std::same_as<T, LogView>
1066 {
1067 const auto result = appendBatch(bytes, origin);
1068
1069 if (!result) {
1070 detail::reportEventError(target(), result.error(), origin);
1071 }
1072
1073 return result.has_value();
1074 }
1075
1079 std::expected<void, ManagedError> setModel(const LogSource &source,
1080 std::source_location origin = std::source_location::current()) const
1081 requires std::same_as<T, LogView>
1082 {
1083 return detail::setLogModel(target(), this->node(), source, origin);
1084 }
1085
1089 bool model(const LogSource &source, std::source_location origin = std::source_location::current()) const
1090 requires std::same_as<T, LogView>
1091 {
1092 const auto result = setModel(source, origin);
1093
1094 if (!result) {
1095 detail::reportEventError(target(), result.error(), origin);
1096 }
1097
1098 return result.has_value();
1099 }
1100
1106 template <class Row>
1107 requires std::same_as<T, VirtualRows<Row>>
1108 std::expected<void, ManagedError> setModel(Model<Row> source, ModelRebindOptions options = {},
1109 std::source_location origin = std::source_location::current()) const;
1113 template <class Row>
1114 requires std::same_as<T, VirtualRows<Row>>
1115 bool model(Model<Row> source, ModelRebindOptions options = {},
1116 std::source_location origin = std::source_location::current()) const;
1122 template <class Row>
1123 requires std::same_as<T, VirtualRows<Row>>
1124 std::expected<void, ManagedError> setModel(const WindowRowsModel<Row> &source, ModelRebindOptions options = {},
1125 std::source_location origin = std::source_location::current()) const;
1129 template <class Row>
1130 requires std::same_as<T, VirtualRows<Row>>
1131 bool model(const WindowRowsModel<Row> &source, ModelRebindOptions options = {},
1132 std::source_location origin = std::source_location::current()) const;
1133
1145 template <class Row>
1146 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1147 std::expected<void, ManagedError>
1149 std::type_identity_t<std::optional<ManagedViewHandler<Row>>> prepared = std::nullopt,
1150 std::source_location origin = std::source_location::current(), ModelRebindOptions options = {}) const {
1151 const auto owner = detail::eventScene(target());
1152
1153 if (!owner) {
1154 auto failure = owner.error();
1155
1156 failure.registrationOrigin = origin;
1157
1158 return std::unexpected(failure);
1159 }
1160
1161 auto result = (*owner)->setModel(this->node(), std::move(source), std::move(prepared), options);
1162
1163 if (!result) {
1164 result.error().registrationOrigin = origin;
1165 }
1166
1167 return result;
1168 }
1169
1177 template <class Value>
1178 requires(std::same_as<T, Label> || std::same_as<T, Button> || std::same_as<T, Border>) &&
1179 std::equality_comparable<Value> && std::copy_constructible<Value>
1180 std::expected<void, ManagedError> setModel(Model<Value> source,
1181 std::source_location origin = std::source_location::current()) const;
1182
1187 template <class Value>
1188 requires(std::same_as<T, Label> || std::same_as<T, Button> || std::same_as<T, Border>) &&
1189 std::equality_comparable<Value> && std::copy_constructible<Value>
1190 bool model(Model<Value> source, std::source_location origin = std::source_location::current()) const {
1191 const auto observation = target();
1192 auto result = setModel(std::move(source), origin);
1193
1194 if (!result) {
1195 detail::reportCaptionModelError(observation, result.error(), origin,
1196 std::same_as<T, Label> ? "Label"
1197 : std::same_as<T, Button> ? "Button"
1198 : "Border");
1199 }
1200
1201 return static_cast<bool>(result);
1202 }
1203
1207 std::expected<void, ManagedError> setModel(const ValueText &source,
1208 std::source_location origin = std::source_location::current()) const
1209 requires(std::same_as<T, Label> || std::same_as<T, Button> || std::same_as<T, Border>);
1210
1214 bool model(const ValueText &source, std::source_location origin = std::source_location::current()) const
1215 requires(std::same_as<T, Label> || std::same_as<T, Button> || std::same_as<T, Border>);
1216
1221 template <class Row>
1222 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1223 std::expected<void, ManagedError> setModel(Model<Row> source, ModelRebindOptions options = {},
1224 std::source_location origin = std::source_location::current()) const;
1225
1229 template <class Row>
1230 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1231 bool model(Model<Row> source, ModelRebindOptions options = {},
1232 std::source_location origin = std::source_location::current()) const {
1233 const auto observation = target();
1234 auto result = setModel(std::move(source), options, origin);
1235 if (!result) {
1236 detail::reportEventError(observation, result.error(), origin);
1237 }
1238 return static_cast<bool>(result);
1239 }
1240
1246 template <class Row>
1247 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1248 std::expected<void, ManagedError>
1250 std::type_identity_t<std::optional<ManagedViewHandler<Row>>> prepared = std::nullopt,
1251 std::source_location origin = std::source_location::current()) const {
1252 return setModel(std::move(source), std::move(prepared), origin, options);
1253 }
1254
1262 template <class Row>
1263 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1265 std::type_identity_t<std::optional<ManagedViewHandler<Row>>> prepared = std::nullopt,
1266 std::source_location origin = std::source_location::current()) const {
1267 const auto result = setModel(std::move(source), std::move(prepared), origin);
1268
1269 if (!result) {
1270 detail::reportEventError(target(), result.error(), origin);
1271 }
1272
1273 return result.has_value();
1274 }
1275
1281 template <class Row>
1282 requires(std::same_as<T, VirtualList<Row>> || std::same_as<T, VirtualTable<Row>>)
1284 std::type_identity_t<std::optional<ManagedViewHandler<Row>>> prepared = std::nullopt,
1285 std::source_location origin = std::source_location::current()) const {
1286 const auto result = setModel(std::move(source), std::move(prepared), origin, options);
1287 if (!result) {
1288 detail::reportEventError(target(), result.error(), origin);
1289 }
1290 return result.has_value();
1291 }
1292
1297 std::expected<std::optional<PositionResolution>, ManagedError>
1298 restoreStatus(std::source_location origin = std::source_location::current()) const
1299 requires requires(const ManagedScene &scene, Node<T> node) { scene.restoreStatus(node); }
1300 {
1301 const auto owner = detail::eventScene(target());
1302 if (!owner) {
1303 auto failure = owner.error();
1304 failure.registrationOrigin = origin;
1305 return std::unexpected(failure);
1306 }
1307 auto result = (*owner)->restoreStatus(this->node());
1308 if (!result) {
1309 result.error().registrationOrigin = origin;
1310 }
1311 return result;
1312 }
1313
1315 std::expected<void, ManagedError> followTail(std::source_location origin = std::source_location::current()) const
1316 requires std::same_as<T, LogView>
1317 {
1318 const auto owner = detail::eventScene(target());
1319
1320 if (!owner) {
1321 return std::unexpected(owner.error());
1322 }
1323
1324 auto result = (*owner)->followLogTail(this->node());
1325
1326 if (!result) {
1327 result.error().registrationOrigin = origin;
1328 }
1329
1330 return result;
1331 }
1332
1334 bool tail(std::source_location origin = std::source_location::current()) const
1335 requires std::same_as<T, LogView>
1336 {
1337 const auto result = followTail(origin);
1338
1339 if (!result) {
1340 detail::reportEventError(target(), result.error(), origin);
1341 }
1342
1343 return result.has_value();
1344 }
1345
1347 std::expected<void, ManagedError> clearLog(std::source_location origin = std::source_location::current()) const
1348 requires std::same_as<T, LogView>
1349 {
1350 const auto owner = detail::eventScene(target());
1351
1352 if (!owner) {
1353 return std::unexpected(owner.error());
1354 }
1355
1356 auto result = (*owner)->clearLog(this->node());
1357
1358 if (!result) {
1359 result.error().registrationOrigin = origin;
1360 }
1361
1362 return result;
1363 }
1364
1366 bool clear(std::source_location origin = std::source_location::current()) const
1367 requires std::same_as<T, LogView>
1368 {
1369 const auto result = clearLog(origin);
1370
1371 if (!result) {
1372 detail::reportEventError(target(), result.error(), origin);
1373 }
1374
1375 return result.has_value();
1376 }
1377
1379 std::expected<LogStatus, ManagedError> status() const
1380 requires std::same_as<T, LogView>
1381 {
1382 const auto owner = detail::eventScene(target());
1383
1384 return owner ? (*owner)->logStatus(this->node()) : std::unexpected(owner.error());
1385 }
1386
1391 std::expected<void, ManagedError> setModel(const DocumentSource &source,
1392 std::source_location origin = std::source_location::current()) const
1393 requires std::same_as<T, DocumentView>
1394 {
1395 return detail::setDocumentModel(target(), this->node(), source, origin);
1396 }
1397
1402 bool model(const DocumentSource &source, std::source_location origin = std::source_location::current()) const
1403 requires std::same_as<T, DocumentView>
1404 {
1405 const auto observation = target();
1406 const auto result = detail::setDocumentModel(observation, this->node(), source, origin);
1407 if (!result) {
1408 detail::reportEventError(observation, result.error(), origin);
1409 }
1410 return result.has_value();
1411 }
1412
1417 std::expected<void, ManagedError> seekByte(std::uint64_t offset,
1418 std::source_location origin = std::source_location::current()) const
1419 requires std::same_as<T, DocumentView>
1420 {
1421 return detail::seekDocument(target(), this->node(), offset, false, origin);
1422 }
1423
1428 bool byte(std::uint64_t offset, std::source_location origin = std::source_location::current()) const
1429 requires std::same_as<T, DocumentView>
1430 {
1431 const auto observation = target();
1432 const auto result = detail::seekDocument(observation, this->node(), offset, false, origin);
1433 if (!result) {
1434 detail::reportEventError(observation, result.error(), origin);
1435 }
1436 return result.has_value();
1437 }
1438
1440 std::expected<void, ManagedError> refresh(std::source_location origin = std::source_location::current()) const
1441 requires std::same_as<T, DocumentView>
1442 {
1443 return detail::seekDocument(target(), this->node(), 0, true, origin);
1444 }
1445
1447 bool reload(std::source_location origin = std::source_location::current()) const
1448 requires std::same_as<T, DocumentView>
1449 {
1450 const auto observation = target();
1451 const auto result = detail::seekDocument(observation, this->node(), 0, true, origin);
1452 if (!result) {
1453 detail::reportEventError(observation, result.error(), origin);
1454 }
1455 return result.has_value();
1456 }
1457
1461 std::expected<void, ManagedError> scrollRows(std::int64_t rows,
1462 std::source_location origin = std::source_location::current()) const
1463 requires std::same_as<T, DocumentView>
1464 {
1465 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1466
1467 return detail::navigateDocument(target(), std::move(node), portals::detail::DocumentNavigation::ROWS, rows, origin);
1468 }
1469
1473 bool scroll(std::int64_t rows, std::source_location origin = std::source_location::current()) const
1474 requires std::same_as<T, DocumentView>
1475 {
1476 const auto observation = target();
1477 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1478 const auto result =
1479 detail::navigateDocument(observation, std::move(node), portals::detail::DocumentNavigation::ROWS, rows, origin);
1480
1481 if (!result) {
1482 detail::reportEventError(observation, result.error(), origin);
1483 }
1484
1485 return result.has_value();
1486 }
1487
1491 std::expected<void, ManagedError> scrollPages(std::int64_t pages,
1492 std::source_location origin = std::source_location::current()) const
1493 requires std::same_as<T, DocumentView>
1494 {
1495 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1496
1497 return detail::navigateDocument(target(), std::move(node), portals::detail::DocumentNavigation::PAGES, pages,
1498 origin);
1499 }
1500
1504 bool page(std::int64_t pages, std::source_location origin = std::source_location::current()) const
1505 requires std::same_as<T, DocumentView>
1506 {
1507 const auto observation = target();
1508 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1509 const auto result =
1510 detail::navigateDocument(observation, std::move(node), portals::detail::DocumentNavigation::PAGES, pages, origin);
1511
1512 if (!result) {
1513 detail::reportEventError(observation, result.error(), origin);
1514 }
1515
1516 return result.has_value();
1517 }
1518
1522 std::expected<void, ManagedError> goHome(std::source_location origin = std::source_location::current()) const
1523 requires std::same_as<T, DocumentView>
1524 {
1525 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1526
1527 return detail::navigateDocument(target(), std::move(node), portals::detail::DocumentNavigation::HOME, 0, origin);
1528 }
1529
1533 bool home(std::source_location origin = std::source_location::current()) const
1534 requires std::same_as<T, DocumentView>
1535 {
1536 const auto observation = target();
1537 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1538 const auto result =
1539 detail::navigateDocument(observation, std::move(node), portals::detail::DocumentNavigation::HOME, 0, origin);
1540
1541 if (!result) {
1542 detail::reportEventError(observation, result.error(), origin);
1543 }
1544
1545 return result.has_value();
1546 }
1547
1551 std::expected<void, ManagedError> goEnd(std::source_location origin = std::source_location::current()) const
1552 requires std::same_as<T, DocumentView>
1553 {
1554 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1555
1556 return detail::navigateDocument(target(), std::move(node), portals::detail::DocumentNavigation::END, 0, origin);
1557 }
1558
1562 bool end(std::source_location origin = std::source_location::current()) const
1563 requires std::same_as<T, DocumentView>
1564 {
1565 const auto observation = target();
1566 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1567 const auto result =
1568 detail::navigateDocument(observation, std::move(node), portals::detail::DocumentNavigation::END, 0, origin);
1569
1570 if (!result) {
1571 detail::reportEventError(observation, result.error(), origin);
1572 }
1573
1574 return result.has_value();
1575 }
1576
1582 std::expected<void, ManagedError> setMode(DocumentViewMode value,
1583 std::source_location origin = std::source_location::current()) const
1584 requires std::same_as<T, DocumentView>
1585 {
1586 return detail::documentMode(target(), this->node(), value, origin);
1587 }
1588
1592 bool mode(DocumentViewMode value, std::source_location origin = std::source_location::current()) const
1593 requires std::same_as<T, DocumentView>
1594 {
1595 const auto observation = target();
1596 const auto result = detail::documentMode(observation, this->node(), value, origin);
1597
1598 if (!result) {
1599 detail::reportEventError(observation, result.error(), origin);
1600 }
1601 return result.has_value();
1602 }
1603
1607 std::expected<void, ManagedError> setHexOptions(DocumentHexOptions options,
1608 std::source_location origin = std::source_location::current()) const
1609 requires std::same_as<T, DocumentView>
1610 {
1611 return detail::documentHexOptions(target(), this->node(), options, origin);
1612 }
1613
1617 bool hexOptions(DocumentHexOptions options, std::source_location origin = std::source_location::current()) const
1618 requires std::same_as<T, DocumentView>
1619 {
1620 const auto observation = target();
1621 const auto result = detail::documentHexOptions(observation, this->node(), options, origin);
1622
1623 if (!result) {
1624 detail::reportEventError(observation, result.error(), origin);
1625 }
1626 return result.has_value();
1627 }
1628
1633 std::expected<void, ManagedError> setLanguage(DocumentLanguage value,
1634 std::source_location origin = std::source_location::current()) const
1635 requires std::same_as<T, DocumentView>
1636 {
1637 return detail::documentLanguage(target(), this->node(), value, origin);
1638 }
1639
1643 std::expected<void, ManagedError> setLanguage(std::string_view name,
1644 std::source_location origin = std::source_location::current()) const
1645 requires std::same_as<T, DocumentView>
1646 {
1647 return setLanguage(documentLanguageFromName(name), origin);
1648 }
1649
1653 bool language(DocumentLanguage value, std::source_location origin = std::source_location::current()) const
1654 requires std::same_as<T, DocumentView>
1655 {
1656 const auto observation = target();
1657 const auto result = detail::documentLanguage(observation, this->node(), value, origin);
1658
1659 if (!result) {
1660 detail::reportEventError(observation, result.error(), origin);
1661 }
1662
1663 return result.has_value();
1664 }
1665
1669 bool language(std::string_view name, std::source_location origin = std::source_location::current()) const
1670 requires std::same_as<T, DocumentView>
1671 {
1672 return language(documentLanguageFromName(name), origin);
1673 }
1674
1678 std::expected<void, ManagedError> setSyntax(DocumentSyntaxPolicy policy,
1679 std::source_location origin = std::source_location::current()) const
1680 requires std::same_as<T, DocumentView>
1681 {
1682 return detail::documentSyntax(target(), this->node(), policy, origin);
1683 }
1684
1688 bool syntax(DocumentSyntaxPolicy policy, std::source_location origin = std::source_location::current()) const
1689 requires std::same_as<T, DocumentView>
1690 {
1691 const auto observation = target();
1692 const auto result = detail::documentSyntax(observation, this->node(), policy, origin);
1693 if (!result) {
1694 detail::reportEventError(observation, result.error(), origin);
1695 }
1696 return result.has_value();
1697 }
1698
1704 std::expected<void, ManagedError> setLineNumbers(bool enabled,
1705 std::source_location origin = std::source_location::current()) const
1706 requires std::same_as<T, DocumentView>
1707 {
1708 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1709
1710 return detail::documentLineNumbers(target(), std::move(node), enabled, origin);
1711 }
1712
1716 bool lineNumbers(bool enabled, std::source_location origin = std::source_location::current()) const
1717 requires std::same_as<T, DocumentView>
1718 {
1719 const auto observation = target();
1720 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1721 const auto result = detail::documentLineNumbers(observation, std::move(node), enabled, origin);
1722
1723 if (!result) {
1724 detail::reportEventError(observation, result.error(), origin);
1725 }
1726
1727 return result.has_value();
1728 }
1729
1733 bool toggleLineNumbers(std::source_location origin = std::source_location::current()) const
1734 requires std::same_as<T, DocumentView>
1735 {
1736 const auto observation = target();
1737 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
1738 const auto result = detail::documentLineNumbers(observation, std::move(node), std::nullopt, origin);
1739
1740 if (!result) {
1741 detail::reportEventError(observation, result.error(), origin);
1742 }
1743
1744 return result.has_value();
1745 }
1746
1748 std::expected<DocumentViewStatus, ManagedError> status() const
1749 requires std::same_as<T, DocumentView>
1750 {
1751 return detail::documentStatus(target(), this->node());
1752 }
1753
1755 std::optional<DocumentViewStatus> currentStatus(std::source_location origin = std::source_location::current()) const
1756 requires std::same_as<T, DocumentView>
1757 {
1758 const auto observation = target();
1759 const auto result = detail::documentStatus(observation, this->node());
1760 if (!result) {
1761 detail::reportEventError(observation, result.error(), origin);
1762 return {};
1763 }
1764 return *result;
1765 }
1766
1771 std::expected<void, ManagedError> setMetrics(ScrollAxisMetrics metrics,
1772 std::source_location origin = std::source_location::current()) const
1773 requires std::same_as<T, ScrollBar>
1774 {
1775 const auto observation = target();
1776 auto owner = detail::eventScene(observation);
1777 if (!owner) {
1778 return std::unexpected(owner.error());
1779 }
1780 auto result = (*owner)->setScrollMetrics(this->node(), metrics);
1781 if (!result) {
1782 detail::reportEventError(observation, result.error(), origin);
1783 }
1784 return result;
1785 }
1786
1790 std::expected<void, ManagedError> ensureVisible(std::source_location origin = std::source_location::current()) const {
1791 return detail::ensureVisible(target(), origin);
1792 }
1793
1798 std::expected<NodeGeometry, ManagedError> geometry() const {
1799 return detail::geometry(target());
1800 }
1801
1803 std::expected<CellSize, ManagedError> size() const {
1804 return geometry().transform([](const NodeGeometry &value) {
1805 return value.local.size();
1806 });
1807 }
1808
1816 template <class Callback>
1818 std::expected<void, ManagedError> onLayout(Callback callback,
1819 std::source_location origin = std::source_location::current()) const {
1820 auto observation = target();
1821 auto owner = detail::eventScene(observation);
1822 if (!owner) {
1823 return std::unexpected(owner.error());
1824 }
1825 auto result = [&]() -> std::expected<void, ManagedError> {
1826 try {
1827 return (*owner)->onLayout(this->node(), std::move(callback), origin);
1828 } catch (const std::bad_alloc &) {
1829 return std::unexpected(ManagedError{ManagedPhase::BIND, this->node().id(), TreeError::NO_MEMORY, {}, {}});
1830 } catch (...) {
1831 return std::unexpected(ManagedError{ManagedPhase::BIND, this->node().id(), TreeError::CALLBACK_FAILED, {}, {}});
1832 }
1833 }();
1834 if (!result) {
1835 detail::reportEventError(observation, result.error(), origin);
1836 }
1837 return result;
1838 }
1839
1849 template <class Callback = detail::QuitCommand>
1850 requires(std::same_as<T, Button> && portals::detail::ManagedAction<Callback, ClickEvent>)
1851 std::expected<void, ManagedError> onClick(Callback action,
1852 std::source_location origin = std::source_location::current()) const {
1853 detail::commandOrigin(action, origin);
1854 auto observation = target();
1855 auto scene = detail::eventScene(observation);
1856
1857 if (!scene) {
1858 return std::unexpected(scene.error());
1859 }
1860
1861 // The forwarding move into the checked scene API is still part of this boundary.
1862 auto result = [&]() -> std::expected<void, ManagedError> {
1863 try {
1864 return (*scene)->onClick(this->node(), std::move(action));
1865 } catch (const std::bad_alloc &) {
1866 return std::unexpected(ManagedError{ManagedPhase::BIND, this->node().id(), TreeError::NO_MEMORY, {}, {}});
1867 } catch (...) {
1868 return std::unexpected(ManagedError{ManagedPhase::BIND, this->node().id(), TreeError::CALLBACK_FAILED, {}, {}});
1869 }
1870 }();
1871
1872 if (!result) {
1873 detail::reportEventError(observation, result.error(), origin);
1874 }
1875
1876 return result;
1877 }
1878
1883 std::expected<void, TreeError> display(DataPresentation value,
1884 std::source_location origin = std::source_location::current()) const
1885 requires std::same_as<T, DataStateView>
1886 {
1887 return detail::displayDataState(target(), value, origin);
1888 }
1889
1895 std::expected<void, ManagedError> focus(std::source_location origin = std::source_location::current()) const {
1896 return focusOperation(&ManagedScene::focus, origin);
1897 }
1898
1902 DialogCommandResult open(std::source_location origin = std::source_location::current()) const
1903 requires std::same_as<T, Dialog>
1904 {
1905 return detail::dialogCommand(target(), true, origin);
1906 }
1907
1911 DialogCommandResult dismiss(std::source_location origin = std::source_location::current()) const
1912 requires(std::same_as<T, Dialog> || std::same_as<T, PopupMenu>)
1913 {
1914 if constexpr (std::same_as<T, PopupMenu>) {
1915 return detail::popupCommand(target(), {}, false, origin);
1916 }
1917 return detail::dialogCommand(target(), false, origin);
1918 }
1919
1925 template <class Anchor>
1926 DialogCommandResult open(const Ref<Anchor> &anchor,
1927 std::source_location origin = std::source_location::current()) const
1928 requires std::same_as<T, PopupMenu>
1929 {
1930 return detail::popupCommand(target(), anchor.target(), true, origin);
1931 }
1932
1934 std::expected<bool, ManagedError> opened() const
1935 requires(std::same_as<T, Dialog> || std::same_as<T, PopupMenu>)
1936 {
1937 if constexpr (std::same_as<T, PopupMenu>) {
1938 return detail::popupOpened(target());
1939 }
1940 auto observation = target();
1941 auto owner = detail::eventScene(observation);
1942 return owner ? (*owner)->dialogOpened(observation->node) : std::unexpected(owner.error());
1943 }
1944
1949 std::expected<void, ManagedError>
1950 enterFocusScope(std::source_location origin = std::source_location::current()) const {
1951 return focusOperation(&ManagedScene::enterFocusScope, origin);
1952 }
1953
1958 std::expected<void, ManagedError>
1959 leaveFocusScope(std::source_location origin = std::source_location::current()) const {
1960 return focusOperation(&ManagedScene::leaveFocusScope, origin);
1961 }
1962
1968 TextProperty text(TextResolver resolver = {}, std::source_location origin = std::source_location::current()) const
1969 requires((std::derived_from<T, Control> && !std::derived_from<T, Slider>) || std::same_as<T, LineEdit> ||
1970 std::same_as<T, SpinBox>)
1971 {
1972 auto target = this->slot_ ? std::shared_ptr<detail::RefTarget>(this->slot_, &this->slot_->target) : nullptr;
1973 constexpr std::string_view TYPE = std::same_as<T, LineEdit> ? "LineEdit"
1974 : std::same_as<T, Label> ? "Label"
1975 : std::same_as<T, Button> ? "Button"
1976 : std::same_as<T, Switch> ? "Switch"
1977 : std::same_as<T, CheckBox> ? "CheckBox"
1978 : std::same_as<T, ThreeState> ? "ThreeState"
1979 : "Control";
1980
1981 return TextProperty(std::move(target), std::move(resolver), TYPE, origin);
1982 }
1983
1985 Ref<LineEdit> editor() const
1986 requires(std::same_as<T, FindBar> || std::derived_from<T, ComboBox>)
1987 {
1988 if constexpr (std::derived_from<T, ComboBox>) {
1989 return detail::choiceEditor(target());
1990 } else {
1991 return detail::findEditor(target());
1992 }
1993 }
1994
1998 TextProperty text(TextResolver resolver = {}, std::source_location origin = std::source_location::current()) const
1999 requires std::same_as<T, ComboBox>
2000 {
2001 return TextProperty(target(), std::move(resolver), "ComboBox", origin);
2002 }
2003
2005 std::expected<ChoiceSelection, ManagedError> selection() const
2006 requires std::derived_from<T, ComboBox>
2007 {
2008 return detail::choiceSelection(target());
2009 }
2010
2012 std::expected<bool, ManagedError> opened() const
2013 requires std::derived_from<T, ComboBox>
2014 {
2015 return detail::choiceOpened(target());
2016 }
2017
2019 std::expected<void, ManagedError> open(std::source_location origin = std::source_location::current()) const
2020 requires std::derived_from<T, ComboBox>
2021 {
2022 return detail::choiceOpen(target(), true, origin);
2023 }
2024
2026 std::expected<void, ManagedError> dismiss(std::source_location origin = std::source_location::current()) const
2027 requires std::derived_from<T, ComboBox>
2028 {
2029 return detail::choiceOpen(target(), false, origin);
2030 }
2031
2037 std::expected<void, ManagedError> select(std::uint64_t index,
2038 std::source_location origin = std::source_location::current()) const
2039 requires std::derived_from<T, ComboBox>
2040 {
2041 return detail::choiceSelect(target(), index, origin);
2042 }
2043
2048 std::expected<void, ManagedError> select(ChoiceSelection value,
2049 std::source_location origin = std::source_location::current()) const
2050 requires std::derived_from<T, ComboBox>
2051 {
2052 return detail::choiceSelect(target(), std::move(value), origin);
2053 }
2054
2056 std::expected<void, ManagedError> clearSelection(std::source_location origin = std::source_location::current()) const
2057 requires std::derived_from<T, ComboBox>
2058 {
2059 return detail::choiceClear(target(), origin);
2060 }
2061
2066 TextProperty text(TextResolver resolver = {}, std::source_location origin = std::source_location::current()) const
2067 requires std::same_as<T, FindBar>
2068 {
2069 return TextProperty(target(), std::move(resolver), "FindBar", origin);
2070 }
2071
2078 std::expected<FindMatch, ManagedError> navigate(FindDirection direction) const
2079 requires std::same_as<T, FindBar>
2080 {
2081 return detail::findNavigate(target(), direction);
2082 }
2083
2085 bool next(std::source_location origin = std::source_location::current()) const
2086 requires std::same_as<T, FindBar>
2087 {
2088 auto observation = target();
2089 auto result = detail::findNavigate(observation, FindDirection::NEXT);
2090 if (!result) {
2091 detail::reportEventError(observation, result.error(), origin);
2092 }
2093 return result && static_cast<bool>(*result);
2094 }
2095
2097 bool previous(std::source_location origin = std::source_location::current()) const
2098 requires std::same_as<T, FindBar>
2099 {
2100 auto observation = target();
2101 auto result = detail::findNavigate(observation, FindDirection::PREVIOUS);
2102 if (!result) {
2103 detail::reportEventError(observation, result.error(), origin);
2104 }
2105 return result && static_cast<bool>(*result);
2106 }
2107
2109 std::expected<FindMatch, ManagedError> match() const
2110 requires std::same_as<T, FindBar>
2111 {
2112 return detail::findMatch(target());
2113 }
2114
2119 std::expected<bool, ManagedError> current(const FindMatch &value) const
2120 requires std::same_as<T, FindBar>
2121 {
2122 return detail::findCurrent(target(), value);
2123 }
2124
2132 std::expected<void, ManagedError> replaceDocument(std::string_view bytes) const
2133 requires std::same_as<T, FindBar>
2134 {
2135 return detail::findDocument(target(), bytes);
2136 }
2137
2142 bool document(std::string_view bytes, std::source_location origin = std::source_location::current()) const
2143 requires std::same_as<T, FindBar>
2144 {
2145 auto observation = target();
2146 auto result = detail::findDocument(observation, bytes);
2147 if (!result) {
2148 detail::reportEventError(observation, result.error(), origin);
2149 }
2150 return result.has_value();
2151 }
2152
2158 EditorCommandResult clearQuery(std::source_location origin = std::source_location::current()) const
2159 requires std::same_as<T, FindBar>
2160 {
2161 return detail::findClear(target(), origin);
2162 }
2163
2165 bool clear(std::source_location origin = std::source_location::current()) const
2166 requires std::same_as<T, FindBar>
2167 {
2168 return static_cast<bool>(detail::findClear(target(), origin));
2169 }
2170
2175 Ref<LineEdit> editor() const
2176 requires std::same_as<T, FormField>
2177 {
2178 return detail::fieldEditor(target());
2179 }
2180
2185 TextProperty text(TextResolver resolver = {}, std::source_location origin = std::source_location::current()) const
2186 requires std::same_as<T, FormField>
2187 {
2188 return TextProperty(target(), std::move(resolver), "FormField", origin);
2189 }
2190
2195 std::expected<FieldValidation, ManagedError> validation() const
2196 requires std::same_as<T, FormField>
2197 {
2198 return detail::fieldValidation(target());
2199 }
2200
2208 std::expected<bool, ManagedError> validate() const
2209 requires std::same_as<T, FormField>
2210 {
2211 return detail::validateField(target());
2212 }
2213
2222 bool valid(std::source_location origin = std::source_location::current()) const
2223 requires std::same_as<T, FormField>
2224 {
2225 auto observation = target();
2226 auto result = detail::validateField(observation);
2227
2228 if (!result) {
2229 detail::reportEventError(observation, result.error(), origin);
2230 }
2231
2232 return result && *result;
2233 }
2234
2239 std::expected<void, ManagedError> display(FieldValidation value) const
2240 requires std::same_as<T, FormField>
2241 {
2242 return detail::displayField(target(), std::move(value));
2243 }
2244
2250 TextProperty text(ProgrammaticChange change, TextResolver resolver = {},
2251 std::source_location origin = std::source_location::current()) const
2252 requires std::same_as<T, LineEdit>
2253 {
2254 return TextProperty(target(), std::move(resolver), "LineEdit", origin, change);
2255 }
2256
2260 EditorCommandResult undo(std::source_location origin = std::source_location::current()) const
2261 requires std::same_as<T, LineEdit>
2262 {
2263 return detail::editorCommand(target(), false, false, origin);
2264 }
2265
2269 EditorCommandResult redo(std::source_location origin = std::source_location::current()) const
2270 requires std::same_as<T, LineEdit>
2271 {
2272 return detail::editorCommand(target(), true, false, origin);
2273 }
2274
2281 EditorCommandResult clear(std::source_location origin = std::source_location::current()) const
2282 requires std::same_as<T, LineEdit>
2283 {
2284 return detail::editorCommand(target(), false, false, origin, true);
2285 }
2286
2290 EditorCommandResult stopGrouping(std::source_location origin = std::source_location::current()) const
2291 requires std::same_as<T, LineEdit>
2292 {
2293 return detail::editorCommand(target(), false, true, origin);
2294 }
2295
2298 requires std::derived_from<T, Control>
2299 {
2300 return TextSource(target(), TextSource::Kind::CAPTION);
2301 }
2302
2306 auto visibleModel() const
2307 requires requires { typename detail::TableRowType<T>::Type; }
2308 {
2309 using Row = typename detail::TableRowType<T>::Type;
2310 auto node = this->slot_ ? std::shared_ptr<const Node<T>>(this->slot_, &this->slot_->node) : nullptr;
2311
2312 return VisibleModelSource<Row>(target(), std::move(node));
2313 }
2314
2319 requires requires { typename T::VirtualRow; };
2320
2323 requires std::same_as<T, LineEdit>
2324 {
2325 return TextSource(target(), TextSource::Kind::DRAFT);
2326 }
2327
2330 requires std::same_as<T, LineEdit>
2331 {
2332 return TextSource(target(), TextSource::Kind::COMMITTED);
2333 }
2334
2336 std::expected<HistoryAvailability, TreeError> historyAvailability() const
2337 requires std::same_as<T, LineEdit>
2338 {
2339 return detail::editorAvailability(target());
2340 }
2341
2343 bool canUndo() const
2344 requires std::same_as<T, LineEdit>
2345 {
2346 const auto value = historyAvailability();
2347
2348 return value && value->canUndo;
2349 }
2350
2352 bool canRedo() const
2353 requires std::same_as<T, LineEdit>
2354 {
2355 const auto value = historyAvailability();
2356
2357 return value && value->canRedo;
2358 }
2359
2360private:
2361 friend struct detail::ClickAccess;
2362 template <class U> friend class Ref;
2363 friend struct detail::AsyncAccess;
2364 friend struct detail::EditorEventAccess;
2365 friend struct detail::ChangeAccess;
2366 friend class KeyInfo;
2367 friend struct detail::KeyHelpAccess;
2368 friend struct detail::LayoutAccess;
2369 friend struct detail::NamedAccess;
2370 friend class DynamicRef;
2371 template <class U> friend class Description;
2372
2373 std::expected<void, ManagedError>
2374 focusOperation(std::expected<void, ManagedError> (ManagedScene::*operation)(Node<Widget>),
2375 std::source_location origin) const {
2376 auto observation = target();
2377 auto owner = detail::eventScene(observation);
2378
2379 if (!owner) {
2380 return std::unexpected(owner.error());
2381 }
2382
2383 auto result = ((*owner)->*operation)(this->node());
2384
2385 if (!result) {
2386 detail::reportFocusError(observation, result.error(), origin);
2387 }
2388
2389 return result;
2390 }
2391
2392 std::shared_ptr<detail::RefTarget> target() const {
2393 return this->slot_ ? std::shared_ptr<detail::RefTarget>(this->slot_, &this->slot_->target) : nullptr;
2394 }
2395};
2396
2397namespace detail {
2404 static StyleStage scopeStyle(const StyleStage &stage, std::shared_ptr<RefTarget> target);
2405
2409 static std::shared_ptr<RefTarget> target(const DynamicRef &reference);
2410
2415 static std::expected<NodeId, ManagedError> scope(ManagedScene &scene, const std::shared_ptr<RefTarget> &target) {
2416 auto owner = eventScene(target);
2417
2418 if (!owner) {
2419 auto failure = owner.error();
2420 failure.phase = ManagedPhase::STYLE;
2421
2422 return std::unexpected(failure);
2423 }
2424
2425 if (*owner != &scene) {
2426 return std::unexpected(ManagedError{ManagedPhase::STYLE, target->node.id(), TreeError::WRONG_SESSION, {}, {}});
2427 }
2428
2429 auto live = scene.boundary(ManagedPhase::STYLE, target->node);
2430
2431 return live ? std::expected<NodeId, ManagedError>(target->node.id()) : std::unexpected(live.error());
2432 }
2433
2438 static std::expected<Node<Widget>, ManagedError> observe(ManagedScene &scene,
2439 const std::shared_ptr<RefTarget> &source) {
2440 auto owner = eventScene(source);
2441
2442 if (!owner) {
2443 return std::unexpected(owner.error());
2444 }
2445
2446 if (*owner != &scene) {
2447 return std::unexpected(ManagedError{ManagedPhase::BIND, source->node.id(), TreeError::WRONG_SESSION, {}, {}});
2448 }
2449
2450 auto allowed = scene.boundary(ManagedPhase::BIND, source->node);
2451
2452 return allowed ? std::expected<Node<Widget>, ManagedError>(source->node) : std::unexpected(allowed.error());
2453 }
2454
2459 static std::expected<Node<Widget>, ManagedError> find(ManagedScene &scene, std::string_view name) {
2460 auto allowed = scene.boundary(ManagedPhase::BIND, scene.root_);
2461
2462 if (!allowed) {
2463 return std::unexpected(allowed.error());
2464 }
2465
2466 Node<Widget> found;
2467
2468 for (const auto &entry : scene.entries_) {
2469 if (entry->removed || !entry->target || entry->target->id != name || name.empty()) {
2470 continue;
2471 }
2472
2473 auto live = scene.app_.tree().read(entry->node, [](const Widget &) {
2474 });
2475
2476 if (!live && (live.error() == TreeError::STALE_NODE || live.error() == TreeError::CLOSED)) {
2477 continue;
2478 }
2479
2480 if (!live) {
2481 return std::unexpected(ManagedError{ManagedPhase::BIND, entry->node.id(), live.error(), {}, {}});
2482 }
2483
2484 if (found != Node<Widget>{}) {
2485 return std::unexpected(ManagedError{ManagedPhase::BIND, entry->node.id(), TreeError::INVALID_ARGUMENT, {}, {}});
2486 }
2487
2488 found = entry->node;
2489 }
2490
2491 if (found == Node<Widget>{}) {
2492 return std::unexpected(ManagedError{ManagedPhase::BIND, {}, TreeError::INVALID_ARGUMENT, {}, {}});
2493 }
2494
2495 return found;
2496 }
2497
2501 static std::expected<Node<LineEdit>, ManagedError> fieldDraft(ManagedScene &scene, Node<Widget> node) {
2502 Node<Widget> editor;
2503 auto checked = scene.app_.tree().read(node, [&](const Widget &widget) {
2504 if (const auto *field = dynamic_cast<const FormField *>(&widget)) {
2505 editor = field->editor();
2506 } else if (const auto *find = dynamic_cast<const FindBar *>(&widget)) {
2507 editor = find->editor();
2508 } else if (const auto *spin = dynamic_cast<const SpinBox *>(&widget)) {
2509 editor = spin->editor();
2510 } else if (const auto *choice = dynamic_cast<const ComboBox *>(&widget)) {
2511 editor = choice->editor();
2512 }
2513 });
2514
2515 if (!checked) {
2516 return std::unexpected(ManagedError{ManagedPhase::BIND, node.id(), checked.error(), {}, {}});
2517 }
2518
2519 Node<LineEdit> result;
2520
2521 checked = scene.app_.tree().read(editor, [&](const Widget &widget) {
2522 if (dynamic_cast<const LineEdit *>(&widget)) {
2523 result = Node<LineEdit>(editor.id());
2524 }
2525 });
2526
2527 return checked ? std::expected<Node<LineEdit>, ManagedError>(result)
2528 : std::unexpected(ManagedError{ManagedPhase::BIND, node.id(), checked.error(), {}, {}});
2529 }
2530
2537 template <class T>
2538 static std::expected<void, ManagedError> publish(const Ref<T> &reference, ManagedScene &scene, Node<Widget> node) {
2539 auto &slot = *reference.slot_;
2540 bool compatible{};
2541 Node<Control> caption;
2542 Node<LineEdit> draft;
2543 Node<Password> secret;
2544 auto checked = scene.app_.tree().read(node, [&](const Widget &widget) {
2545 if constexpr (std::same_as<T, Widget>) {
2546 compatible = true;
2547 } else {
2548 compatible = dynamic_cast<const T *>(&widget) != nullptr;
2549 }
2550
2551 if (dynamic_cast<const Control *>(&widget)) {
2552 caption = Node<Control>(node.id());
2553 }
2554
2555 if (dynamic_cast<const LineEdit *>(&widget)) {
2556 draft = Node<LineEdit>(node.id());
2557 }
2558 if (dynamic_cast<const Password *>(&widget)) {
2559 secret = Node<Password>(node.id());
2560 }
2561 });
2562
2563 if (!checked || !compatible) {
2564 return std::unexpected(
2565 ManagedError{ManagedPhase::BIND, node.id(), checked ? TreeError::INVALID_ARGUMENT : checked.error(), {}, {}});
2566 }
2567
2568 if constexpr (std::same_as<T, FormField> || std::same_as<T, FindBar> || std::same_as<T, SpinBox> ||
2569 std::derived_from<T, ComboBox>) {
2570 auto editor = fieldDraft(scene, node);
2571
2572 if (!editor) {
2573 return std::unexpected(editor.error());
2574 }
2575
2576 draft = *editor;
2577 }
2578
2579 slot.node = Node<T>(node.id());
2580 slot.target.scene = &scene;
2581 slot.target.lifetime = scene.lifetime_;
2582 slot.target.node = node;
2583 slot.target.caption = caption;
2584 slot.target.draft = draft;
2585 slot.target.secret = secret;
2586
2587 return {};
2588 }
2589
2594 template <class T> static void reject(const Ref<T> &reference, const ManagedError &failure) {
2595 reference.slot_->target.failure = std::make_shared<const ManagedError>(failure);
2596 }
2597
2602 static void report(ManagedScene &scene, ManagedError &failure, const LookupSource &source) {
2603 scene.reportShortError(failure, "scene.get", source.name, source.expectedType, source.origin);
2604 }
2605
2610 template <class T> static std::shared_ptr<RefTarget> target(const Ref<T> &reference) {
2611 return reference.target();
2612 }
2613
2618 template <class T> static Ref<T> request(const LookupSource &request) {
2619 Ref<T> reference;
2620 LookupSource source(request);
2621
2622 source.expectedType = typeid(T).name();
2623
2624 auto result =
2625 requestLookup(source, [reference](ManagedScene &scene, std::expected<Node<Widget>, ManagedError> node) {
2626 auto published =
2627 node ? publish(reference, scene, *node) : std::expected<void, ManagedError>(std::unexpected(node.error()));
2628
2629 if (!published) {
2630 reject(reference, published.error());
2631 }
2632
2633 return published;
2634 });
2635
2636 if (!result) {
2637 reject(reference, result.error());
2638 }
2639
2640 return reference;
2641 }
2642};
2643} // namespace detail
2644
2649class DynamicRef {
2650public:
2655 template <class T>
2656 requires std::derived_from<T, Widget>
2657 operator Ref<T>() const {
2658 auto source = source_;
2659
2660 source.observation = detail::NamedAccess::target(reference_);
2661
2662 return detail::NamedAccess::request<T>(source);
2663 }
2664
2669 TextProperty text(TextResolver resolver = {}, std::source_location origin = std::source_location::current()) const {
2670 return TextProperty(reference_.target(), std::move(resolver), "Widget", origin);
2671 }
2672
2678 template <class Callback = detail::QuitCommand>
2680 std::expected<void, ManagedError> onClick(Callback callback,
2681 std::source_location origin = std::source_location::current()) const {
2682 Ref<Button> typed = *this;
2683
2684 return typed.onClick(std::move(callback), origin);
2685 }
2686
2688 Node<Widget> node() const noexcept {
2689 return reference_.node();
2690 }
2691
2692private:
2693 friend class Scene;
2694 friend struct detail::NamedAccess;
2695
2696 explicit DynamicRef(const detail::LookupSource &source)
2697 : source_(source), reference_(detail::NamedAccess::request<Widget>(source_)) {
2698 }
2699
2700 detail::LookupSource source_;
2701 Ref<Widget> reference_;
2702};
2703
2704inline std::shared_ptr<detail::RefTarget> detail::NamedAccess::target(const DynamicRef &reference) {
2705 return reference.reference_.target();
2706}
2707
2708} // namespace portals::ui
Frame using the existing vertical LinearLayout with one-cell insets for each present side....
Definition primitives.hpp:105
One-line button; registration is an explicit caller-owned ActionBinding.
Definition controls.hpp:161
Owning accepted row identity and bounded label, independent of editor draft and source lifetime.
Definition combo_box.hpp:19
Retained editable model-backed choice; the tree owns its ordinary editor and trigger.
Definition combo_box.hpp:39
UI-owned one-line control with owning Unicode text and local paint coordinates. Mutate through the fr...
Definition controls.hpp:39
Retained Column composition of status and content; it owns no provider, cache or second runtime.
Definition data_presentation.hpp:102
Full-host structural root containing at most one visible opaque panel. This is deliberately not a Siz...
Definition dialog.hpp:102
Read-only retained document viewport; source I/O, decoding and layout run on application workers....
Definition document_view.hpp:97
Owning checked editor command, preserving exactly its collector reporting receipt....
Definition editor_command.hpp:23
Retained query/navigation/count composition over owning document or model search results....
Definition find_bar.hpp:118
Owning immutable selected range; retains original data, never a scene or widget. Empty handles repres...
Definition find_bar.hpp:64
Retained label/editor/help/message composition using the ordinary vertical layout....
Definition form_field.hpp:73
Noninteractive horizontal determinate gauge with widget-owned fill text. Paint has no owning allocati...
Definition primitives.hpp:193
Ordinary nonmodal focus-scope container; its sole content is an existing ScrollArea.
Definition help_view.hpp:31
Noninteractive Unicode label; text remains data, including control characters.
Definition controls.hpp:142
UI-owned Unicode draft; mutate only through its scoped binding between frames. Cursor/anchor are UTF-...
Definition line_edit.hpp:205
Native bounded plain-text log with whole-grapheme wrap and a stable reading anchor....
Definition log_view.hpp:64
Weak UI handle to a model owned by one ManagedScene. Handles may be copied and destroyed on any threa...
Definition managed_model.hpp:120
Additive lifecycle owner over one existing Application subtree. UI affine and nonmovable....
Definition managed.hpp:530
std::expected< void, ManagedError > focus(Node< Widget > node)
Enter a scope or focus an ordinary registered control through the same blur path.
std::expected< void, ManagedError > leaveFocusScope(Node< Widget > node)
Leave the top focus-return scope; callback errors retain the published return.
std::expected< void, ManagedError > enterFocusScope(Node< Widget > node)
Enter a declared scope while saving exact previous focus in the existing router. This focus-only oper...
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Node()=default
Empty observer; checked access fails.
NodeId id() const noexcept
Copy the stable diagnostic identity.
Definition widget.hpp:109
Copyable identity of immutable logical bytes in protected native storage.
Definition password_value.hpp:44
Protected single-line editor with numeric metadata and constant-mask frame data. The draft and snapsh...
Definition password.hpp:74
Sized action-backed popup plane, owned by one private managed Dialog activation. Use ui::popupMenu as...
Definition popup_menu.hpp:50
Ordinary one-focus-stop, model-owned resident radio group with clipped row painting.
Definition radio_group.hpp:86
Lay visible children from left to right.
Definition layout.hpp:250
Retained ordinary content owner with optional one-cell frame and embedded bars. Add one content root ...
Definition scroll_controls.hpp:49
Independent one-axis projection of an owning controller, without a content offset....
Definition scroll_controls.hpp:127
Synchronous read-only byte borrow, valid only during its callback.
Definition secure_string.hpp:195
Horizontal numeric view using the existing control style, layout and input runtime....
Definition slider.hpp:61
Numeric editor with one ordinary LineEdit and two nonfocusable step buttons. The containing tree owns...
Definition spin_box.hpp:18
Retained indeterminate indicator using the receiving scene's existing scheduler. Construct through ui...
Definition spinner.hpp:115
One-line boolean switch using the ordinary CheckBox binding and theme.
Definition controls.hpp:383
Owning literal bytes or a resource key, measured only at resolution.
Definition text_value.hpp:42
Copyable worker-safe endpoint for short, always deferred UI commands. The callback and its captures s...
Definition ui_delivery.hpp:77
UiEndpoint()=default
Construct an empty closed endpoint.
One UI-owned view with bounded owning row text and one independent model consumer....
Definition virtual_list.hpp:133
Bounded real widget subtrees, independent of the text-only VirtualList.
Definition virtual_rows.hpp:136
One UI-owned table with bounded owning cell text and one independent model consumer....
Definition virtual_table.hpp:154
UI-owned extension object. Hooks borrow their arguments for one call. Models are separate explicit ow...
Definition widget.hpp:32
Switch bool property observing the original Ref slot; never owns a widget or scene....
Definition ui_ref.hpp:422
CheckedProperty operator=(bool value)
Definition ui_ref.hpp:462
std::expected< PropertyUpdate< bool >, ManagedError > result() const
Definition ui_ref.hpp:474
CheckedProperty(const CheckedProperty &)=default
Copy an observation without reading or changing either model.
CheckedProperty operator=(const CheckedProperty &source)
Copy the source bool into this original destination; never rebind either proxy.
Definition ui_ref.hpp:432
std::expected< bool, ManagedError > get() const
Definition ui_ref.hpp:446
std::expected< PropertyUpdate< bool >, ManagedError > set(bool value, std::source_location origin=std::source_location::current())
Definition ui_ref.hpp:453
CheckedProperty(CheckedProperty &&)=default
Transfer an observation; the source remains a valid empty/moved observation.
Single-use owning construction recipe; no mounted widget ownership.
Definition ui_description.hpp:48
Owning checked command that also permits the admitted short callback form. This is a narrow facade re...
Definition dialog_command_result.hpp:20
Owning cold source descriptor; copies retain the same provider, revision namespace and budget....
Definition ui_document_view.hpp:17
Dynamic named observation with checked caption/editor and Button capabilities. Copies own the request...
Definition ui_ref.hpp:2649
Node< Widget > node() const noexcept
Definition ui_ref.hpp:2688
TextProperty text(TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2669
std::expected< void, ManagedError > onClick(Callback callback, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2680
Consuming metadata for one canonical annotated registration; refs resolve after complete mount.
Definition ui_key_info.hpp:10
Owning deferred external log binding; construction performs no file I/O. Copies share the provider an...
Definition ui_log_view.hpp:48
Owning cold model declaration; copies share one single-scene registration. Construction does not read...
Definition ui_model.hpp:129
Node< T > node() const noexcept
Definition ui_ref.hpp:731
NodeRef()
Allocate an empty observing slot, with no widget ownership.
Definition ui_ref.hpp:727
Weak numeric property facade with an owning saved operation observation. Mutation returns a new obser...
Definition ui_ref.hpp:333
NumericProperty(const NumericProperty &other)=default
NumericProperty operator=(const NumericProperty &other)
std::expected< double, ManagedError > get() const
std::expected< PropertyUpdate< NumericValue >, ManagedError > result() const
NumericProperty set(double value, std::source_location origin=std::source_location::current())
NumericProperty operator=(double value)
NumericProperty(NumericProperty &&other)=default
Typed Widget observation; explicit composite specializations reuse their existing weak facades.
Definition ui_ref.hpp:761
std::expected< bool, ManagedError > opened() const
Definition ui_ref.hpp:2012
bool model(Model< Value > source, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1190
std::expected< void, ManagedError > leaveFocusScope(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1959
std::expected< void, ManagedError > close(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1020
std::expected< DocumentViewStatus, ManagedError > status() const
Definition ui_ref.hpp:1748
std::expected< void, ManagedError > goEnd(std::source_location origin=std::source_location::current()) const
Admit a one-shot boundary navigation command.
Definition ui_ref.hpp:1551
std::expected< void, ManagedError > seekByte(std::uint64_t offset, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1417
std::expected< void, ManagedError > withPlaintext(F &&callback, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:944
bool model(const DocumentSource &source, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1402
std::expected< UiEndpoint< Value >, ManagedError > delivery(Callback callback, std::source_location origin=std::source_location::current()) const
Register a checked, node-scoped worker-to-UI delivery endpoint.
Definition ui_ref.hpp:818
bool end(std::source_location origin=std::source_location::current()) const
Admit a one-shot boundary navigation command.
Definition ui_ref.hpp:1562
std::expected< bool, ManagedError > validate() const
Definition ui_ref.hpp:2208
DialogCommandResult open(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1902
std::expected< void, ManagedError > display(FieldValidation value) const
Definition ui_ref.hpp:2239
bool lineNumbers(bool enabled, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1716
std::expected< void, ManagedError > setMode(DocumentViewMode value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1582
std::expected< void, ManagedError > enterFocusScope(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1950
std::expected< void, ManagedError > onLayout(Callback callback, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1818
std::optional< DocumentViewStatus > currentStatus(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1755
std::expected< ChoiceSelection, ManagedError > selection() const
Definition ui_ref.hpp:2005
std::expected< FindMatch, ManagedError > match() const
Definition ui_ref.hpp:2109
TextProperty text(TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2185
bool language(std::string_view name, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1669
std::expected< void, ManagedError > value(PasswordValue value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:929
bool reload(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1447
bool page(std::int64_t pages, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1504
std::expected< void, ManagedError > setLineNumbers(bool enabled, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1704
std::expected< void, ManagedError > focus(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1895
std::expected< void, ManagedError > setLanguage(DocumentLanguage value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1633
bool canUndo() const
Definition ui_ref.hpp:2343
std::expected< void, ManagedError > scrollPages(std::int64_t pages, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1491
Model< VirtualRowsPosition > position() const
Definition ui_virtual_rows.hpp:841
std::expected< void, ManagedError > label(const TextValue &value, const TextResolver &resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1004
std::expected< LogStatus, ManagedError > status() const
Definition ui_ref.hpp:1379
std::expected< std::optional< PositionResolution >, ManagedError > restoreStatus(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1298
TextSource captionText() const
Definition ui_ref.hpp:2297
std::expected< void, ManagedError > onClick(Callback action, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1851
bool clear(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1366
EditorCommandResult stopGrouping(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2290
std::expected< void, ManagedError > clearLog(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1347
bool model(Model< Row > source, ModelRebindOptions options={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1231
std::expected< void, ManagedError > setModel(Model< Value > source, std::source_location origin=std::source_location::current()) const
Replace a scalar caption source while preserving its original projection.
Definition ui_value_model.hpp:744
TextProperty text(TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1968
std::expected< void, ManagedError > setModel(ManagedModel< Row > source, ModelRebindOptions options, std::type_identity_t< std::optional< ManagedViewHandler< Row > > > prepared=std::nullopt, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1249
DialogCommandResult open(const Ref< Anchor > &anchor, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1926
std::expected< void, ManagedError > setModel(const LogSource &source, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1079
std::expected< void, ManagedError > open(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2019
bool byte(std::uint64_t offset, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1428
TextProperty text(ProgrammaticChange change, TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2250
std::expected< FindMatch, ManagedError > navigate(FindDirection direction) const
Definition ui_ref.hpp:2078
std::expected< void, ManagedError > setLanguage(std::string_view name, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1643
std::expected< void, ManagedError > setModel(const WindowRowsModel< Row > &source, ModelRebindOptions options={}, std::source_location origin=std::source_location::current()) const
Replace native window delivery without inventing extent or remounting the host.
Definition ui_virtual_rows.hpp:906
bool next(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2085
Ref< LineEdit > editor() const
Definition ui_ref.hpp:1985
std::expected< NodeGeometry, ManagedError > geometry() const
Definition ui_ref.hpp:1798
std::expected< void, TreeError > display(DataPresentation value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1883
bool canRedo() const
Definition ui_ref.hpp:2352
std::expected< CellSize, ManagedError > size() const
Definition ui_ref.hpp:1803
bool append(std::string_view bytes, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1064
EditorCommandResult redo(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2269
DialogCommandResult dismiss(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1911
std::expected< LogAppendReceipt, ManagedError > appendBatch(std::string_view bytes, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1042
bool model(Model< Row > source, ModelRebindOptions options={}, std::source_location origin=std::source_location::current()) const
Definition ui_virtual_rows.hpp:895
bool home(std::source_location origin=std::source_location::current()) const
Admit a one-shot boundary navigation command.
Definition ui_ref.hpp:1533
std::expected< HistoryAvailability, TreeError > historyAvailability() const
Definition ui_ref.hpp:2336
EditorCommandResult undo(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2260
std::expected< void, ManagedError > setModel(ManagedModel< Row > source, std::type_identity_t< std::optional< ManagedViewHandler< Row > > > prepared=std::nullopt, std::source_location origin=std::source_location::current(), ModelRebindOptions options={}) const
Replace a virtual list/table model with the same row type, retaining the node and presentation.
Definition ui_ref.hpp:1148
std::expected< void, ManagedError > refresh(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1440
std::expected< void, ManagedError > setOffset(ScrollAxis axis, ScrollOffset offset, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1031
bool model(const LogSource &source, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1089
std::expected< void, ManagedError > select(ChoiceSelection value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2048
std::expected< void, ManagedError > stop(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:980
std::expected< bool, ManagedError > opened() const
Definition ui_ref.hpp:1934
std::expected< void, ManagedError > setModel(Model< Row > source, ModelRebindOptions options={}, std::source_location origin=std::source_location::current()) const
Replace a delegated host's finite model while retaining its node.
Definition ui_model.hpp:1041
auto visibleModel() const
Definition ui_ref.hpp:2306
std::expected< void, ManagedError > dismiss(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2026
std::expected< void, ManagedError > followTail(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1315
EditorCommandResult activate(std::source_location origin=std::source_location::current()) const
Invoke the existing semantic button route synchronously on UI; focus is unchanged.
Definition ui_ref.hpp:856
std::expected< void, ManagedError > ensureVisible(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1790
TextProperty text(TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2066
Ref()
Allocate an empty observing slot on the UI thread; may throw std::bad_alloc.
Definition ui_ref.hpp:766
std::expected< void, ManagedError > value(double value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:867
std::expected< void, ManagedError > setModel(const ValueText &source, std::source_location origin=std::source_location::current()) const
Definition ui_value_text.hpp:512
std::expected< RadioGroupValue, ManagedError > value() const
Definition ui_ref.hpp:782
std::expected< void, ManagedError > setHexOptions(DocumentHexOptions options, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1607
bool language(DocumentLanguage value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1653
std::expected< void, ManagedError > clearSelection(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2056
TextSource committedText() const
Definition ui_ref.hpp:2329
std::expected< FieldValidation, ManagedError > validation() const
Definition ui_ref.hpp:2195
std::expected< void, ManagedError > setMetrics(ScrollAxisMetrics metrics, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1771
std::expected< void, ManagedError > open(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1013
Ref< LineEdit > editor() const
Definition ui_ref.hpp:2175
CheckedProperty checked(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:773
TextProperty text(TextResolver resolver={}, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1998
bool scroll(std::int64_t rows, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1473
EditorCommandResult clear(std::source_location origin=std::source_location::current()) const
Clear the visible draft as one user operation, applying the configured EditMode.
Definition ui_ref.hpp:2281
bool model(ManagedModel< Row > source, ModelRebindOptions options, std::type_identity_t< std::optional< ManagedViewHandler< Row > > > prepared=std::nullopt, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1283
std::expected< void, ManagedError > scrollRows(std::int64_t rows, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1461
std::expected< void, ManagedError > label(std::string_view value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:991
std::expected< PropertyUpdate< RadioGroupValue >, ManagedError > select(std::optional< RowId > id, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:793
bool syntax(DocumentSyntaxPolicy policy, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1688
TextSource draftText() const
Definition ui_ref.hpp:2322
bool toggleLineNumbers(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1733
EditorCommandResult clearQuery(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2158
std::expected< void, ManagedError > start(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:970
std::expected< PasswordValue, ManagedError > value(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:920
bool mode(DocumentViewMode value, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1592
bool model(const WindowRowsModel< Row > &source, ModelRebindOptions options={}, std::source_location origin=std::source_location::current()) const
Definition ui_virtual_rows.hpp:932
bool model(ManagedModel< Row > source, std::type_identity_t< std::optional< ManagedViewHandler< Row > > > prepared=std::nullopt, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1264
std::expected< void, ManagedError > goHome(std::source_location origin=std::source_location::current()) const
Admit a one-shot boundary navigation command.
Definition ui_ref.hpp:1522
bool valid(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2222
std::expected< bool, ManagedError > current(const FindMatch &value) const
Definition ui_ref.hpp:2119
bool document(std::string_view bytes, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2142
std::expected< void, ManagedError > select(std::uint64_t index, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2037
std::expected< void, ManagedError > setModel(const DocumentSource &source, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1391
bool tail(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1334
std::expected< void, ManagedError > adjust(double delta, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:908
bool previous(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2097
bool hexOptions(DocumentHexOptions options, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1617
Ref< LineEdit > lineEdit() const
Definition ui_ref.hpp:896
bool clear(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:2165
std::expected< void, ManagedError > replaceDocument(std::string_view bytes) const
Definition ui_ref.hpp:2132
NumericProperty value(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:879
SpinBoxNumericProperty value(std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:888
std::expected< void, ManagedError > setSyntax(DocumentSyntaxPolicy policy, std::source_location origin=std::source_location::current()) const
Definition ui_ref.hpp:1678
Single-use lazy owner of one Application and ManagedScene; no second runtime. Construct and operate o...
Definition ui_scene.hpp:253
Numeric draft assignment observation. The saved result distinguishes draft acceptance from publicatio...
Definition ui_ref.hpp:384
SpinBoxNumericProperty operator=(double value)
SpinBoxNumericProperty(SpinBoxNumericProperty &&other)=default
std::expected< SpinBoxResult, ManagedError > result() const
SpinBoxNumericProperty set(double value, std::source_location origin=std::source_location::current())
std::expected< double, ManagedError > get() const
SpinBoxNumericProperty(const SpinBoxNumericProperty &other)=default
SpinBoxNumericProperty operator=(const SpinBoxNumericProperty &other)
Copyable immutable owning style payload with one shared stage identity. Independent unnamed stages co...
Definition ui_style.hpp:39
Copyable observing text property; copies own their resolver and last-operation result....
Definition ui_ref.hpp:585
TextProperty operator=(const TextResult &value)
TextResult operator+(const TextProperty &value) const
TextProperty operator=(const TextValue &value)
TextProperty(TextProperty &&other)=default
TextResult operator+(const TextResult &value) const
TextSource source() const
Definition ui_ref.hpp:590
TextProperty set(const TextValue &value, std::source_location origin=std::source_location::current())
TextProperty(const TextProperty &other)=default
TextProperty append(const TextValue &value, std::source_location origin=std::source_location::current())
TextProperty operator=(const TextProperty &value)
std::expected< std::string, ManagedError > get() const
Copy validated UTF-8 text out of the live widget without retaining its storage.
TextResult operator+(std::string_view value) const
TextProperty operator+=(const TextResult &value)
TextProperty operator+=(std::string_view value)
TextResult operator+(const TextValue &value) const
std::expected< void, ManagedError > result() const
Inspect the last mutation of this particular proxy; newly created proxies have success.
TextProperty set(std::string_view value, std::source_location origin=std::source_location::current())
TextProperty operator=(std::string_view value)
TextProperty append(std::string_view value, std::source_location origin=std::source_location::current())
TextProperty operator+=(const TextValue &value)
Owning read-only concatenation, including the original typed failure when reading fails....
Definition ui_ref.hpp:534
TextResult operator+(const TextValue &value) const
TextResult operator+(std::string_view value) const
std::expected< GraphemeText, ManagedError > result() const
TextResult operator+(const TextResult &value) const
TextResult operator+(const TextProperty &value) const
Copyable read-only source observing one caption, visible draft or accepted editor model....
Definition ui_ref.hpp:302
std::expected< GraphemeText, ManagedError > snapshot() const
Owning cold formatted text with explicit scalar dependencies, separate from its input roots....
Definition ui_value_text.hpp:37
Copyable deferred observation of one original table, without scene/widget ownership.
Definition ui_ref.hpp:503
std::expected< VisibleModelSnapshot< T >, VisibleModelError > snapshot() const
Definition ui_ref.hpp:506
A compact action optionally receives owning event parameters.
Definition managed.hpp:239
Public Portals API.
Definition action.hpp:8
DocumentSyntaxPolicy
Recovery policy; the language still selects the lexical rules.
Definition document_highlight_types.hpp:31
std::variant< ManagedError, VisibleModelReadError > VisibleModelError
Exact scene access failure or owning table preparation/provider failure.
Definition managed.hpp:43
DocumentViewMode
Projection of the same original source bytes.
Definition document_view.hpp:37
DocumentLanguage
Explicit lexical profiles; unknown names resolve to PLAIN.
Definition document_highlight_types.hpp:11
@ COMMITTED
Confirmation completed Property::set; inspect its exact receipt.
Definition line_edit.hpp:83
FindDirection
Direction through the stored bounded prefix; both directions wrap.
Definition find_bar.hpp:26
@ PREVIOUS
Retreat, wrapping the first stored match to the last.
Definition find_bar.hpp:28
@ NEXT
Advance, wrapping the last stored match to the first.
Definition find_bar.hpp:27
@ STYLE
Register or apply styles, including a theme change.
Definition managed_diagnostics.hpp:52
@ BIND
Register a managed callback, binding or presentation adapter.
Definition managed_diagnostics.hpp:51
@ TEXT
Read or mutate a fluent caption/editor draft through a checked observing reference.
Definition managed_diagnostics.hpp:57
ScrollAxis
Logical scrolling axis; X increases right and Y increases down.
Definition scroll_geometry.hpp:15
DocumentLanguage documentLanguageFromName(std::string_view name) noexcept
ProgrammaticChange
History policy of an explicit programmatic text change.
Definition line_edit.hpp:41
std::function< std::expected< void, TreeError >(const ModelFrame< T > &, const std::optional< ModelRequest< T > > &)> ManagedViewHandler
Owning callback after each successful virtual-view preparation, including layout retries....
Definition managed_model.hpp:25
@ CLOSED
The owning tree or source is closed.
Definition widget_types.hpp:31
@ CALLBACK_FAILED
A user extension or callback threw.
Definition widget_types.hpp:37
@ WRONG_SESSION
An identity or scope belongs to another tree/scheduler.
Definition widget_types.hpp:29
@ STALE_NODE
The observed node or model consumer is absent or retired.
Definition widget_types.hpp:30
@ INVALID_ARGUMENT
An option, enum value or operation argument is invalid.
Definition widget_types.hpp:27
@ NO_MEMORY
Allocation failed inside the operation boundary.
Definition widget_types.hpp:33
Owning scalar state of one immutable presentation producer.
Definition data_presentation.hpp:21
Fixed raw-byte rows; auto-fit may choose a smaller row at preparation time.
Definition document_view.hpp:43
Owning validation presentation; messages remain meaningful without color.
Definition form_field.hpp:25
Original error plus independent runner/restoration and cleanup failures.
Definition managed_diagnostics.hpp:62
Explicit rebinding policy; omitted history options inherit the session's settings.
Definition managed_navigation.hpp:44
Owning arranged geometry; invalid geometry must never be used for hit-testing.
Definition widget_types.hpp:48
A successful set result; notification rejection does not undo the committed value....
Definition property.hpp:38
Owning one-axis logical metrics, independent of materialized content.
Definition scroll_geometry.hpp:41
Owning exact integral position and sub-cell remainder; no affinity or invalidation.
Definition scroll_geometry.hpp:35
Owning committed row-host orientation; native cursor sources never invent ordinals.
Definition virtual_rows.hpp:53
Cold native window delivery capability, with no invented finite extent/current.
Definition ui_virtual_rows.hpp:364
Internal bridge for checked access to managed scene and recipe state.
Definition ui_recipe_access.hpp:28
Checked registration bridge to the checkbox's sole managed binding.
Definition ui_event_access.hpp:105
Checked adapter to the managed-owned click chain; never owns a widget or scene.
Definition ui_event_access.hpp:36
Checked registration bridge to the editor's existing managed-owned binding.
Definition ui_event_access.hpp:71
Checked adapter to managed-owned layout observations; never owns a widget or scene.
Definition ui_event_access.hpp:11
Owning request identity; the facade and its widgets remain weakly observed.
Definition ui_ref.hpp:46
std::string name
Case-sensitive ID; fallible default construction stays checked.
Definition ui_ref.hpp:52
std::weak_ptr< SceneAnchor > anchor
Stable facade publication, revoked before cleanup.
Definition ui_ref.hpp:50
std::thread::id owner
Immutable originating UI thread.
Definition ui_ref.hpp:51
~LookupSource()=default
Suppress implicit noexcept moves; checked MSVC string transfers can allocate.
const char * expectedType
Static RTTI label for typed diagnostic context.
Definition ui_ref.hpp:54
std::shared_ptr< RefTarget > observation
Optional original dynamic slot for identity-preserving conversion.
Definition ui_ref.hpp:55
std::source_location origin
Original lookup site.
Definition ui_ref.hpp:53
Internal checked named publication bridge; no widget or scene ownership escapes.
Definition ui_ref.hpp:2399
static std::expected< Node< LineEdit >, ManagedError > fieldDraft(ManagedScene &scene, Node< Widget > node)
Definition ui_ref.hpp:2501
static std::expected< NodeId, ManagedError > scope(ManagedScene &scene, const std::shared_ptr< RefTarget > &target)
Definition ui_ref.hpp:2415
static Ref< T > request(const LookupSource &request)
Definition ui_ref.hpp:2618
static std::shared_ptr< RefTarget > target(const DynamicRef &reference)
Definition ui_ref.hpp:2704
static void report(ManagedScene &scene, ManagedError &failure, const LookupSource &source)
Definition ui_ref.hpp:2602
static std::expected< Node< Widget >, ManagedError > find(ManagedScene &scene, std::string_view name)
Definition ui_ref.hpp:2459
static std::shared_ptr< RefTarget > target(const Ref< T > &reference)
Definition ui_ref.hpp:2610
static std::expected< void, ManagedError > publish(const Ref< T > &reference, ManagedScene &scene, Node< Widget > node)
Definition ui_ref.hpp:2538
static void reject(const Ref< T > &reference, const ManagedError &failure)
Definition ui_ref.hpp:2594
static std::expected< Node< Widget >, ManagedError > observe(ManagedScene &scene, const std::shared_ptr< RefTarget > &source)
Definition ui_ref.hpp:2438
static StyleStage scopeStyle(const StyleStage &stage, std::shared_ptr< RefTarget > target)
Definition ui_style.hpp:208
Shared observation; publication and all mutable fields belong to the constructing UI thread.
Definition ui_ref.hpp:71
const std::thread::id owner
Immutable affinity checked before mutable fields.
Definition ui_ref.hpp:72
Node< Widget > node
Published identity, never automatically reset.
Definition ui_ref.hpp:75
Node< Password > secret
Protected editor identity; never grants plaintext access.
Definition ui_ref.hpp:79
std::weak_ptr< const void > lifetime
Does not retain the scene or its widgets.
Definition ui_ref.hpp:74
Node< LineEdit > draft
Typed editor identity, empty for other widgets.
Definition ui_ref.hpp:78
std::shared_ptr< const ManagedError > failure
Owning failure, allocated only for a rejected named request.
Definition ui_ref.hpp:77
Node< Control > caption
Typed caption identity, empty for other widgets.
Definition ui_ref.hpp:76
ManagedScene * scene
Borrowed only while lifetime remains live on UI.
Definition ui_ref.hpp:73
Stable weak facade publication; mutable fields are accessed only after UI admission.
Definition ui_scene.hpp:209
T Type
Domain value retained by each model row.
Definition ui_ref.hpp:173
Definition ui_ref.hpp:169