From e30546c22f0642873a99234bbca308362a7c8966 Mon Sep 17 00:00:00 2001 From: "Diego E. Moreno" Date: Sun, 28 Apr 2024 11:34:13 +0200 Subject: [PATCH] Codebase: Continuing to improve --- Dockerfile | 12 +- tools/editor/app/core/ModuleManager.cpp | 188 ++++++++++++------------ tools/editor/app/src/editor.cpp | 170 +++++++++++---------- 3 files changed, 191 insertions(+), 179 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1de070..30f8851 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,12 @@ FROM ubuntu:24.04 # Mettre à jour les paquets ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -RUN apt-get install software-properties-common -y -RUN add-apt-repository ppa:graphics-drivers -RUN apt-get install nvidia-driver-440 -y -RUN apt-get clean \ -RUN rm -rf /var/lib/apt/lists/* +RUN apt-get update \ + && apt-get install software-properties-common -y \ + && add-apt-repository ppa:graphics-drivers \ + && apt-get install nvidia-driver-440 -y \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # Installer les paquets nécessaires RUN apt-get install -y xorg nano xterm libx11-dev git libglfw3-dev make gcc libxi-dev libxcursor-dev libspdlog-dev vulkan-tools wget libglfw3 libvulkan-dev cmake libxinerama-dev unzip nvidia-driver-470 nlohmann-json3-dev diff --git a/tools/editor/app/core/ModuleManager.cpp b/tools/editor/app/core/ModuleManager.cpp index 885edaf..71fe34b 100644 --- a/tools/editor/app/core/ModuleManager.cpp +++ b/tools/editor/app/core/ModuleManager.cpp @@ -333,8 +333,36 @@ void ModuleManager::OnImGuiRender() ImGui::End(); } -void ModuleManager::menubar() -{ + +// Helper functions for menu items + +void handleRefresh() { + // Behavior +} + +void handleAddToProject() { + // Behavior +} + +void handleFilterBuildRebuild() { + // Behavior +} + +void handleGlobalBuild() { + // Behavior +} + +void handleCreateModule() { + // Behavior +} + +void handleSearch() { + // Behavior +} + +// Main menu function + +void ModuleManager::menubar() { static ImTextureID refreshIcon = this->m_RefreshIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); static ImTextureID addIcon = this->m_AddIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); static bool open_ADDMODULE = false; @@ -343,65 +371,49 @@ void ModuleManager::menubar() static int selected = 0; static std::vector syslabels; - for (auto em : ctx->IO.sys_em) - { + for (auto em : ctx->IO.sys_em) { bool add = true; - for (auto label : syslabels) - { - if (label == em->m_group) - { + for (auto label : syslabels) { + if (label == em->m_group) { add = false; } } - if (add) - { + if (add) { syslabels.push_back(em->m_group); } } - if (open_ADDMODULE) - { - if (ImGui::BeginPopupModal("Add module(s)", NULL, ImGuiWindowFlags_MenuBar)) - { - if (ImGui::BeginMenuBar()) - { - if (ImGui::Button("Close")) - { - open_ADDMODULE = false; - } - if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) - { - // Behavior - } - ImGui::Separator(); - if (ImGui::ImageButtonWithText(addIcon, "Browse public modules", ImVec2(this->m_AddIcon->GetWidth(), this->m_AddIcon->GetHeight()))) - { - // Behavior - } - ImGui::Separator(); - if (ImGui::BeginMenu("Filters")) - { - if (ImGui::MenuItem("Build/Rebuild single parts")) - { - // Behavior - } - if (ImGui::MenuItem("Global build")) - { - // Behavior + if (open_ADDMODULE) { + if (ImGui::BeginPopupModal("Add module(s)", NULL, ImGuiWindowFlags_MenuBar)) { + if (ImGui::BeginMenuBar()) { + if (ImGui::Button("Close")) { + open_ADDMODULE = false; + } + if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) { + handleRefresh(); + } + ImGui::Separator(); + if (ImGui::ImageButtonWithText(addIcon, "Browse public modules", ImVec2(this->m_AddIcon->GetWidth(), this->m_AddIcon->GetHeight()))) { + // Behavior + } + ImGui::Separator(); + if (ImGui::BeginMenu("Filters")) { + if (ImGui::MenuItem("Build/Rebuild single parts")) { + handleFilterBuildRebuild(); + } + if (ImGui::MenuItem("Global build")) { + handleGlobalBuild(); + } + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); } - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - ImGui::BeginChild("left pane", ImVec2(230, -1), true); - for (int i = 0; i < syslabels.size(); i++) - { - if (i == 0) - { + for (int i = 0; i < syslabels.size(); i++) { + if (i == 0) { std::string label = "All modules (" + std::to_string(this->ctx->IO.sys_em.size()) + ")"; ImGui::TextColored(ImVec4(0.4, 0.4, 0.4, 1), label.c_str()); } @@ -409,10 +421,8 @@ void ModuleManager::menubar() std::string label; int number = 0; - for (auto sysem : this->ctx->IO.sys_em) - { - if (sysem->m_group == syslabels[i]) - { + for (auto sysem : this->ctx->IO.sys_em) { + if (sysem->m_group == syslabels[i]) { number++; } } @@ -436,10 +446,8 @@ void ModuleManager::menubar() ImGuiID id = ImGui::GetID(label.c_str()); ImGui::BeginChildFrame(id, ImVec2(0, 0), true); - for (int i = 0; i < ctx->IO.sys_em.size(); i++) - { - if (ctx->IO.sys_em[i]->m_group == syslabels[selected]) - { + for (int i = 0; i < ctx->IO.sys_em.size(); i++) { + if (ctx->IO.sys_em[i]->m_group == syslabels[selected]) { std::string childLabel = "module##" + ctx->IO.sys_em[i]->m_name; ImGui::BeginChild(childLabel.c_str(), ImVec2(0, 250), true); @@ -487,14 +495,11 @@ void ModuleManager::menubar() { ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.5f), "Contributors : "); int i = 0; - for (auto contributor : ctx->IO.sys_em[i]->m_contributors) - { + for (auto contributor : ctx->IO.sys_em[i]->m_contributors) { i++; - if (i <= 3) - { + if (i <= 3) { } - else - { + else { ImGui::SameLine(); int counter = ctx->IO.sys_em[i]->m_contributors.size() - 3; std::string label = " and " + std::to_string(counter) + " other..."; @@ -504,10 +509,9 @@ void ModuleManager::menubar() } } - if (ImGui::ImageButtonWithText(addIcon, "Add to the current project", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) - { - // Behavior - } + if (ImGui::ImageButtonWithText(addIcon, "Add to the current project", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) { + handleAddToProject(); + } ImGui::EndChild(); } ImGui::EndChildFrame(); @@ -519,54 +523,42 @@ void ModuleManager::menubar() if (open_ADDMODULE) ImGui::OpenPopup("Add module(s)"); - if (ImGui::BeginMenuBar()) - { - if (ImGui::ImageButtonWithText(addIcon, "Add", ImVec2(this->m_AddIcon->GetWidth(), this->m_AddIcon->GetHeight()))) - { + if (ImGui::BeginMenuBar()) { + if (ImGui::ImageButtonWithText(addIcon, "Add", ImVec2(this->m_AddIcon->GetWidth(), this->m_AddIcon->GetHeight()))) { open_ADDMODULE = true; } - if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) - { - // Behavior + if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight()))) { + handleRefresh(); } ImGui::Separator(); - if (ImGui::BeginMenu("Filters")) - { - if (ImGui::MenuItem("Build/Rebuild single parts")) - { - // Behavior + if (ImGui::BeginMenu("Filters")) { + if (ImGui::MenuItem("Build/Rebuild single parts")) { + handleFilterBuildRebuild(); } - if (ImGui::MenuItem("Global build")) - { - // Behavior + if (ImGui::MenuItem("Global build")) { + handleGlobalBuild(); } ImGui::EndMenu(); } - if (ImGui::BeginMenu("Create a module")) - { - if (ImGui::MenuItem("Build/Rebuild single parts")) - { - // Behavior + if (ImGui::BeginMenu("Create a module")) { + if (ImGui::MenuItem("Build/Rebuild single parts")) { + handleCreateModule(); } - if (ImGui::MenuItem("Global build")) - { - // Behavior + if (ImGui::MenuItem("Global build")) { + handleGlobalBuild(); } ImGui::EndMenu(); } - if (ImGui::BeginMenu("Search")) - { - if (ImGui::MenuItem("Build/Rebuild single parts")) - { - // Behavior + if (ImGui::BeginMenu("Search")) { + if (ImGui::MenuItem("Build/Rebuild single parts")) { + handleSearch(); } - if (ImGui::MenuItem("Global build")) - { - // Behavior + if (ImGui::MenuItem("Global build")) { + handleGlobalBuild(); } ImGui::EndMenu(); } ImGui::EndMenuBar(); } -} \ No newline at end of file +} diff --git a/tools/editor/app/src/editor.cpp b/tools/editor/app/src/editor.cpp index 4527f75..a412f91 100644 --- a/tools/editor/app/src/editor.cpp +++ b/tools/editor/app/src/editor.cpp @@ -1,82 +1,102 @@ #include "editor.h" -void ApplicationLayer::menubar(const std::shared_ptr& exampleLayer, UIKit::Application* app) -{ - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Exit")) - { - app->Close(); - } - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Edit")) - { - if (ImGui::MenuItem("Project Settings", "Main configurations of this project")) - { - // Behavior - } - ImGui::Separator(); - if (ImGui::MenuItem("Manage plugins", "Add, remove, edit plugins of this project")) - { - // Behavior - } - if (ImGui::MenuItem("Manage modules", "Project file manager", &exampleLayer->ShowModulesManager)) - { - // Behavior - } - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Window")) - { - if (ImGui::MenuItem("Show bottom toolbar", "Get some usefull tools in a bottom bar.")) - { - // Behavior - } - if (ImGui::MenuItem("Show simplified header", "Reduce the size of header")) - { - app->m_Specification.CustomTitlebar = !app->m_Specification.CustomTitlebar; - } - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Tools")) - { - if (ImGui::MenuItem("Content Browser", "Project file manager", &exampleLayer->ShowContentBrowser)) - { - // Behavior - } - if (ImGui::MenuItem("Project Viewer", "Project component manager", &exampleLayer->ShowProjectViewer)) - { - // Behavior - } - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Help")) - { - if (ImGui::MenuItem("News", "Get latest Vortex news")) - { - // Behavior +// Helper functions for menu items + +void handleExit(UIKit::Application* app) { + app->Close(); +} + +void handleProjectSettings() { + // Behavior +} + +void handleManagePlugins() { + // Behavior +} + +void handleManageModules(bool& showModulesManager) { + // Behavior +} + +void handleShowBottomToolbar() { + // Behavior +} + +void handleShowSimplifiedHeader(UIKit::Application* app) { + app->m_Specification.CustomTitlebar = !app->m_Specification.CustomTitlebar; +} + +void handleContentBrowser(bool& showContentBrowser) { + // Behavior +} + +void handleProjectViewer(bool& showProjectViewer) { + // Behavior +} + +void handleNews() { + // Behavior +} + +void handleCommunity() { + // Behavior +} + +void handleTutorials() { + // Behavior +} + +void handleDocumentation() { + // Behavior +} + +// Main menu function +void ApplicationLayer::menubar(const std::shared_ptr& exampleLayer, UIKit::Application* app) { + if (ImGui::BeginMenu("File")) { + if (ImGui::MenuItem("Exit")) + handleExit(app); + ImGui::EndMenu(); } - if (ImGui::MenuItem("Community", "Join a community of creators")) - { - // Behavior + + if (ImGui::BeginMenu("Edit")) { + if (ImGui::MenuItem("Project Settings", "Main configurations of this project")) + handleProjectSettings(); + ImGui::Separator(); + if (ImGui::MenuItem("Manage plugins", "Add, remove, edit plugins of this project")) + handleManagePlugins(); + if (ImGui::MenuItem("Manage modules", "Project file manager", &exampleLayer->ShowModulesManager)) + handleManageModules(exampleLayer->ShowModulesManager); + ImGui::EndMenu(); } - if (ImGui::MenuItem("Tutorials", "Get bunch of tutorials")) - { - // Behavior + + if (ImGui::BeginMenu("Window")) { + if (ImGui::MenuItem("Show bottom toolbar", "Get some useful tools in a bottom bar.")) + handleShowBottomToolbar(); + if (ImGui::MenuItem("Show simplified header", "Reduce the size of header")) + handleShowSimplifiedHeader(app); + ImGui::EndMenu(); } - if (ImGui::MenuItem("Documentation", "See official documentation of Vortex Maker")) - { - // Behavior + + if (ImGui::BeginMenu("Tools")) { + if (ImGui::MenuItem("Content Browser", "Project file manager", &exampleLayer->ShowContentBrowser)) + handleContentBrowser(exampleLayer->ShowContentBrowser); + if (ImGui::MenuItem("Project Viewer", "Project component manager", &exampleLayer->ShowProjectViewer)) + handleProjectViewer(exampleLayer->ShowProjectViewer); + ImGui::EndMenu(); } - ImGui::Separator(); - if (ImGui::MenuItem("Exit")) - { - app->Close(); + + if (ImGui::BeginMenu("Help")) { + if (ImGui::MenuItem("News", "Get latest Vortex news")) + handleNews(); + if (ImGui::MenuItem("Community", "Join a community of creators")) + handleCommunity(); + if (ImGui::MenuItem("Tutorials", "Get bunch of tutorials")) + handleTutorials(); + if (ImGui::MenuItem("Documentation", "See official documentation of Vortex Maker")) + handleDocumentation(); + ImGui::Separator(); + if (ImGui::MenuItem("Exit")) + handleExit(app); + ImGui::EndMenu(); } - ImGui::EndMenu(); - } -} \ No newline at end of file +}