Skip to content
MASS4ORGPublic

About

GPU accelerated IM GUI system

Resources

Code of conduct

Contributing

Security policy

Stars

29 stars

Watchers

0 watching

Forks

Latest commit

 

History

154 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guinevere

guinevere

CI Release NuGet License: MIT Discord

A GPU accelerated immediate mode GUI system built on SkiaSharp, designed for high-performance applications with modern graphics APIs support. You can use it to create rich and beautiful apps.

Guinevere overview Guinevere overview Guinevere overview

Important

Guinevere is a very new library. While an earlier iteration is actively used within the Turian Game Engine, this specific library hasn't yet established a track record of reliability in production environments.

Highlights

  • Cross-Platform: Windows, Linux & Mac
  • Immediate Mode
  • 100% C# with Latest .NET
  • GPU Accelerated Rendering
  • Fluent API
  • Multiple Graphics API Support
  • Multiple Framework Integrations
Integration Graphics API C# Framework Use Case
Vulkan.SilkNET Vulkan Silk.NET Maximum performance, modern graphics
OpenGl.SilkNET OpenGL Silk.NET High-performance applications (Recommended)
OpenGl.OpenTK OpenGL OpenTK Game development, tools
OpenGl.Raylib OpenGL Raylib-cs Simple games, prototypes

Table of Contents

Quick Start

Starting a New App

  1. Create a new .NET project:

    dotnet new console -n MyGuinevereApp
    cd MyGuinevereApp
  2. Install Guinevere and an integration package:

    dotnet add package MASS4.Guinevere
    dotnet add package MASS4.Guinevere.OpenGL.SilkNET
  3. Basic Usage:

    using Guinevere;
    using Guinevere.OpenGL.SilkNET;
    
    public abstract class Program
    {
        public static void Main()
        {
            var gui = new Gui();
            using var win = new GuiWindow(gui);
    
            win.RunGui(() =>
            {
                gui.DrawRect(gui.ScreenRect, Color.Blue);
                gui.DrawText("Hello, world!");
            });
        }
    }

Features

Layout

  • Flexible box model: margins, padding, gaps, alignment

  • Horizontal/vertical flow with Direction(Axis.Horizontal|Vertical) (alias FlowDir)

  • Responsive sizing: Expand(), ExpandWidth(), ExpandHeight()

  • Every distance is a Size: width, height, min/max bounds, gap, margins, padding, alignment offsets and absolute positions blend pixels, percentages, aspect ratios, remaining space, content size and largest-child size. Plain numbers convert to pixels. Bounds below zero resolve to zero; when a minimum exceeds its maximum, the minimum wins.

  • Node-relative sizes: Size.PercentOf(node, t) sizes from another node of the same frame, settling within the frame and reporting stale or cyclic references

  • Free-space distribution: an expanding gap or margin (Gap(Size.Expand()), MarginLeft(Size.Expand())) shares leftover space, and Spacing(SpacingTypes.SpaceBetween | SpaceAround | SpaceEvenly | Center …) distributes it

  • Content alignment with AlignContent(x, y), AlignContentX/Y and AlignSelf: plain numbers are fractions of the free space; a Size adds pixel offsets

  • Blending: AddWidth/AddHeight, LerpWidth/LerpHeight and Add/Lerp forms for bounds, gap, padding and margin

  • Rectangle slicing for drawing: rect.AlignLeft(Size.Percentage(0.5f)), AlignCenterY, Padding(x, y), HPadding, Expand, AddY, SetHeight and more

    // Flexible layout with alignment and spacing
    using (gui.Node().Expand()
        .Direction(Axis.Horizontal)
        .Gap(20)
        .Margin(30)
        .Padding(15)
        .AlignContent(0.5f, 0.2f)
        .Enter())
    {
        // Children laid out horizontally with gaps
    }
    
    // Responsive sizing
    gui.Node().ExpandWidth().Height(100).Margin(10, 20).Padding(5, 10, 15, 20);
    
    // A continuous animation from 120 pixels to half the parent width.
    var width = Size.Lerp(Size.Pixels(120), Size.Percentage(0.5f), progress);
    gui.Node().Width(width).Height(80);
    
    // Contributions can also be composed directly.
    gui.Node().Width(Size.FitContent() + Size.Pixels(24)).Padding(Size.Percentage(0.02f));
    
    // A tab container blending the heights of two tabs while sliding between them.
    container.Height(Size.Lerp(Size.PercentOf(firstTab), Size.PercentOf(secondTab), slide));

