Xui.Core.UI.Layer

Assembly: Xui.Core · C# declarations · Assembly overview

Types

struct BorderLayer<TView, TChild>

A layer that draws a background fill, a border stroke, and optional padding around a child layer. Rendering logic is identical to Xui.Core.UI.Border but expressed as a composable struct with no heap allocation.

public struct BorderLayer<TView, TChild> : ILayer<TView> where TView : ILayerHost where TChild : struct, ILayer<TView>
{
    public TChild Child;
    public Frame BorderThickness;
    public CornerRadius CornerRadius;
    public Color BackgroundColor;
    public Color BorderColor;
    public Frame Padding;
    public Size Measure(TView view, Size availableSize, IMeasureContext context);
    public void Arrange(TView view, Rect rect, IMeasureContext context);
    public void Render(TView view, IContext context);
    public void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);
    public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(TView view, ref KeyEventRef e);
    public void OnChar(TView view, ref KeyEventRef e);
    public void OnFocus(TView view);
    public void OnBlur(TView view);
}

void BorderLayer<TView, TChild>.Animate(TView view, TimeSpan previousTime, TimeSpan currentTime)

public void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);

Advances time-based state (animations, blinking cursors, etc.).

void BorderLayer<TView, TChild>.Arrange(TView view, Rect rect, IMeasureContext context)

public void Arrange(TView view, Rect rect, IMeasureContext context);

Finalises position and size within rect.

Color BorderLayer<TView, TChild>.BackgroundColor

public Color BackgroundColor;

Background fill color.

Color BorderLayer<TView, TChild>.BorderColor

public Color BorderColor;

Border stroke color.

Frame BorderLayer<TView, TChild>.BorderThickness

public Frame BorderThickness;

Per-side border thickness.

TChild BorderLayer<TView, TChild>.Child

public TChild Child;

The inner layer rendered inside the border and padding.

CornerRadius BorderLayer<TView, TChild>.CornerRadius

public CornerRadius CornerRadius;

Corner radius for the background fill and border stroke.

Size BorderLayer<TView, TChild>.Measure(TView view, Size availableSize, IMeasureContext context)

public Size Measure(TView view, Size availableSize, IMeasureContext context);

Returns the desired border-edge size given the available space.

void BorderLayer<TView, TChild>.OnBlur(TView view)

public void OnBlur(TView view);

Called when the host view loses keyboard focus.

void BorderLayer<TView, TChild>.OnChar(TView view, ref KeyEventRef e)

public void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void BorderLayer<TView, TChild>.OnFocus(TView view)

public void OnFocus(TView view);

Called when the host view gains keyboard focus.

void BorderLayer<TView, TChild>.OnKeyDown(TView view, ref KeyEventRef e)

public void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void BorderLayer<TView, TChild>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

Frame BorderLayer<TView, TChild>.Padding

public Frame Padding;

Padding between the border edge and the child layer.

void BorderLayer<TView, TChild>.Render(TView view, IContext context)

public void Render(TView view, IContext context);

Draws content. Called after Arrange.

struct ContentLayer

A terminal layer that delegates layout and rendering to a child Xui.Core.UI.View, bridging the layer tree back into the standard view hierarchy. Input routing is left to the Xui.Core.UI.Input.EventRouter which hit-tests the child view directly, so all input methods here are intentional no-ops.

public struct ContentLayer : ILayer<View>
{
    public View? Child;
    public Size Measure(View view, Size availableSize, IMeasureContext context);
    public void Arrange(View view, Rect rect, IMeasureContext context);
    public void Render(View view, IContext context);
    public void Animate(View view, TimeSpan previousTime, TimeSpan currentTime);
    public void OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(View view, ref KeyEventRef e);
    public void OnChar(View view, ref KeyEventRef e);
    public void OnFocus(View view);
    public void OnBlur(View view);
}

void ContentLayer.Animate(View view, TimeSpan previousTime, TimeSpan currentTime)

public void Animate(View view, TimeSpan previousTime, TimeSpan currentTime);

Advances time-based state (animations, blinking cursors, etc.).

void ContentLayer.Arrange(View view, Rect rect, IMeasureContext context)

