diff --git a/nui/include/nui/frontend/attributes/impl/attribute.hpp b/nui/include/nui/frontend/attributes/impl/attribute.hpp index d394cdc..62ab30d 100644 --- a/nui/include/nui/frontend/attributes/impl/attribute.hpp +++ b/nui/include/nui/frontend/attributes/impl/attribute.hpp @@ -23,6 +23,7 @@ namespace Nui std::string data; }; + Attribute() = default; Attribute( std::function setter, std::function&& element)> createEvent = {}, @@ -67,8 +68,8 @@ namespace Nui bool isStringData() const; private: - std::variant attributeImpl_; - std::function&& element)> createEvent_; - std::function clearEvent_; + std::variant attributeImpl_{}; + std::function&& element)> createEvent_{}; + std::function clearEvent_{}; }; } diff --git a/nui/include/nui/frontend/components/dialog.hpp b/nui/include/nui/frontend/components/dialog.hpp index d3fc65c..fd47b1a 100644 --- a/nui/include/nui/frontend/components/dialog.hpp +++ b/nui/include/nui/frontend/components/dialog.hpp @@ -32,11 +32,11 @@ namespace Nui::Components struct ConstructionArgs { - Observed> className = std::nullopt; - Observed title = ""; - Observed body = ""; - Observed buttonClassName = ""; - Observed buttonConfiguration = ButtonConfiguration::Ok; + std::optional className{std::nullopt}; + std::string title{""}; + std::string body{""}; + std::string buttonClassName{""}; + ButtonConfiguration buttonConfiguration{ButtonConfiguration::Ok}; std::function onButtonClicked = [](Button) {}; }; @@ -107,6 +107,11 @@ namespace Nui::Components private: bool isOpen_; std::weak_ptr element_; - ConstructionArgs args_; + Observed> className_; + Observed title_; + Observed body_; + Observed buttonClassName_; + Observed buttonConfiguration_; + std::function onButtonClicked_; }; } \ No newline at end of file diff --git a/nui/include/nui/frontend/dom/basic_element.hpp b/nui/include/nui/frontend/dom/basic_element.hpp index 18ac3f7..0a66e6b 100644 --- a/nui/include/nui/frontend/dom/basic_element.hpp +++ b/nui/include/nui/frontend/dom/basic_element.hpp @@ -13,7 +13,7 @@ namespace Nui::Dom class BasicElement : public std::enable_shared_from_this { public: - BasicElement(Nui::val val) + explicit BasicElement(Nui::val val) : element_{std::move(val)} {} virtual ~BasicElement() = default; diff --git a/nui/include/nui/frontend/dom/childless_element.hpp b/nui/include/nui/frontend/dom/childless_element.hpp index f9949a4..0d4f952 100644 --- a/nui/include/nui/frontend/dom/childless_element.hpp +++ b/nui/include/nui/frontend/dom/childless_element.hpp @@ -4,6 +4,10 @@ #include #include +#include +#include +#include + namespace Nui::Dom { /** @@ -13,10 +17,10 @@ namespace Nui::Dom class ChildlessElement : public BasicElement { public: - ChildlessElement(HtmlElement const& elem) + explicit ChildlessElement(HtmlElement const& elem) : BasicElement{ChildlessElement::createElement(elem)} {} - ChildlessElement(Nui::val val) + explicit ChildlessElement(Nui::val val) : BasicElement{std::move(val)} {} diff --git a/nui/include/nui/frontend/dom/element.hpp b/nui/include/nui/frontend/dom/element.hpp index 94e27cf..1bf1e60 100644 --- a/nui/include/nui/frontend/dom/element.hpp +++ b/nui/include/nui/frontend/dom/element.hpp @@ -46,13 +46,13 @@ namespace Nui::Dom using const_iterator = collection_type::const_iterator; using value_type = collection_type::value_type; - Element(HtmlElement const& elem) + explicit Element(HtmlElement const& elem) : ChildlessElement{elem} , children_{} , unsetup_{} {} - Element(Nui::val val) + explicit Element(Nui::val val) : ChildlessElement{std::move(val)} , children_{} , unsetup_{} diff --git a/nui/include/nui/frontend/dom/reference.hpp b/nui/include/nui/frontend/dom/reference.hpp index d5d8c97..a36eab5 100644 --- a/nui/include/nui/frontend/dom/reference.hpp +++ b/nui/include/nui/frontend/dom/reference.hpp @@ -13,7 +13,7 @@ namespace Nui::Dom struct ReferencePasser { public: - ReferencePasser(T&& func) + explicit ReferencePasser(T&& func) : func_{std::move(func)} {} void operator()(std::weak_ptr&& weakElement) const diff --git a/nui/include/nui/frontend/event_system/observed_value.hpp b/nui/include/nui/frontend/event_system/observed_value.hpp index fb6ca92..c18fa26 100644 --- a/nui/include/nui/frontend/event_system/observed_value.hpp +++ b/nui/include/nui/frontend/event_system/observed_value.hpp @@ -168,10 +168,22 @@ namespace Nui } return *this; }; + ModifiableObserved& operator=(ContainedT const& contained) + { + contained_ = contained; + update(); + return *this; + } + ModifiableObserved& operator=(ContainedT&& contained) + { + contained_ = std::move(contained); + update(); + return *this; + } ~ModifiableObserved() = default; template - ModifiableObserved(T&& t) + explicit ModifiableObserved(T&& t) : contained_{std::forward(t)} {} @@ -316,9 +328,14 @@ namespace Nui { return ref_; } - void operator=(T&& ref) + void operator=(T&& val) + { + ref_ = std::move(val); + owner_->insertRangeChecked(pos_, pos_, RangeStateType::Modify); + } + void operator=(T const& val) { - ref_ = std::forward(ref); + ref_ = val; owner_->insertRangeChecked(pos_, pos_, RangeStateType::Modify); } @@ -527,12 +544,12 @@ namespace Nui , afterEffectId_{registerAfterEffect()} {} template - ObservedContainer(T&& t) + explicit ObservedContainer(T&& t) : ModifiableObserved{std::forward(t)} , rangeContext_{static_cast(contained_.size())} , afterEffectId_{registerAfterEffect()} {} - ObservedContainer(RangeEventContext&& rangeContext) + explicit ObservedContainer(RangeEventContext&& rangeContext) : ModifiableObserved{} , rangeContext_{std::move(rangeContext)} , afterEffectId_{registerAfterEffect()} @@ -987,6 +1004,17 @@ namespace Nui using ModifiableObserved::ModifiableObserved; using ModifiableObserved::operator=; using ModifiableObserved::operator->; + + Observed& operator=(T const& contained) + { + ModifiableObserved::operator=(contained); + return *this; + } + Observed& operator=(T&& contained) + { + ModifiableObserved::operator=(std::move(contained)); + return *this; + } }; template class Observed> : public ObservedContainer> @@ -996,6 +1024,17 @@ namespace Nui using ObservedContainer>::operator=; using ObservedContainer>::operator->; static constexpr auto isRandomAccess = true; + + Observed>& operator=(std::vector const& contained) + { + ObservedContainer>::operator=(contained); + return *this; + } + Observed>& operator=(std::vector&& contained) + { + ObservedContainer>::operator=(std::move(contained)); + return *this; + } }; template class Observed> : public ObservedContainer> @@ -1005,6 +1044,17 @@ namespace Nui using ObservedContainer>::operator=; using ObservedContainer>::operator->; static constexpr auto isRandomAccess = true; + + Observed>& operator=(std::deque const& contained) + { + ObservedContainer>::operator=(contained); + return *this; + } + Observed>& operator=(std::deque&& contained) + { + ObservedContainer>::operator=(std::move(contained)); + return *this; + } }; template class Observed> : public ObservedContainer> @@ -1015,6 +1065,17 @@ namespace Nui using ObservedContainer>::operator->; static constexpr auto isRandomAccess = true; + Observed>& operator=(std::basic_string const& contained) + { + ObservedContainer>::operator=(contained); + return *this; + } + Observed>& operator=(std::basic_string&& contained) + { + ObservedContainer>::operator=(std::move(contained)); + return *this; + } + Observed>& erase(std::size_t index = 0, std::size_t count = std::string::npos) { const auto sizeBefore = this->contained_.size(); @@ -1027,6 +1088,9 @@ namespace Nui class Observed> : public ObservedContainer> { public: + using ObservedContainer>::ObservedContainer; + using ObservedContainer>::operator=; + using ObservedContainer>::operator->; static constexpr auto isRandomAccess = false; public: @@ -1034,11 +1098,22 @@ namespace Nui : ObservedContainer>{RangeEventContext{0, true}} {} template > - Observed(T&& t) + explicit Observed(T&& t) : ObservedContainer>{ std::forward(t), RangeEventContext{static_cast(t.size()), true}} {} + + Observed>& operator=(std::set const& contained) + { + ObservedContainer>::operator=(contained); + return *this; + } + Observed>& operator=(std::set&& contained) + { + ObservedContainer>::operator=(std::move(contained)); + return *this; + } }; template @@ -1118,7 +1193,7 @@ namespace Nui struct CopiableObservedWrap // minimal wrapper to make Observed copiable { public: - constexpr CopiableObservedWrap(Observed const& observed) + explicit constexpr CopiableObservedWrap(Observed const& observed) : observed_{&observed} {} diff --git a/nui/include/nui/frontend/event_system/observed_value_combinator.hpp b/nui/include/nui/frontend/event_system/observed_value_combinator.hpp index 6c87303..5ec9deb 100644 --- a/nui/include/nui/frontend/event_system/observed_value_combinator.hpp +++ b/nui/include/nui/frontend/event_system/observed_value_combinator.hpp @@ -12,10 +12,10 @@ namespace Nui class ObservedValueCombinatorBase { public: - constexpr ObservedValueCombinatorBase(ObservedValues const&... observedValues) + explicit constexpr ObservedValueCombinatorBase(ObservedValues const&... observedValues) : observedValues_{observedValues...} {} - constexpr ObservedValueCombinatorBase(std::tuple observedValues) + explicit constexpr ObservedValueCombinatorBase(std::tuple observedValues) : observedValues_{std::move(observedValues)} {} diff --git a/nui/include/nui/frontend/event_system/range.hpp b/nui/include/nui/frontend/event_system/range.hpp index bbba76d..26e3734 100644 --- a/nui/include/nui/frontend/event_system/range.hpp +++ b/nui/include/nui/frontend/event_system/range.hpp @@ -6,7 +6,7 @@ namespace Nui class ObservedRange { public: - constexpr ObservedRange(ObservedValue& observedValues) + explicit constexpr ObservedRange(ObservedValue& observedValues) : observedValue_{observedValues} {} diff --git a/nui/include/nui/frontend/event_system/range_event_context.hpp b/nui/include/nui/frontend/event_system/range_event_context.hpp index 840aa4a..76cdca5 100644 --- a/nui/include/nui/frontend/event_system/range_event_context.hpp +++ b/nui/include/nui/frontend/event_system/range_event_context.hpp @@ -182,7 +182,7 @@ namespace Nui class RangeEventContext { public: - RangeEventContext(long dataSize) + explicit RangeEventContext(long dataSize) : modificationRanges_{} , fullRangeUpdate_{true} , disableOptimizations_{false} diff --git a/nui/src/nui/frontend/components/dialog.cpp b/nui/src/nui/frontend/components/dialog.cpp index a9c8938..7d4e048 100644 --- a/nui/src/nui/frontend/components/dialog.cpp +++ b/nui/src/nui/frontend/components/dialog.cpp @@ -23,7 +23,12 @@ namespace Nui::Components DialogController::DialogController(ConstructionArgs&& args) : isOpen_{false} , element_{} - , args_{std::move(args)} + , className_{std::move(args.className)} + , title_{std::move(args.title)} + , body_{std::move(args.body)} + , buttonClassName_{std::move(args.buttonClassName)} + , buttonConfiguration_{std::move(args.buttonConfiguration)} + , onButtonClicked_{std::move(args.onButtonClicked)} {} //--------------------------------------------------------------------------------------------------------------------- void DialogController::showModal() @@ -54,32 +59,32 @@ namespace Nui::Components //--------------------------------------------------------------------------------------------------------------------- void DialogController::setClassName(std::string const& className) { - args_.className = className; + className_ = className; } //--------------------------------------------------------------------------------------------------------------------- void DialogController::setButtonClassName(std::string const& className) { - args_.buttonClassName = className; + buttonClassName_ = className; } //--------------------------------------------------------------------------------------------------------------------- void DialogController::setTitle(std::string const& title) { - args_.title = title; + title_ = title; } //--------------------------------------------------------------------------------------------------------------------- void DialogController::setBody(std::string const& body) { - args_.body = body; + body_ = body; } //--------------------------------------------------------------------------------------------------------------------- void DialogController::setButtonConfiguration(ButtonConfiguration buttons) { - args_.buttonConfiguration = buttons; + buttonConfiguration_ = buttons; } //--------------------------------------------------------------------------------------------------------------------- void DialogController::setOnButtonClicked(std::function const& onButtonClicked) { - args_.onButtonClicked = onButtonClicked; + onButtonClicked_ = onButtonClicked; } //--------------------------------------------------------------------------------------------------------------------- Nui::ElementRenderer Dialog(DialogController& controller) @@ -89,7 +94,7 @@ namespace Nui::Components // clang-format off return dialog{ - class_ = controller.args_.className, + class_ = controller.className_, reference = [&controller](auto&& element){ controller.element_ = std::static_pointer_cast(element.lock()); } @@ -98,23 +103,23 @@ namespace Nui::Components method = "dialog" }( h1{}( - controller.args_.title + controller.title_ ), p{}( - controller.args_.body + controller.body_ ), menu{}( - observe(controller.args_.buttonConfiguration), - [&controller, &conf = controller.args_.buttonConfiguration]() -> Nui::ElementRenderer { + observe(controller.buttonConfiguration_), + [&controller, &conf = controller.buttonConfiguration_]() -> Nui::ElementRenderer { switch (conf.value()) { case(DialogController::ButtonConfiguration::Ok): { return button{ - class_ = controller.args_.buttonClassName, + class_ = controller.buttonClassName_, type = "submit", onClick = [&controller](){ controller.isOpen_ = false; - controller.args_.onButtonClicked(DialogController::Button::Ok); + controller.onButtonClicked_(DialogController::Button::Ok); } }("Ok"); } @@ -122,19 +127,19 @@ namespace Nui::Components { return fragment( button{ - class_ = controller.args_.buttonClassName, + class_ = controller.buttonClassName_, type = "submit", onClick = [&controller](){ controller.isOpen_ = false; - controller.args_.onButtonClicked(DialogController::Button::Ok); + controller.onButtonClicked_(DialogController::Button::Ok); } }("Ok"), button{ - class_ = controller.args_.buttonClassName, + class_ = controller.buttonClassName_, type = "cancel", onClick = [&controller](){ controller.isOpen_ = false; - controller.args_.onButtonClicked(DialogController::Button::Cancel); + controller.onButtonClicked_(DialogController::Button::Cancel); } }("Cancel") ); @@ -143,19 +148,19 @@ namespace Nui::Components { return fragment( button{ - class_ = controller.args_.buttonClassName, + class_ = controller.buttonClassName_, type = "submit", onClick = [&controller](){ controller.isOpen_ = false; - controller.args_.onButtonClicked(DialogController::Button::Yes); + controller.onButtonClicked_(DialogController::Button::Yes); } }("Yes"), button{ - class_ = controller.args_.buttonClassName, + class_ = controller.buttonClassName_, type = "cancel", onClick = [&controller](){ controller.isOpen_ = false; - controller.args_.onButtonClicked(DialogController::Button::No); + controller.onButtonClicked_(DialogController::Button::No); } }("No") ); diff --git a/nui/test/nui/components/test_table.hpp b/nui/test/nui/components/test_table.hpp index 9d61d6f..f7739a4 100644 --- a/nui/test/nui/components/test_table.hpp +++ b/nui/test/nui/components/test_table.hpp @@ -62,7 +62,7 @@ namespace Nui::Tests { using namespace Nui::Components; - Nui::Observed caption = "Caption"; + Nui::Observed caption{"Caption"}; auto const table = Table{{ .tableModel = tableModel_, diff --git a/nui/test/nui/test_ranges.hpp b/nui/test/nui/test_ranges.hpp index e97de55..f84f6f2 100644 --- a/nui/test/nui/test_ranges.hpp +++ b/nui/test/nui/test_ranges.hpp @@ -52,7 +52,7 @@ namespace Nui::Tests TEST_F(TestRanges, SubscriptOperatorAssignmentUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -65,7 +65,7 @@ namespace Nui::Tests TEST_F(TestRanges, FullAssignmentUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -78,7 +78,7 @@ namespace Nui::Tests TEST_F(TestRanges, PushBackUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -96,7 +96,7 @@ namespace Nui::Tests TEST_F(TestRanges, PopBackUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -109,7 +109,7 @@ namespace Nui::Tests TEST_F(TestRanges, InsertUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; std::vector vec2 = {'1', '2', '3'}; rangeTextBodyRender(vec, parent); @@ -189,7 +189,7 @@ namespace Nui::Tests TEST_F(TestRanges, ClearUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -202,7 +202,7 @@ namespace Nui::Tests TEST_F(TestRanges, SwapUpdatesView) { Nui::val parent; - Observed> vec1 = {{'A', 'B', 'C', 'D'}}; + Observed> vec1{{'A', 'B', 'C', 'D'}}; std::vector vec2 = {'X', 'Y', 'Z'}; rangeTextBodyRender(vec1, parent); @@ -216,7 +216,7 @@ namespace Nui::Tests TEST_F(TestRanges, ResizeUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -229,7 +229,7 @@ namespace Nui::Tests TEST_F(TestRanges, ResizeWithFillValueUpdatesView) { Nui::val parent; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -242,7 +242,7 @@ namespace Nui::Tests TEST_F(TestRanges, AssignWithFillValueUpdatesView) { Nui::val parent; - Observed> vec1 = {{'A', 'B', 'C', 'D'}}; + Observed> vec1{{'A', 'B', 'C', 'D'}}; std::vector vec2 = {'X', 'Y', 'Z'}; rangeTextBodyRender(vec1, parent); @@ -264,7 +264,7 @@ namespace Nui::Tests TEST_F(TestRanges, AssignWithRangeUpdatesView) { Nui::val parent; - Observed> vec1 = {{'A', 'B', 'C', 'D'}}; + Observed> vec1{{'A', 'B', 'C', 'D'}}; std::vector vec2 = {'X', 'Y', 'Z'}; rangeTextBodyRender(vec1, parent); @@ -278,7 +278,7 @@ namespace Nui::Tests TEST_F(TestRanges, AssignWithInitializerListUpdatesView) { Nui::val parent; - Observed> vec1 = {{'A', 'B', 'C', 'D'}}; + Observed> vec1{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(vec1, parent); textBodyParityTest(vec1, parent); @@ -291,7 +291,7 @@ namespace Nui::Tests TEST_F(TestRanges, EmplaceBackUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -304,7 +304,7 @@ namespace Nui::Tests TEST_F(TestRanges, EmplaceUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -317,7 +317,7 @@ namespace Nui::Tests TEST_F(TestRanges, ModificationThroughPointerUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -330,7 +330,7 @@ namespace Nui::Tests TEST_F(TestRanges, ModificationThroughReferenceUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -343,7 +343,7 @@ namespace Nui::Tests TEST_F(TestRanges, ModificationThroughIteratorUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -356,7 +356,7 @@ namespace Nui::Tests TEST_F(TestRanges, ChangeOfReferenceFromBackUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -369,7 +369,7 @@ namespace Nui::Tests TEST_F(TestRanges, ChangeOfReferenceFromAtUpdatesView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -382,7 +382,7 @@ namespace Nui::Tests TEST_F(TestRanges, ChangeOfIteratorFromEndUpdateView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; rangeTextBodyRender(vec, parent); textBodyParityTest(vec, parent); @@ -395,7 +395,7 @@ namespace Nui::Tests TEST_F(TestRanges, ChangeOfIteratorFromRbeginUpdateView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; auto rbegin = vec.rbegin(); rangeTextBodyRender(vec, parent); @@ -409,7 +409,7 @@ namespace Nui::Tests TEST_F(TestRanges, ChangeOfIteratorFromRendUpdateView) { Nui::val parent; - Observed> vec = {{"A", "B", "C", "D"}}; + Observed> vec{{"A", "B", "C", "D"}}; auto rend = vec.rend(); rangeTextBodyRender(vec, parent); @@ -423,7 +423,7 @@ namespace Nui::Tests TEST_F(TestRanges, PushFrontUpdatesView) { Nui::val parent; - Observed> container = {{'A', 'B', 'C', 'D'}}; + Observed> container{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(container, parent); textBodyParityTest(container, parent); @@ -441,7 +441,7 @@ namespace Nui::Tests TEST_F(TestRanges, PopFrontUpdatesView) { Nui::val parent; - Observed> container = {{'A', 'B', 'C', 'D'}}; + Observed> container{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(container, parent); textBodyParityTest(container, parent); @@ -454,7 +454,7 @@ namespace Nui::Tests TEST_F(TestRanges, AggregatedInsertsUpdateCorrectly) { Nui::val parent; - Observed> container = {{'A', 'B', 'C', 'D'}}; + Observed> container{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(container, parent); textBodyParityTest(container, parent); @@ -468,7 +468,7 @@ namespace Nui::Tests TEST_F(TestRanges, AggregatedInsertsUpdateCorrectly2) { Nui::val parent; - Observed> container = {{'A', 'B', 'C', 'D'}}; + Observed> container{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(container, parent); textBodyParityTest(container, parent); @@ -483,7 +483,7 @@ namespace Nui::Tests TEST_F(TestRanges, MixOfInsertionAndErasureUpdateCorrectly) { Nui::val parent; - Observed> container = {{'A', 'B', 'C', 'D'}}; + Observed> container{{'A', 'B', 'C', 'D'}}; rangeTextBodyRender(container, parent); textBodyParityTest(container, parent); diff --git a/nui/test/nui/test_render.hpp b/nui/test/nui/test_render.hpp index ff261e4..8cd9953 100644 --- a/nui/test/nui/test_render.hpp +++ b/nui/test/nui/test_render.hpp @@ -78,7 +78,7 @@ namespace Nui::Tests using namespace Nui::Attributes; Nui::val elem; - Observed textContent = "Hello World"; + Observed textContent{"Hello World"}; render(div{}(span{reference = elem}(textContent))); @@ -95,7 +95,7 @@ namespace Nui::Tests using namespace Nui::Attributes; Nui::val elem; - Observed textContent = 13; + Observed textContent{13}; render(div{}(span{reference = elem}(textContent))); @@ -112,7 +112,7 @@ namespace Nui::Tests using namespace Nui::Attributes; Nui::val elem; - Observed textContent = 13.5; + Observed textContent{13.5}; render(div{}(span{reference = elem}(textContent))); @@ -156,7 +156,7 @@ namespace Nui::Tests using namespace Nui::Attributes; Nui::val nested; - Observed toggle = true; + Observed toggle{true}; render(body{}(observe(toggle), [&toggle, &nested]() { if (*toggle) @@ -183,8 +183,8 @@ namespace Nui::Tests using namespace Nui::Attributes; Nui::val nested; - Observed toggle = true; - Observed text = "Hello"; + Observed toggle{true}; + Observed text{"Hello"}; render(body{}(observe(toggle, text), [&toggle, &nested, &text]() -> ElementRenderer { if (*toggle) @@ -215,7 +215,7 @@ namespace Nui::Tests using Nui::Elements::body; using namespace Nui::Attributes; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; render(body{}(range(vec), [&vec](long long i, auto const& element) { return div{}(std::string{element} + ":" + std::to_string(i)); @@ -237,7 +237,7 @@ namespace Nui::Tests using Nui::Elements::body; using namespace Nui::Attributes; - Observed> vec = {{'A', 'B', 'C', 'D'}}; + Observed> vec{{'A', 'B', 'C', 'D'}}; auto verifyParity = [&vec]() { EXPECT_EQ( @@ -311,7 +311,7 @@ namespace Nui::Tests using Nui::Elements::button; using namespace Nui::Attributes; - Nui::Observed toggle = true; + Nui::Observed toggle{true}; StableElement stable; // clang-format off @@ -366,9 +366,9 @@ namespace Nui::Tests using Nui::Elements::span; using namespace Nui::Attributes; - Nui::Observed toggle = true; + Nui::Observed toggle{true}; StableElement stable; - Nui::Observed spanId = "dynamic"; + Nui::Observed spanId{"dynamic"}; // clang-format off render(div{}( @@ -417,7 +417,7 @@ namespace Nui::Tests using Nui::Elements::fragment; using namespace Nui::Attributes; - Nui::Observed toggle = true; + Nui::Observed toggle{true}; StableElement stable; // clang-format off @@ -451,7 +451,7 @@ namespace Nui::Tests using Nui::nil; using namespace Nui::Attributes; - Nui::Observed toggle = true; + Nui::Observed toggle{true}; StableElement stable; // Does not make much sense, but is not causing any issues: @@ -469,7 +469,7 @@ namespace Nui::Tests using Nui::Elements::button; using namespace Nui::Attributes; - Nui::Observed toggle = true; + Nui::Observed toggle{true}; StableElement stable; std::string once = "once"; @@ -554,7 +554,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; render(div{}(text{textContent}())); @@ -571,7 +571,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; render(div{}(text{textContent}())); @@ -599,7 +599,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; render(div{}(span{}(), text{textContent}(), div{}())); @@ -618,7 +618,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; StableElement stable; render(div{}(span{}(), stabilize(stable, text{textContent}()), div{}())); @@ -648,7 +648,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; render(div{}(fragment(text{textContent}()))); @@ -665,7 +665,7 @@ namespace Nui::Tests { using namespace Nui::Elements; - Nui::Observed textContent = "Hello World"; + Nui::Observed textContent{"Hello World"}; render(div{}(fragment(span{}(), text{textContent}(), div{}())));