Engineering
Under the hood of Nimbus. Explore the architecture, design decisions, and internal mechanisms.
1. Architecture Overview
Nimbus is built on top of the .NET Framework 4.0 and WPF (Windows Presentation Foundation). It acts as a lightweight wrapper that translates XML declarative syntax into native WPF objects at runtime.
State Management • Plugins • Events
(Visuals)
(Behavior)
(Debug)
2. Execution Pipeline
When you run nimbus run App.xml, the following sequence occurs:
- Parsing:
XmlParserreads the XML file and separates UI, Logic, and Styles. - Initialization:
WpfEngineinitializes state variables and loads plugins. - UI Generation:
WpfUItraverses the XML tree and recursively creates WPF controls (`Grid`, `Button`, etc.). - Event Wiring: The engine connects attributes like `onClick` to the internal event handler system.
- Window Show: The main window is displayed using `Application.Run()`.
3. WpfEngine.cs
The central nervous system of the framework. It holds:
State Dictionary
Stores all variables (`_state`) and provides thread-safe access.
Bindings
Maps variable names to UI properties for automatic updates.
Plugin Manager
Loads DLLs and C# scripts dynamically at runtime.
4. UI Generation (WpfUI.cs)
Nimbus does NOT use `XamlReader.Parse`. Instead, it manually constructs the visual tree for maximum control and custom component support.
Custom Component Logic
When the parser encounters a tag like <GlassCard>, it doesn't just create a generic control. It calls a specific generator method that assembles a complex visual tree (Border + BlurEffect + ContentPresenter).
// Pseudo-code of internal logic
if (tagName == "GlassCard") {
var border = new Border();
border.Effect = new BlurEffect();
border.Background = new SolidColorBrush(...);
// ... add children
return border;
}
5. Hot Reload Logic
The engine uses a FileSystemWatcher to monitor the `App.xml` file.
When a change is detected:
- The file is re-read.
- The old Window content is cleared.
- The logic section is re-parsed (updating handlers).
- The UI is re-generated and injected into the existing Window instance.
- State variables are preserved (so you don't lose data).