A high-performance retained-mode UI framework for HexaEngine β a cross-platform 3D game engine. HexaEngine.UI provides a complete UI solution for building in-engine editors, game interfaces, and interactive applications with a familiar XAML-inspired workflow.
- Discord: https://discord.gg/VawN5d8HMh
- Declarative UI tree with automatic layout and rendering
- XAML-based markup for defining UI hierarchies
- Resource dictionaries for reusable styles and templates
Built-in controls for common UI patterns:
- Layout Containers:
Grid,StackPanel,Border,Panel - Content Controls:
Button,Label,ContentControl - Text Input:
TextBox,TextBoxBase - Image Display:
Imagewith various stretch modes - Scrolling:
ScrollViewer,ScrollBarwith customizable behavior - Primitives:
Thumb,ButtonBase,RangeBasefor building custom controls
- Automatic layout calculation with measure/arrange passes
- Support for margins, padding, and alignment
- Grid-based layouts with row/column definitions
- Stack-based layouts (horizontal/vertical)
- Thickness and corner radius for borders
- Hardware-accelerated rendering with command list batching
- Custom brush system for fills and strokes
- Clipping and transformation support
- Vector and sprite font rendering
- Text layout with word wrapping, alignment, and flow control
- FreeType-based font rendering (sprite and vector fonts)
- Advanced text layout with metrics
- Support for text alignment, wrapping, and direction
- Paragraph alignment and incremental tab stops
- Glyph-level control and custom text formatting
- Timeline-based animations with storyboards
- Animatable properties via
IAnimatableinterface - Animation scheduling and composition
- Duration and easing support
- Dependency property system for reactive updates
- Binding support with multiple modes (OneWay, TwoWay, OneTime, OneWayToSource)
- Value converters for data transformation
- Update source triggers for fine-grained control
- Mouse and keyboard event routing
- Focus management and text composition
- Drag operations with delta tracking
- Click modes (Press, Release, Hover)
- Built for .NET 10
- Nullable reference types enabled
- Trim and AOT analysis enabled
- Unsafe code support for performance-critical paths
dotnet add package HexaEngine.UIInstall-Package HexaEngine.UIusing HexaEngine.UI;
using HexaEngine.UI.Controls;
// Create a UI window
var window = new UIWindow();
// Create a root layout
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
// Add a label
var label = new Label
{
Content = "Hello, HexaEngine.UI!",
FontSize = 24,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
Grid.SetRow(label, 0);
grid.Children.Add(label);
// Add a button
var button = new Button
{
Content = "Click Me",
Width = 120,
Height = 40,
HorizontalAlignment = HorizontalAlignment.Center
};
button.Click += (s, e) => Console.WriteLine("Button clicked!");
Grid.SetRow(button, 1);
grid.Children.Add(button);
// Set the root element
window.Content = grid;using HexaEngine.UI.Markup;
string xaml = @"
<Grid xmlns='http://hexaengine.com/ui'>
<Grid.RowDefinitions>
<RowDefinition Height='*'/>
<RowDefinition Height='Auto'/>
</Grid.RowDefinitions>
<Label Grid.Row='0' Content='Hello, World!'
FontSize='24'
HorizontalAlignment='Center'
VerticalAlignment='Center'/>
<Button Grid.Row='1' Content='Click Me'
Width='120' Height='40'
HorizontalAlignment='Center'/>
</Grid>";
var element = XamlReader.Parse(xaml);public class ViewModel : DependencyObject
{
public static readonly DependencyProperty MessageProperty =
DependencyProperty.Register(
nameof(Message),
typeof(string),
typeof(ViewModel),
new PropertyMetadata("Hello"));
public string Message
{
get => (string)GetValue(MessageProperty);
set => SetValue(MessageProperty, value);
}
}
// Bind a label to the view model
var viewModel = new ViewModel();
var label = new Label();
label.SetBinding(Label.ContentProperty, new Binding(nameof(ViewModel.Message))
{
Source = viewModel,
Mode = BindingMode.OneWay
});UIElement: Base class for all visual elements with layout and input handlingFrameworkElement: Extends UIElement with data binding and stylingDependencyObject: Provides dependency property system for reactive propertiesVisual: Low-level rendering primitive with transformation and clippingUIRenderer: Manages rendering of UI trees to graphics deviceUICommandList: Command buffer for batched rendering operations
- Measure: Elements calculate their desired size
- Arrange: Elements are positioned and sized within available space
- Render: Visual tree is traversed and rendered to command list
HexaEngine.UI uses a custom rendering pipeline optimized for UI:
- Primitive Rendering: Basic shapes (rectangles, lines)
- Texture Rendering: Images and sprite fonts
- Vector Rendering: Vector graphics and vector fonts
- Shader Support: Customizable HLSL shaders for advanced effects
Shaders included:
assets/HexaEngine.UI/shaders/prim/- Primitive rendering shadersassets/HexaEngine.UI/shaders/tex/- Texture rendering shadersassets/HexaEngine.UI/shaders/vec/- Vector rendering shaders
- .NET 10 or higher
- Graphics device supporting DirectX/Vulkan/OpenGL (via HexaEngine.Core)
- Command list batching reduces draw calls
- Layout invalidation is propagated efficiently through the visual tree
- Text layout caching minimizes re-computation
- Resource pooling for graphics objects
- Unsafe code paths for critical rendering operations
For detailed API documentation, visit https://docs.hexa-studios.net/
HexaEngine.UI- Core UI classes and frameworkHexaEngine.UI.Controls- Built-in UI controlsHexaEngine.UI.Controls.Primitives- Base classes for custom controlsHexaEngine.UI.Graphics- Rendering and graphics resourcesHexaEngine.UI.Graphics.Text- Text rendering and typographyHexaEngine.UI.Markup- XAML parsing and markup extensionsHexaEngine.UI.Animation- Animation systemHexaEngine.UI.Xaml- XAML schema and type system
Contributions are welcome! Please visit the HexaEngine GitHub repository for contribution guidelines.
This project is licensed under the terms specified in the LICENSE.txt file.
- FreeType for font rendering support
- HexaEngine - Main game engine
For more information, visit https://hexa-studios.net/