diff --git a/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf b/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf index 430873a..05c447f 100644 --- a/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf +++ b/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf @@ -1149,7 +1149,7 @@ namespace GlitchyEditor.EditWindows } /// Shows the context menu for the given file/folder. - private void ShowItemContextMenu() //(TreeNode fileOrFolder, DirectoryItemType itemType, ref bool wantsDelete) + private void ShowItemContextMenu() { bool singleEntry = _selectedFiles.Count == 1; @@ -1223,24 +1223,21 @@ namespace GlitchyEditor.EditWindows ImGui.EndMenu(); } - /*if (singleEntry && itemType != .ParentDirectory) + ImGui.Separator(); + + if (ImGui.MenuItem("Rename")) { - ImGui.Separator(); + // Copy the path, just for the rare case that fileOrFolder gets deleted + _assetToRename.Set(firstEntry->Path); - if (ImGui.MenuItem("Rename")) - { - // Copy the path, just for the rare case that fileOrFolder gets deleted - _assetToRename.Set(fileOrFolder->Path); - - fileOrFolder->Name.CopyTo(_renameFileNameBuffer); - } - - if (ImGui.MenuItem("Delete")) - { - wantsDelete = true; - } + firstEntry->Name.CopyTo(_renameFileNameBuffer); } -*/ + + if (ImGui.MenuItem("Delete")) + { + _wantsDelete = true; + } + ImGui.Separator(); if (singleEntry && ImGui.MenuItem("Properties...")) @@ -1279,6 +1276,8 @@ namespace GlitchyEditor.EditWindows } } + private TreeNode _directoryToShowChildren; + void DrawNavigationBar() { ImGui.BeginDisabled(!_directoryHistory.CanGoBack); @@ -1337,6 +1336,48 @@ namespace GlitchyEditor.EditWindows String buttonText = scope .(128); + void DirectorySelectionContextMenu(TreeNode parent, ImGui.PopupFlags flags = .MouseButtonRight) + { + void ShowDirectories(TreeNode parent) + { + for (TreeNode node in parent.Children.Where((c) => c->IsDirectory)) + { + buttonText.SetF($"{node->Name}##{node->Path}"); + + if (node.Children.Any((c) => c->IsDirectory)) + { + if (ImGui.BeginMenu(buttonText)) + { + ShowDirectories(node); + ImGui.EndMenu(); + } + + if (ImGui.IsItemClicked()) + { + Navigate(node); + ImGui.CloseCurrentPopup(); + } + } + else + { + if (ImGui.MenuItem(buttonText)) + { + Navigate(node); + ImGui.CloseCurrentPopup(); + } + } + } + } + + // id == null -> Use ID of last Item + if (ImGui.BeginPopupContextItem(null, flags)) + { + ShowDirectories(parent); + + ImGui.EndPopup(); + } + } + for (TreeNode node in path) { buttonText.SetF($"{node->Name}##{node->Path}"); @@ -1346,6 +1387,8 @@ namespace GlitchyEditor.EditWindows Navigate(node); } + DirectorySelectionContextMenu(node.Parent); + ImGui.SameLine(); ImGui.Text("/"); @@ -1353,6 +1396,13 @@ namespace GlitchyEditor.EditWindows ImGui.SameLine(); } + if (_currentDirectoryNode.Children.Any((c) => c->IsDirectory)) + { + ImGui.Button("..."); + + DirectorySelectionContextMenu(_currentDirectoryNode, .MouseButtonLeft); + } + ImGui.NewLine(); } }