Tiny, lightweight, and type-safe managed Windows library for lifecycle management and window creation
- 💨 Extremly fast and lightweight
- Made with a single responsibility, spawn a window and manage its lifecycle. From calling
Run()to the window being displayed takes on average 170ms
- Made with a single responsibility, spawn a window and manage its lifecycle. From calling
- ✅ Type safe:
- Fully abstracts away raw
User32P/Invoke calls into type-safe C# abstractions.
- Fully abstracts away raw
- 🎫 Easy event lifecycle:
- Zero-allocation event system. Every underlying Windows message (
WM_*) maps neatly to a dedicatedEventDispatcher.
- Zero-allocation event system. Every underlying Windows message (
- 🛠️ Developer Comforts
- Has a safe cross-thread scheduling, low-memory handling indicators via
WM_COMPACTING, system theme detection, native taskbar flashing api and a clipboard api.
- Has a safe cross-thread scheduling, low-memory handling indicators via
- 🚫 No AI Slop
- Purely written by passionete single-brain-celled autistic individual
Getting a window up and running requires minimal boilerplate!
Here's how to initialize ChibiWindow and hook into events
// Create window class
var window = new ChibiWindow
{
Title = "Hello! 🌸"
};
// Hook into the easy event ecosystem
window.OnWindowCreated.Subscribe(ev =>
{
Console.WriteLine($"Window successfully spawned with handle: {ev.Handle}");
});
window.OnKeyDown.Subscribe(ev =>
{
Console.WriteLine($"Key Pressed: {ev.Key}");
if (ev.Key == User32.VK.VK_ESCAPE)
{
window.Dispose();
}
});
window.OnMouseMove.Subscribe(ev =>
{
Console.WriteLine($"Mouse Moved: {ev.Now.X}, {ev.Now.Y}");
});
// Bind your custom loop frame logic
window.OnFrame = () =>
{
// Your rendering logic here!
// If left null, Chibi automatically optimizes CPU cycles via MsgWaitForMultipleObjectsEx
// If you are making more complex program or a game, I recommend not using this and using your own render loop/thread instead
};
// Run the window (this blocks the execution thread)
window.Run(1280, 720, WindowFlags.Resizable | WindowFlags.HighPixelDensity);Install via the NuGet Package Manager Console:
Install-Package SynesthesiaDev.Chibi.CoreOr via the .NET CLI:
dotnet add package SynesthesiaDev.Chibi.Core⣇⣿⠘⣿⣿⣿⡿⡿⣟⣟⢟⢟⢝⠵⡝⣿⡿⢂⣼⣿⣷⣌⠩⡫⡻⣝⠹⢿⣿⣷
⡆⣿⣆⠱⣝⡵⣝⢅⠙⣿⢕⢕⢕⢕⢝⣥⢒⠅⣿⣿⣿⡿⣳⣌⠪⡪⣡⢑⢝⣇
⡆⣿⣿⣦⠹⣳⣳⣕⢅⠈⢗⢕⢕⢕⢕⢕⢈⢆⠟⠋⠉⠁⠉⠉⠁⠈⠼⢐⢕⢽
⡗⢰⣶⣶⣦⣝⢝⢕⢕⠅⡆⢕⢕⢕⢕⢕⣴⠏⣠⡶⠛⡉⡉⡛⢶⣦⡀⠐⣕⢕
⡝⡄⢻⢟⣿⣿⣷⣕⣕⣅⣿⣔⣕⣵⣵⣿⣿⢠⣿⢠⣮⡈⣌⠨⠅⠹⣷⡀⢱⢕
⡝⡵⠟⠈⢀⣀⣀⡀⠉⢿⣿⣿⣿⣿⣿⣿⣿⣼⣿⢈⡋⠴⢿⡟⣡⡇⣿⡇⡀⢕
⡝⠁⣠⣾⠟⡉⡉⡉⠻⣦⣻⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣦⣥⣿⡇⡿⣰⢗⢄
⠁⢰⣿⡏⣴⣌⠈⣌⠡⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⣉⣉⣁⣄⢖⢕⢕⢕
⡀⢻⣿⡇⢙⠁⠴⢿⡟⣡⡆⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣵⣵⣿
⡻⣄⣻⣿⣌⠘⢿⣷⣥⣿⠇⣿⣿⣿⣿⣿⣿⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣷⢄⠻⣿⣟⠿⠦⠍⠉⣡⣾⣿⣿⣿⣿⣿⣿⢸⣿⣦⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟
⡕⡑⣑⣈⣻⢗⢟⢞⢝⣻⣿⣿⣿⣿⣿⣿⣿⠸⣿⠿⠃⣿⣿⣿⣿⣿⣿⡿⠁⣠
⡝⡵⡈⢟⢕⢕⢕⢕⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⣀⣈⠙
⡝⡵⡕⡀⠑⠳⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⡠⡲⡫⡪⡪⡣
ps.. in Chibi.Example is included cool particle sim
that I wrote using GDI32 as a test