Skip to content
/ MewUI Public

A cross-platform and lightweight, code-first .NET GUI framework aimed at NativeAOT.

License

Notifications You must be signed in to change notification settings

aprillz/MewUI

Repository files navigation

한국어

Aprillz.MewUI

.NET Windows Linux NativeAOT License: MIT NuGet NuGet Downloads


😺 MewUI is a cross-platform and lightweight, code-first .NET GUI framework aimed at NativeAOT.

🧪 Experimental Prototype

Important

This project is a proof-of-concept prototype for validating ideas and exploring design directions.
As it evolves toward v1.0, APIs, internal architecture, and runtime behavior may change significantly.
Backward compatibility is not guaranteed at this stage.

🤖 AI-Assisted Development

Note

This project was developed using an AI prompt–driven workflow.
Design and implementation were performed through iterative prompting without direct manual code edits,
with each step reviewed and refined by the developer.


🚀 Try It Out

You can run it immediately by entering the following command in the Windows command line or a Linux terminal. (.NET 10 SDK required)

Warning

This command downloads and executes code directly from GitHub.

curl -sL https://raw.githubusercontent.com/aprillz/MewUI/refs/heads/main/samples/FBASample/fba_sample.cs -o - | dotnet run -

Video

MewUI.Demo_0.4.1.mp4

Screenshots

Light Dark
Light (screenshot) Dark (screenshot)

✨ Highlights

  • 📦 NativeAOT + trimming first
  • 🪶 Lightweight by design (small EXE, low memory footprint, fast first frame — see benchmark below)
  • 🧩 Fluent C# markup (no XAML)

🪶 Lightweight

  • Executable size: NativeAOT + Trim focused (sample win-x64-trimmed is ~ 2.2 MB)
  • Sample runtime benchmark (NativeAOT + Trimmed, 50 launches):
Backend Loaded avg/p95 (ms) FirstFrame avg/p95 (ms) WS avg/p95 (MB) PS avg/p95 (MB)
Direct2D 10 / 11 178 / 190 40.0 / 40.1 54.8 / 55.8
GDI 15 / 21 54 / 67 15.2 / 15.3 4.6 / 4.8

🚀 Quickstart


🧪 C# Markup at a Glance


🎯 Concept

MewUI is a code-first GUI framework with three priorities:

  • NativeAOT + trimming friendliness
  • Small footprint, fast startup, low memory usage
  • Fluent C# markup for building UI trees (no XAML)
  • AOT-friendly binding

Non-goals (by design):

  • WPF-style animations, visual effects, or heavy composition pipelines
  • A large, “kitchen-sink” control catalog (keep the surface area small and predictable)
  • Complex path-based data binding
  • Full XAML/WPF compatibility or designer-first workflows

✂️ NativeAOT / Trim

  • The library aims to be trimming-safe by default (explicit code paths, no reflection-based binding).
  • Windows interop uses source-generated P/Invoke (LibraryImport) for NativeAOT compatibility.
  • On Linux, building with NativeAOT requires the AOT workload in addition to the regular .NET SDK (e.g. install dotnet-sdk-aot-10.0).
  • If you introduce new interop or dynamic features, verify with the trimmed publish profile above.

To check output size locally:

  • Publish: dotnet publish .\samples\MewUI.Sample\MewUI.Sample.csproj -c Release -p:PublishProfile=win-x64-trimmed
  • Inspect: .artifacts\publish\MewUI.Sample\win-x64-trimmed\

Reference (sample, win-x64-trimmed):

  • Aprillz.MewUI.Sample.exe ~ 2,257 KB

🔗 State & Binding (AOT-friendly)

Bindings are explicit and delegate-based (no reflection):

using Aprillz.MewUI.Binding;
using Aprillz.MewUI.Controls;

var percent = new ObservableValue<double>(
    initialValue: 0.25,
    coerce: v => Math.Clamp(v, 0, 1));

var slider = new Slider().BindValue(percent);
var label  = new Label().BindText(percent, v => $"Percent ({v:P0})");

🧱 Controls / Panels

Controls (implemented):

  • Button
  • Label, Image
  • TextBox, MultiLineTextBox
  • CheckBox, RadioButton
  • ComboBox, ListBox
  • Slider, ProgressBar
  • TabControl, GroupBox
  • MenuBar, ContextMenu, ToolTip (in-window popups)
  • Window
  • DispatcherTimer

Panels:

  • Grid (rows/columns with Auto, *, pixel)
  • StackPanel (horizontal/vertical + spacing)
  • DockPanel (dock edges + last-child fill)
  • UniformGrid (equal cells)
  • WrapPanel (wrap + item size + spacing)

🎨 Theme

MewUI uses a Theme object (colors + metrics) and ThemeManager to control defaults and runtime changes.

  • Configure defaults before Application.Run(...) via ThemeManager.Default*
  • Change at runtime via Application.Current.SetTheme(...) / Application.Current.SetAccent(...)

See: docs/Theme.md


🖌️ Rendering Backends

Rendering is abstracted through:

  • IGraphicsFactory / IGraphicsContext

Backends:

  • Direct2D (Windows): Aprillz.MewUI.Backend.Direct2D
  • GDI (Windows): Aprillz.MewUI.Backend.Gdi
  • OpenGL (Windows): Aprillz.MewUI.Backend.OpenGL.Win32
  • OpenGL (Linux/X11): Aprillz.MewUI.Backend.OpenGL.X11
  • Vulkan (Linux/X11, experimental): Aprillz.MewUI.Backend.Vulkan.X11

Backends are registered by the referenced backend packages (Trim/AOT-friendly). In app code you typically either:

  • call *Backend.Register() before Application.Run(...), or
  • use the builder chain: Application.Create().Use...().Run(...)

🪟 Platform Abstraction

Windowing and the message loop are abstracted behind a platform layer.

Currently implemented:

  • Windows (Aprillz.MewUI.Platform.Win32)
  • Linux/X11 (Aprillz.MewUI.Platform.X11, experimental)

Linux dialogs dependency

On Linux, MessageBox and file dialogs are currently implemented via external tools:

  • zenity (GNOME/GTK)
  • kdialog (KDE)

If neither is available in PATH, MewUI throws: PlatformNotSupportedException: No supported Linux dialog tool found (zenity/kdialog).


📄Docs


🧭 Roadmap (TODO)

Controls

  • ToggleSwitch
  • GridView

Features

  • Simple template support (Delegate-based)

Platforms

  • Linux/Wayland
  • macOS

Tooling

  • Hot Reload
  • Design-time preview

About

A cross-platform and lightweight, code-first .NET GUI framework aimed at NativeAOT.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages