From 7ff4444a2579584f0887504eb0ec3a284cee4bb6 Mon Sep 17 00:00:00 2001 From: lnd3 Date: Tue, 24 Sep 2024 21:18:53 +0200 Subject: [PATCH] Rename uiStorage. --- .../include/rendering/ui/UIContainer.h | 14 +++++----- .../include/rendering/ui/UICreator.h | 2 +- .../include/rendering/ui/UINodeEditor.h | 8 +++--- .../include/rendering/ui/UIVisitors.h | 8 +++--- .../source/common/ui/UIContainer.cpp | 26 +++++++++---------- .../rendering/source/common/ui/UICreator.cpp | 24 ++++++++--------- .../rendering/source/common/ui/UIVisitors.cpp | 6 ++--- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/packages/rendering/include/rendering/ui/UIContainer.h b/packages/rendering/include/rendering/ui/UIContainer.h index 584af8b2..b49909af 100644 --- a/packages/rendering/include/rendering/ui/UIContainer.h +++ b/packages/rendering/include/rendering/ui/UIContainer.h @@ -413,10 +413,10 @@ namespace l::ui { UISplitMode mSplitMode; }; - class UIStorage { + class UIManager { public: - UIStorage() = default; - ~UIStorage() = default; + UIManager() = default; + ~UIManager() = default; UIHandle Add(std::unique_ptr container); void Remove(const UIHandle& handle); @@ -426,9 +426,9 @@ namespace l::ui { int32_t mIdCounter = 1; }; - UIHandle CreateContainer(UIStorage& uiStorage, uint32_t flags, UIRenderType renderType = UIRenderType::Rect, UIAlignH alignH = UIAlignH::Left, UIAlignV alignV = UIAlignV::Top, UILayoutH layoutH = UILayoutH::Fixed, UILayoutV layoutV = UILayoutV::Fixed); - UIHandle CreateSplit(UIStorage& uiStorage, uint32_t flags, UIRenderType renderType, UISplitMode splitMode = UISplitMode::AppendV, UILayoutH layoutH = UILayoutH::Fixed, UILayoutV layoutV = UILayoutV::Fixed); - void DeleteContainer(UIStorage& uiStorage, UIHandle handle); - void DeleteContainer(UIStorage& uiStorage, UIContainer* container); + UIHandle CreateContainer(UIManager& uiManager, uint32_t flags, UIRenderType renderType = UIRenderType::Rect, UIAlignH alignH = UIAlignH::Left, UIAlignV alignV = UIAlignV::Top, UILayoutH layoutH = UILayoutH::Fixed, UILayoutV layoutV = UILayoutV::Fixed); + UIHandle CreateSplit(UIManager& uiManager, uint32_t flags, UIRenderType renderType, UISplitMode splitMode = UISplitMode::AppendV, UILayoutH layoutH = UILayoutH::Fixed, UILayoutV layoutV = UILayoutV::Fixed); + void DeleteContainer(UIManager& uiManager, UIHandle handle); + void DeleteContainer(UIManager& uiManager, UIContainer* container); } diff --git a/packages/rendering/include/rendering/ui/UICreator.h b/packages/rendering/include/rendering/ui/UICreator.h index 038e91e3..08445cfd 100644 --- a/packages/rendering/include/rendering/ui/UICreator.h +++ b/packages/rendering/include/rendering/ui/UICreator.h @@ -19,5 +19,5 @@ namespace l::ui { - UIHandle CreateUINode(UIStorage& uiStorage, l::nodegraph::NodeGraphBase& node, ImVec2 p); + UIHandle CreateUINode(UIManager& uiManager, l::nodegraph::NodeGraphBase& node, ImVec2 p); } diff --git a/packages/rendering/include/rendering/ui/UINodeEditor.h b/packages/rendering/include/rendering/ui/UINodeEditor.h index 673052b5..592a85d0 100644 --- a/packages/rendering/include/rendering/ui/UINodeEditor.h +++ b/packages/rendering/include/rendering/ui/UINodeEditor.h @@ -18,8 +18,8 @@ namespace l::ui { class UINodeEditor : public UIBase { public: - UINodeEditor(std::string_view editorName) : mUIWindow(editorName), mLinkIOVisitor(mUIStorage), mSelectVisitor(mUIStorage) { - mUIRoot = CreateContainer(mUIStorage, l::ui::UIContainer_DragFlag | l::ui::UIContainer_ZoomFlag); + UINodeEditor(std::string_view editorName) : mUIWindow(editorName), mLinkIOVisitor(mUIManager), mSelectVisitor(mUIManager) { + mUIRoot = CreateContainer(mUIManager, l::ui::UIContainer_DragFlag | l::ui::UIContainer_ZoomFlag); mUIWindow.SetContentWindow([&]() { ImGui::PushItemWidth(400); @@ -57,7 +57,7 @@ namespace l::ui { auto nodeId = mNGSchema->NewNode(it.GetId()); auto node = mNGSchema->GetNode(nodeId); if (node != nullptr) { - auto uiNode = l::ui::CreateUINode(mUIStorage, *node, p); + auto uiNode = l::ui::CreateUINode(mUIManager, *node, p); mUIRoot->Add(uiNode); } } @@ -119,7 +119,7 @@ namespace l::ui { protected: UIWindow mUIWindow; - UIStorage mUIStorage; + UIManager mUIManager; UIHandle mUIRoot; InputState mUIInput; diff --git a/packages/rendering/include/rendering/ui/UIVisitors.h b/packages/rendering/include/rendering/ui/UIVisitors.h index f25b11fe..f98697c3 100644 --- a/packages/rendering/include/rendering/ui/UIVisitors.h +++ b/packages/rendering/include/rendering/ui/UIVisitors.h @@ -52,7 +52,7 @@ namespace l::ui { class UISelect : public UIVisitor { public: - UISelect(UIStorage& uiStorage) : mUIStorage(uiStorage) {} + UISelect(UIManager& uiManager) : mUIManager(uiManager) {} virtual bool Visit(UIContainer& container, const InputState& input); @@ -61,7 +61,7 @@ namespace l::ui { } protected: std::unordered_set mSelectedContainers; - UIStorage& mUIStorage; + UIManager& mUIManager; l::nodegraph::NodeGraphSchema* mNGSchema = nullptr; }; @@ -102,7 +102,7 @@ namespace l::ui { public: using HandlerFunctionType = bool(int32_t, int32_t, int32_t, int32_t, bool); - UILinkIO(UIStorage& uiStorage) : mUIStorage(uiStorage) {} + UILinkIO(UIManager& uiManager) : mUIManager(uiManager) {} ~UILinkIO() = default; virtual bool Active(UIContainer& container, const InputState& input); @@ -131,7 +131,7 @@ namespace l::ui { protected: bool mDragging = false; UIHandle mLinkContainer; - UIStorage& mUIStorage; + UIManager& mUIManager; l::nodegraph::NodeGraphSchema* mNGSchema = nullptr; }; diff --git a/packages/rendering/source/common/ui/UIContainer.cpp b/packages/rendering/source/common/ui/UIContainer.cpp index c86698b1..4e83d1d1 100644 --- a/packages/rendering/source/common/ui/UIContainer.cpp +++ b/packages/rendering/source/common/ui/UIContainer.cpp @@ -280,7 +280,7 @@ namespace l::ui { return false; } - UIHandle UIStorage::Add(std::unique_ptr container) { + UIHandle UIManager::Add(std::unique_ptr container) { auto id = mIdCounter++; auto stringId = container->GetStringId(); container->SetId(id); @@ -288,56 +288,56 @@ namespace l::ui { return UIHandle{ id, stringId, mContainers.at(id).get() }; } - void UIStorage::Remove(const UIHandle& handle) { + void UIManager::Remove(const UIHandle& handle) { if (handle.IsValid()) { mContainers.erase(handle.GetId()); } } - void UIStorage::Remove(UIContainer* container) { + void UIManager::Remove(UIContainer* container) { if (container != nullptr) { mContainers.erase(container->GetId()); } } - UIHandle CreateContainer(UIStorage& uiStorage, uint32_t flags, UIRenderType renderType, UIAlignH alignH, UIAlignV alignV, UILayoutH layoutH, UILayoutV layoutV) { + UIHandle CreateContainer(UIManager& uiManager, uint32_t flags, UIRenderType renderType, UIAlignH alignH, UIAlignV alignV, UILayoutH layoutH, UILayoutV layoutV) { std::unique_ptr container = std::make_unique(flags, renderType, alignH, alignV, layoutH, layoutV); auto stringId = CreateUniqueStringId(); container->SetStringId(stringId); - return uiStorage.Add(std::move(container)); + return uiManager.Add(std::move(container)); } - UIHandle CreateSplit(UIStorage& uiStorage, uint32_t flags, UIRenderType renderType, UISplitMode splitMode, UILayoutH layoutH, UILayoutV layoutV) { + UIHandle CreateSplit(UIManager& uiManager, uint32_t flags, UIRenderType renderType, UISplitMode splitMode, UILayoutH layoutH, UILayoutV layoutV) { std::unique_ptr container = std::make_unique(flags, renderType, splitMode, layoutH, layoutV); auto stringId = CreateUniqueStringId(); container->SetStringId(stringId); - return uiStorage.Add(std::move(container)); + return uiManager.Add(std::move(container)); } - void DeleteContainer(UIStorage& uiStorage, UIHandle handle) { + void DeleteContainer(UIManager& uiManager, UIHandle handle) { if (handle.IsValid()) { ASSERT(handle.Get()->GetParent() != nullptr); handle.Get()->GetParent()->Remove(handle); handle->ForEachChild([&](UIContainer* container) { - uiStorage.Remove(container); + uiManager.Remove(container); }); - uiStorage.Remove(handle); + uiManager.Remove(handle); } } - void DeleteContainer(UIStorage& uiStorage, UIContainer* container) { + void DeleteContainer(UIManager& uiManager, UIContainer* container) { if (container != nullptr) { ASSERT(container->GetParent() != nullptr); container->GetParent()->Remove(container); container->ForEachChild([&](UIContainer* c) { - uiStorage.Remove(c); + uiManager.Remove(c); }); - uiStorage.Remove(container); + uiManager.Remove(container); } } } diff --git a/packages/rendering/source/common/ui/UICreator.cpp b/packages/rendering/source/common/ui/UICreator.cpp index 6dd38d10..ffdc0ed0 100644 --- a/packages/rendering/source/common/ui/UICreator.cpp +++ b/packages/rendering/source/common/ui/UICreator.cpp @@ -5,14 +5,14 @@ namespace l::ui { - UIHandle CreateUINode(UIStorage& uiStorage, l::nodegraph::NodeGraphBase& node, ImVec2 p) { + UIHandle CreateUINode(UIManager& uiManager, l::nodegraph::NodeGraphBase& node, ImVec2 p) { auto numInputChannels = node.GetNumInputs(); auto numOutputChannels = node.GetNumOutputs(); auto numRows = numInputChannels > numOutputChannels ? numInputChannels : numOutputChannels; - auto node4 = CreateSplit(uiStorage, l::ui::UIContainer_ResizeFlag | l::ui::UIContainer_MoveFlag | l::ui::UIContainer_DrawFlag | UIContainer_SelectFlag, l::ui::UIRenderType::RectFilled, l::ui::UISplitMode::AppendV); + auto node4 = CreateSplit(uiManager, l::ui::UIContainer_ResizeFlag | l::ui::UIContainer_MoveFlag | l::ui::UIContainer_DrawFlag | UIContainer_SelectFlag, l::ui::UIRenderType::RectFilled, l::ui::UISplitMode::AppendV); node4->SetColor(ImVec4(0.15f, 0.15f, 0.15f, 1.0f)); node4->SetPosition(p); node4->GetContainerArea().mMargin = 0.0f; @@ -22,12 +22,12 @@ namespace l::ui { float ioSize = 4.0f; float ioOffsetV = 1.6f; - auto row0 = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::RectFilled, l::ui::UIAlignH::Left, l::ui::UIAlignV::Top, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Fixed); + auto row0 = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::RectFilled, l::ui::UIAlignH::Left, l::ui::UIAlignV::Top, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Fixed); row0->SetSize(ImVec2(1.0f, 18.0f)); row0->GetContainerArea().mMargin = 2.0f; node4->Add(row0); { - auto connector1Text = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Center, l::ui::UIAlignV::Middle); + auto connector1Text = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Center, l::ui::UIAlignV::Middle); connector1Text->SetDisplayName(node.GetName()); auto textSize = ImGui::CalcTextSize(node.GetName().data()); sizeEstimate.x = sizeEstimate.x < textSize.x ? textSize.x : sizeEstimate.x; @@ -35,7 +35,7 @@ namespace l::ui { row0->Add(connector1Text); } for (int8_t i = 0; i < numInputChannels || i < numOutputChannels || i < numInputChannels || i < numOutputChannels; i++) { - auto row = CreateContainer(uiStorage, 0, l::ui::UIRenderType::Rect, l::ui::UIAlignH::Left, l::ui::UIAlignV::Top, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Fixed); + auto row = CreateContainer(uiManager, 0, l::ui::UIRenderType::Rect, l::ui::UIAlignH::Left, l::ui::UIAlignV::Top, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Fixed); row->GetContainerArea().mMargin = ioSize; node4->Add(row); { @@ -44,7 +44,7 @@ namespace l::ui { float estimatedWidth = 0.0f; if (showsInput && !node.IsDataConstant(i)) { - auto in = CreateContainer(uiStorage, l::ui::UIContainer_InputFlag | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::CircleFilled, l::ui::UIAlignH::Left); + auto in = CreateContainer(uiManager, l::ui::UIContainer_InputFlag | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::CircleFilled, l::ui::UIAlignH::Left); in->SetPosition(ImVec2(-ioSize, ioSize * ioOffsetV)); in->SetSize(ImVec2(ioSize, ioSize)); in->GetContainerArea().mMargin = 0.0f; @@ -52,7 +52,7 @@ namespace l::ui { in->SetChannelId(i); estimatedWidth += ioSize; row->Add(in); - auto inText = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Left); + auto inText = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Left); inText->SetPosition(ImVec2(0.0f, 0.0f)); inText->SetDisplayName(node.GetInputName(i)); estimatedWidth += ImGui::CalcTextSize(node.GetInputName(i).data()).x; @@ -60,7 +60,7 @@ namespace l::ui { } if (node.IsDataVisible(i)) { - auto inText = CreateContainer(uiStorage, (node.IsDataEditable(i) ? l::ui::UIContainer_EditFlag : 0) | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::NodeOutputValue, l::ui::UIAlignH::Left); + auto inText = CreateContainer(uiManager, (node.IsDataEditable(i) ? l::ui::UIContainer_EditFlag : 0) | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::NodeOutputValue, l::ui::UIAlignH::Left); inText->SetPosition(ImVec2(estimatedWidth, 0.0f)); inText->SetSize(ImVec2(10 * 7, 14.0f)); inText->SetNodeId(node.GetId()); @@ -70,7 +70,7 @@ namespace l::ui { } if (showsOutput) { - auto out = CreateContainer(uiStorage, l::ui::UIContainer_OutputFlag | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::CircleFilled, l::ui::UIAlignH::Right); + auto out = CreateContainer(uiManager, l::ui::UIContainer_OutputFlag | l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::CircleFilled, l::ui::UIAlignH::Right); out->SetPosition(ImVec2(ioSize * 2.0f, ioSize * ioOffsetV)); out->SetSize(ImVec2(ioSize, ioSize)); out->GetContainerArea().mMargin = 0.0f; @@ -78,7 +78,7 @@ namespace l::ui { out->SetChannelId(i); estimatedWidth += ioSize; row->Add(out); - auto outText = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Right); + auto outText = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Text, l::ui::UIAlignH::Right); outText->SetPosition(ImVec2(0.0f, 0.0f)); outText->SetDisplayName(node.GetOutputName(i)); estimatedWidth += ImGui::CalcTextSize(node.GetOutputName(i).data()).x; @@ -89,13 +89,13 @@ namespace l::ui { } if (node.GetOutputType() == l::nodegraph::OutputType::ExternalVisualOutput) { - auto row = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Rect, l::ui::UIAlignH::Left, l::ui::UIAlignV::Bottom, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Parent); + auto row = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::Rect, l::ui::UIAlignH::Left, l::ui::UIAlignV::Bottom, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Parent); row->SetPosition(ImVec2(0.0f, 0.0f)); row->GetContainerArea().mMargin = ioSize; node4->Add(row); float estimatedWidth = 0.0f; - auto plot = CreateContainer(uiStorage, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::NodeOutputGraph, l::ui::UIAlignH::Center, l::ui::UIAlignV::Bottom, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Parent); + auto plot = CreateContainer(uiManager, l::ui::UIContainer_DrawFlag, l::ui::UIRenderType::NodeOutputGraph, l::ui::UIAlignH::Center, l::ui::UIAlignV::Bottom, l::ui::UILayoutH::Parent, l::ui::UILayoutV::Parent); plot->SetPosition(ImVec2(estimatedWidth, 0.0f)); plot->SetSize(ImVec2(100, 100)); plot->SetNodeId(node.GetId()); diff --git a/packages/rendering/source/common/ui/UIVisitors.cpp b/packages/rendering/source/common/ui/UIVisitors.cpp index 1ca5d65e..1efaf270 100644 --- a/packages/rendering/source/common/ui/UIVisitors.cpp +++ b/packages/rendering/source/common/ui/UIVisitors.cpp @@ -182,7 +182,7 @@ namespace l::ui { if (mNGSchema != nullptr) { mNGSchema->RemoveNode(it->GetNodeId()); } - DeleteContainer(mUIStorage, it); + DeleteContainer(mUIManager, it); } mSelectedContainers.clear(); return true; @@ -435,7 +435,7 @@ namespace l::ui { ImVec2 pT = layoutArea.Transform(pCenter); if (OverlapCircle(input.mCurPos, pT, 2.0f * size.x * layoutArea.mScale)) { mDragging = true; - mLinkContainer = CreateContainer(mUIStorage, UIContainer_LinkFlag | UIContainer_DrawFlag, UIRenderType::LinkH); + mLinkContainer = CreateContainer(mUIManager, UIContainer_LinkFlag | UIContainer_DrawFlag, UIRenderType::LinkH); container.Add(mLinkContainer); return true; } @@ -489,7 +489,7 @@ namespace l::ui { mLinkContainer.Reset(); } else { - DeleteContainer(mUIStorage, mLinkContainer.Get()); + DeleteContainer(mUIManager, mLinkContainer.Get()); mDragging = false; mLinkContainer.Reset(); return true;