diff --git a/build/savedatda.json b/build/savedatda.json new file mode 100644 index 0000000..31ce767 --- /dev/null +++ b/build/savedatda.json @@ -0,0 +1,4 @@ +{ + "data": {}, + "save": true +} \ No newline at end of file diff --git a/lib/cherry b/lib/cherry index 73671d2..61b914a 160000 --- a/lib/cherry +++ b/lib/cherry @@ -1 +1 @@ -Subproject commit 73671d22866ce25f64ebbf06d3ddcbd16c6d9b46 +Subproject commit 61b914ad5717fa514b9d626052489dbde7e6f1ab diff --git a/lib/json b/lib/json index 6325839..378e091 160000 --- a/lib/json +++ b/lib/json @@ -1 +1 @@ -Subproject commit 63258397761b3dd96dd171e5a5ad5aa915834c35 +Subproject commit 378e091795a70fced276cd882bd8a6a428668fe5 diff --git a/lib/spdlog b/lib/spdlog index 16e0d2e..1245bf8 160000 --- a/lib/spdlog +++ b/lib/spdlog @@ -1 +1 @@ -Subproject commit 16e0d2e77c9b8c741b0b23d9def2db04de6b1b41 +Subproject commit 1245bf8e8a19d914271df03124da9593f3634a9c diff --git a/main/src/modules/interface.cpp b/main/src/modules/interface.cpp index 053ef2d..5f9dd9a 100755 --- a/main/src/modules/interface.cpp +++ b/main/src/modules/interface.cpp @@ -45,6 +45,11 @@ void ModuleInterface::AddInputEvent(const ModuleInputEvent &event) void ModuleInterface::RefreshMainWindow() { + if(!&Cherry::Application::Get()) + { + return; + } + // Remove potential old main window for (auto &window : Cherry::Application::Get().m_AppWindows) { @@ -67,6 +72,11 @@ void ModuleInterface::RefreshMainWindow() void ModuleInterface::SetMainWindow(const std::shared_ptr &win) { m_main_window = win; + + if(&Cherry::Application::Get()) + { + RefreshMainWindow(); + } } /** diff --git a/ui/editor/app/core/modules_utility/modules_utility.cpp b/ui/editor/app/core/modules_utility/modules_utility.cpp index d5e6c9f..c978253 100755 --- a/ui/editor/app/core/modules_utility/modules_utility.cpp +++ b/ui/editor/app/core/modules_utility/modules_utility.cpp @@ -76,6 +76,23 @@ namespace VortexEditor truncatedText = name + "\n"; } + + const char *originalDesc = module->m_description.c_str(); + std::string truncatedDesc = module->m_description; + + if (ImGui::CalcTextSize(originalDesc).x > maxTextWidth) + { + truncatedDesc = module->m_description.substr(0, 20); + if (ImGui::CalcTextSize(truncatedDesc.c_str()).x > maxTextWidth) + { + truncatedDesc = module->m_description.substr(0, 10) + "\n" + module->m_description.substr(10, 10); + } + } + else + { + truncatedDesc = module->m_description + "\n"; + } + ImVec2 fixedSize(maxTextWidth + padding * 2 + 150.0f, logoSize + extraHeight + padding * 2); ImVec2 cursorPos = ImGui::GetCursorScreenPos(); @@ -166,7 +183,8 @@ namespace VortexEditor ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.5f, 1.0f)); ImGui::PushItemWidth(maxTextWidth); - ImGui::TextWrapped(module->m_description.c_str()); + + DrawDescription(drawList, descriptionPos, truncatedDesc.c_str(), ModulesSearch, highlightColor, textColor, highlightTextColor); ImGui::PopItemWidth(); ImGui::PopStyleColor(); diff --git a/ui/editor/app/core/utils.hpp b/ui/editor/app/core/utils.hpp index 90ad461..11ae6c8 100755 --- a/ui/editor/app/core/utils.hpp +++ b/ui/editor/app/core/utils.hpp @@ -248,6 +248,41 @@ static void MyButton(const std::string &name, int w, int h) if (cursorPos.x + totalSize.x < windowVisibleX2) ImGui::SameLine(); } +static void DrawDescription(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor) +{ + if (!text || !search || !*search) + { + drawList->AddText(textPos, textColor, text); + return; + } + + const char *start = text; + const char *found = strstr(start, search); + while (found) + { + if (found > start) + { + std::string preText(start, found); + drawList->AddText(textPos, textColor, preText.c_str()); + textPos.x += ImGui::CalcTextSize(preText.c_str()).x; + } + + ImVec2 highlightPos = textPos; + ImVec2 highlightSize = ImGui::CalcTextSize(search); + drawList->AddRectFilled(highlightPos, ImVec2(highlightPos.x + highlightSize.x, highlightPos.y + highlightSize.y), highlightColor); + drawList->AddText(textPos, highlightTextColor, search); + textPos.x += highlightSize.x; + + start = found + strlen(search); + found = strstr(start, search); + } + + if (*start) + { + drawList->AddText(textPos, textColor, start); + } +} + static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor) { @@ -261,7 +296,6 @@ static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char const char *found = strstr(start, search); while (found) { - // Dessiner le texte avant la correspondance if (found > start) { std::string preText(start, found); @@ -269,19 +303,16 @@ static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char textPos.x += ImGui::CalcTextSize(preText.c_str()).x; } - // Dessiner la correspondance mise en surbrillance avec un texte noir ImVec2 highlightPos = textPos; ImVec2 highlightSize = ImGui::CalcTextSize(search); drawList->AddRectFilled(highlightPos, ImVec2(highlightPos.x + highlightSize.x, highlightPos.y + highlightSize.y), highlightColor); drawList->AddText(textPos, highlightTextColor, search); textPos.x += highlightSize.x; - // Passer à la partie suivante du texte start = found + strlen(search); found = strstr(start, search); } - // Dessiner le texte restant après la dernière correspondance if (*start) { drawList->AddText(textPos, textColor, start); diff --git a/ui/editor/app/instances/content_browser/content_browser.cpp b/ui/editor/app/instances/content_browser/content_browser.cpp index aba2d3d..460fed5 100755 --- a/ui/editor/app/instances/content_browser/content_browser.cpp +++ b/ui/editor/app/instances/content_browser/content_browser.cpp @@ -493,16 +493,46 @@ namespace VortexEditor std::string label = std::to_string(m_Selected.size()) + " selected."; ImGui::Text(label.c_str()); } }); + m_AppWindow->m_Closable = true; + m_AppWindow->SetCloseCallback([this]() + { Cherry::DeleteAppWindow(m_AppWindow); }); m_AppWindow->SetRightMenubarCallback([this]() { - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.4f, 0.4f, 0.4f, 0.7f)); - - if(cp_SettingsButton->Render()) - { - // - } - ImGui::PopStyleColor(); }); + { + static std::shared_ptr btn = std::make_shared("LogicContentManager.FindModules.Filter", "####filder"); + btn->SetScale(0.85f); + btn->SetInternalMarginX(10.0f); + btn->SetLogoSize(15, 15); + + btn->SetDropDownImage(Application::CookPath("resources/imgs/icons/misc/icon_down.png")); + btn->SetImagePath(Cherry::GetPath("resources/imgs/icons/misc/icon_filter.png")); + if (btn->Render("LogicContentManager")) +{ + ImVec2 mousePos = ImGui::GetMousePos(); + ImVec2 displaySize = ImGui::GetIO().DisplaySize; + ImVec2 popupSize(150, 100); + + if (mousePos.x + popupSize.x > displaySize.x) { + mousePos.x -= popupSize.x; + } + if (mousePos.y + popupSize.y > displaySize.y) { + mousePos.y -= popupSize.y; + } + + ImGui::SetNextWindowPos(mousePos); + ImGui::OpenPopup("ContextMenu"); +} + +if (ImGui::BeginPopup("ContextMenu")) +{ + ImGui::Checkbox("Show Filter pannel", &m_ShowFilterPannel); + ImGui::Checkbox("Show Thumbnail pannel", &m_ShowThumbnailVisualizer); + + ImGui::EndPopup(); +} + + } }); m_BaseDirectory = start_path; m_CurrentDirectory = m_BaseDirectory; @@ -510,22 +540,25 @@ namespace VortexEditor ContentBrowserChild sidebar("RenderSideBar", [this]() { RenderSideBar(); }); sidebar.Enable(); - sidebar.m_BackgroundColor = ImVec4(0.0f, 0.6f, 0.6f, 1.0f); + sidebar.m_DefaultSize = 250.0f; AddChild(sidebar); ContentBrowserChild filterbar("RenderFiltersBar", [this]() { RenderFiltersBar(); }); filterbar.Disable(); + filterbar.m_DefaultSize = 250.0f; AddChild(filterbar); ContentBrowserChild contentbar("RenderContentBar", [this]() { RenderContentBar(); }); contentbar.Enable(); + contentbar.m_DefaultSize = 750.0f; AddChild(ContentBrowserChild(contentbar)); ContentBrowserChild detailsbar("RenderDetailsBar", [this]() { RenderDetailsBar(); }); detailsbar.Disable(); + detailsbar.m_DefaultSize = 250.0f; AddChild(ContentBrowserChild(detailsbar)); } @@ -571,7 +604,7 @@ namespace VortexEditor } } - bool ContentBrowserAppWindow::MyButton(const std::string &name, const std::string &path, const std::string &description, const std::string &size, bool selected, const std::string &logo, ImU32 bgColor = IM_COL32(100, 100, 100, 255), ImU32 borderColor = IM_COL32(150, 150, 150, 255), ImU32 lineColor = IM_COL32(255, 255, 0, 255), float maxTextWidth = 100.0f, float borderRadius = 5.0f) + bool ContentBrowserAppWindow::ItemCard(const std::string &name, const std::string &path, const std::string &description, const std::string &size, bool selected, const std::string &logo, ImU32 bgColor = IM_COL32(100, 100, 100, 255), ImU32 borderColor = IM_COL32(150, 150, 150, 255), ImU32 lineColor = IM_COL32(255, 255, 0, 255), float maxTextWidth = 100.0f, float borderRadius = 5.0f) { bool pressed = false; @@ -1340,7 +1373,7 @@ namespace VortexEditor std::string folderSizeString = formatFileSize(folderSize); ImGui::PushID(filenameString.c_str()); - if (MyButton(filenameString, path, itemEntry.first->m_Description, folderSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_picture_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(itemEntry.first->m_LineColor.x, itemEntry.first->m_LineColor.y, itemEntry.first->m_LineColor.z, itemEntry.first->m_LineColor.w))) + if (ItemCard(filenameString, path, itemEntry.first->m_Description, folderSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_picture_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(itemEntry.first->m_LineColor.x, itemEntry.first->m_LineColor.y, itemEntry.first->m_LineColor.z, itemEntry.first->m_LineColor.w))) { if (ImGui::IsMouseDoubleClicked(0)) { @@ -1388,7 +1421,7 @@ namespace VortexEditor { case FileTypes::File_PICTURE: { - if (MyButton(filenameString, path, "Picture file", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_picture_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(255, 100, 150, 255))) + if (ItemCard(filenameString, path, "Picture file", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_picture_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(255, 100, 150, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1404,7 +1437,7 @@ namespace VortexEditor } case FileTypes::File_GIT: { - if (MyButton(filenameString, path, "Git File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_git_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) + if (ItemCard(filenameString, path, "Git File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_git_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1420,7 +1453,7 @@ namespace VortexEditor } case FileTypes::File_H: { - if (MyButton(filenameString, path, "C Header File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_c_h_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(220, 100, 220, 255))) + if (ItemCard(filenameString, path, "C Header File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_c_h_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(220, 100, 220, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1436,7 +1469,7 @@ namespace VortexEditor } case FileTypes::File_C: { - if (MyButton(filenameString, path, "C Source File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_c_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) + if (ItemCard(filenameString, path, "C Source File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_c_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1452,7 +1485,7 @@ namespace VortexEditor } case FileTypes::File_HPP: { - if (MyButton(filenameString, path, "C++ Header File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_cpp_h_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) + if (ItemCard(filenameString, path, "C++ Header File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_cpp_h_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1468,7 +1501,7 @@ namespace VortexEditor } case FileTypes::File_CPP: { - if (MyButton(filenameString, path, "C++ Source File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_cpp_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) + if (ItemCard(filenameString, path, "C++ Source File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_cpp_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(100, 100, 255, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1484,7 +1517,7 @@ namespace VortexEditor } case FileTypes::File_INI: { - if (MyButton(filenameString, path, "Init File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_ini_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(150, 150, 150, 255))) + if (ItemCard(filenameString, path, "Init File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_ini_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(150, 150, 150, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -1500,7 +1533,7 @@ namespace VortexEditor } default: { - if (MyButton(filenameString, path, "File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_unknow_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(150, 150, 150, 255))) + if (ItemCard(filenameString, path, "File", fileSizeString, selected, Application::CookPath("resources/imgs/icons/files/icon_unknow_file.png"), IM_COL32(56, 56, 56, 150), IM_COL32(50, 50, 50, 255), IM_COL32(150, 150, 150, 255))) { if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) { @@ -2045,9 +2078,9 @@ namespace VortexEditor return m_AppWindow; } - std::shared_ptr ContentBrowserAppWindow::Create(const std::string &name, const std::string& base_path) + std::shared_ptr ContentBrowserAppWindow::Create(const std::string &name, const std::string &base_path) { - auto instance = std::shared_ptr(new ContentBrowserAppWindow(name,base_path)); + auto instance = std::shared_ptr(new ContentBrowserAppWindow(name, base_path)); instance->SetupRenderCallback(); return instance; } @@ -2061,95 +2094,134 @@ namespace VortexEditor self->Render(); } }); } +void ContentBrowserAppWindow::Render() +{ + const float splitterWidth = 1.5f; + const float margin = 10.0f; + + auto &children = m_Childs; + ImVec2 availableSize = ImGui::GetContentRegionAvail(); - void ContentBrowserAppWindow::Render() + for (size_t i = 0; i < children.size(); ++i) { - const float splitterWidth = 2.5f; - const float margin = 10.0f; + auto &child = children[i]; + + if (child.m_Name == "RenderFiltersBar") + { + child.m_Disabled = !m_ShowFilterPannel; + } - auto &children = m_Childs; - static float lastTotalWidth = 0.0f; + if (child.m_Name == "RenderDetailsBar") + { + child.m_Disabled = !m_ShowThumbnailVisualizer; + } + } - ImVec2 availableSize = ImGui::GetContentRegionAvail(); - float totalAvailableSize = availableSize.x - (children.size() - 1) * splitterWidth - 40.0f; + if (m_ShowFilterPannel != m_PreviousFilterPannelState || m_ShowThumbnailVisualizer != m_PreviousThumbnailVisualizerState) + { + m_ChildSizesInitialized = false; + } - float usedSize = 0.0f; - int childrenWithoutDefaultSize = 0; + if (!m_ChildSizesInitialized) + { + float totalAvailableWidth = availableSize.x - (children.size() - 1) * splitterWidth; + int visibleChildrenCount = 0; - if (totalAvailableSize != lastTotalWidth && lastTotalWidth > 0.0f) + for (auto &child : children) { - float scale = totalAvailableSize / lastTotalWidth; + if (!child.m_Disabled) + visibleChildrenCount++; + } - for (auto &child : children) + float defaultSize = visibleChildrenCount > 0 ? totalAvailableWidth / visibleChildrenCount : 0.0f; + + for (auto &child : children) + { + if (!child.m_Disabled) { - child.m_Size *= scale; + child.m_Size = std::max(defaultSize, 50.0f); + } + else + { + child.m_Size = 0.0f; } - - lastTotalWidth = totalAvailableSize; } - if (lastTotalWidth == 0.0f) + m_ChildSizesInitialized = true; + } + + float totalChildSize = 0.0f; + int visibleChildrenCount = 0; + + for (auto &child : children) + { + if (!child.m_Disabled) { - float totalSizeAssigned = 0.0f; + totalChildSize += child.m_Size; + visibleChildrenCount++; + } + } - for (auto &child : children) - { - if (child.m_Disabled) - { - continue; - } + totalChildSize += (visibleChildrenCount - 1) * splitterWidth; - if (!child.m_Initialized || totalAvailableSize != lastTotalWidth) - { - if (child.m_DefaultSize > 0.0f) - { - child.m_Size = child.m_DefaultSize; - } - else - { - child.m_Size = totalAvailableSize / children.size(); - } - child.m_Initialized = true; - } - totalSizeAssigned += child.m_Size; - } + if (totalChildSize > availableSize.x) + { + float scaleFactor = availableSize.x / totalChildSize; - if (totalSizeAssigned < totalAvailableSize) + for (auto &child : children) + { + if (!child.m_Disabled) { - float remainingSize = totalAvailableSize - totalSizeAssigned; - for (auto &child : children) - { - child.m_Size += remainingSize / children.size(); - } + child.m_Size = std::max(child.m_Size * scaleFactor, 50.0f); } - - lastTotalWidth = totalAvailableSize; } + } - for (size_t i = 0; i < children.size(); ++i) + for (size_t i = 0; i < children.size(); ++i) + { + auto &child = children[i]; + + if (child.m_Disabled) { - auto &child = children[i]; + continue; + } - ImGui::PushStyleColor(ImGuiCol_ChildBg, child.m_BackgroundColor); - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGui::PushStyleColor(ImGuiCol_ChildBg, child.m_BackgroundColor); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); - std::string childname = child.m_Name + "##cbchildnh" + m_AppWindow->m_Name; - ImGui::BeginChild(childname.c_str(), ImVec2(child.m_Size, availableSize.y), true); + std::string childname = child.m_Name + "##cbchildnh" + m_AppWindow->m_Name + child.m_Name; + ImGui::BeginChild(childname.c_str(), ImVec2(child.m_Size, availableSize.y), true); - child.m_Child(); + child.m_Child(); - ImGui::EndChild(); - ImGui::PopStyleColor(2); + ImGui::EndChild(); + ImGui::PopStyleColor(2); + + int nextChildIndex = -1; + for (size_t j = i + 1; j < children.size(); ++j) + { + if (!children[j].m_Disabled) + { + nextChildIndex = j; + break; + } + } - if (i + 1 < children.size()) + if (nextChildIndex != -1) + { + VortexEditor::ContentBrowserChild &next_child = children[nextChildIndex]; + + if (i + 1 < children.size() && !children[i].m_Disabled && !next_child.m_Disabled) { - auto &next_child = children[i + 1]; ImGui::SameLine(); - std::string lab = "##cbsplitter" + child.m_Name + m_AppWindow->m_Name; + std::string lab = child.m_Name + m_AppWindow->m_Name + "####" + child.m_Name; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.5f, 0.5f, 1.0f)); - ImGui::Button(lab.c_str(), ImVec2(splitterWidth, -1)); + if(ImGui::Button(lab.c_str(), ImVec2(splitterWidth, -1))) + { + std::cout << "CLICKED " << lab << std::endl; + } ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) @@ -2161,21 +2233,17 @@ namespace VortexEditor { float delta = ImGui::GetIO().MouseDelta.x; - if (child.m_Size + delta < child.m_MinSize + margin) - { - delta = child.m_MinSize + margin - child.m_Size; - } - if (next_child.m_Size - delta < next_child.m_MinSize + margin) + if (child.m_Size >= 50.0f || child.m_Size == 0.0f) { - delta = next_child.m_Size - next_child.m_MinSize - margin; + if (next_child.m_Size >= 50.0f || next_child.m_Size == 0.0f) + { + child.m_Size += delta; + next_child.m_Size -= delta; + } } - if (child.m_Size + delta >= child.m_MinSize + margin && next_child.m_Size - delta >= next_child.m_MinSize + margin) - { - child.m_Size += delta; - next_child.m_Size -= delta; - lastTotalWidth = totalAvailableSize; - } + child.m_Size = std::max(child.m_Size, 50.0f); + next_child.m_Size = std::max(next_child.m_Size, 50.0f); } ImGui::SameLine(); @@ -2183,4 +2251,8 @@ namespace VortexEditor } } + m_PreviousFilterPannelState = m_ShowFilterPannel; + m_PreviousThumbnailVisualizerState = m_ShowThumbnailVisualizer; +} + } \ No newline at end of file diff --git a/ui/editor/app/instances/content_browser/content_browser.hpp b/ui/editor/app/instances/content_browser/content_browser.hpp index 6ec5211..4e93add 100755 --- a/ui/editor/app/instances/content_browser/content_browser.hpp +++ b/ui/editor/app/instances/content_browser/content_browser.hpp @@ -85,41 +85,30 @@ namespace VortexEditor std::string handler_plugin_name; }; - struct ContentBrowserChild +struct ContentBrowserChild +{ + std::function m_Child; + std::string m_Name; + bool m_Disabled = true; + float m_DefaultSize = 0.0f; + float m_Size = 0.0f; + ImVec4 m_BackgroundColor = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); + + void Enable() { - std::function m_Child; - std::string m_Name; - bool m_Disabled = true; - float m_DefaultSize = 0.0f; - float m_MinSize; - float m_MaxSize; - float m_Size = 200.0f; - float m_Ratio = 0.0f; - bool m_Resizable = true; - bool m_ResizeDisabled = false; - bool m_Initialized = false; - bool m_InitializedSec = false; - bool m_InitializedTh = false; - ImVec4 m_BackgroundColor = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - - void Enable() - { - m_Disabled = true; - } + m_Disabled = false; + } - void Disable() - { - m_Disabled = false; - } + void Disable() + { + m_Disabled = true; + } + + ContentBrowserChild(const std::string &name, const std::function &child, float defaultSize = 0.0f) + : m_Name(name), m_Child(child), m_DefaultSize(defaultSize), m_Size(defaultSize) {} + ContentBrowserChild(){}; +}; - ContentBrowserChild(const std::string &name, const std::function &child, const float &default_size = 0.0f, const bool &resize_disabled = false, const float &min_size = 0.0f, const float &max_size = 0.0f) - : m_Name(name), - m_Child(child), - m_ResizeDisabled(resize_disabled), - m_DefaultSize(default_size), - m_MinSize(min_size), - m_MaxSize(max_size) {} - }; class ContentBrowserAppWindow : public std::enable_shared_from_this { @@ -131,7 +120,7 @@ namespace VortexEditor void SetupRenderCallback(); void Render(); - bool MyButton(const std::string &name, const std::string &path, const std::string &description, const std::string &size, bool selected, const std::string &logo, ImU32 bgColor, ImU32 borderColor, ImU32 lineColor, float maxTextWidth, float borderRadius); + bool ItemCard(const std::string &name, const std::string &path, const std::string &description, const std::string &size, bool selected, const std::string &logo, ImU32 bgColor, ImU32 borderColor, ImU32 lineColor, float maxTextWidth, float borderRadius); void AddChild(const ContentBrowserChild &child); void ChangeDirectory(const std::filesystem::path &newDirectory); void GoBack(); @@ -195,11 +184,16 @@ namespace VortexEditor bool m_ShowTypes = false; bool m_ShowSizes = false; - // !!! - bool m_ShowFolderPannel = true; bool m_ShowFilterPannel = false; bool m_ShowThumbnailVisualizer = false; + bool m_PreviousFilterPannelState = false; + bool m_PreviousThumbnailVisualizerState = false; + + // !!! + bool m_ShowFolderPannel = true; bool m_ShowSelectionQuantifier = false; + bool m_ChildSizesInitialized = false; + ContentShowMode m_ShowMode = ContentShowMode::Thumbmails; diff --git a/ui/editor/app/instances/logs_utility/logs_utility.cpp b/ui/editor/app/instances/logs_utility/logs_utility.cpp index d0794b9..53094b3 100755 --- a/ui/editor/app/instances/logs_utility/logs_utility.cpp +++ b/ui/editor/app/instances/logs_utility/logs_utility.cpp @@ -13,7 +13,50 @@ namespace VortexEditor { m_AppWindow = std::make_shared(name, name); m_AppWindow->SetIcon("/usr/local/include/Vortex/imgs/vortex.png"); + m_AppWindow->SetInternalPaddingX(8.0f); + m_AppWindow->SetInternalPaddingY(8.0f); std::shared_ptr win = m_AppWindow; + m_CmdInputValue = std::make_shared(""); + + m_AppWindow->m_Closable = true; + m_AppWindow->SetCloseCallback([this]() + { Cherry::DeleteAppWindow(m_AppWindow); }); + + + m_AppWindow->SetLeftMenubarCallback([]() + { + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.4f, 0.4f, 0.4f, 0.7f)); + + { + std::shared_ptr btn = Application::Get().CreateComponent("add_button", "Clear", Application::CookPath("resources/imgs/icons/misc/icon_add.png")); + btn->SetScale(0.85f); + btn->SetInternalMarginX(10.0f); + btn->SetLogoSize(15, 15); + + if (btn->Render()) + { + } + } + ImGui::PopStyleColor(); }); + + m_AppWindow->SetLeftBottombarCallback([this]() + { + { + std::shared_ptr btn = Application::Get().CreateComponent("add_button", "Options.add", Application::CookPath("resources/imgs/icons/misc/icon_add.png")); + btn->SetScale(0.85f); + btn->SetInternalMarginX(10.0f); + btn->SetLogoSize(15, 15); + + if (btn->Render()) + { + } + } + { + ImGui::SetNextItemWidth(300.0f); + auto input = Application::Get().CreateComponent("keyvaldouble_1", m_CmdInputValue, "Simple string value"); + input->Render("input"); + } + }); this->ctx = VortexMaker::GetCurrentContext(); } @@ -42,81 +85,144 @@ namespace VortexEditor void LogsUtilityAppWindow::Render() { - float oldsize = ImGui::GetFont()->Scale; - ImGui::GetFont()->Scale *= 1.3; - ImGui::PushFont(ImGui::GetFont()); + // Configuration de la couleur de fond pour le "terminal" + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); - ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.5f), "Project contents of : "); - ImGui::SameLine(); - // ImGui::Text(this->ctx->name.c_str()); + // Crée un Child scrollable + if (ImGui::BeginChild("TerminalChild", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) + { + static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoPadOuterX | ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody; - ImGui::GetFont()->Scale = oldsize; - ImGui::PopFont(); + const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; - ImGui::Separator(); + // Début du tableau + if (ImGui::BeginTable("LogsTable", 4, flags)) + { + // Configuration des colonnes + ImGui::TableSetupColumn("Level", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 4.0f); + ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("Origin", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 12.0f); + ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f); - static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; - const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; + // Pas de header + // ImGui::TableHeadersRow(); <-- Supprimé - if (ImGui::BeginTable("3ways", 4, flags)) - { - // The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On - ImGui::TableSetupColumn("Level", ImGuiTableColumnFlags_NoHide); - ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f); - ImGui::TableSetupColumn("Origin", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 12.0f); - ImGui::TableSetupColumn("Log", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f); - ImGui::TableHeadersRow(); - - for (auto log : VortexMaker::GetCurrentContext()->registered_logs) - { - if (log->m_level == spdlog::level::critical && !FatalFilter) - continue; - if (log->m_level == spdlog::level::err && !ErrorFilter) - continue; - if (log->m_level == spdlog::level::warn && !WarnFilter) - continue; - if (log->m_level == spdlog::level::info && !InfoFilter) - continue; - - ImGui::TableNextRow(); - for (int i = 0; i <= 3; i++) + // Parcourir les logs + for (auto log : VortexMaker::GetCurrentContext()->registered_logs) { - ImGui::TableSetColumnIndex(i); - if (i == 0) + if ((log->m_level == spdlog::level::critical && !FatalFilter) || + (log->m_level == spdlog::level::err && !ErrorFilter) || + (log->m_level == spdlog::level::warn && !WarnFilter) || + (log->m_level == spdlog::level::info && !InfoFilter)) + { + continue; + } + + ImGui::TableNextRow(); + + // Gestion du survol et de la copie + bool is_hovered = ImGui::IsItemHovered(); + if (is_hovered) + { + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // Texte surbrillant + } + + if (ImGui::IsMouseClicked(0) && is_hovered) { - if (log->m_level == spdlog::level::critical) + std::string content_to_copy = log->m_timestamp + " | " + log->m_filter + " | " + log->m_message; + ImGui::SetClipboardText(content_to_copy.c_str()); + } + + // Colonnes du tableau + for (int i = 0; i <= 3; i++) + { + ImGui::TableSetColumnIndex(i); + if (i == 0) // Niveau avec pastille { - ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Fatal"); + ImVec4 color; + switch (log->m_level) + { + case spdlog::level::critical: + color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f); + break; // Rouge + case spdlog::level::err: + color = ImVec4(0.8f, 0.2f, 0.2f, 1.0f); + break; // Rouge clair + case spdlog::level::warn: + color = ImVec4(0.8f, 0.8f, 0.0f, 1.0f); + break; // Jaune + case spdlog::level::info: + color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f); + break; // Vert + default: + color = ImVec4(0.5f, 0.5f, 0.5f, 1.0f); + break; // Gris par défaut + } + + // Récupérer la position actuelle + ImVec2 pos = ImGui::GetCursorScreenPos(); + float radius = ImGui::GetFontSize() * 0.2f; // Taille du cercle + ImVec2 center = ImVec2(pos.x + radius, pos.y + radius); // Calculer le centre du cercle + + // Dessiner le cercle coloré + ImGui::GetWindowDrawList()->AddCircleFilled(center, radius, ImGui::GetColorU32(color)); + + // Ajuster le curseur pour laisser de l'espace après le cercle + ImGui::Dummy(ImVec2(radius * 2.5f, radius * 2.0f)); // Espace réservé (largeur et hauteur) } - else if (log->m_level == spdlog::level::err) + + else if (i == 1) // Message (coloré par niveau + texte wrappé) { - ImGui::TextColored(ImVec4(0.8f, 0.2f, 0.2f, 1.0f), "Error"); + ImVec4 message_color; + if (log->m_level == spdlog::level::critical) + { + message_color = ImVec4(0.5f, 0.0f, 0.0f, 1.0f); // Rouge foncé + } + else if (log->m_level == spdlog::level::err) + { + message_color = ImVec4(0.8f, 0.2f, 0.2f, 1.0f); // Rouge clair + } + else if (log->m_level == spdlog::level::warn) + { + message_color = ImVec4(1.0f, 1.0f, 0.0f, 1.0f); // Jaune + } + else + { + message_color = ImVec4(1.0f, 1.0f, 1.0f, 0.8f); // Blanc (par défaut) + } + + ImGui::PushTextWrapPos(ImGui::GetCursorPosX() + ImGui::GetColumnWidth()); + ImGui::TextColored(message_color, log->m_message.c_str()); + ImGui::PopTextWrapPos(); } - else if (log->m_level == spdlog::level::warn) + else if (i == 2) // Origin (aligné à droite) { - ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.0f, 1.0f), "Warning"); + float column_width = ImGui::GetColumnWidth(); + float text_width = ImGui::CalcTextSize(log->m_filter.c_str()).x; + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + column_width - text_width); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.5f), log->m_filter.c_str()); } - else if (log->m_level == spdlog::level::info) + else if (i == 3) // Timestamp (aligné à droite) { - ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Information"); + float column_width = ImGui::GetColumnWidth(); + float text_width = ImGui::CalcTextSize(log->m_timestamp.c_str()).x; + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + column_width - text_width); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.5f), log->m_timestamp.c_str()); } } - else if (i == 1) - { - ImGui::Text(log->m_timestamp.c_str()); - } - else if (i == 2) - { - ImGui::Text(log->m_filter.c_str()); - } - else if (i == 3) + + // Nettoyage des styles + if (is_hovered) { - ImGui::Text(log->m_message.c_str()); + ImGui::PopStyleColor(); } } + + ImGui::EndTable(); } - ImGui::EndTable(); } + ImGui::EndChild(); + ImGui::PopStyleColor(); // Restaurer la couleur de fond } void LogsUtilityAppWindow::OnImGuiRender() diff --git a/ui/editor/app/instances/logs_utility/logs_utility.hpp b/ui/editor/app/instances/logs_utility/logs_utility.hpp index 96d4794..9b17019 100755 --- a/ui/editor/app/instances/logs_utility/logs_utility.hpp +++ b/ui/editor/app/instances/logs_utility/logs_utility.hpp @@ -35,6 +35,7 @@ namespace VortexEditor private: VxContext *ctx; bool opened; + std::shared_ptr m_CmdInputValue; std::shared_ptr m_AppWindow; }; } diff --git a/ui/editor/app/src/editor.cpp b/ui/editor/app/src/editor.cpp index 93b81a6..16d84c7 100755 --- a/ui/editor/app/src/editor.cpp +++ b/ui/editor/app/src/editor.cpp @@ -374,7 +374,7 @@ Cherry::Application *CreateEditor(int argc, char **argv) app->SetDefaultLocale("en"); app->SetLocale("fr"); - for(auto& modules : VortexMaker::GetCurrentContext()->IO.em) + for (auto &modules : VortexMaker::GetCurrentContext()->IO.em) { modules->RefreshMainWindow(); } @@ -556,14 +556,20 @@ Cherry::Application *CreateEditor(int argc, char **argv) if (ImGui::BeginMenu("Tools")) { - if (ImGui::MenuItem("Content Browser", "Open a new project content browser", false)) + + Cherry::MenuItemTextSeparator("Contents, managment"); + + if (ImGui::MenuItem("Content Browser", "Open a content browser", Cherry::GetTexture(Cherry::GetPath("resources/imgs/icons/misc/icon_collection.png")), c_Editor->GetModuleUtilityVisibility())) { c_Editor->SpawnContentBrowser(); - } - if (ImGui::MenuItem("Logs utility", "Open a new console logs", false)) + } + + Cherry::MenuItemTextSeparator("Console, logs, debugging"); + if (ImGui::MenuItem("Console logs", "Open a console with logs", Cherry::GetTexture(Cherry::GetPath("resources/imgs/icons/misc/icon_journal.png")), c_Editor->GetModuleUtilityVisibility())) { c_Editor->SpawnLogsUtility(); - } + } + ImGui::EndMenu(); } diff --git a/ui/editor/app/src/editor.hpp b/ui/editor/app/src/editor.hpp index 47fbb69..9018675 100755 --- a/ui/editor/app/src/editor.hpp +++ b/ui/editor/app/src/editor.hpp @@ -146,7 +146,7 @@ class Editor void SpawnContentBrowser() { - std::string label = "Content Browser ####-" + std::to_string(c_ContentBrowserInstances.size() + 1); + std::string label = "Content Browser ####Content Browser-" + std::to_string(c_ContentBrowserInstances.size() + 1); std::shared_ptr ContentBrowser = VortexEditor::ContentBrowserAppWindow::Create(label.c_str(), "/home/diego"); Cherry::AddAppWindow(ContentBrowser->GetAppWindow()); c_ContentBrowserInstances.push_back(ContentBrowser); @@ -154,7 +154,7 @@ class Editor void SpawnLogsUtility() { - std::string label = "Logs utility ####-" + std::to_string(c_LogsUtilityInstances.size() + 1); + std::string label = "Logs utility ####Logs utility-" + std::to_string(c_LogsUtilityInstances.size() + 1); std::shared_ptr LogsUtility = VortexEditor::LogsUtilityAppWindow::Create(label.c_str()); Cherry::AddAppWindow(LogsUtility->GetAppWindow()); c_LogsUtilityInstances.push_back(LogsUtility);