Fast navigation in "address bar"

This commit is contained in:
Simon Lübeß
2025-07-06 18:52:59 +02:00
parent 3e9c9e8202
commit 5f5192b0f4
@@ -1149,7 +1149,7 @@ namespace GlitchyEditor.EditWindows
} }
/// Shows the context menu for the given file/folder. /// Shows the context menu for the given file/folder.
private void ShowItemContextMenu() //(TreeNode<AssetNode> fileOrFolder, DirectoryItemType itemType, ref bool wantsDelete) private void ShowItemContextMenu()
{ {
bool singleEntry = _selectedFiles.Count == 1; bool singleEntry = _selectedFiles.Count == 1;
@@ -1223,24 +1223,21 @@ namespace GlitchyEditor.EditWindows
ImGui.EndMenu(); ImGui.EndMenu();
} }
/*if (singleEntry && itemType != .ParentDirectory)
{
ImGui.Separator(); ImGui.Separator();
if (ImGui.MenuItem("Rename")) if (ImGui.MenuItem("Rename"))
{ {
// Copy the path, just for the rare case that fileOrFolder gets deleted // Copy the path, just for the rare case that fileOrFolder gets deleted
_assetToRename.Set(fileOrFolder->Path); _assetToRename.Set(firstEntry->Path);
fileOrFolder->Name.CopyTo(_renameFileNameBuffer); firstEntry->Name.CopyTo(_renameFileNameBuffer);
} }
if (ImGui.MenuItem("Delete")) if (ImGui.MenuItem("Delete"))
{ {
wantsDelete = true; _wantsDelete = true;
} }
}
*/
ImGui.Separator(); ImGui.Separator();
if (singleEntry && ImGui.MenuItem("Properties...")) if (singleEntry && ImGui.MenuItem("Properties..."))
@@ -1279,6 +1276,8 @@ namespace GlitchyEditor.EditWindows
} }
} }
private TreeNode<AssetNode> _directoryToShowChildren;
void DrawNavigationBar() void DrawNavigationBar()
{ {
ImGui.BeginDisabled(!_directoryHistory.CanGoBack); ImGui.BeginDisabled(!_directoryHistory.CanGoBack);
@@ -1337,6 +1336,48 @@ namespace GlitchyEditor.EditWindows
String buttonText = scope .(128); String buttonText = scope .(128);
void DirectorySelectionContextMenu(TreeNode<AssetNode> parent, ImGui.PopupFlags flags = .MouseButtonRight)
{
void ShowDirectories(TreeNode<AssetNode> parent)
{
for (TreeNode<AssetNode> 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<AssetNode> node in path) for (TreeNode<AssetNode> node in path)
{ {
buttonText.SetF($"{node->Name}##{node->Path}"); buttonText.SetF($"{node->Name}##{node->Path}");
@@ -1346,6 +1387,8 @@ namespace GlitchyEditor.EditWindows
Navigate(node); Navigate(node);
} }
DirectorySelectionContextMenu(node.Parent);
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text("/"); ImGui.Text("/");
@@ -1353,6 +1396,13 @@ namespace GlitchyEditor.EditWindows
ImGui.SameLine(); ImGui.SameLine();
} }
if (_currentDirectoryNode.Children.Any((c) => c->IsDirectory))
{
ImGui.Button("...");
DirectorySelectionContextMenu(_currentDirectoryNode, .MouseButtonLeft);
}
ImGui.NewLine(); ImGui.NewLine();
} }
} }