Attempt #3 at making an ImGui backend for C# for simple, cross-platform UI creation.
| GimmeGui | ||
| GimmeGui.Demo | ||
| .gitignore | ||
| GimmeGui.slnx | ||
| LICENSE | ||
| README.md | ||
GimmeGui - for when you need GUI now.
GimmeGui is a simple C# backend for Dear ImGui that makes it easy to quickly get set up and running with a functional UI.
Basic usage
Displaying a UI is a simple matter of calling GimmeGui.Now(Action<Window, Renderer>) and passing in your UI drawing function.
Below is a demo program showing how quickly you can create a window to render your GUI in:
using Hexa.NET.ImGui;
using System.Numerics;
using GimmeGuiLib;
namespace DemoProgram;
static class Program
{
static bool _check;
static string _input = "";
static float _slider;
static Vector4 _color = Vector4.One; // Initialize to white
public static void Main(string[] args)
{
// Using an inline delegate for simplicity
GimmeGui.Now((window, renderer) =>
{
/*
* The u8 makes constant UTF8 strings to avoid
* UTF16 -> UTF8 conversions each frame.
*/
if (ImGui.Begin("Here's a window!"u8))
{
ImGui.SeparatorText("Here's a few test widgets just to show this works"u8);
ImGui.Checkbox("Check this out!"u8, ref _check);
ImGui.InputText("Type here"u8, ref _input, 1024);
ImGui.SliderFloat("Slide me!"u8, ref _slider, 0f, 10f);
ImGui.ColorEdit4("Color input!"u8, ref _color.X);
// I find adding curly braces makes push/pop areas more visible.
ImGui.PushStyleColor(ImGuiCol.Text, _color);
{
ImGui.TextWrapped("Here's some text that'll be colored by the color picker widget"u8);
}
ImGui.PopStyleColor();
}
ImGui.End();
if (_check)
ImGui.ShowDemoWindow();
});
}
}
Currently the user-facing API is rather simplistic, but there is a more advanced example in the demo project if you want to get your hands dirty.
Libraries used
- Dear ImGui by ocornut
- SDL3-CS by edwardgushchin
- Hexa.NET.ImGui from HexaEngine
- NetVips by kleisauke
- Wraps LibVips