From 1d5e3a964020943e5774b2bdb9ee8931f717cd54 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 27 Sep 2023 22:43:28 -0400 Subject: [PATCH] Fixed context menu on files in file system, added back double click to load project in welcome window --- Editor/src/Windows/FileSystemUI.cpp | 45 +++++++++---------- Editor/src/Windows/WelcomeWindow.cpp | 9 +++- .../Rendering/Buffers/VertexBufferLayout.h | 30 ------------- 3 files changed, 30 insertions(+), 54 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 9e659547..51175bfb 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -39,10 +39,6 @@ namespace Nuake void FileSystemUI::EditorInterfaceDrawFiletree(Ref dir) { - - - - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_FramePadding; //if (is_selected) @@ -76,6 +72,19 @@ namespace Nuake ImVec2 prevCursor = ImGui::GetCursorPos(); ImVec2 prevScreenPos = ImGui::GetCursorScreenPos(); const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.Directory == directory, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150)); + const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId); + if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1)) + { + ImGui::OpenPopup(hoverMenuId.c_str()); + m_HasClickedOnFile = true; + } + + const std::string renameId = "Rename" + std::string("##") + hoverMenuId; + bool shouldRename = false; + + const std::string deleteId = "Delete" + std::string("##") + hoverMenuId; + bool shouldDelete = false; + if (selected) { if (ImGui::IsMouseDoubleClicked(0)) @@ -93,7 +102,6 @@ namespace Nuake ImGui::SetCursorPos(prevCursor); ImGui::Image((ImTextureID)TextureManager::Get()->GetTexture("Resources/Images/folder_icon.png")->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0)); - auto imguiStyle = ImGui::GetStyle(); ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0); @@ -113,18 +121,7 @@ namespace Nuake ImGui::TextColored({ 1, 1, 1, 0.5f }, "Folder"); ImGui::PopStyleVar(); - const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId); - if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1)) - { - ImGui::OpenPopup(hoverMenuId.c_str()); - m_HasClickedOnFile = true; - } - - const std::string renameId = "Rename" + std::string("##") + hoverMenuId; - bool shouldRename = false; - - const std::string deleteId = "Delete" + std::string("##") + hoverMenuId; - bool shouldDelete = false; + if (ImGui::BeginPopup(hoverMenuId.c_str())) { @@ -239,6 +236,13 @@ namespace Nuake std::string id = std::string("##") + file->GetAbsolutePath(); const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.File == file, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150)); + const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId); + if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1)) + { + ImGui::OpenPopup(hoverMenuId.c_str()); + m_HasClickedOnFile = true; + } + bool shouldOpenScene = false; if (selected) { @@ -395,12 +399,7 @@ namespace Nuake ImGui::PopStyleVar(); - const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId); - if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1)) - { - ImGui::OpenPopup(hoverMenuId.c_str()); - m_HasClickedOnFile = true; - } + const std::string openSceneId = "Open Scene" + std::string("##") + hoverMenuId; diff --git a/Editor/src/Windows/WelcomeWindow.cpp b/Editor/src/Windows/WelcomeWindow.cpp index 8c02ec41..842fd2bf 100644 --- a/Editor/src/Windows/WelcomeWindow.cpp +++ b/Editor/src/Windows/WelcomeWindow.cpp @@ -207,12 +207,19 @@ namespace Nuake draw_list->ChannelsSetCurrent(1); //ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0)); - bool result = ImGui::Selectable(selectableName.c_str(), SelectedProject == itemIndex, ImGuiSelectableFlags_AllowOverlap, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight)); + bool result = ImGui::Selectable(selectableName.c_str(), SelectedProject == itemIndex, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight)); if (result) { SelectedProject = itemIndex; } + if (result && ImGui::IsMouseDoubleClicked(0)) + { + SaveRecentFile(); + + queuedProjectPath = _Projects[SelectedProject].Path;; + } + //ImGui::PopStyleColor(); draw_list->ChannelsMerge(); diff --git a/Nuake/src/Rendering/Buffers/VertexBufferLayout.h b/Nuake/src/Rendering/Buffers/VertexBufferLayout.h index 94f6c737..a0cbb0f5 100644 --- a/Nuake/src/Rendering/Buffers/VertexBufferLayout.h +++ b/Nuake/src/Rendering/Buffers/VertexBufferLayout.h @@ -77,34 +77,4 @@ namespace Nuake { inline unsigned int GetStride() const { return m_Stride; } }; - -#ifdef NK_WINs - template<> - void VertexBufferLayout::Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::FLOAT, count, false }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::FLOAT) * count; - } - - template<> - void VertexBufferLayout::Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::UINT, count, false }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UINT) * count; - } - - template<> - void VertexBufferLayout::Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::INT, count, false }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::INT) * count; - } - - template<> - void VertexBufferLayout::Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::UBYTE, count, true }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UBYTE) * count; - } - #endif } \ No newline at end of file