.. index:: pair: class; EE::UI::UIBindingGroup .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group: class EE::UI::UIBindingGroup ============================ .. toctree:: :hidden: struct_EE_UI_UIBindingGroup_Entry.rst struct_EE_UI_UIBindingGroup_Error.rst struct_EE_UI_UIBindingGroup_ObservableEntry.rst struct_EE_UI_UIBindingGroup_PropertyEntry.rst struct_EE_UI_UIBindingGroup_RawEntry.rst Overview ~~~~~~~~ Owns heterogeneous bindings and exposes aggregate form state. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class UIBindingGroup { public: // typedefs typedef :ref:`SmallVector`<:ref:`Error`, 4> :ref:`Errors`; typedef :ref:`SmallVector`<:ref:`UIWidget`*, 4> :ref:`Widgets`; typedef std::function :target:`Callback`; // structs struct :ref:`Entry`; struct :ref:`Error`; template struct :ref:`ObservableEntry`; template struct :ref:`PropertyEntry`; template struct :ref:`RawEntry`; // construction :target:`UIBindingGroup`(); :target:`UIBindingGroup`(const UIBindingGroup&); :target:`UIBindingGroup`(UIBindingGroup&&); :target:`~UIBindingGroup`(); // methods UIBindingGroup& :target:`operator=`(const UIBindingGroup&); UIBindingGroup& :target:`operator=`(UIBindingGroup&&); template UIBindingGroup& :ref:`hold`(:ref:`UIValueBinding`&& binding); template UIBindingGroup& :target:`operator+=`(:ref:`UIValueBinding`&& binding); template UIBindingGroup& :ref:`hold`(std::unique_ptr<:ref:`UIDataBind`> binding); template UIBindingGroup& :target:`operator+=`(std::unique_ptr<:ref:`UIDataBind`> binding); template UIBindingGroup& :ref:`hold`(:ref:`UIProperty`& property); template UIBindingGroup& :ref:`operator+=`(:ref:`UIProperty`& property); bool :ref:`isValid`() const; bool :ref:`isDirty`() const; :ref:`ObservableValue`& :ref:`validValue`(); :ref:`ObservableValue`& :ref:`dirtyValue`(); :ref:`Errors` :ref:`errors`() const; :ref:`Widgets` :ref:`widgets`() const; :ref:`UIWidget`* :ref:`firstInvalidWidget`() const; void :ref:`markClean`(); void :ref:`reset`(); void :ref:`clear`(); std::size_t :ref:`size`() const; void :ref:`onChange`(:ref:`Callback` callback); }; .. _details-class_e_e_1_1_u_i_1_1_u_i_binding_group: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Owns heterogeneous bindings and exposes aggregate form state. Dirty state compares live values with explicit per-binding baselines. The group owns bindings, but never owns their widgets or model values. Disabled widgets are excluded from aggregate validation. :ref:`clear() ` and destruction disconnect all bindings. .. ref-code-block:: cpp UIBindingGroup form; form += bindValue( name, nameInput, requiredName ); form += bindValue( port, portInput, validPort ); auto canSave = computedValue( form.validValue(), form.dirtyValue(), []( bool valid, bool dirty ) { return valid && dirty; } ); Typedefs -------- .. index:: pair: typedef; Errors .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1aa862c4e90978947baa2ea2db13aa3b21: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef :ref:`SmallVector`<:ref:`Error`, 4> Errors Inline-backed error collection sized for ordinary forms. .. index:: pair: typedef; Widgets .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1ae7ac8076b0f64ecd614cb5d32ae1fc4e: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef :ref:`SmallVector`<:ref:`UIWidget`*, 4> Widgets Inline-backed widget collection sized for ordinary forms. Methods ------- .. index:: pair: function; hold .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a4dc4700c338341f6e1a4794f097e98a1: .. ref-code-block:: cpp :class: doxyrest-title-code-block template UIBindingGroup& hold(:ref:`UIValueBinding`&& binding) Adds and takes ownership of a typed binding. .. rubric:: Returns: This group, allowing several bindings to be added in one expression. .. index:: pair: function; hold .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a4046ce76823dd7e4b1e2c349c2fbcad0: .. ref-code-block:: cpp :class: doxyrest-title-code-block template UIBindingGroup& hold(std::unique_ptr<:ref:`UIDataBind`> binding) Adds and takes ownership of a legacy :ref:`UIDataBind `. .. index:: pair: function; hold .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a33b77ef1b1fe8bbc01a160c85b415f24: .. ref-code-block:: cpp :class: doxyrest-title-code-block template UIBindingGroup& hold(:ref:`UIProperty`& property) Tracks a :ref:`UIProperty ` without taking ownership of it. The entry expires safely if ``property`` is destroyed first. Its current value becomes the initial clean baseline. .. index:: pair: function; operator+= .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a7f6865c3cda15f54a2a6cdf9de7f1032: .. ref-code-block:: cpp :class: doxyrest-title-code-block template UIBindingGroup& operator+=(:ref:`UIProperty`& property) Convenience form of :ref:`hold(UIProperty\&) `. .. index:: pair: function; isValid .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a55dbe3acb1ea774a99d189d46812eed9: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isValid() const Disabled fields are intentionally ignored, which supports conditional form sections. .. rubric:: Returns: true when every binding attached to an enabled widget is valid. .. index:: pair: function; isDirty .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1ad3bb25f634316302862c79247d9f33d9: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isDirty() const .. rubric:: Returns: true when at least one value differs from its current clean baseline. .. index:: pair: function; validValue .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a54dbf49593fccc3c43ec7c7d492722fc: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ObservableValue`& validValue() .. rubric:: Returns: Observable aggregate validity, suitable for computed values and commands. .. index:: pair: function; dirtyValue .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1af9726cbce15bdc50d1a06766124ed572: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ObservableValue`& dirtyValue() .. rubric:: Returns: Observable aggregate dirty state, suitable for computed values and commands. .. index:: pair: function; errors .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a0f3efe5133cf634898661bf955de7940: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Errors` errors() const .. rubric:: Returns: Invalid enabled bindings in insertion order. .. index:: pair: function; widgets .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1aed7f71c6c59a3c75baf64ac2967a66fb: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Widgets` widgets() const The order within a legacy multi-widget :ref:`UIDataBind ` or :ref:`UIProperty ` is unspecified. .. rubric:: Returns: Connected widgets grouped by binding insertion order. .. index:: pair: function; firstInvalidWidget .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1ace8e8eb0d9da12b95b1bd8ef01b96b94: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`UIWidget`* firstInvalidWidget() const .. rubric:: Returns: The first invalid enabled widget in insertion order, or nullptr. .. index:: pair: function; markClean .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a622520262bd13b13747ba9436985fff3: .. ref-code-block:: cpp :class: doxyrest-title-code-block void markClean() Makes every binding's current value its new clean/reset baseline. .. index:: pair: function; reset .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a8ab3ae0380b97aa8ae061a71c6ac537c: .. ref-code-block:: cpp :class: doxyrest-title-code-block void reset() Restores every binding to the baseline recorded at insertion or :ref:`markClean() `. .. index:: pair: function; clear .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1a7c6f0be6fccfd8c6b9ea5ab713c47e75: .. ref-code-block:: cpp :class: doxyrest-title-code-block void clear() Destroys all owned bindings and resets aggregate state. .. index:: pair: function; size .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1afc2782272ec3065a164e1b9f4347301d: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::size_t size() const .. rubric:: Returns: The number of bindings owned by the group. .. index:: pair: function; onChange .. _doxid-class_e_e_1_1_u_i_1_1_u_i_binding_group_1ac13b61df7db0ff6b1412be6bad5c1696: .. ref-code-block:: cpp :class: doxyrest-title-code-block void onChange(:ref:`Callback` callback) Replaces the callback invoked after a relevant group event. A non-empty callback is invoked once immediately, then after value, validation, enabled-state, baseline, or membership changes. Use :ref:`validValue() ` /dirtyValue() when only aggregate transitions matter, since those observables suppress equal values.