Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 53 additions & 19 deletions SilkWindows/Implementations/FileManager/NewSubfolderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,49 @@ internal sealed class NewSubfolderWindow(DirectoryInfo directoryInfo) : IImguiDr
public void Init()
{
}

public void OnRender(string windowName, double deltaSeconds, ImFonts fonts)
{
ImGui.BeginChild(directoryInfo.FullName + '/');

// Top margin
ImGui.Dummy(new Vector2(0, 20));

// Left margin using indent
ImGui.Indent(20);

ImGui.PushFont(fonts.Large);
ImGui.Text("Enter name for new subfolder:");
ImGui.PopFont();


// Spacing between label and input
ImGui.Dummy(new Vector2(0, 10));

ImGui.SetNextItemWidth(ImGui.GetWindowWidth()-40); // Set a specific width for the input field

if (ImGui.InputText("##newSubfolderInput", ref _newSubfolderInput, 32))
{
_inputValid = _newSubfolderInput.Length > 0
&& _newSubfolderInput.IndexOfAny(Path.GetInvalidFileNameChars()) < 0;
}

if(!_inputValid)

// Spacing between input and button
ImGui.Dummy(new Vector2(0, 15));

if (!_inputValid)
ImGui.BeginDisabled();


// Button colors for visual feedback
var buttonColor = new Vector4(0.2f, 0.6f, 0.9f, 1f);
var buttonHoverColor = new Vector4(0.3f, 0.7f, 1f, 1f);
var buttonActiveColor = new Vector4(0.15f, 0.5f, 0.8f, 1f);

ImGui.PushStyleColor(ImGuiCol.Button, buttonColor);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, buttonHoverColor);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, buttonActiveColor);

// Button padding
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(20, 10));

if (ImGui.Button("Create"))
{
try
Expand All @@ -46,45 +72,53 @@ public void OnRender(string windowName, double deltaSeconds, ImFonts fonts)
_errorText = e.Message;
}
}

if(!_inputValid)

ImGui.PopStyleVar(); // Frame padding
ImGui.PopStyleColor(3); // Button colors
ImGui.PopFont();

if (!_inputValid)
ImGui.EndDisabled();

if (!string.IsNullOrWhiteSpace(_errorText))
{
ImGui.Dummy(new Vector2(0, 10));
var errorColor = new Vector4(1f, 0.1f, 0.1f, 1f);
ImGui.PushFont(fonts.Bold);
ImGui.PushStyleColor(ImGuiCol.Text, errorColor);
ImGui.Text(_errorText);
ImGui.PopStyleColor();
ImGui.PopFont();
}


ImGui.Unindent(20);

ImGui.EndChild();
}

public void OnWindowUpdate(double deltaSeconds, out bool shouldClose)
{
shouldClose = _shouldClose;

}

public void OnClose()
{

}

public void OnFileDrop(string[] filePaths)
{

}

public void OnWindowFocusChanged(bool changedTo)
{

}

public DirectoryInfo? Result { get; private set; }

private string _errorText = "";
private bool _shouldClose;
private bool _inputValid;
Expand Down
Loading