public void Arrange(View view, Rect rect, IMeasureContext context);

Finalises position and size within rect.

View? ContentLayer.Child

public View? Child;

The child view to measure, arrange, and render.

Size ContentLayer.Measure(View view, Size availableSize, IMeasureContext context)

public Size Measure(View view, Size availableSize, IMeasureContext context);

Returns the desired border-edge size given the available space.

void ContentLayer.OnBlur(View view)

public void OnBlur(View view);

Called when the host view loses keyboard focus.

void ContentLayer.OnChar(View view, ref KeyEventRef e)

public void OnChar(View view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void ContentLayer.OnFocus(View view)

public void OnFocus(View view);

Called when the host view gains keyboard focus.

void ContentLayer.OnKeyDown(View view, ref KeyEventRef e)

public void OnKeyDown(View view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void ContentLayer.OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

void ContentLayer.Render(View view, IContext context)

public void Render(View view, IContext context);

Draws content. Called after Arrange.

class DockLayer

Container for dock layout types. Usage: DockLayer.Dock3<View, StepButton, NumberInputLayer, StepButton>

public static class DockLayer
{
    public enum Align
    {
        Left,
        Stretch,
        Right
    }

    public struct Docked<T>
        where T : struct
    {
        public Align Align;
        public T Child;
    }

    public struct Dock2<TView, T1, T2> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView>
    {
        public Docked<T1> Child1;
        public Docked<T2> Child2;
        public Size Measure(TView view, Size available, IMeasureContext ctx);
        public void Arrange(TView view, Rect rect, IMeasureContext ctx);
        public void Render(TView view, IContext ctx);
        public void Animate(TView view, TimeSpan p, TimeSpan c);
        public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
        public void OnKeyDown(TView view, ref KeyEventRef e);
        public void OnChar(TView view, ref KeyEventRef e);
        public void OnFocus(TView view);
        public void OnBlur(TView view);
    }

    public struct Dock3<TView, T1, T2, T3> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView> where T3 : struct, ILayer<TView>
    {
        public Docked<T1> Child1;
        public Docked<T2> Child2;
        public Docked<T3> Child3;
        public Size Measure(TView view, Size available, IMeasureContext ctx);
        public void Arrange(TView view, Rect rect, IMeasureContext ctx);
        public void Render(TView view, IContext ctx);
        public void Animate(TView view, TimeSpan p, TimeSpan c);
        public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
        public void OnKeyDown(TView view, ref KeyEventRef e);
        public void OnChar(TView view, ref KeyEventRef e);
        public void OnFocus(TView view);
        public void OnBlur(TView view);
    }

    public struct Dock4<TView, T1, T2, T3, T4> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView> where T3 : struct, ILayer<TView> where T4 : struct, ILayer<TView>
    {
        public Docked<T1> Child1;
        public Docked<T2> Child2;
        public Docked<T3> Child3;
        public Docked<T4> Child4;
        public Size Measure(TView view, Size available, IMeasureContext ctx);
        public void Arrange(TView view, Rect rect, IMeasureContext ctx);
        public void Render(TView view, IContext ctx);
        public void Animate(TView view, TimeSpan p, TimeSpan c);
        public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
        public void OnKeyDown(TView view, ref KeyEventRef e);
        public void OnChar(TView view, ref KeyEventRef e);
        public void OnFocus(TView view);
        public void OnBlur(TView view);
    }
}

enum DockLayer.Align

Determines how docked children are aligned on the cross axis.

public enum Align
{
    Left,
    Stretch,
    Right
}

Align.Left

Left

Align to the left edge.

Align.Right

Right

Align to the right edge.

Align.Stretch

Stretch

Stretch to fill the available cross-axis space.

struct DockLayer.Dock2<TView, T1, T2>

Two-slot dock layout.

public struct Dock2<TView, T1, T2> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView>
{
    public Docked<T1> Child1;
    public Docked<T2> Child2;
    public Size Measure(TView view, Size available, IMeasureContext ctx);
    public void Arrange(TView view, Rect rect, IMeasureContext ctx);
    public void Render(TView view, IContext ctx);
    public void Animate(TView view, TimeSpan p, TimeSpan c);
    public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(TView view, ref KeyEventRef e);
    public void OnChar(TView view, ref KeyEventRef e);
    public void OnFocus(TView view);
    public void OnBlur(TView view);
}

void Dock2<TView, T1, T2>.Animate(TView view, TimeSpan p, TimeSpan c)

public void Animate(TView view, TimeSpan p, TimeSpan c);

Advances time-based state (animations, blinking cursors, etc.).

void Dock2<TView, T1, T2>.Arrange(TView view, Rect rect, IMeasureContext ctx)

public void Arrange(TView view, Rect rect, IMeasureContext ctx);

Finalises position and size within rect.

Docked<T1> Dock2<TView, T1, T2>.Child1

public Docked<T1> Child1;

The first docked child.

Docked<T2> Dock2<TView, T1, T2>.Child2

public Docked<T2> Child2;

The second docked child.

Size Dock2<TView, T1, T2>.Measure(TView view, Size available, IMeasureContext ctx)

public Size Measure(TView view, Size available, IMeasureContext ctx);

Returns the desired border-edge size given the available space.

void Dock2<TView, T1, T2>.OnBlur(TView view)

public void OnBlur(TView view);

Called when the host view loses keyboard focus.

void Dock2<TView, T1, T2>.OnChar(TView view, ref KeyEventRef e)

public void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void Dock2<TView, T1, T2>.OnFocus(TView view)

public void OnFocus(TView view);

Called when the host view gains keyboard focus.

void Dock2<TView, T1, T2>.OnKeyDown(TView view, ref KeyEventRef e)

public void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void Dock2<TView, T1, T2>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

void Dock2<TView, T1, T2>.Render(TView view, IContext ctx)

public void Render(TView view, IContext ctx);

Draws content. Called after Arrange.

struct DockLayer.Dock3<TView, T1, T2, T3>

Three-slot dock layout. Typical usage: Left button | Stretch content | Right button.

public struct Dock3<TView, T1, T2, T3> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView> where T3 : struct, ILayer<TView>
{
    public Docked<T1> Child1;
    public Docked<T2> Child2;
    public Docked<T3> Child3;
    public Size Measure(TView view, Size available, IMeasureContext ctx);
    public void Arrange(TView view, Rect rect, IMeasureContext ctx);
    public void Render(TView view, IContext ctx);
    public void Animate(TView view, TimeSpan p, TimeSpan c);
    public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(TView view, ref KeyEventRef e);
    public void OnChar(TView view, ref KeyEventRef e);
    public void OnFocus(TView view);
    public void OnBlur(TView view);
}

void Dock3<TView, T1, T2, T3>.Animate(TView view, TimeSpan p, TimeSpan c)

public void Animate(TView view, TimeSpan p, TimeSpan c);

Advances time-based state (animations, blinking cursors, etc.).

void Dock3<TView, T1, T2, T3>.Arrange(TView view, Rect rect, IMeasureContext ctx)

public void Arrange(TView view, Rect rect, IMeasureContext ctx);

Finalises position and size within rect.

Docked<T1> Dock3<TView, T1, T2, T3>.Child1

public Docked<T1> Child1;

The first docked child.

Docked<T2> Dock3<TView, T1, T2, T3>.Child2

public Docked<T2> Child2;

The second docked child.

Docked<T3> Dock3<TView, T1, T2, T3>.Child3

public Docked<T3> Child3;

The third docked child.

Size Dock3<TView, T1, T2, T3>.Measure(TView view, Size available, IMeasureContext ctx)

public Size Measure(TView view, Size available, IMeasureContext ctx);

Returns the desired border-edge size given the available space.

void Dock3<TView, T1, T2, T3>.OnBlur(TView view)

public void OnBlur(TView view);

Called when the host view loses keyboard focus.

void Dock3<TView, T1, T2, T3>.OnChar(TView view, ref KeyEventRef e)

public void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void Dock3<TView, T1, T2, T3>.OnFocus(TView view)

public void OnFocus(TView view);

Called when the host view gains keyboard focus.

void Dock3<TView, T1, T2, T3>.OnKeyDown(TView view, ref KeyEventRef e)

public void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void Dock3<TView, T1, T2, T3>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

void Dock3<TView, T1, T2, T3>.Render(TView view, IContext ctx)

public void Render(TView view, IContext ctx);

Draws content. Called after Arrange.

struct DockLayer.Dock4<TView, T1, T2, T3, T4>

Four-slot dock layout.

public struct Dock4<TView, T1, T2, T3, T4> : ILayer<TView> where TView : ILayerHost where T1 : struct, ILayer<TView> where T2 : struct, ILayer<TView> where T3 : struct, ILayer<TView> where T4 : struct, ILayer<TView>
{
    public Docked<T1> Child1;
    public Docked<T2> Child2;
    public Docked<T3> Child3;
    public Docked<T4> Child4;
    public Size Measure(TView view, Size available, IMeasureContext ctx);
    public void Arrange(TView view, Rect rect, IMeasureContext ctx);
    public void Render(TView view, IContext ctx);
    public void Animate(TView view, TimeSpan p, TimeSpan c);
    public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(TView view, ref KeyEventRef e);
    public void OnChar(TView view, ref KeyEventRef e);
    public void OnFocus(TView view);
    public void OnBlur(TView view);
}

void Dock4<TView, T1, T2, T3, T4>.Animate(TView view, TimeSpan p, TimeSpan c)

public void Animate(TView view, TimeSpan p, TimeSpan c);

Advances time-based state (animations, blinking cursors, etc.).

void Dock4<TView, T1, T2, T3, T4>.Arrange(TView view, Rect rect, IMeasureContext ctx)

public void Arrange(TView view, Rect rect, IMeasureContext ctx);

Finalises position and size within rect.

Docked<T1> Dock4<TView, T1, T2, T3, T4>.Child1

public Docked<T1> Child1;

The first docked child.

Docked<T2> Dock4<TView, T1, T2, T3, T4>.Child2

public Docked<T2> Child2;

The second docked child.

Docked<T3> Dock4<TView, T1, T2, T3, T4>.Child3

public Docked<T3> Child3;

The third docked child.

Docked<T4> Dock4<TView, T1, T2, T3, T4>.Child4

public Docked<T4> Child4;

The fourth docked child.

Size Dock4<TView, T1, T2, T3, T4>.Measure(TView view, Size available, IMeasureContext ctx)

public Size Measure(TView view, Size available, IMeasureContext ctx);

Returns the desired border-edge size given the available space.

void Dock4<TView, T1, T2, T3, T4>.OnBlur(TView view)

public void OnBlur(TView view);

Called when the host view loses keyboard focus.

void Dock4<TView, T1, T2, T3, T4>.OnChar(TView view, ref KeyEventRef e)

public void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void Dock4<TView, T1, T2, T3, T4>.OnFocus(TView view)

public void OnFocus(TView view);

Called when the host view gains keyboard focus.

void Dock4<TView, T1, T2, T3, T4>.OnKeyDown(TView view, ref KeyEventRef e)

public void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void Dock4<TView, T1, T2, T3, T4>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

void Dock4<TView, T1, T2, T3, T4>.Render(TView view, IContext ctx)

public void Render(TView view, IContext ctx);

Draws content. Called after Arrange.

struct DockLayer.Docked<T>

Wraps a dockable child with its alignment setting.

public struct Docked<T>
    where T : struct
{
    public Align Align;
    public T Child;
}

Align Docked<T>.Align

public Align Align;

The cross-axis alignment for the docked child.

T Docked<T>.Child

public T Child;

The docked child layer.

struct FocusBorderLayer<TView, TChild>

A Xui.Core.UI.Layer.BorderLayer2](../xui-core-ui-layer/index.md#api-ce3e0b25f8e8191f) variant that switches border color when the host view has keyboard focus. All layout and rendering is delegated to an inner [Xui.Core.UI.Layer.BorderLayer2; only Xui.Core.UI.Layer.FocusBorderLayer2.Render(0,Xui.Core.Canvas.IContext) swaps the color, and Xui.Core.UI.Layer.FocusBorderLayer2.OnFocus(0) / Xui.Core.UI.Layer.FocusBorderLayer2.OnBlur(0) request a repaint.

public struct FocusBorderLayer<TView, TChild> : ILayer<TView> where TView : ILayerHost where TChild : struct, ILayer<TView>
{
    public BorderLayer<TView, TChild> Border;
    public Color FocusedBorderColor;
    public Frame BorderThickness { get; set; }
    public CornerRadius CornerRadius { get; set; }
    public Color BackgroundColor { get; set; }
    public Color BorderColor { get; set; }
    public Frame Padding { get; set; }

    public Size Measure(TView view, Size availableSize, IMeasureContext context);
    public void Arrange(TView view, Rect rect, IMeasureContext context);
    public void Render(TView view, IContext context);
    public void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);
    public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(TView view, ref KeyEventRef e);
    public void OnChar(TView view, ref KeyEventRef e);
    public void OnFocus(TView view);
    public void OnBlur(TView view);
}

void FocusBorderLayer<TView, TChild>.Animate(TView view, TimeSpan previousTime, TimeSpan currentTime)

public void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);

