From 1c97a5e9c494e6fbe39f3803c73a0b729db4b085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sun, 6 Jul 2025 12:55:09 +0200 Subject: [PATCH] Asset Browser: No longer show parent directory entry, navigate forward/backword with XButtons --- .../src/EditWindows/ContentBrowserWindow.bf | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf b/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf index 52e7675..fec1669 100644 --- a/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf +++ b/GlitchyEditor/src/EditWindows/ContentBrowserWindow.bf @@ -689,30 +689,35 @@ namespace GlitchyEditor.EditWindows /// Renders the contents of _currentDirectory. Returns the node of the current directory, or null if the browser isn't in a directory. private void DrawCurrentDirectory(TreeNode currentDirectoryNode) { + // TODO: Yes we really have to come up with a good system for hotkeys... var currentDirectoryNode; if (Input.IsKeyPressed(.Alt)) { if (Input.IsKeyPressing(.Up)) { - if (currentDirectoryNode.Parent != _manager.AssetHierarchy.RootNode) - { - _directoryHistory.Navigate(currentDirectoryNode.Parent->Path); - - _selectedFiles.ClearAndDeleteItems(); - currentDirectoryNode = currentDirectoryNode.Parent; - } + NavigateUp(); } if (Input.IsKeyPressing(.Left)) { NavigateBack(); } + if (Input .IsKeyPressing(.Right)) { NavigateForward(); } } + if (Input.IsMouseButtonPressing(.XButton1)) + { + NavigateForward(); + } + if (Input.IsMouseButtonPressing(.XButton2)) + { + NavigateBack(); + } + List> directoryEntries = null; StringView searchFilter = StringView(&_filesFilter); @@ -738,20 +743,9 @@ namespace GlitchyEditor.EditWindows directoryEntries = scope:: List>(); currentDirectoryNode.Children.CopyTo(directoryEntries); - - if (currentDirectoryNode.Parent != _manager.AssetHierarchy.RootNode) - { - directoryEntries.Add(currentDirectoryNode.Parent); - } } directoryEntries.Sort((entry1, entry2) => { - // Place parent directory at front - if (entry1 == currentDirectoryNode.Parent) - return -1; - if (entry2 == currentDirectoryNode.Parent) - return 1; - // Try to sort so that directories are before files. int score = entry2->IsDirectory <=> entry1->IsDirectory; @@ -778,7 +772,7 @@ namespace GlitchyEditor.EditWindows ImGui.PushID(entry->Path); - DrawDirectoryEntry(entry, entry == currentDirectoryNode.Parent ? .ParentDirectory : .Default); + DrawDirectoryEntry(entry); column++; @@ -878,14 +872,8 @@ namespace GlitchyEditor.EditWindows } } - enum DirectoryItemType - { - Default, - ParentDirectory - } - /// Renders the button for the given directory entry. - private void DrawDirectoryEntry(TreeNode entry, DirectoryItemType itemType) + private void DrawDirectoryEntry(TreeNode entry) { ImGui.PushStyleVar(.WindowPadding, .(0, 0)); ImGui.PushStyleVar(.FramePadding, .(0, 0)); @@ -1002,7 +990,7 @@ namespace GlitchyEditor.EditWindows else { ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + IconSize.X); - ImGui.Text(itemType == .ParentDirectory ? ".." : entry->Name); + ImGui.Text(entry->Name); ImGui.PopTextWrapPos(); } @@ -1352,9 +1340,13 @@ namespace GlitchyEditor.EditWindows ImGui.PushScopedStyleVar!(ImGui.TypedStyleVar.ItemSpacing(spacing)); ImGui.PushScopedStyleVar!(ImGui.TypedStyleVar.FrameRounding(0)); + String buttonText = scope .(128); + for (TreeNode node in path) { - if (ImGui.Button(node->Name) && node != _currentDirectoryNode) + buttonText.SetF($"{node->Name}##{node->Path}"); + + if (ImGui.Button(buttonText) && node != _currentDirectoryNode) { Navigate(node); }