This project is no longer maintained. Its functionality has been moved to ktsu.ImGuiApp.
Please migrate to the new library for continued support and updates.
A comprehensive library for custom popup windows and modal dialogs using ImGui.NET, providing a rich set of UI components for interactive applications.
- Modal: Base modal window with customizable content and size
- MessageOK: Simple message dialog with OK button
- Prompt: Customizable prompt with multiple button options
- InputString: Text input popup with validation
- InputInt: Integer input popup with numeric validation
- InputFloat: Floating-point input popup with numeric validation
- SearchableList: Searchable dropdown list with filtering capabilities
- FilesystemBrowser: Advanced file/directory browser with:
- Open and Save modes
- File and Directory targeting
- Pattern filtering support
- Navigation breadcrumbs
- Responsive Design: All popups adapt to content and custom sizing
- Keyboard Navigation: Full keyboard support with proper focus management
- Validation: Built-in input validation and error handling
- Customizable: Flexible styling and layout options
- Type-Safe: Generic components with strong typing
Install-Package ktsu.ImGuiPopupsdotnet add package ktsu.ImGuiPopups<PackageReference Include="ktsu.ImGuiPopups" Version="1.3.5" />using ktsu.ImGuiPopups;
// Create popup instances (typically as class members)
private static readonly ImGuiPopups.MessageOK messageOK = new();
private static readonly ImGuiPopups.InputString inputString = new();
private static readonly ImGuiPopups.SearchableList<string> searchableList = new();
// In your ImGui render loop
private void OnRender()
{
// Show a simple message
if (ImGui.Button("Show Message"))
{
messageOK.Open("Information", "Hello, World!");
}
// Get text input from user
if (ImGui.Button("Get Input"))
{
inputString.Open("Enter Name", "Name:", "Default Name",
result => Console.WriteLine($"User entered: {result}"));
}
// Show searchable selection
if (ImGui.Button("Select Item"))
{
var items = new[] { "Apple", "Banana", "Cherry", "Date" };
searchableList.Open("Select Fruit", "Choose:", items, null,
item => item, // Text converter
selected => Console.WriteLine($"Selected: {selected}"),
Vector2.Zero);
}
// Render all popups (call this once per frame)
messageOK.ShowIfOpen();
inputString.ShowIfOpen();
searchableList.ShowIfOpen();
}Simple message dialog with an OK button.
var messageOK = new ImGuiPopups.MessageOK();
messageOK.Open("Title", "Your message here");Get validated input from users:
// String input
var inputString = new ImGuiPopups.InputString();
inputString.Open("Enter Text", "Label:", "default", result => HandleString(result));
// Integer input
var inputInt = new ImGuiPopups.InputInt();
inputInt.Open("Enter Number", "Value:", 42, result => HandleInt(result));
// Float input
var inputFloat = new ImGuiPopups.InputFloat();
inputFloat.Open("Enter Float", "Value:", 3.14f, result => HandleFloat(result));Searchable selection from a list of items:
var searchableList = new ImGuiPopups.SearchableList<MyClass>();
searchableList.Open(
title: "Select Item",
label: "Choose an item:",
items: myItemList,
defaultItem: null,
getText: item => item.DisplayName, // How to display items
onConfirm: selected => HandleSelection(selected),
customSize: new Vector2(400, 300)
);Advanced file and directory browser:
var browser = new ImGuiPopups.FilesystemBrowser();
// Open file
browser.Open(
title: "Open File",
mode: FilesystemBrowserMode.Open,
target: FilesystemBrowserTarget.File,
startPath: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
onConfirm: path => OpenFile(path),
patterns: new[] { "*.txt", "*.md" } // Optional file filters
);
// Save file
browser.Open(
title: "Save File",
mode: FilesystemBrowserMode.Save,
target: FilesystemBrowserTarget.File,
startPath: currentDirectory,
onConfirm: path => SaveFile(path)
);Create custom modal dialogs:
var customModal = new ImGuiPopups.Modal();
customModal.Open("Custom Dialog", () => {
ImGui.Text("Custom content here");
if (ImGui.Button("Close"))
{
ImGui.CloseCurrentPopup();
}
}, new Vector2(300, 200));All popups support custom sizing:
// Fixed size
popup.Open("Title", "Content", new Vector2(400, 300));
// Auto-size (Vector2.Zero)
popup.Open("Title", "Content", Vector2.Zero);Prompts support different text layout modes:
var prompt = new ImGuiPopups.Prompt();
prompt.Open("Title", "Long message text here...",
buttons: new() { { "OK", null }, { "Cancel", null } },
textLayoutType: PromptTextLayoutType.Wrapped, // or Unformatted
size: new Vector2(400, 200)
);Input components provide built-in validation:
inputInt.Open("Enter Age", "Age (1-120):", 25, result => {
if (result < 1 || result > 120)
{
messageOK.Open("Error", "Age must be between 1 and 120");
return;
}
ProcessAge(result);
});The repository includes a comprehensive demo application showcasing all components:
git clone https://github.com/ktsu-dev/ImGuiPopups.git
cd ImGuiPopups
dotnet run --project ImGuiPopupsDemo- Hexa.NET.ImGui - ImGui.NET bindings
- ktsu.Extensions - Utility extensions
- ktsu.CaseConverter - String case conversion
- ktsu.ScopedAction - RAII-style actions
- ktsu.StrongPaths - Type-safe path handling
- ktsu.TextFilter - Text filtering utilities
- Microsoft.Extensions.FileSystemGlobbing - File pattern matching
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE.md file for details.
See CHANGELOG.md for a detailed history of changes.
ktsu.dev - Building tools for developers