Advances time-based state (animations, blinking cursors, etc.).

void FocusBorderLayer<TView, TChild>.Arrange(TView view, Rect rect, IMeasureContext context)

public void Arrange(TView view, Rect rect, IMeasureContext context);

Finalises position and size within rect.

Color FocusBorderLayer<TView, TChild>.BackgroundColor

public Color BackgroundColor { get; set; }

Background fill color.

BorderLayer<TView, TChild> FocusBorderLayer<TView, TChild>.Border

public BorderLayer<TView, TChild> Border;

The inner border layer that owns all geometry and rendering.

Color FocusBorderLayer<TView, TChild>.BorderColor

public Color BorderColor { get; set; }

Border stroke color.

Frame FocusBorderLayer<TView, TChild>.BorderThickness

public Frame BorderThickness { get; set; }

Per-side border thickness.

CornerRadius FocusBorderLayer<TView, TChild>.CornerRadius

public CornerRadius CornerRadius { get; set; }

Corner radius for the background fill and border stroke.

Color FocusBorderLayer<TView, TChild>.FocusedBorderColor

public Color FocusedBorderColor;

Border color used when the host view has keyboard focus.

Size FocusBorderLayer<TView, TChild>.Measure(TView view, Size availableSize, IMeasureContext context)

public Size Measure(TView view, Size availableSize, IMeasureContext context);