Interaction & Focus

  • Custom interactables for arbitrary shapes and regions

  • Pointer capture, drag-and-drop, and input blocking

  • Focus registration, nested navigation scopes, Tab cycling, and directional navigation

  • DOM-style events (click, drag, scroll, key, text, focus) with capture/target/bubble propagation, StopPropagation and PreventDefault

  • Cursor shapes per node and pointer modes (hidden, relative, wrapped) across integrations

    // Custom interactive area with shape
    var interactable = gui.GetInteractable();
    if (interactable.OnHover()) gui.DrawBackgroundRect(Color.LightBlue);
    if (interactable.OnClick()) Console.WriteLine("Clicked!");
    
    var shape = Shape.Circle(50);
    var shaped = gui.GetInteractable(position, shape);
    // One listener on a list serves every row; the click bubbles up with the row as its target.
    using (gui.Node().Cursor(PointerCursor.Hand).Enter())
    {
        gui.On<ClickEvent>(e => Select(e.TargetId));
        foreach (var row in rows)
            using (gui.Node(-1, 32, $"row/{row}").Enter()) { /* ... */ }
    }

    Events for a frame's input run at the start of that frame, against the tree the previous frame laid out, so listeners change state before the new tree is built. PreventDefault hides the handled edge from gui.Input, so polling controls do not react a second time.

Text & Styling

  • Rich text rendering with Unicode and emoji

  • Wrapping, sizes, and color control

  • TextLayoutOptions controls word, character, or mixed wrapping, line height, line limits, and a configurable ellipsis. DrawText and WrappedTextLayout share the line-breaking rules; SetTextLayout makes these settings inheritable within a node scope. Styled nodes accept text-wrap, line-height, max-lines, and text-ellipsis declarations.

  • Theming via transient color changes

  • Runtime .pss (PanGui Style Sheet) theme files with nested selectors, > child selectors, custom modifiers, $tokens layered across sheets and host overrides, host-readable @const metadata, #inherit(...) variants, @font-face/url() resolved against the sheet, @import through a host resolver, file:line:col errors, cached resolution, and non-destructive provider/file reloads

    gui.DrawText("Title", 24, Color.White);
    gui.DrawText("Wrapped text", 12, Color.Gray, wrapWidth: 300);
    gui.DrawText("Select and copy this label", selectable: true);
    gui.DrawText("A long message", wrapWidth: 300,
        layout: new TextLayoutOptions { WrapMode = TextWrapMode.WordThenCharacter, MaxLines = 3 });
    gui.SetTextColor(Color.Red); // all text from now on will be red by default
    gui.DrawText("Red text");
    gui.SetTextColor(Color.White);

    Stylesheets live in the optional MASS4.Guinevere.Styling package (dotnet add package MASS4.Guinevere.Styling) and use PanGui's prop = value; syntax:

    var styles = StyleSheetSource.FromFile("theme.pss");
    gui.AddStyleSheet(styles);
    gui.StyleSheets.SetToken("accent", "#ff8800"); // host override above every sheet
    var themeName = styles.Current.Constants["theme-name"];
    
    using (gui.StyledNode("checkbox", isChecked ? ["checked"] : []).Enter()) { }
    @const theme-name = "Night";
    @const spacing = 12;
    $accent = #4a90e2;
    @font-face { font-family = "Inter"; src = url("fonts/Inter.ttf"); }
    
    checkbox {
        padding = @spacing;
        :checked(0.2 ease-out) { background-color = $accent; }
    }

    Icons are glyphs, images or vector pictures drawn with gui.Icon(icon, size, tint). With the styling package, icon#id rules (glyph/font-family or src/tint, plus color) form swappable icon themes read by gui.StyledIcon("scene.move"). SVG sources need the optional MASS4.Guinevere.Svg package.

    Styled nodes draw background colors or linear-gradients, box-shadows, per-corner border-radius and outlines, and apply opacity, cursor and text color/font-* that child text inherits.

    Transition annotations, shapes, effects, mixins and macros parse for source compatibility and are kept in StyleSheet.Deferred; animated interpolation, expressions and applying those constructs remain planned styling features. The CSS-flavored prop: value;/--x/var() form is only accepted with StyleSheetOptions.AllowCssSyntax for migration tools.

    Excalibur's colors are sheet tokens. ExcaliburStyles.SetTheme(gui, ExcaliburStyles.Dark) swaps the whole set (Light, Dark, MonoLight, MonoDark or any token sheet), and a subtree overrides only the tokens it needs; control dimensions stay independent, inheritable scope values:

    using (gui.Node().Enter())
    {
        gui.SetStyleToken("accent", Color.Orange);
        gui.CurrentNodeScope.Set(ControlStyles.Value<ControlFieldHeight, float>(40f));
        gui.Button("Locally styled");
    }

