Improved entry placement, word wrapping for file names

This commit is contained in:
Simon Lübeß
2025-07-04 10:45:42 +02:00
parent 5cffe34620
commit 736c8ce205
@@ -619,8 +619,6 @@ namespace GlitchyEditor.EditWindows
} }
} }
private static float2 DirectoryItemSize = .(110, 110);
const float2 padding = .(24, 24); const float2 padding = .(24, 24);
//private Rectangle _selectionRect = .(float.NaN, -1); //private Rectangle _selectionRect = .(float.NaN, -1);
@@ -659,10 +657,6 @@ namespace GlitchyEditor.EditWindows
List<TreeNode<AssetNode>> directoryEntries = null; List<TreeNode<AssetNode>> directoryEntries = null;
ImGui.Style* style = ImGui.GetStyle();
float window_visible_x2 = ImGui.GetWindowPos().x + ImGui.GetWindowContentRegionMax().x;
StringView searchFilter = StringView(&_filesFilter); StringView searchFilter = StringView(&_filesFilter);
if (_searchEverywhere && searchFilter.Length > 0) if (_searchEverywhere && searchFilter.Length > 0)
@@ -712,13 +706,10 @@ namespace GlitchyEditor.EditWindows
return score; return score;
}); });
ImGui.PushStyleVar(.ItemSpacing, float2(0, 0)); float buttonsPerRow = ImGui.GetContentRegionAvail().x / (IconSize.X + ImGui.GetStyle().ItemSpacing.x);
defer ImGui.PopStyleVar();
float buttonsPerRow = ImGui.GetContentRegionAvail().x / (DirectoryItemSize.X + ImGui.GetStyle().ItemSpacing.x);
int actualButtonsPerRow = (int)buttonsPerRow; int actualButtonsPerRow = (int)buttonsPerRow;
float actualSpace = (ImGui.GetContentRegionAvail().x - actualButtonsPerRow * DirectoryItemSize.X) / (actualButtonsPerRow + 1); float actualSpace = (ImGui.GetContentRegionAvail().x - actualButtonsPerRow * IconSize.X) / (actualButtonsPerRow);
int column = 0; int column = 0;
@@ -734,7 +725,7 @@ namespace GlitchyEditor.EditWindows
column++; column++;
if (column < actualButtonsPerRow) if (column < actualButtonsPerRow)
ImGui.SameLine((DirectoryItemSize.X + actualSpace) * column); ImGui.SameLine((IconSize.X + actualSpace) * column);
else else
column = 0; column = 0;
@@ -842,9 +833,7 @@ namespace GlitchyEditor.EditWindows
defer {ImGui.PopStyleVar(3); } defer {ImGui.PopStyleVar(3); }
float2 DirectoryItemSize = IconSize + (float2)ImGui.GetStyle().WindowPadding * 2 + float2(0, ImGui.GetFontSize()); ImGui.BeginGroup();
ImGui.BeginChild("item", (.)DirectoryItemSize, .None, .NoScrollbar);
if (IsFileSelected(entry->Path)) if (IsFileSelected(entry->Path))
{ {
@@ -940,7 +929,9 @@ namespace GlitchyEditor.EditWindows
} }
else else
{ {
ImGui.TextUnformatted(itemType == .ParentDirectory ? ".." : entry->Name); ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + IconSize.X);
ImGui.Text(itemType == .ParentDirectory ? ".." : entry->Name);
ImGui.PopTextWrapPos();
} }
if (ImGui.BeginPopupContextWindow()) if (ImGui.BeginPopupContextWindow())
@@ -979,7 +970,7 @@ namespace GlitchyEditor.EditWindows
ImGui.EndPopup(); ImGui.EndPopup();
} }
ImGui.EndChild(); ImGui.EndGroup();
ImGui.AttachTooltip(entry->Name); ImGui.AttachTooltip(entry->Name);
} }