Returns the desired border-edge size given the available space.

void FocusBorderLayer<TView, TChild>.OnBlur(TView view)

public void OnBlur(TView view);

Called when the host view loses keyboard focus.

void FocusBorderLayer<TView, TChild>.OnChar(TView view, ref KeyEventRef e)

public void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void FocusBorderLayer<TView, TChild>.OnFocus(TView view)

public void OnFocus(TView view);

Called when the host view gains keyboard focus.

void FocusBorderLayer<TView, TChild>.OnKeyDown(TView view, ref KeyEventRef e)

public void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void FocusBorderLayer<TView, TChild>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

Frame FocusBorderLayer<TView, TChild>.Padding

public Frame Padding { get; set; }

Padding between the border edge and the child layer.

void FocusBorderLayer<TView, TChild>.Render(TView view, IContext context)

public void Render(TView view, IContext context);

Draws content. Called after Arrange.

interface IButtonAction<THost>

Zero-allocation click handler for button layers. Implement as a private nested struct inside the owning view so Xui.Core.UI.Layer.IButtonAction1.Execute(0) receives the fully-typed host and can call any method on it without closures.

public interface IButtonAction<in THost>
    where THost : ILayerHost
{
    void Execute(THost host);
}

void IButtonAction<THost>.Execute(THost host)

