diff options
author | rtk0c <[email protected]> | 2021-06-10 18:07:30 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-06-10 18:07:30 -0700 |
commit | 222cfec6ad882196d8927f73e30d905daae89556 (patch) | |
tree | 9347bb0ebf99cc79e4ee629d0edf7fd744bdeb1b /core/src | |
parent | dc09ba073744292a4d4af0445e5095f424fffa22 (diff) |
Polish UI and add translations
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/Model/Assets.cpp | 113 | ||||
-rw-r--r-- | core/src/Model/Assets.hpp | 19 | ||||
-rw-r--r-- | core/src/Model/Template/Template.hpp | 2 | ||||
-rw-r--r-- | core/src/Model/Template/Template_Main.cpp | 22 | ||||
-rw-r--r-- | core/src/Model/Workflow/Workflow.hpp | 2 | ||||
-rw-r--r-- | core/src/Model/Workflow/Workflow_Main.cpp | 16 | ||||
-rw-r--r-- | core/src/UI/Localization.hpp | 29 | ||||
-rw-r--r-- | core/src/UI/UI_Items.cpp | 12 | ||||
-rw-r--r-- | core/src/UI/UI_MainWindow.cpp | 4 | ||||
-rw-r--r-- | core/src/UI/UI_Templates.cpp | 49 | ||||
-rw-r--r-- | core/src/UI/UI_Workflows.cpp | 50 |
11 files changed, 144 insertions, 174 deletions
diff --git a/core/src/Model/Assets.cpp b/core/src/Model/Assets.cpp index 0e53537..ac3335a 100644 --- a/core/src/Model/Assets.cpp +++ b/core/src/Model/Assets.cpp @@ -81,6 +81,11 @@ void AssetList::Reload() }); } +int AssetList::GetCount() const +{ + return mPrivate->Assets.size(); +} + const SavedAsset* AssetList::FindByName(std::string_view name) const { auto iter = mPrivate->Assets.find(name); @@ -166,99 +171,46 @@ void AssetList::SetCacheSizeLimit(int limit) mPrivate->CacheSizeLimit = limit; } -void AssetList::DisplayBigIconsList(ListState& state) +void AssetList::DisplayIconsList(ListState& state) { // TODO } -void AssetList::DisplayDetailsTable(ListState& state) +void AssetList::DisplayDetailsList(ListState& state) { SetupDetailsTable("AssetDetailsTable"); for (auto& asset : mPrivate->Assets) { - DrawDetailsTableRow(state, asset); ImGui::TableNextRow(); + DrawDetailsTableRow(state, asset); } ImGui::EndTable(); } -void AssetList::OpenBigIconsPopup() -{ - ImGui::OpenPopup("Manage assets##BigIcons"); -} - -void AssetList::DisplayBigIconsPopup(PopupState& state) -{ - if (ImGui::BeginPopupModal("Manage assets##BigIcons")) { - DisplayBigIconsList(state); - DisplayPopupControls(state); - ImGui::EndPopup(); - } -} - -void AssetList::OpenDetailsPopup() -{ - ImGui::OpenPopup("Manage assets##Details"); -} - -void AssetList::DisplayDetailsPopup(PopupState& state) -{ - if (ImGui::BeginPopupModal("Manage assets##Details")) { - DisplayBigIconsList(state); - DisplayPopupControls(state); - ImGui::EndPopup(); - } -} - -void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const -{ - for (auto entry : fs::directory_iterator(containerDir)) { - if (!entry.is_regular_file()) continue; - - // If the caller provided an extension to match against, and it doesn't equal to current file extension, skip - if (!extension.empty() && - entry.path().extension() != extension) - { - continue; - } - - callback(SavedAsset{ - .Name = RetrieveNameFromFile(entry.path()), - .Uuid = RetrieveUuidFromFile(entry.path()), - // TODO load payload - }); - } -} - -void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const -{ - // TODO -} - -void AssetList::DisplayPopupControls(PopupState& state) +void AssetList::DisplayControls(ListState& state) { auto& ps = mPrivate->PopupPrivateState; auto ls = LocaleStrings::Instance.get(); - bool openedDummy = false; + bool openedDummy = true; if (ImGui::Button(ls->Add.Get())) { - ImGui::OpenPopup("Create template"); + ImGui::OpenPopup(ls->AddDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Create template", &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::BeginPopupModal(ls->AddDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { DisplayAssetCreator(state); ImGui::EndPopup(); } ImGui::SameLine(); if (ImGui::Button(ls->Rename.Get(), state.SelectedAsset == nullptr)) { - ImGui::OpenPopup("Rename template"); + ImGui::OpenPopup(ls->RenameDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Rename template")) { + if (ImGui::BeginPopupModal(ls->RenameDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::InputText("New name", &ps.NewName)) { ps.Validate(*this); } - if (ImGui::Button(ls->DialogConfirm.Get(), ps.HasErrors())) { + if (ImGui::Button(ls->Confirm.Get(), ps.HasErrors())) { ImGui::CloseCurrentPopup(); auto movedAsset = Rename(state.SelectedAsset->Name, ps.NewName); @@ -268,7 +220,7 @@ void AssetList::DisplayPopupControls(PopupState& state) ps = {}; } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } @@ -279,10 +231,10 @@ void AssetList::DisplayPopupControls(PopupState& state) ImGui::SameLine(); if (ImGui::Button(ls->Delete.Get(), state.SelectedAsset == nullptr)) { - ImGui::OpenPopup("Delete confirmation"); + ImGui::OpenPopup(ls->DeleteDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Delete confirmation")) { - if (ImGui::Button(ls->DialogConfirm.Get())) { + if (ImGui::BeginPopupModal(ls->DeleteDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::Button(ls->Confirm.Get())) { ImGui::CloseCurrentPopup(); auto& assetName = state.SelectedAsset->Name; @@ -291,9 +243,34 @@ void AssetList::DisplayPopupControls(PopupState& state) state.SelectedAsset = nullptr; } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } + +void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const +{ + for (auto entry : fs::directory_iterator(containerDir)) { + if (!entry.is_regular_file()) continue; + + // If the caller provided an extension to match against, and it doesn't equal to current file extension, skip + if (!extension.empty() && + entry.path().extension() != extension) + { + continue; + } + + callback(SavedAsset{ + .Name = RetrieveNameFromFile(entry.path()), + .Uuid = RetrieveUuidFromFile(entry.path()), + // TODO load payload + }); + } +} + +void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const +{ + // TODO +} diff --git a/core/src/Model/Assets.hpp b/core/src/Model/Assets.hpp index e035f51..adde97b 100644 --- a/core/src/Model/Assets.hpp +++ b/core/src/Model/Assets.hpp @@ -48,6 +48,7 @@ public: // TODO support file watches void Reload(); + int GetCount() const; const SavedAsset* FindByName(std::string_view name) const; const SavedAsset& Create(SavedAsset asset); std::unique_ptr<Asset> CreateAndLoad(SavedAsset asset); @@ -66,16 +67,9 @@ public: { const SavedAsset* SelectedAsset = nullptr; }; - void DisplayBigIconsList(ListState& state); - void DisplayDetailsTable(ListState& state); - - struct PopupState : public ListState - { - }; - void OpenBigIconsPopup(); - void DisplayBigIconsPopup(PopupState& state); - void OpenDetailsPopup(); - void DisplayDetailsPopup(PopupState& state); + void DisplayIconsList(ListState& state); + void DisplayDetailsList(ListState& state); + void DisplayControls(ListState& state); protected: virtual void DiscoverFiles(const std::function<void(SavedAsset)>& callback) const = 0; @@ -93,15 +87,12 @@ protected: virtual uuids::uuid RetrieveUuidFromFile(const std::filesystem::path& file) const = 0; virtual std::filesystem::path RetrievePathFromAsset(const SavedAsset& asset) const = 0; - virtual void DisplayAssetCreator(PopupState& state) = 0; + virtual void DisplayAssetCreator(ListState& state) = 0; /// This should call ImGui::BeginTable() along with other accessories such as setting up the header row. virtual void SetupDetailsTable(const char* tableId) const = 0; virtual void DrawBigIcon(ListState& state, const SavedAsset& asset) const = 0; virtual void DrawDetailsTableRow(ListState& state, const SavedAsset& asset) const = 0; - -private: - void DisplayPopupControls(PopupState& state); }; template <class T> diff --git a/core/src/Model/Template/Template.hpp b/core/src/Model/Template/Template.hpp index fdac574..7cfbb8b 100644 --- a/core/src/Model/Template/Template.hpp +++ b/core/src/Model/Template/Template.hpp @@ -64,7 +64,7 @@ protected: virtual Template* LoadImpl(const SavedAsset& diskForm) const override; - virtual void DisplayAssetCreator(PopupState& state) override; + virtual void DisplayAssetCreator(ListState& state) override; virtual void SetupDetailsTable(const char* tableId) const override; virtual void DrawBigIcon(ListState& state, const SavedAsset& asset) const override; diff --git a/core/src/Model/Template/Template_Main.cpp b/core/src/Model/Template/Template_Main.cpp index ebec490..7d1b755 100644 --- a/core/src/Model/Template/Template_Main.cpp +++ b/core/src/Model/Template/Template_Main.cpp @@ -89,7 +89,7 @@ Template* TemplateAssetList::LoadImpl(const SavedAsset& asset) const return tmpl.release(); } -void TemplateAssetList::DisplayAssetCreator(PopupState& state) +void TemplateAssetList::DisplayAssetCreator(ListState& state) { auto ls = LocaleStrings::Instance.get(); @@ -111,17 +111,17 @@ void TemplateAssetList::DisplayAssetCreator(PopupState& state) switch (mACNewNameError) { case NameSelectionError::None: break; case NameSelectionError::Duplicated: - ImGui::ErrorMessage("Duplicate template name"); + ImGui::ErrorMessage(ls->DuplicateNameError.Get()); break; case NameSelectionError::Empty: - ImGui::ErrorMessage("Template name cannot be empty"); + ImGui::ErrorMessage(ls->EmptyNameError.Get()); break; } }; auto ShowNewKindErrors = [&]() -> void { if (mACNewKind == Template::InvalidKind) { - ImGui::ErrorMessage("Must select a valid template type"); + ImGui::ErrorMessage(ls->InvalidTemplateTypeError.Get()); } }; @@ -136,11 +136,11 @@ void TemplateAssetList::DisplayAssetCreator(PopupState& state) ValidateNewName(); }; - if (ImGui::InputText("Name", &mACNewName)) { + if (ImGui::InputText(ls->Name.Get(), &mACNewName)) { ValidateNewName(); } - if (ImGui::BeginCombo("Type", Template::FormatKind(mACNewKind))) { + if (ImGui::BeginCombo(ls->Type.Get(), Template::FormatKind(mACNewKind))) { for (int i = 0; i < Template::KindCount; ++i) { auto kind = static_cast<Template::Kind>(i); if (ImGui::Selectable(Template::FormatKind(kind), mACNewKind == kind)) { @@ -153,7 +153,7 @@ void TemplateAssetList::DisplayAssetCreator(PopupState& state) ShowNewNameErrors(); ShowNewKindErrors(); - if (ImGui::Button(ls->DialogConfirm.Get(), !IsInputValid())) { + if (ImGui::Button(ls->Confirm.Get(), !IsInputValid())) { ImGui::CloseCurrentPopup(); Create(SavedAsset{ @@ -163,17 +163,19 @@ void TemplateAssetList::DisplayAssetCreator(PopupState& state) ResetState(); } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } } void TemplateAssetList::SetupDetailsTable(const char* tableId) const { + auto ls = LocaleStrings::Instance.get(); + ImGui::BeginTable(tableId, 2, ImGuiTableFlags_Borders); - ImGui::TableSetupColumn("Name"); - ImGui::TableSetupColumn("Type"); + ImGui::TableSetupColumn(ls->Name.Get()); + ImGui::TableSetupColumn(ls->Type.Get()); ImGui::TableHeadersRow(); } diff --git a/core/src/Model/Workflow/Workflow.hpp b/core/src/Model/Workflow/Workflow.hpp index 95dcafe..3dc6f38 100644 --- a/core/src/Model/Workflow/Workflow.hpp +++ b/core/src/Model/Workflow/Workflow.hpp @@ -294,7 +294,7 @@ public: virtual Workflow* LoadImpl(const SavedAsset& diskForm) const override; - virtual void DisplayAssetCreator(PopupState& state) override; + virtual void DisplayAssetCreator(ListState& state) override; virtual void SetupDetailsTable(const char* tableId) const override; virtual void DrawBigIcon(ListState& state, const SavedAsset& asset) const override; diff --git a/core/src/Model/Workflow/Workflow_Main.cpp b/core/src/Model/Workflow/Workflow_Main.cpp index 99c70a7..a01ab7b 100644 --- a/core/src/Model/Workflow/Workflow_Main.cpp +++ b/core/src/Model/Workflow/Workflow_Main.cpp @@ -802,7 +802,7 @@ Workflow* WorkflowAssetList::LoadImpl(const SavedAsset& asset) const return workflow.release(); } -void WorkflowAssetList::DisplayAssetCreator(PopupState& state) +void WorkflowAssetList::DisplayAssetCreator(ListState& state) { auto ls = LocaleStrings::Instance.get(); @@ -824,10 +824,10 @@ void WorkflowAssetList::DisplayAssetCreator(PopupState& state) switch (mACNewNameError) { case NameSelectionError::None: break; case NameSelectionError::Duplicated: - ImGui::ErrorMessage("Duplicate template name"); + ImGui::ErrorMessage(ls->DuplicateNameError.Get()); break; case NameSelectionError::Empty: - ImGui::ErrorMessage("Template name cannot be empty"); + ImGui::ErrorMessage(ls->EmptyNameError.Get()); break; } }; @@ -841,13 +841,13 @@ void WorkflowAssetList::DisplayAssetCreator(PopupState& state) ValidateNewName(); }; - if (ImGui::InputText("Name", &mACNewName)) { + if (ImGui::InputText(ls->Name.Get(), &mACNewName)) { ValidateNewName(); } ShowNewNameErrors(); - if (ImGui::Button(ls->DialogConfirm.Get(), !IsInputValid())) { + if (ImGui::Button(ls->Confirm.Get(), !IsInputValid())) { ImGui::CloseCurrentPopup(); Create(SavedAsset{ @@ -856,16 +856,18 @@ void WorkflowAssetList::DisplayAssetCreator(PopupState& state) ResetState(); } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } } void WorkflowAssetList::SetupDetailsTable(const char* tableId) const { + auto ls = LocaleStrings::Instance.get(); + ImGui::BeginTable(tableId, 1, ImGuiTableFlags_Borders); - ImGui::TableSetupColumn("Name"); + ImGui::TableSetupColumn(ls->Name.Get()); ImGui::TableHeadersRow(); } diff --git a/core/src/UI/Localization.hpp b/core/src/UI/Localization.hpp index 43ee23b..3474053 100644 --- a/core/src/UI/Localization.hpp +++ b/core/src/UI/Localization.hpp @@ -21,9 +21,19 @@ public: BasicTranslation Delete{ "Generic.Delete"sv }; BasicTranslation Rename{ "Generic.Rename"sv }; BasicTranslation Disconnect{ "Generic.Disconnect"sv }; + BasicTranslation Open{ "Generic.Open"sv }; BasicTranslation Close{ "Generic.Close"sv }; - BasicTranslation DialogConfirm{ "Generic.Dialog.Confirm"sv }; - BasicTranslation DialogCancel{ "Generic.Dialog.Cancel"sv }; + BasicTranslation Confirm{ "Generic.Confirm"sv }; + BasicTranslation Cancel{ "Generic.Cancel"sv }; + BasicTranslation Name{ "Generic.Name"sv }; + BasicTranslation Type{ "Generic.Type"sv }; + + BasicTranslation AddDialogTitle{ "Generic.Add.DialogTitle"sv }; + BasicTranslation DeleteDialogTitle{ "Generic.Delete.DialogTitle"sv }; + BasicTranslation RenameDialogTitle{ "Generic.Rename.DialogTitle"sv }; + + BasicTranslation EmptyNameError{ "Generic.EmptyNameError"sv }; + BasicTranslation DuplicateNameError{ "Generic.DuplicateNameError"sv }; /* Main window */ @@ -101,13 +111,16 @@ public: BasicTranslation ItemStockColumn{ "Item.Column.Stock"sv }; BasicTranslation ItemPriceColumn{ "Item.Column.Price"sv }; - BasicTranslation EmptyItemNameError{ "Item.EmptyNameError"sv }; - BasicTranslation DuplicateItemNameError{ "Item.DuplicateNameError"sv }; + /* Assets */ + + BasicTranslation OpenAsset{ "Asset.Open"sv }; + BasicTranslation OpenAssetDialogTitle{ "Asset.Open.DialogTitle"sv }; + BasicTranslation ManageAssets{ "Asset.Manage"sv }; + BasicTranslation ManageAssetsDialogTitle{ "Asset.Manage.DialogTitle"sv }; /* Workflow tab */ - BasicTranslation OpenWorkflow{ "Workflow.Open"sv }; - BasicTranslation OpenWorkflowDialogTitle{ "Workflow.Open.DialogTitle"sv }; - BasicTranslation ManageWorkflows{ "Workflow.Manage"sv }; - BasicTranslation ManageWorkflowsDialogTitle{ "Workflow.Manage.DialogTitle"sv }; + /* Templates tab */ + + BasicTranslation InvalidTemplateTypeError{ "Template.InvalidTypeError"sv }; }; diff --git a/core/src/UI/UI_Items.cpp b/core/src/UI/UI_Items.cpp index d006166..6887f23 100644 --- a/core/src/UI/UI_Items.cpp +++ b/core/src/UI/UI_Items.cpp @@ -57,16 +57,16 @@ ActionResult ItemEditor(ItemList<T>& list, T* item) if constexpr (kHasEmail) ImGui::InputText(ls->ItemEmailColumn.Get(), &email); if (name.empty()) { - ImGui::ErrorMessage("%s", ls->EmptyItemNameError.Get()); + ImGui::ErrorMessage("%s", ls->EmptyNameError.Get()); } if (duplicateName) { - ImGui::ErrorMessage("%s", ls->DuplicateItemNameError.Get()); + ImGui::ErrorMessage("%s", ls->DuplicateNameError.Get()); } // Return Value auto rv = ActionResult::Pending; - if (ImGui::Button(ls->DialogConfirm.Get(), name.empty() || duplicateName)) { + if (ImGui::Button(ls->Confirm.Get(), name.empty() || duplicateName)) { if (item->GetName() != name) { item->SetName(std::move(name)); } @@ -85,7 +85,7 @@ ActionResult ItemEditor(ItemList<T>& list, T* item) } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); ClearStates(); rv = ActionResult::Canceled; @@ -221,12 +221,12 @@ void ItemListEditor(ItemList<T>& list) if (ImGui::BeginPopupModal(ls->DeleteItemDialogTitle.Get(), &opened, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::TextUnformatted(ls->DeleteItemDialogMessage.Get()); - if (ImGui::Button(ls->DialogConfirm.Get())) { + if (ImGui::Button(ls->Confirm.Get())) { ImGui::CloseCurrentPopup(); } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } diff --git a/core/src/UI/UI_MainWindow.cpp b/core/src/UI/UI_MainWindow.cpp index 18f6731..8131508 100644 --- a/core/src/UI/UI_MainWindow.cpp +++ b/core/src/UI/UI_MainWindow.cpp @@ -84,7 +84,7 @@ void ProjectTab_NoProject() ImGui::Spacing(); - if (ImGui::Button(ls->DialogConfirm.Get(), !dirNameIsValid || projectName.empty())) { + if (ImGui::Button(ls->Confirm.Get(), !dirNameIsValid || projectName.empty())) { ImGui::CloseCurrentPopup(); gs.SetCurrentProject(std::make_unique<Project>(std::move(dirPath), std::move(projectName))); @@ -97,7 +97,7 @@ void ProjectTab_NoProject() } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } diff --git a/core/src/UI/UI_Templates.cpp b/core/src/UI/UI_Templates.cpp index d48e8bf..b3a1e05 100644 --- a/core/src/UI/UI_Templates.cpp +++ b/core/src/UI/UI_Templates.cpp @@ -137,16 +137,9 @@ void UI::TemplatesTab() auto ls = LocaleStrings::Instance.get(); auto& project = *GlobalStates::GetInstance().GetCurrentProject(); - enum class PopupType - { - None, - TemplateSelect, - Management, - }; - static std::unique_ptr<TemplateUI> openTemplate; - static AssetList::PopupState popup; - static PopupType popupType = PopupType::None; + static AssetList::ListState state; + bool openedDummy = true; // Toolbar item: close if (ImGui::Button(ls->Close.Get(), openTemplate == nullptr)) { @@ -155,30 +148,30 @@ void UI::TemplatesTab() // Toolbar item: open... ImGui::SameLine(); - if (ImGui::Button("Open...")) { - project.Templates.OpenDetailsPopup(); - popupType = PopupType::TemplateSelect; + if (ImGui::Button(ls->OpenAsset.Get())) { + ImGui::OpenPopup(ls->OpenAssetDialogTitle.Get()); + } + if (ImGui::BeginPopupModal(ls->OpenAssetDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::Button(ls->Open.Get(), state.SelectedAsset == nullptr)) { + auto kind = static_cast<Template::Kind>(state.SelectedAsset->Payload); + openTemplate = TemplateUI::CreateByKind(kind); + } + ImGui::SameLine(); + project.Templates.DisplayControls(state); + project.Templates.DisplayDetailsList(state); + + ImGui::EndPopup(); } // Toolbar item: manage... ImGui::SameLine(); - if (ImGui::Button("Manage...")) { - project.Templates.OpenDetailsPopup(); - popupType = PopupType::Management; + if (ImGui::Button(ls->ManageAssets.Get())) { + ImGui::OpenPopup(ls->ManageAssetsDialogTitle.Get()); } - - switch (popupType) { - case PopupType::TemplateSelect: - if (ImGui::Button("Open", popup.SelectedAsset == nullptr)) { - auto kind = static_cast<Template::Kind>(popup.SelectedAsset->Payload); - openTemplate = TemplateUI::CreateByKind(kind); - } - project.Templates.DisplayDetailsPopup(popup); - break; - - default: - project.Templates.DisplayDetailsPopup(popup); - break; + if (ImGui::BeginPopupModal(ls->ManageAssetsDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + project.Templates.DisplayControls(state); + project.Templates.DisplayDetailsList(state); + ImGui::EndPopup(); } if (openTemplate) { diff --git a/core/src/UI/UI_Workflows.cpp b/core/src/UI/UI_Workflows.cpp index 3c23c30..3230cf9 100644 --- a/core/src/UI/UI_Workflows.cpp +++ b/core/src/UI/UI_Workflows.cpp @@ -365,16 +365,9 @@ void UI::WorkflowsTab() auto ls = LocaleStrings::Instance.get(); auto& project = *GlobalStates::GetInstance().GetCurrentProject(); - enum class PopupType - { - None, - WorkflowSelect, - Management, - }; - static std::unique_ptr<WorkflowUI> openWorkflow; - static AssetList::PopupState popup; - static PopupType popupType = PopupType::None; + static AssetList::ListState state; + bool openedDummy = true; // Toolbar item: close if (ImGui::Button(ls->Close.Get(), openWorkflow == nullptr)) { @@ -383,31 +376,30 @@ void UI::WorkflowsTab() // Toolbar item: open... ImGui::SameLine(); - if (ImGui::Button(ls->OpenWorkflow.Get())) { - project.Workflows.OpenDetailsPopup(); - popupType = PopupType::WorkflowSelect; + if (ImGui::Button(ls->OpenAsset.Get())) { + ImGui::OpenPopup(ls->OpenAssetDialogTitle.Get()); + } + if (ImGui::BeginPopupModal(ls->OpenAssetDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::Button(ls->Open.Get(), state.SelectedAsset == nullptr)) { + auto workflow = project.Workflows.Load(*state.SelectedAsset); + openWorkflow = std::make_unique<WorkflowUI>(std::move(workflow)); + } + ImGui::SameLine(); + project.Workflows.DisplayControls(state); + project.Workflows.DisplayDetailsList(state); + + ImGui::EndPopup(); } // Toolbar item: manage... ImGui::SameLine(); - if (ImGui::Button(ls->ManageWorkflows.Get())) { - project.Workflows.OpenDetailsPopup(); - popupType = PopupType::Management; + if (ImGui::Button(ls->ManageAssets.Get())) { + ImGui::OpenPopup(ls->ManageAssetsDialogTitle.Get()); } - - project.Workflows.DisplayDetailsPopup(popup); - switch (popupType) { - case PopupType::WorkflowSelect: - if (ImGui::Button("Open", popup.SelectedAsset == nullptr)) { - auto workflow = project.Workflows.Load(*popup.SelectedAsset); - openWorkflow = std::make_unique<WorkflowUI>(std::move(workflow)); - } - project.Workflows.DisplayDetailsPopup(popup); - break; - - default: - project.Workflows.DisplayDetailsPopup(popup); - break; + if (ImGui::BeginPopupModal(ls->ManageAssetsDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + project.Workflows.DisplayControls(state); + project.Workflows.DisplayDetailsList(state); + ImGui::EndPopup(); } if (openWorkflow) { |