mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-04 11:35:06 +03:00
NK-107 - Context Menu Folder
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemUI::DrawDirectory(Ref<Directory> directory)
|
||||
void FileSystemUI::DrawDirectory(Ref<Directory> directory, uint32_t drawId)
|
||||
{
|
||||
ImGui::PushFont(FontManager::GetFont(Icons));
|
||||
const char* icon = ICON_FA_FOLDER;
|
||||
@@ -65,6 +65,63 @@ namespace Nuake
|
||||
m_CurrentDirectory = directory;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup(hoverMenuId.c_str()))
|
||||
{
|
||||
if (ImGui::MenuItem("Open"))
|
||||
{
|
||||
m_CurrentDirectory = directory;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginMenu("Copy"))
|
||||
{
|
||||
if (ImGui::MenuItem("Full Path"))
|
||||
{
|
||||
OS::CopyToClipboard(directory->fullPath);
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Directory Name"))
|
||||
{
|
||||
OS::CopyToClipboard(String::Split(directory->name, '/')[0]);
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Delete"))
|
||||
{
|
||||
if (FileSystem::DeleteFolder(directory->fullPath) != 0)
|
||||
{
|
||||
Logger::Log("Failed to remove directory: " + directory->name, "editor", CRITICAL);
|
||||
}
|
||||
RefreshFileBrowser();
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 0.2f));
|
||||
if (ImGui::MenuItem("Rename"))
|
||||
{
|
||||
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("Show in File Explorer"))
|
||||
{
|
||||
OS::OpenIn(directory->fullPath);
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::Text(directory->name.c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
@@ -229,10 +286,7 @@ namespace Nuake
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
if (file->GetExtension() == ".scene")
|
||||
{
|
||||
PopupHelper::Confirmation(openScene);
|
||||
}
|
||||
shouldOpenScene = file->GetExtension() == ".scene";
|
||||
}
|
||||
|
||||
if (shouldOpenScene)
|
||||
@@ -545,7 +599,7 @@ namespace Nuake
|
||||
else
|
||||
ImGui::TableNextRow();
|
||||
|
||||
DrawDirectory(d);
|
||||
DrawDirectory(d, i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Nuake {
|
||||
void DrawDirectoryContent();
|
||||
void DrawFiletree();
|
||||
void EditorInterfaceDrawFiletree(Ref<Directory> dir);
|
||||
void DrawDirectory(Ref<Directory> directory);
|
||||
void DrawDirectory(Ref<Directory> directory, uint32_t drawId);
|
||||
bool EntityContainsItself(Entity source, Entity target);
|
||||
void DrawFile(Ref<File> file, uint32_t drawId);
|
||||
void DrawDirectoryExplorer();
|
||||
|
||||
@@ -178,6 +178,11 @@ namespace Nuake
|
||||
return std::remove(path.c_str());
|
||||
}
|
||||
|
||||
int FileSystem::DeleteFolder(const std::string& path)
|
||||
{
|
||||
return std::filesystem::remove_all(path.c_str());
|
||||
}
|
||||
|
||||
Ref<Directory> FileSystem::GetFileTree()
|
||||
{
|
||||
return RootDirectory;
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Nuake
|
||||
static bool WriteLine(const std::string line);
|
||||
static void EndWriteFile();
|
||||
static int RemoveFile(const std::string& path);
|
||||
static int DeleteFolder(const std::string& path);
|
||||
};
|
||||
|
||||
class File
|
||||
|
||||
Reference in New Issue
Block a user