void Execute(THost host);

Executes the button action on the given host view.

  • host — The host view that owns the button.

interface ILayer<TView>

A composable struct that handles a portion of a view's layout, rendering, and input. Layers are value types composed at compile time — no virtual dispatch, no allocations. The host TView provides resources and invalidation callbacks; the layer carries its own state and logic.

public interface ILayer<in TView>
    where TView : ILayerHost
{
    void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);
    Size Measure(TView view, Size availableSize, IMeasureContext context);
    void Arrange(TView view, Rect rect, IMeasureContext context);
    void Render(TView view, IContext context);
    void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);
    void OnKeyDown(TView view, ref KeyEventRef e);
    void OnChar(TView view, ref KeyEventRef e);
    void OnFocus(TView view);
    void OnBlur(TView view);
}

void ILayer<TView>.Animate(TView view, TimeSpan previousTime, TimeSpan currentTime)

void Animate(TView view, TimeSpan previousTime, TimeSpan currentTime);

Advances time-based state (animations, blinking cursors, etc.).

void ILayer<TView>.Arrange(TView view, Rect rect, IMeasureContext context)

void Arrange(TView view, Rect rect, IMeasureContext context);

Finalises position and size within rect.

Size ILayer<TView>.Measure(TView view, Size availableSize, IMeasureContext context)