Animation

  • Smooth value/state transitions

  • AnimationFloat and AnimateBool01() helpers

  • Layout sizes can interpolate between arbitrary Size modes without switching modes mid-animation

  • Easing functions: Linear, EaseIn/Out, SmoothStep, BackOut, ElasticOut, BounceOut

  • Live metrics: ActiveAnimationCount

    var fade = gui.AnimateBool01(isVisible, 0.5f, Easing.SmoothStep);
    var animFloat = gui.GetAnimationFloat(value);
    animFloat.AnimateTo(target, 0.3f, Easing.ElasticOut);
    var v = animFloat.GetValue();
    
    var animatedWidth = Size.Lerp(
        Size.Pixels(100),
        Size.Percentage(0.6f) + Size.FitContent(0.15f),
        fade);
    gui.Node().Width(animatedWidth);

/mass4/dev/Guinevere/.zed // Status gui.DrawText($"Active animations: {gui.ActiveAnimationCount}", 12, Color.White);


### Shapes & Effects

Drawing overloads with an explicit color record direct primitive commands. Geometry-only overloads return mutable `Shape` objects for fluent effects; `DrawShape(position, shape)` returns a translated copy. For example, `gui.DrawRect(rect, Color.Blue)` draws directly, while `gui.DrawRect(rect).SolidColor(Color.Blue)` supports chained effects. `gui.DrawBackgroundRect()` returns a white fluent background; pass a color or `null` explicitly for a direct background.

- Basic shapes: circle, rectangle, arc
- Fills: solid, linear/radial gradients
- Borders and rounded corners
- Shadows: inner/outer with blur and spread
- Shape operations: union, subtract, intersect, transform