Size Measure(TView view, Size availableSize, IMeasureContext context);

Returns the desired border-edge size given the available space.

void ILayer<TView>.OnBlur(TView view)

void OnBlur(TView view);

Called when the host view loses keyboard focus.

void ILayer<TView>.OnChar(TView view, ref KeyEventRef e)

void OnChar(TView view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void ILayer<TView>.OnFocus(TView view)

void OnFocus(TView view);

Called when the host view gains keyboard focus.

void ILayer<TView>.OnKeyDown(TView view, ref KeyEventRef e)

void OnKeyDown(TView view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void ILayer<TView>.OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase)

void OnPointerEvent(TView view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

void ILayer<TView>.Render(TView view, IContext context)

void Render(TView view, IContext context);

Draws content. Called after Arrange.

interface ILayerHost

The contract a host view must satisfy to be used with Xui.Core.UI.Layer.ILayer1`. Provides the invalidation, focus, pointer-capture, and service-resolution APIs that layers call on their host during layout, rendering, and input handling.

public interface ILayerHost : IServiceProvider
{
    Rect Frame { get; }

    bool IsFocused { get; }

    bool Focus();
    void InvalidateRender();
    void InvalidateMeasure();
    void RequestAnimationFrame();
    void CapturePointer(int pointerId, IPointerGesture? gesture = null);
    void ReleasePointer(int pointerId);
}

void ILayerHost.CapturePointer(int pointerId, IPointerGesture? gesture = null)

void CapturePointer(int pointerId, IPointerGesture? gesture = null);

Routes all subsequent pointer events for pointerId to this view.

  • pointerId — The platform-assigned pointer identifier.

  • gesture — Optional gesture marker (see Xui.Core.UI.Input.PointerGestures) so ancestor containers can negotiate handover.

bool ILayerHost.Focus()

bool Focus();

Requests keyboard focus for the host view. Returns true if focus was granted.

Rect ILayerHost.Frame

Rect Frame { get; }

The arranged frame of the host view, in parent-local coordinates.

void ILayerHost.InvalidateMeasure()

void InvalidateMeasure();

Marks the view as needing re-measure (and re-layout).

void ILayerHost.InvalidateRender()

void InvalidateRender();

Marks the view as needing re-render.

bool ILayerHost.IsFocused

bool IsFocused { get; }

Whether the host view currently holds keyboard focus.

void ILayerHost.ReleasePointer(int pointerId)

void ReleasePointer(int pointerId);

Releases a previously captured pointer.

void ILayerHost.RequestAnimationFrame()

void RequestAnimationFrame();

Schedules an animation frame callback via AnimateCore.

class LayerView<TView, TLayer>

A Xui.Core.UI.View that owns a single TLayer struct and delegates every layout, rendering, and input override to it, passing itself as the fully-typed TView host to every layer method.

Because the compiler resolves TLayer statically, all delegation is devirtualised and inlined by the JIT — zero overhead compared to writing the overrides by hand.

Child views: This class is a leaf by default (Count = 0). Subclasses that host child Xui.Core.UI.View instances should override Xui.Core.UI.View.Count and Xui.Core.UI.View.Item(System.Int32), and manage attachment via Xui.Core.UI.View.SetProtectedChild``1(``0@,``0). Use Xui.Core.UI.Layer.ContentLayer to bridge those views back into the layer tree.

  • TView — The concrete view subclass. Must be the class that inherits this. Pass Xui.Core.UI.View when no specific host type is needed.

  • TLayer — The layer struct type.

public class LayerView<TView, TLayer> : View where TView : View where TLayer : struct, ILayer<TView>
{
    protected TLayer Layer;
    protected override void AnimateCore(TimeSpan previousTime, TimeSpan currentTime);
    protected override Size MeasureCore(Size availableSize, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
    protected override void RenderCore(IContext context);
    public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase);
    public override void OnKeyDown(ref KeyEventRef e);
    public override void OnChar(ref KeyEventRef e);
    protected internal override void OnFocus();
    protected internal override void OnBlur();
}

void LayerView<TView, TLayer>.AnimateCore(TimeSpan previousTime, TimeSpan currentTime)

protected override void AnimateCore(TimeSpan previousTime, TimeSpan currentTime);

Override to animate this view and its children.

void LayerView<TView, TLayer>.ArrangeCore(Rect rect, IMeasureContext context)

protected override void ArrangeCore(Rect rect, IMeasureContext context);

Override to arrange children within this view's final frame.

TLayer LayerView<TView, TLayer>.Layer

protected TLayer Layer;

The layer struct that owns all layout and rendering logic for this view.

Size LayerView<TView, TLayer>.MeasureCore(Size availableSize, IMeasureContext context)

protected override Size MeasureCore(Size availableSize, IMeasureContext context);

Override to compute the desired border-edge size.

void LayerView<TView, TLayer>.OnBlur()

protected internal override void OnBlur();

Called when this view loses keyboard focus.

void LayerView<TView, TLayer>.OnChar(ref KeyEventRef e)

public override void OnChar(ref KeyEventRef e);

Called when a character is input while this view has focus.

void LayerView<TView, TLayer>.OnFocus()

protected internal override void OnFocus();

Called when this view receives keyboard focus.

void LayerView<TView, TLayer>.OnKeyDown(ref KeyEventRef e)

public override void OnKeyDown(ref KeyEventRef e);

Called when a key is pressed while this view has focus.

void LayerView<TView, TLayer>.OnPointerEvent(ref PointerEventRef e, EventPhase phase)

public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase);

Called during event dispatch to handle a pointer event in a specific event phase.

void LayerView<TView, TLayer>.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

struct TextInputLayer

A leaf layer that implements single-line text input: typing, selection, caret blinking, password masking, and mouse-driven selection. Shares document state with native text input adapters.

The layer stores the arranged Xui.Core.UI.Layer.TextInputLayer.contentRect during Xui.Core.UI.Layer.TextInputLayer.Arrange(Xui.Core.UI.View,Xui.Core.Math2D.Rect,Xui.Core.Canvas.IMeasureContext) so that Xui.Core.UI.Layer.TextInputLayer.Render(Xui.Core.UI.View,Xui.Core.Canvas.IContext) and pointer hit-testing both know the exact text area, independent of any border or padding applied by a wrapping layer.

public struct TextInputLayer : ILayer<View>
{
    public TextEditingState Editor { get; }
    public bool NativeSelection { get; set; }
    public bool HasText { get; }
    public string Text { get; set; }
    public Interval<uint>.ClosedOpen Selection { get; set; }
    public bool IsPassword { get; set; }
    public bool SelectAllOnFocus { get; set; }
    public Func<char, bool>? InputFilter { get; set; }
    public Color Color { get; set; }
    public Color SelectedColor { get; set; }
    public Color SelectionBackgroundColor { get; set; }
    public CornerRadius SelectionCornerRadius { get; set; }
    public Frame Padding { get; set; }
    public Font Font { get; set; }

    public Size Measure(View view, Size availableSize, IMeasureContext context);
    public void Arrange(View view, Rect rect, IMeasureContext context);
    public void Render(View view, IContext context);
    public void Animate(View view, TimeSpan previousTime, TimeSpan currentTime);
    public void OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase);
    public void OnKeyDown(View view, ref KeyEventRef e);
    public void OnChar(View view, ref KeyEventRef e);
    public void OnFocus(View view);
    public void OnBlur(View view);
    public Rect GetCaretRect(View view, int offset, ITextMeasureContext measure);
    public int GetTextPosition(View view, Point point, ITextMeasureContext measure);
}

void TextInputLayer.Animate(View view, TimeSpan previousTime, TimeSpan currentTime)

public void Animate(View view, TimeSpan previousTime, TimeSpan currentTime);

Advances time-based state (animations, blinking cursors, etc.).

void TextInputLayer.Arrange(View view, Rect rect, IMeasureContext context)

public void Arrange(View view, Rect rect, IMeasureContext context);

Finalises position and size within rect.

Color TextInputLayer.Color

public Color Color { get; set; }

Normal text color.

TextEditingState TextInputLayer.Editor

public TextEditingState Editor { get; }

The editing state shared with native adapters.

Font TextInputLayer.Font

public Font Font { get; set; }

Font used for input measurement, hit testing, and rendering.

Rect TextInputLayer.GetCaretRect(View view, int offset, ITextMeasureContext measure)

public Rect GetCaretRect(View view, int offset, ITextMeasureContext measure);

Returns caret geometry in window coordinates.

int TextInputLayer.GetTextPosition(View view, Point point, ITextMeasureContext measure)

public int GetTextPosition(View view, Point point, ITextMeasureContext measure);

Hit-tests text using a point in window coordinates.

bool TextInputLayer.HasText

public bool HasText { get; }

Whether the input contains text, without allocating a string.

Func<char, bool>? TextInputLayer.InputFilter

public Func<char, bool>? InputFilter { get; set; }

Optional character filter. Return true to accept, false to reject.

bool TextInputLayer.IsPassword

public bool IsPassword { get; set; }

When true, displays bullet characters instead of the actual text.

Size TextInputLayer.Measure(View view, Size availableSize, IMeasureContext context)

public Size Measure(View view, Size availableSize, IMeasureContext context);

Returns the desired border-edge size given the available space.

bool TextInputLayer.NativeSelection

public bool NativeSelection { get; set; }

Whether the platform draws and manipulates the selection.

void TextInputLayer.OnBlur(View view)

public void OnBlur(View view);

Called when the host view loses keyboard focus.

void TextInputLayer.OnChar(View view, ref KeyEventRef e)

public void OnChar(View view, ref KeyEventRef e);

Handles a character input event while the host view has focus.

void TextInputLayer.OnFocus(View view)

public void OnFocus(View view);

Called when the host view gains keyboard focus.

void TextInputLayer.OnKeyDown(View view, ref KeyEventRef e)

public void OnKeyDown(View view, ref KeyEventRef e);

Handles a key-down event while the host view has focus.

void TextInputLayer.OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase)

public void OnPointerEvent(View view, ref PointerEventRef e, EventPhase phase);

Handles a pointer event in the given dispatch phase.

Frame TextInputLayer.Padding

public Frame Padding { get; set; }

Inset applied to the arranged rect before text layout and hit-testing.

void TextInputLayer.Render(View view, IContext context)

public void Render(View view, IContext context);

Draws content. Called after Arrange.

bool TextInputLayer.SelectAllOnFocus

public bool SelectAllOnFocus { get; set; }

When true (default), selects all text when the view gains focus.

Color TextInputLayer.SelectedColor

public Color SelectedColor { get; set; }

Color of text inside the selection highlight.

ClosedOpen TextInputLayer.Selection

public Interval<uint>.ClosedOpen Selection { get; set; }

Gets or sets the selection as a half-open interval [Start, End). Start == End represents the caret position.

Color TextInputLayer.SelectionBackgroundColor

public Color SelectionBackgroundColor { get; set; }

Background color drawn behind selected text.

CornerRadius TextInputLayer.SelectionCornerRadius

public CornerRadius SelectionCornerRadius { get; set; }

Corner radius of the selection highlight rectangle. Zero by default.

string TextInputLayer.Text

public string Text { get; set; }

Gets or sets the text content.