```csharp
// Basic shape & gradient
gui.DrawShape(center, Shape.Circle(100))
    .LinearGradientColor(Color.Red, Color.Blue, Angle.Degrees(45))
    .InnerShadow(Color.Black, new Vector2(0, 2), blur: 5, spread: -2)
    .OuterShadow(Color.Gray, new Vector2(2, 2), blur: 8, spread: 0);

// Composition
var combined = Shape.Circle(60) + Shape.Rectangle(80, 40);
gui.DrawShape(center, combined);

// Simple rect helpers
gui.DrawBackgroundRect(Color.Blue, radius: 10);
// gui.DrawRectBorder(rect, Color.Red, thickness: 2);

Scrolling & Clipping

  • Scrollbars: ScrollY() / ScrollX()

  • Clip content to node bounds: ClipContent()

  • Programmatic control: ScrollToTop(), SetScrollPercentage()

  • Custom clip shapes with SetClipArea()

    using (gui.Node(400, 300).Enter())
    {
        gui.ScrollY(Color.Black, Color.Gray);
        gui.ClipContent();
    
        for (int i = 0; i < 50; i++)
            gui.DrawText($"Line {i + 1}", 14, Color.White);
    }
    
    // Programmatic control
    gui.ScrollToTop("scrollNodeId");
    gui.SetScrollPercentage("scrollNodeId", Axis.Vertical, 0.5f);
    
    // Custom clip area
    gui.SetClipArea(gui.CurrentNode, Shape.Circle(100));

Headless Controls

Core provides visual-free Pressable, Toggleable, Selectable, Draggable, and Repeatable behaviors. Apply one inside any layout node and render from its stable ControlVisualState; activation is delivered in the next layout pass so application state cannot produce different trees in a frame's layout and render passes. Platforms can optionally provide IControlActivationSource for controller or command activation and IControlSemanticsSink for accessibility metadata.

Excalibur Controls

The ready-to-use control collection lives in the separate MASS4.Guinevere.Excalibur package. It provides buttons, text and numeric inputs, menus, popups, dialogs, trees, tabs, docking, notifications, and more.

Selection controls include searchable MultiDropdown with removable chips and filtered bulk actions, plus EnumDropdown with automatic flag checkboxes, button groups and previous/next paging.

dotnet add package MASS4.Guinevere.Excalibur

Platform integrations publish input, clipboard, window, timing, renderer and DPI services through gui.Platform. Optional cursor, native-dialog, texture, GPU-effect and accessibility features use typed discovery with explicit fallback behavior.

Autoformers

Attribute-driven forms ship as three packages. MASS4.Attributes holds the metadata ([Show], [Range], [Button], [Title], …) with no GUI dependency. Autoformers reflects a plain object into a GUI-free FormModel of sections, fields and collections. Autoformers.Excalibur renders that model with Excalibur controls through gui.Form.

Enum fields are searchable by default; [Flags] enables multiple selection. Use [EnumButtons] for a button group, [EnumPaging] for previous/next controls, and [EnumLabel("Label")] on enum members for display labels. Multi-object flag edits preserve each owner's unrelated bits. See the attribute catalog and enum form examples.

dotnet add package MASS4.Attributes
dotnet add package MASS4.Autoformers
dotnet add package MASS4.Autoformers.Excalibur

Layering & Transforms

  • Z-index layering and transforms

    gui.SetZIndex(10);
    // gui.SetTransform(Matrix3x2.CreateScale(1.2f, 1.2f, center));

Performance

  • GPU-accelerated rendering via SkiaSharp

  • Immediate mode with minimal memory overhead

  • Dirty-flag updates and multi-pass rendering

  • Real-time metrics: FPS, frame count, delta time

    // Pass-based work split
    if (gui.Pass == Pass.Pass1Layout)
    {
        // Layout calculations
    }
    else if (gui.Pass == Pass.Pass2Render)
    {
        // Rendering only
    }
    
    // Metrics
    gui.DrawText($"FPS: {gui.Time.SmoothFps:F1}", 12, Color.White);
    gui.DrawText($"Frame: {gui.Time.Frames}", 12, Color.White);
    gui.DrawText($"Delta: {gui.Time.DeltaTime * 1000:F1}ms", 12, Color.White);

Examples

The repository includes comprehensive Examples demonstrating various features.

Contributing

Read the contribution guide before opening an issue or pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

The integration packages embed three fonts. Roboto provides ordinary text; Noto Emoji provides Unicode emoji fallback; Font Awesome 6 Free provides widget icons. Roboto and Noto Emoji use Apache 2.0 and the SIL Open Font License 1.1 respectively; the Font Awesome font also uses the SIL Open Font License 1.1. Each integration package includes the license texts and font notices. The Font Awesome solid font is embedded once per integration (about 388 KiB); Noto Emoji is about 2 MiB. Call gui.DrawGlyph(codepoint) for a Font Awesome icon, gui.DrawText(text) for ordinary text and emoji, or set the fonts per scope with SetWidgetIconFont, SetTextFont, and SetEmojiFont. The older SetIconFont still changes both icon and fallback fonts. Font Awesome's glyphs use private Unicode codepoints; use WidgetIcons for the built-in glyphs or Font Awesome's published mappings.

About

GPU accelerated IM GUI system

Resources

Code of conduct

Contributing

Security policy

Stars

29 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages