Xui.Core.UI

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

Types

readonly struct ArrangeConstraints

Immutable input to an arrangement operation.

public readonly struct ArrangeConstraints
{
    public ArrangeConstraints(Size availableSize, Size desiredSize, Point anchor, LayoutSizeMode xSize = LayoutSizeMode.Exact, LayoutSizeMode ySize = LayoutSizeMode.Exact, LayoutAlign xAlign = LayoutAlign.Start, LayoutAlign yAlign = LayoutAlign.Start);
    public Size AvailableSize { get; }
    public Size DesiredSize { get; }
    public Point Anchor { get; }
    public LayoutSizeMode XSize { get; }
    public LayoutSizeMode YSize { get; }
    public LayoutAlign XAlign { get; }
    public LayoutAlign YAlign { get; }
}

ArrangeConstraints.ArrangeConstraints(Size availableSize, Size desiredSize, Point anchor, LayoutSizeMode xSize = LayoutSizeMode.Exact, LayoutSizeMode ySize = LayoutSizeMode.Exact, LayoutAlign xAlign = LayoutAlign.Start, LayoutAlign yAlign = LayoutAlign.Start)

public ArrangeConstraints(Size availableSize, Size desiredSize, Point anchor, LayoutSizeMode xSize = LayoutSizeMode.Exact, LayoutSizeMode ySize = LayoutSizeMode.Exact, LayoutAlign xAlign = LayoutAlign.Start, LayoutAlign yAlign = LayoutAlign.Start);

Initializes arrangement constraints.

Point ArrangeConstraints.Anchor

public Point Anchor { get; }

Reference point for alignment.

Size ArrangeConstraints.AvailableSize

public Size AvailableSize { get; }

Available margin-box size.

Size ArrangeConstraints.DesiredSize

public Size DesiredSize { get; }

Desired margin-box size from measurement.

LayoutAlign ArrangeConstraints.XAlign

public LayoutAlign XAlign { get; }

Horizontal anchor alignment.

LayoutSizeMode ArrangeConstraints.XSize

public LayoutSizeMode XSize { get; }

Horizontal sizing mode.

LayoutAlign ArrangeConstraints.YAlign

public LayoutAlign YAlign { get; }

Vertical anchor alignment.

LayoutSizeMode ArrangeConstraints.YSize

public LayoutSizeMode YSize { get; }

Vertical sizing mode.

ref struct AttachEventRef

Passed to Xui.Core.UI.View.OnAttach(Xui.Core.UI.AttachEventRef@) when a view is added to the visual tree. Carries tree-wide shared resources (e.g. instrumentation) down the DFS walk so every view in the subtree receives them without per-view service lookups.

public ref struct AttachEventRef
{
    public InstrumentsAccessor Instruments;
    public AttachEventRef();
}

AttachEventRef.AttachEventRef()

public AttachEventRef();

Initializes a new Xui.Core.UI.AttachEventRef.

InstrumentsAccessor AttachEventRef.Instruments

public InstrumentsAccessor Instruments;

Instrumentation sink for the visual tree. Views receive this during attach and store it so invalidation methods (e.g. Xui.Core.UI.View.InvalidateRender, Xui.Core.UI.View.RequestAnimationFrame) can log consistently with the render-surface instrumentation carried by Xui.Core.UI.LayoutFrameContext.Instruments.

class Border

A view that draws a background, border, and padding around a single child content view. All rendering is owned by Xui.Core.UI.Layer.BorderLayer2](../xui-core-ui-layer/index.md#api-ce3e0b25f8e8191f) composed with [Xui.Core.UI.Layer.ContentLayer](../xui-core-ui-layer/index.md#api-57531bb01cd513a7). The child view lives in Layer.Child.Child and is managed via the standard [Xui.Core.UI.View.SetProtectedChild1(0@,``0)` lifecycle.

public class Border : LayerView<View, BorderLayer<View, ContentLayer>>
{
    public View? Content { get; set; }
    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 override int Count { get; }

    public override View this[int index] { get; }
}

Color Border.BackgroundColor

public Color BackgroundColor { get; set; }

Gets or sets the background fill color.

Color Border.BorderColor

public Color BorderColor { get; set; }

Gets or sets the border stroke color.

Frame Border.BorderThickness

public Frame BorderThickness { get; set; }

Gets or sets the per-side border thickness.

View? Border.Content

public View? Content { get; set; }

Gets or sets the content view displayed inside the border.

CornerRadius Border.CornerRadius

public CornerRadius CornerRadius { get; set; }

Gets or sets the corner radius.

int Border.Count

public override int Count { get; }

Returns the number of child views. Used by layout containers and traversal logic. Leaf views should return 0.

View Border.this[int index]

public override View this[int index] { get; }

Indexer to access child views by index. Layout containers should implement this to expose their children.

Frame Border.Padding

public Frame Padding { get; set; }

Gets or sets the padding between the border edge and the content.

struct ClassNameCollection

A compact collection of CSS-like class name strings for a view. Stores up to 3 class names inline without allocation. If more are added, spills over into a System.Collections.Generic.HashSet1`.

public struct ClassNameCollection : IEnumerable<string>
{
    public readonly int Count { get; }

    public readonly bool Contains(string className);
    public bool Add(string className);
    public bool Remove(string className);
    public static ClassNameCollection operator +(ClassNameCollection collection, string className);
    public static ClassNameCollection operator -(ClassNameCollection collection, string className);
    public readonly IEnumerator<string> GetEnumerator();
}

bool ClassNameCollection.Add(string className)

public bool Add(string className);

Adds a class name to the collection. Returns true if it was added (not already present).

readonly bool ClassNameCollection.Contains(string className)

public readonly bool Contains(string className);

Returns true if the collection contains the specified class name.

readonly int ClassNameCollection.Count

public readonly int Count { get; }

Returns the number of class names in the collection.

readonly IEnumerator<string> ClassNameCollection.GetEnumerator()

public readonly IEnumerator<string> GetEnumerator();

Returns an enumerator that iterates over all class names in the collection.

bool ClassNameCollection.Remove(string className)

public bool Remove(string className);

Removes a class name from the collection. Returns true if it was found and removed.

ClassNameCollection ClassNameCollection.operator +(ClassNameCollection collection, string className)

public static ClassNameCollection operator +(ClassNameCollection collection, string className);

Adds a class name to the collection and returns the updated collection.

ClassNameCollection ClassNameCollection.operator -(ClassNameCollection collection, string className)

public static ClassNameCollection operator -(ClassNameCollection collection, string className);

Removes a class name from the collection and returns the updated collection.

ref struct DetachEventRef

Passed to Xui.Core.UI.View.OnDetach(Xui.Core.UI.DetachEventRef@) when a view is removed from the visual tree.

public ref struct DetachEventRef
{
    public DetachEventRef();
}

DetachEventRef.DetachEventRef()

public DetachEventRef();

Initializes a new Xui.Core.UI.DetachEventRef.

enum Direction

Indicates the semantic inline direction of content, such as left-to-right or right-to-left. Used to resolve text alignment, layout flow, and mirroring behavior.

public enum Direction : byte
{
    Inherit = 0,
    LeftToRight = 1,
    RightToLeft = 2
}

Direction.Inherit

Inherit = 0

Inherit direction from the parent view.

Direction.LeftToRight

LeftToRight = 1

Left-to-right flow (default for Western languages).

Direction.RightToLeft

RightToLeft = 2

Right-to-left flow (used in Arabic, Hebrew, etc).

enum Flow

Controls whether layout and rendering should respect directionality and writing mode. Used to suppress mirroring and bidi-aware behavior for diagrams, graphs, and non-linguistic views.

public enum Flow : byte
{
    Inherit = 0,
    Aware = 1,
    Unaware = 2
}

Flow.Aware

Aware = 1

Enable direction-aware and writing-mode-aware behavior.

Flow.Inherit

Inherit = 0

Inherit flow behavior from the parent view.

Flow.Unaware

Unaware = 2

Disable all direction-aware layout and rendering. Used for charts, maps, etc.

enum FlowDirection

Represents the resolved physical direction of layout flow along an axis. This is derived from Xui.Core.UI.WritingMode and Xui.Core.UI.Direction, and is used to control stacking, alignment, and layout flow along block or inline axes.

public enum FlowDirection : byte
{
    LeftToRight = 0,
    RightToLeft = 1,
    TopToBottom = 2,
    BottomToTop = 3
}

FlowDirection.BottomToTop

BottomToTop = 3

Content flows from bottom to top.

FlowDirection.LeftToRight

LeftToRight = 0

Content flows from left to right.

FlowDirection.RightToLeft

RightToLeft = 1

Content flows from right to left.

FlowDirection.TopToBottom

TopToBottom = 2

Content flows from top to bottom.

enum HorizontalAlignment

Specifies how a view should be aligned horizontally within its layout bounds. Used by parent containers during layout to position the view along the inline axis.

public enum HorizontalAlignment : byte
{
    Stretch = 0,
    Left = 1,
    Center = 2,
    Right = 3
}

HorizontalAlignment.Center

Center = 2

Center horizontally within the available space.

HorizontalAlignment.Left

Left = 1

Align to the left edge (or start edge in LTR layouts).

HorizontalAlignment.Right

Right = 3

Align to the right edge (or start edge in RTL layouts).

HorizontalAlignment.Stretch

Stretch = 0

Stretch to fill the full available horizontal space.

class HorizontalStack

A layout container that arranges its children horizontally from left to right. Each child is measured with unconstrained width and a constrained height. The container expands to fit the combined width of all children.

public class HorizontalStack : ViewCollection
{
    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
}

void HorizontalStack.ArrangeCore(Rect rect, IMeasureContext context)

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

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

Size HorizontalStack.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Override to compute the desired border-edge size.

class HorizontalUniformStack

A layout container that arranges its children in a horizontal stack, assigning each child the same width.

If the parent provides a constrained width, the container divides the available width equally among all children.

If the width is unconstrained (infinite), the container measures each child to determine the maximum width, and assigns that uniform width to all columns.

The height of the container is based on the tallest child.

public class HorizontalUniformStack : ViewCollection
{
    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
}

void HorizontalUniformStack.ArrangeCore(Rect rect, IMeasureContext context)

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

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

Size HorizontalUniformStack.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Measures the desired size of this layout container and its children, based on the available space provided by the parent.

  • availableBorderEdgeSize — The space available for layout, excluding padding and borders.

  • context — The measure context used for child measurement.

Returns: The desired size of this container based on its layout strategy.

interface IFocus

Service interface for programmatic focus navigation. Resolved via this.GetService<IFocus>() from any Xui.Core.UI.View. Xui.Core.UI.RootView provides the default implementation.

public interface IFocus
{
    void Next();
    void Previous();
    View? GetNext(bool wrap = false);
    View? GetPrevious(bool wrap = false);
    View? FocusedView { get; set; }
}

View? IFocus.FocusedView

View? FocusedView { get; set; }

Gets or sets the view that currently holds keyboard focus. Setting to null clears focus. Setting fires Xui.Core.UI.View.OnBlur / Xui.Core.UI.View.OnFocus on the affected views.

View? IFocus.GetNext(bool wrap = false)

View? GetNext(bool wrap = false);

Returns the next focusable view without moving focus. Does not wrap by default.

View? IFocus.GetPrevious(bool wrap = false)

View? GetPrevious(bool wrap = false);

Returns the preceding focusable view without moving focus. Does not wrap by default.

void IFocus.Next()

void Next();

Moves focus to the next focusable element (same order as Tab).

void IFocus.Previous()

void Previous();

Moves focus to the previous focusable element (same order as Shift+Tab).

interface IFullScreenView

Declares whether root content supplies an opaque background for the entire window.

This is a coverage promise, not a layout hint. Return true only when every draw covers the whole display area with opaque pixels. Hosts may skip their clear. Wrappers must forward the promise explicitly, and changes must invalidate the view.

public interface IFullScreenView
{
    bool DrawsOpaqueFullScreen { get; }
}

bool IFullScreenView.DrawsOpaqueFullScreen

bool DrawsOpaqueFullScreen { get; }

Whether the current state paints the whole display area opaquely.

interface IOverlay

A transient in-window overlay acquired via GetService<IOverlay>(). Rendered by Xui.Core.UI.RootView on top of all other content — no native window is created. Works on every platform (Windows, macOS, iOS, Android, Browser) with no platform-specific code.

Use this for cross-platform scenarios: mobile, simulators, web/SPA, or in-app surfaces like top-of-screen search fields that must stay within the window. For native OS-level popups that can extend outside the app window, use Xui.Core.UI.IPopup instead.

Usage pattern:

var overlay = this.GetService<IOverlay>();
overlay.Show(content, anchorRect, PopupPlacement.Below);

The overlay auto-dismisses when the user clicks outside. Disposing the overlay closes it if still visible.

public interface IOverlay : IDisposable
{
    void Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None);
    void Close();
    bool IsVisible { get; }

    event Action? Closed;
}

void IOverlay.Close()

void Close();

Closes the overlay if visible.

event Action? IOverlay.Closed

event Action? Closed;

Raised when the overlay is dismissed (click-outside, explicit close, or parent window close).

bool IOverlay.IsVisible

bool IsVisible { get; }

Whether the overlay is currently visible.

void IOverlay.Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None)

void Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None);

Shows the overlay with the given content, positioned relative to anchorRect (in the owning window's coordinate space).

  • content — The view to display inside the overlay.

  • anchorRect — The rect of the triggering element in window coordinates. Used to position the overlay (for example, below a button).

  • placement — Preferred placement direction.

  • size — Desired overlay size. If null, a default size is used.

  • effect — Visual backdrop effect (reserved for future use).

interface IPopup

A transient native popup surface acquired via GetService<IPopup>(). Each call returns a new instance backed by a platform-specific child window, which can extend beyond the parent window bounds.

Available on platforms that support native popups (Windows, macOS). For cross-platform in-window overlays that work on all platforms including mobile, web, and simulators, use Xui.Core.UI.IOverlay instead.

Usage pattern (similar to Xui.Core.Canvas.IImage):

var popup = this.GetService<IPopup>();
popup.Show(content, anchorRect, PopupPlacement.Below);

The popup auto-dismisses when the user clicks outside. Disposing the popup closes it if still visible.

public interface IPopup : IDisposable
{
    void Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None);
    void Close();
    bool IsVisible { get; }

    event Action? Closed;
}

void IPopup.Close()

void Close();

Closes the popup if visible.

event Action? IPopup.Closed

event Action? Closed;

Raised when the popup is dismissed (click-outside, explicit close, or parent window close).

bool IPopup.IsVisible

bool IsVisible { get; }

Whether the popup is currently visible.

void IPopup.Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None)

void Show(View content, Rect anchorRect, PopupPlacement placement = PopupPlacement.Below, Size? size = null, PopupEffect effect = PopupEffect.None);

Shows the popup with the given content, positioned relative to anchorRect (in the owning window's coordinate space).

  • content — The view to display inside the popup.

  • anchorRect — The rect of the triggering element in window coordinates. The platform uses this to position the popup so that (for example) a selected item aligns with the anchor text.

  • placement — Preferred placement direction.

  • size — Desired popup size. If null, the platform falls back to a default size.

  • effect — Visual backdrop effect to apply to the popup window.

interface ITextEditingClient

A canvas text editor that a native text-input service can manipulate.

public interface ITextEditingClient : ITextInputClient
{
    TextEditingState Editor { get; }

    bool NativeSelection { get; set; }

    Rect InputBounds { get; }

    Rect GetCaretRect(int offset, ITextMeasureContext measure);
    int GetTextPosition(Point point, ITextMeasureContext measure);
}

TextEditingState ITextEditingClient.Editor

TextEditingState Editor { get; }

The document and selection shared with the native input system.

Rect ITextEditingClient.GetCaretRect(int offset, ITextMeasureContext measure)

Rect GetCaretRect(int offset, ITextMeasureContext measure);

Returns the caret rectangle for a UTF-16 offset, in logical window coordinates.

int ITextEditingClient.GetTextPosition(Point point, ITextMeasureContext measure)

int GetTextPosition(Point point, ITextMeasureContext measure);

Hit-tests a logical window point, returning a UTF-16 grapheme boundary.

Rect ITextEditingClient.InputBounds

Rect InputBounds { get; }

The input's hit-test bounds, in logical window coordinates.

bool ITextEditingClient.NativeSelection

bool NativeSelection { get; set; }

Whether a native interaction owns caret, selection handles, and touch selection.

interface ITextInputClient

Basic text-entry capabilities of a focusable view. Focus requests the software keyboard; the responder can query these traits without copying the text buffer. This does not imply support for marked text, IME composition, or native range editing.

public interface ITextInputClient
{
    bool HasText { get; }

    bool IsPassword { get; }

    TextInputOptions InputOptions { get; }

    bool CanPerformInputAction(TextInputAction action);
    void PerformInputAction(TextInputAction action);
}

bool ITextInputClient.CanPerformInputAction(TextInputAction action)

bool CanPerformInputAction(TextInputAction action);

Whether a keyboard action is currently available.

bool ITextInputClient.HasText

bool HasText { get; }

Whether the input contains any text.

TextInputOptions ITextInputClient.InputOptions

TextInputOptions InputOptions { get; }

Keyboard layout, content semantics and return-key action.

bool ITextInputClient.IsPassword

bool IsPassword { get; }

Whether the input is a masked password field.

void ITextInputClient.PerformInputAction(TextInputAction action)

void PerformInputAction(TextInputAction action);

Handles a keyboard action, including focus navigation or finishing editing.

class ImageView

A view that displays an image. Works like HTMLImageElement: it holds an Xui.Core.Canvas.IImage handle (acquired from the service chain) and sets its source via Xui.Core.Canvas.IImage.Load(System.String). The platform catalog handles caching and device-lost rehydration transparently.

public class ImageView : View
{
    public string? Source { get; set; }

    protected override void OnActivate();
    protected override void OnDeactivate();
    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void RenderCore(IContext context);
}

Size ImageView.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Override to compute the desired border-edge size.

void ImageView.OnActivate()

protected override void OnActivate();

Called when this view becomes active — it will receive events, render, and animate. Override this to start animations, subscribe to data sources, or acquire resources.

void ImageView.OnDeactivate()

protected override void OnDeactivate();

Called when this view becomes dormant — it should stop animations, timers, and event subscriptions. The view may remain in the tree (e.g., in a virtualizing panel's recycle pool).

void ImageView.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

string? ImageView.Source

public string? Source { get; set; }

Gets or sets the URI of the image to display. Setting this property triggers a load if the view is already active.

class Label

A view that displays a single line of styled text.

public class Label : View
{
    public string Text { get; set; }
    public Color TextColor { get; set; }
    public Font Font { get; set; }
    public string FontFamily { get; set; }
    public nfloat FontSize { get; set; }
    public FontStyle FontStyle { get; set; }
    public FontWeight FontWeight { get; set; }
    public FontStretch FontStretch { get; set; }
    public nfloat LineHeight { get; set; }

    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void RenderCore(IContext context);
}

Font Label.Font

public Font Font { get; set; }

Gets or sets the complete font used for text measurement and rendering.

string Label.FontFamily

public string FontFamily { get; set; }

Gets or sets the font family used for rendering the text.

NFloat Label.FontSize

public nfloat FontSize { get; set; }

Gets or sets the font size in points.

FontStretch Label.FontStretch

public FontStretch FontStretch { get; set; }

Gets or sets the font stretch (e.g., condensed, semi-expanded etc.).

FontStyle Label.FontStyle

public FontStyle FontStyle { get; set; }

Gets or sets the font style (e.g., normal, italic, oblique).

FontWeight Label.FontWeight

public FontWeight FontWeight { get; set; }

Gets or sets the font weight (e.g., normal, bold, numeric weight).

NFloat Label.LineHeight

public nfloat LineHeight { get; set; }

Gets or sets the line height of the text, in user units.

If set to a numeric value, this value overrides the default line height computation from the font metrics. If set to System.Runtime.InteropServices.NFloat.NaN, the line height will be automatically computed based on the font's ascender, descender, and line gap, or fallback to a platform-specific multiplier of the Xui.Core.Canvas.Font.FontSize (typically 1.2×).

Size Label.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Override to compute the desired border-edge size.

void Label.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

string Label.Text

public string Text { get; set; }

Gets or sets the text content displayed by the label.

Color Label.TextColor

public Color TextColor { get; set; }

Gets or sets the color used to fill the text.

enum LayoutAlign

Defines an anchor alignment on one layout axis.

public enum LayoutAlign : byte
{
    Start,
    Center,
    End,
}

LayoutAlign.Center

Center

Align to the center.

LayoutAlign.End

End

Align to the end edge.

LayoutAlign.Start

Start

Align to the start edge.

readonly struct LayoutFrameContext

Immutable services and timing shared by every view visited during one render-surface update.

public readonly struct LayoutFrameContext
{
    public LayoutFrameContext(TimeSpan previousTime, TimeSpan currentTime, IMeasureContext? measureContext, IContext? renderContext, InstrumentsAccessor instruments);
    public TimeSpan PreviousTime { get; }
    public TimeSpan CurrentTime { get; }
    public IMeasureContext? MeasureContext { get; }
    public IContext? RenderContext { get; }
    public InstrumentsAccessor Instruments { get; }
}

LayoutFrameContext.LayoutFrameContext(TimeSpan previousTime, TimeSpan currentTime, IMeasureContext? measureContext, IContext? renderContext, InstrumentsAccessor instruments)

public LayoutFrameContext(TimeSpan previousTime, TimeSpan currentTime, IMeasureContext? measureContext, IContext? renderContext, InstrumentsAccessor instruments);

Initializes a frame context.

TimeSpan LayoutFrameContext.CurrentTime

public TimeSpan CurrentTime { get; }

Time of this frame.

InstrumentsAccessor LayoutFrameContext.Instruments

public InstrumentsAccessor Instruments { get; }

Instrumentation associated with this render surface.

IMeasureContext? LayoutFrameContext.MeasureContext

public IMeasureContext? MeasureContext { get; }

Measurement services for this render surface.

TimeSpan LayoutFrameContext.PreviousTime

public TimeSpan PreviousTime { get; }

Time of the preceding frame.

IContext? LayoutFrameContext.RenderContext

public IContext? RenderContext { get; }

Rendering context for this render surface.

struct LayoutMeasurements

Per-view results written by an update. The caller owns this value and passes it by reference, so sibling updates cannot share or overwrite one another's results.

public struct LayoutMeasurements
{
    public Size DesiredSize;
    public Rect ArrangedRect;
}

Rect LayoutMeasurements.ArrangedRect

public Rect ArrangedRect;

Final border-edge rectangle produced by arrangement.

Size LayoutMeasurements.DesiredSize

public Size DesiredSize;

Desired margin-box size produced by measurement.

enum LayoutPass

Passes that may be requested during a render-surface update.

[Flags]
public enum LayoutPass : byte
{
    Animate = 1 << 0,
    Measure = 1 << 1,
    Arrange = 1 << 2,
    Render = 1 << 3,
}

LayoutPass.Animate

Animate = 1 << 0

Advance time-based state.

LayoutPass.Arrange

Arrange = 1 << 2

Arrange final frame.

LayoutPass.Measure

Measure = 1 << 1

Measure desired size.

LayoutPass.Render

Render = 1 << 3

Render the view.

enum LayoutSizeMode

Defines how an axis participates in a layout pass.

public enum LayoutSizeMode : byte
{
    Exact,
    AtMost,
}

LayoutSizeMode.AtMost

AtMost

The view may size to content without exceeding the available size.

LayoutSizeMode.Exact

Exact

The view must exactly match the available size.

readonly struct LayoutUpdate

Pass selection and per-pass immutable constraints for one view update.

public readonly struct LayoutUpdate
{
    public LayoutUpdate(LayoutPass pass, MeasureConstraints measure, ArrangeConstraints arrange);
    public LayoutPass Pass { get; }
    public MeasureConstraints Measure { get; }
    public ArrangeConstraints Arrange { get; }
    public bool IsAnimate { get; }
    public bool IsMeasure { get; }
    public bool IsArrange { get; }
    public bool IsRender { get; }
}

LayoutUpdate.LayoutUpdate(LayoutPass pass, MeasureConstraints measure, ArrangeConstraints arrange)

public LayoutUpdate(LayoutPass pass, MeasureConstraints measure, ArrangeConstraints arrange);

Initializes a layout update.

ArrangeConstraints LayoutUpdate.Arrange

public ArrangeConstraints Arrange { get; }

Arrangement constraints.

bool LayoutUpdate.IsAnimate

public bool IsAnimate { get; }

Whether animation is requested.

bool LayoutUpdate.IsArrange

public bool IsArrange { get; }

Whether arrangement is requested.

bool LayoutUpdate.IsMeasure

public bool IsMeasure { get; }

Whether measurement is requested.

bool LayoutUpdate.IsRender

public bool IsRender { get; }

Whether rendering is requested.

MeasureConstraints LayoutUpdate.Measure

public MeasureConstraints Measure { get; }

Measurement constraints.

LayoutPass LayoutUpdate.Pass

public LayoutPass Pass { get; }

Requested passes.

readonly struct MeasureConstraints

Immutable input to a measurement operation.

public readonly struct MeasureConstraints
{
    public MeasureConstraints(Size availableSize, LayoutSizeMode xSize = LayoutSizeMode.AtMost, LayoutSizeMode ySize = LayoutSizeMode.AtMost);
    public Size AvailableSize { get; }
    public LayoutSizeMode XSize { get; }
    public LayoutSizeMode YSize { get; }
}

MeasureConstraints.MeasureConstraints(Size availableSize, LayoutSizeMode xSize = LayoutSizeMode.AtMost, LayoutSizeMode ySize = LayoutSizeMode.AtMost)

public MeasureConstraints(Size availableSize, LayoutSizeMode xSize = LayoutSizeMode.AtMost, LayoutSizeMode ySize = LayoutSizeMode.AtMost);

Initializes measurement constraints.

Size MeasureConstraints.AvailableSize

public Size AvailableSize { get; }

Available margin-box size.

LayoutSizeMode MeasureConstraints.XSize

public LayoutSizeMode XSize { get; }

Horizontal sizing mode.

LayoutSizeMode MeasureConstraints.YSize

public LayoutSizeMode YSize { get; }

Vertical sizing mode.

enum PopupEffect

Controls the visual backdrop material of a popup surface. Mirrors Xui.Core.Abstract.IWindow.IDesktopStyle.WindowBackdrop for popup-specific use.

public enum PopupEffect
{
    None = 0,
    Translucent = 1,
}

PopupEffect.None

None = 0

Standard opaque popup with no translucency.

PopupEffect.Translucent

Translucent = 1

Translucent popup using the system's standard popup/popover material. On macOS this uses NSVisualEffectView with the Popover material, which on macOS 26+ automatically gains the liquid-glass treatment.

enum PopupPlacement

Specifies the preferred placement of a popup relative to its anchor rect. The platform may adjust placement to keep the popup on screen.

public enum PopupPlacement
{
    Below,
    Above,
    Right,
    Left,
}

PopupPlacement.Above

Above

Show above the anchor.

PopupPlacement.Below

Below

Show below the anchor (default for dropdowns/comboboxes).

PopupPlacement.Left

Left

Show to the left of the anchor.

PopupPlacement.Right

Right

Show to the right of the anchor (e.g. nested/submenu).

class RootView

The root container view that bridges a Xui.Core.UI.RootView.Window with its UI content hierarchy.

public class RootView : View, IContent, IFocus
{
    public IRenderSurfaceInstrumentsSink? RenderSurfaceInstruments { get; }
    public EventRouter EventRouter { get; }
    public Window Window { get; }
    public View? FocusedView { get; set; }
    public View? Content { get; set; }
    public override int Count { get; }

    public override View this[int index] { get; }

    protected override Size MeasureCore(Size available, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
    protected override void RenderCore(IContext context);
    public RootView(Window window);
    public override object? GetService(Type serviceType);
    protected override void OnChildRenderChanged(View child);
}

RootView.RootView(Window window)

public RootView(Window window);

Initializes a new RootView for the given window.

  • window — The window that owns this root view.

void RootView.ArrangeCore(Rect rect, IMeasureContext context)

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

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

View? RootView.Content

public View? Content { get; set; }

Gets or sets the single content view hosted by this root view.

int RootView.Count

public override int Count { get; }

The content followed by visible in-window overlays, in render and hit-test order.

EventRouter RootView.EventRouter

public EventRouter EventRouter { get; }

The input event router for this view tree.

View? RootView.FocusedView

public View? FocusedView { get; set; }

The currently focused view within this tree, or null if none.

object? RootView.GetService(Type serviceType)

public override object? GetService(Type serviceType);

Resolves a service of the given type by walking up the parent chain. Returns null if no ancestor provides the service.

View RootView.this[int index]

public override View this[int index] { get; }

Gets the child view at the given index.

Size RootView.MeasureCore(Size available, IMeasureContext context)

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

Override to compute the desired border-edge size.

void RootView.OnChildRenderChanged(View child)

protected override void OnChildRenderChanged(View child);

Called when a child view signals that its rendered state has changed.

void RootView.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

IRenderSurfaceInstrumentsSink? RootView.RenderSurfaceInstruments

public IRenderSurfaceInstrumentsSink? RenderSurfaceInstruments { get; }

The render-surface instruments that own this visual tree, if instrumentation is enabled.

Window RootView.Window

public Window Window { get; }

The window that owns this root view.

enum ScrollDirection

Controls which axis (or axes) a Xui.Core.UI.ScrollView scrolls along.

public enum ScrollDirection
{
    Vertical,
    Horizontal,
    Both
}

ScrollDirection.Both

Both

Scrolls both axes simultaneously (map-panning style).

ScrollDirection.Horizontal

Horizontal

Scrolls horizontally only.

ScrollDirection.Vertical

Vertical

Scrolls vertically only (default).

class ScrollView

A container that clips its content and allows scrolling via pointer drag/fling and scroll wheel input. Supports vertical, horizontal, or both axes. Displays thin overlay scrollbar indicators on the relevant edges.

public partial class ScrollView
{
}
public partial class ScrollView
{
    public override void OnScrollWheel(ref ScrollWheelEventRef e);
}
public partial class ScrollView : View
{
    public Vector ScrollOffset { get; }

    public event Action<Vector>? ScrollChanged;
    public View? Overlay { get; set; }
    public nfloat ScrollbarWidth { get; set; }
    public nfloat ScrollbarEndInset { get; set; }
    public bool ClipToViewport { get; set; }
    public bool UseCompositionGroup { get; set; }
    public new ScrollDirection Direction { get; set; }
    public View? Content { get; set; }
    public override int Count { get; }

    public override View this[int index] { get; }

    protected override void OnActivate();
    protected override Size MeasureCore(Size available, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
    public override Point TransformPoint(Point point);
    public override Point InverseTransformPoint(Point point);
    public override Rect TransformRect(Rect rect);
    public override Rect InverseTransformRect(Rect rect);
    public override bool HitTest(Point point);
    protected override void RenderCore(IContext context);
    public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase);
    protected override void AnimateCore(TimeSpan previous, TimeSpan current);
    protected override void OnDeactivate();
}

void ScrollView.AnimateCore(TimeSpan previous, TimeSpan current)

protected override void AnimateCore(TimeSpan previous, TimeSpan current);

Override to animate this view and its children.

void ScrollView.ArrangeCore(Rect rect, IMeasureContext context)

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

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

bool ScrollView.ClipToViewport

public bool ClipToViewport { get; set; }

Gets or sets whether content is clipped and culled to the viewport. Disable this for a root scroller that is laid out inside a safe area but is allowed to paint underneath the system areas while it scrolls.

View? ScrollView.Content

public View? Content { get; set; }

Gets or sets the single child view to scroll.

int ScrollView.Count

public override int Count { get; }

Number of child views.

ScrollDirection ScrollView.Direction

public new ScrollDirection Direction { get; set; }

Gets or sets which axis (or axes) this scroll view responds to.

bool ScrollView.HitTest(Point point)

public override bool HitTest(Point point);

Determines whether the given point (in this view's local coordinates) hits this view's visual bounds. Used for input dispatch and hit testing.

  • point — The point to test, relative to this view's coordinate space.

Returns: true if the point is inside the view's frame; otherwise false.

Point ScrollView.InverseTransformPoint(Point point)

public override Point InverseTransformPoint(Point point);

Maps a point from this view's local coordinate space into its parent coordinate space.

This must be the inverse of Xui.Core.UI.View.TransformPoint(Xui.Core.Math2D.Point) for points that can be hit tested. It is separate so a view can support coordinate mappings that are not yet represented by the canvas transform API.

Rect ScrollView.InverseTransformRect(Rect rect)

public override Rect InverseTransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's coordinate space into its parent coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

View ScrollView.this[int index]

public override View this[int index] { get; }

Gets the child view at the given index.

Size ScrollView.MeasureCore(Size available, IMeasureContext context)

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

Override to compute the desired border-edge size.

void ScrollView.OnActivate()

protected override void OnActivate();

Called when this view becomes active — it will receive events, render, and animate. Override this to start animations, subscribe to data sources, or acquire resources.

void ScrollView.OnDeactivate()

protected override void OnDeactivate();

Called when this view becomes dormant — it should stop animations, timers, and event subscriptions. The view may remain in the tree (e.g., in a virtualizing panel's recycle pool).

void ScrollView.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 ScrollView.OnScrollWheel(ref ScrollWheelEventRef e)

public override void OnScrollWheel(ref ScrollWheelEventRef e);

Called when a scroll wheel or trackpad scroll event is dispatched to this view. Override to handle scroll input. Set Xui.Core.Abstract.Events.ScrollWheelEventRef.Handled to stop propagation.

View? ScrollView.Overlay

public View? Overlay { get; set; }

A viewport-sized foreground view that stays outside the content's scroll transform. Its input still participates in this scroll view's gesture negotiation.

void ScrollView.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

event Action<Vector>? ScrollView.ScrollChanged

public event Action<Vector>? ScrollChanged;

Raised after the content's scroll transform changes, including during inertia and rebound.

Vector ScrollView.ScrollOffset

public Vector ScrollOffset { get; }

Current scroll displacement, including elastic overscroll.

NFloat ScrollView.ScrollbarEndInset

public nfloat ScrollbarEndInset { get; set; }

Inset at each end of the scrollbar. When unset, adapts to the screen corners.

NFloat ScrollView.ScrollbarWidth

public nfloat ScrollbarWidth { get; set; }

Width of the scrollbar track in points.

Point ScrollView.TransformPoint(Point point)

public override Point TransformPoint(Point point);

Maps a point from this view's parent coordinate space into this view's local coordinate space.

Layout still supplies frames using the existing coordinate model. The default identity mapping deliberately preserves that behaviour until a container opts into a local coordinate transform. Containers such as Xui.Core.UI.ScrollView can override this to map input into their content space.

Rect ScrollView.TransformRect(Rect rect)

public override Rect TransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's parent coordinate space into this view's coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

bool ScrollView.UseCompositionGroup

public bool UseCompositionGroup { get; set; }

Retains this viewport as a native composition surface where supported.

class TextBox

A single-line text input view implemented as LayerView<View, FocusBorderLayer<View, TextInputLayer>>. All text editing state, selection, caret blinking, and hit-testing live in Xui.Core.UI.Layer.TextInputLayer; focus-aware border drawing lives in Xui.Core.UI.Layer.FocusBorderLayer2`.

public class TextBox : LayerView<View, FocusBorderLayer<View, TextInputLayer>>, ITextEditingClient
{
    public override bool Focusable { get; }
    public TextInputOptions InputOptions { get; set; }

    public bool CanPerformInputAction(TextInputAction action);
    public void PerformInputAction(TextInputAction action);
    public Xui.Core.UI.Input.TextEditingState Editor { get; }
    public bool NativeSelection { get; set; }
    public Rect InputBounds { get; }

    public Rect GetCaretRect(int offset, ITextMeasureContext measure);
    public int GetTextPosition(Point point, ITextMeasureContext measure);
    public bool HasText { get; }

    protected override void OnDeactivate();
    public TextBox();
    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 Font Font { get; set; }
    public string FontFamily { get; set; }
    public nfloat FontSize { get; set; }
    public FontStyle FontStyle { get; set; }
    public FontWeight FontWeight { get; set; }
    public FontStretch FontStretch { get; set; }
}

TextBox.TextBox()

public TextBox();

Initializes a new Xui.Core.UI.TextBox with default styling.

bool TextBox.CanPerformInputAction(TextInputAction action)

public bool CanPerformInputAction(TextInputAction action);

Whether a keyboard action is currently available.

Color TextBox.Color

public Color Color { get; set; }

Gets or sets the text color.

TextEditingState TextBox.Editor

public Xui.Core.UI.Input.TextEditingState Editor { get; }

The document and selection shared with the native input system.

bool TextBox.Focusable

public override bool Focusable { get; }

Gets whether this view can receive keyboard focus. Always true for Xui.Core.UI.TextBox.

Font TextBox.Font

public Font Font { get; set; }

Gets or sets the complete text font.

string TextBox.FontFamily

public string FontFamily { get; set; }

Gets or sets the font family name.

NFloat TextBox.FontSize

public nfloat FontSize { get; set; }

Gets or sets the font size.

FontStretch TextBox.FontStretch

public FontStretch FontStretch { get; set; }

Gets or sets the font stretch.

FontStyle TextBox.FontStyle

public FontStyle FontStyle { get; set; }

Gets or sets the font style.

FontWeight TextBox.FontWeight

public FontWeight FontWeight { get; set; }

Gets or sets the font weight.

Rect TextBox.GetCaretRect(int offset, ITextMeasureContext measure)

public Rect GetCaretRect(int offset, ITextMeasureContext measure);

Returns the caret rectangle for a UTF-16 offset, in logical window coordinates.

int TextBox.GetTextPosition(Point point, ITextMeasureContext measure)

public int GetTextPosition(Point point, ITextMeasureContext measure);

Hit-tests a logical window point, returning a UTF-16 grapheme boundary.

bool TextBox.HasText

public bool HasText { get; }

Whether the input contains any text.

Rect TextBox.InputBounds

public Rect InputBounds { get; }

The input's hit-test bounds, in logical window coordinates.

Func<char, bool>? TextBox.InputFilter

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

Gets or sets the character filter predicate for input validation.

TextInputOptions TextBox.InputOptions

public TextInputOptions InputOptions { get; set; }

Keyboard hints, applied when this field receives focus.

bool TextBox.IsPassword

public bool IsPassword { get; set; }

Gets or sets whether input is masked as a password.

bool TextBox.NativeSelection

public bool NativeSelection { get; set; }

Whether a native interaction owns caret, selection handles, and touch selection.

void TextBox.OnDeactivate()

protected override void OnDeactivate();

Called when this view becomes dormant — it should stop animations, timers, and event subscriptions. The view may remain in the tree (e.g., in a virtualizing panel's recycle pool).

void TextBox.PerformInputAction(TextInputAction action)

public void PerformInputAction(TextInputAction action);

Handles a keyboard action, including focus navigation or finishing editing.

bool TextBox.SelectAllOnFocus

public bool SelectAllOnFocus { get; set; }

Gets or sets whether all text is selected when the view receives focus.

Color TextBox.SelectedColor

public Color SelectedColor { get; set; }

Gets or sets the color of selected text.

ClosedOpen TextBox.Selection

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

Gets or sets the current text selection range.

Color TextBox.SelectionBackgroundColor

public Color SelectionBackgroundColor { get; set; }

Gets or sets the background color of the selection.

string TextBox.Text

public string Text { get; set; }

Gets or sets the text content of this input.

class TransformView

Hosts one child and presents it through an affine transform without changing its layout rectangle. Input and render culling are mapped through the inverse transform so a translated or scaled child remains interactive and cullable.

public class TransformView : View
{
    public bool UseCompositionGroup { get; set; }
    public View? Content { get; set; }
    public AffineTransform Transform { get; set; }
    public override int Count { get; }

    public override View this[int index] { get; }

    public override Rect CullingFrame { get; }

    public override Point TransformPoint(Point point);
    public override Point InverseTransformPoint(Point point);
    public override Rect TransformRect(Rect rect);
    public override Rect InverseTransformRect(Rect rect);
    public override bool HitTest(Point point);
    protected override void RenderCore(IContext context);
    protected virtual void RenderTransformedContent(IContext context);
}

View? TransformView.Content

public View? Content { get; set; }

Gets or sets the single child presented by this host.

int TransformView.Count

public override int Count { get; }

Returns the number of child views. Used by layout containers and traversal logic. Leaf views should return 0.

Rect TransformView.CullingFrame

public override Rect CullingFrame { get; }

Gets this view's conservative bounds in its parent coordinate space for render culling.

A container may override this when its rendered geometry differs from its layout frame. Computing the union of descendant culling frames is deliberately deferred: it can be more expensive than rendering for small subtrees.

bool TransformView.HitTest(Point point)

public override bool HitTest(Point point);

Determines whether the given point (in this view's local coordinates) hits this view's visual bounds. Used for input dispatch and hit testing.

  • point — The point to test, relative to this view's coordinate space.

Returns: true if the point is inside the view's frame; otherwise false.

Point TransformView.InverseTransformPoint(Point point)

public override Point InverseTransformPoint(Point point);

Maps a point from this view's local coordinate space into its parent coordinate space.

This must be the inverse of Xui.Core.UI.View.TransformPoint(Xui.Core.Math2D.Point) for points that can be hit tested. It is separate so a view can support coordinate mappings that are not yet represented by the canvas transform API.

Rect TransformView.InverseTransformRect(Rect rect)

public override Rect InverseTransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's coordinate space into its parent coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

View TransformView.this[int index]

public override View this[int index] { get; }

Indexer to access child views by index. Layout containers should implement this to expose their children.

void TransformView.RenderCore(IContext context)

protected override void RenderCore(IContext context);

Override to render this view and its children.

void TransformView.RenderTransformedContent(IContext context)

protected virtual void RenderTransformedContent(IContext context);

Renders content after Xui.Core.UI.TransformView.Transform has been applied.

AffineTransform TransformView.Transform

public AffineTransform Transform { get; set; }

Gets or sets the transform from this view's layout coordinates into its parent presentation coordinates.

Point TransformView.TransformPoint(Point point)

public override Point TransformPoint(Point point);

Maps a point from this view's parent coordinate space into this view's local coordinate space.

Layout still supplies frames using the existing coordinate model. The default identity mapping deliberately preserves that behaviour until a container opts into a local coordinate transform. Containers such as Xui.Core.UI.ScrollView can override this to map input into their content space.

Rect TransformView.TransformRect(Rect rect)

public override Rect TransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's parent coordinate space into this view's coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

bool TransformView.UseCompositionGroup

public bool UseCompositionGroup { get; set; }

Retain the complete child drawing while only its native surface transform changes.

enum VerticalAlignment

Specifies how a view should be aligned vertically within its layout bounds. Used by parent containers to control vertical positioning along the block axis.

public enum VerticalAlignment : byte
{
    Stretch = 0,
    Top = 1,
    Middle = 2,
    Bottom = 3
}

VerticalAlignment.Bottom

Bottom = 3

Align to the bottom edge (or start edge in bottom-up layouts).

VerticalAlignment.Middle

Middle = 2

Center vertically within the available space.

VerticalAlignment.Stretch

Stretch = 0

Stretch to fill the full available vertical space.

VerticalAlignment.Top

Top = 1

Align to the top edge (or start edge in top-down layouts).

class VerticalStack

A layout container that arranges its children vertically from top to bottom. Each child is measured with an unconstrained height and is allowed to take up as much vertical space as needed. The container expands to fit the combined height of all children.

public class VerticalStack : ViewCollection
{
    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
}

void VerticalStack.ArrangeCore(Rect rect, IMeasureContext context)

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

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

Size VerticalStack.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Override to compute the desired border-edge size.

class VerticalUniformStack

A layout container that arranges its children in a vertical stack, giving each child the same height.

If the parent provides a constrained height, the container divides the available height equally among all children.

If the height is unconstrained (infinite), the container measures each child to determine the maximum height, and uses that height for all rows.

public class VerticalUniformStack : ViewCollection
{
    protected override Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected override void ArrangeCore(Rect rect, IMeasureContext context);
}

void VerticalUniformStack.ArrangeCore(Rect rect, IMeasureContext context)

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

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

Size VerticalUniformStack.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

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

Override to compute the desired border-edge size.

class View

Base class for all UI elements in the Xui layout engine. A view participates in layout, rendering, and input hit testing, and may contain child views.

Base class for all UI elements in the Xui layout engine. A view participates in layout, rendering, and input hit testing, and may contain child views.

public partial class View : IServiceProvider, Layer.ILayerHost
{
    public virtual object? GetService(Type serviceType);
}
public partial class View
{
    public nint this[Extra<nint> key] { get; set; }

    public nfloat this[Extra<nfloat> key] { get; set; }

    public string? this[Extra<string?> key] { get; set; }

    public bool this[Extra<bool> key] { get; set; }

    public object? this[Extra key] { get; set; }

    public abstract class Extra
    {
    }

    public sealed class Extra<T> : Extra
    {
        public T DefaultValue { get; }

        public Extra(T defaultValue = default !);
        public T Get(View view);
    }
}
public partial class View
{
    protected internal virtual void OnFocus();
    protected internal virtual void OnBlur();
    public virtual bool Focusable { get; }
    public virtual bool RequiresKeyboard { get; }
    public bool IsFocused { get; }

    public bool Focus();
    public void Blur();
}
public partial class View
{
    public virtual int Count { get; }

    public virtual View this[int index] { get; }

    protected void AddProtectedChild(View child);
    protected void RemoveProtectedChild(View child);
    protected void SetProtectedChild<T>(ref T? field, T? value)
        where T : View;
}
public partial class View
{
    public virtual void OnPointerEvent(ref PointerEventRef e, EventPhase phase);
    public virtual void OnScrollWheel(ref ScrollWheelEventRef e);
    public virtual void OnZoom(ref ZoomEventRef e);
    public virtual void OnKeyDown(ref KeyEventRef e);
    public virtual void OnChar(ref KeyEventRef e);
}
public partial class View
{
    protected Rect? RenderCullingFrame { get; }

    public virtual void Update(in LayoutFrameContext frame, in LayoutUpdate update, ref LayoutMeasurements measurements);
    public void Animate(TimeSpan previousTime, TimeSpan currentTime);
    public Size Measure(Size availableSize, IMeasureContext context);
    public Rect Arrange(Rect rect, IMeasureContext context, Size? desiredSize = null);
    public void Render(IContext context);
    protected void AnimateShell(in LayoutFrameContext frame);
    protected void MeasureShell(in LayoutFrameContext frame, in MeasureConstraints constraints, ref LayoutMeasurements measurements);
    protected void ArrangeShell(in LayoutFrameContext frame, in ArrangeConstraints constraints, ref LayoutMeasurements measurements);
    protected void RenderShell(in LayoutFrameContext frame, Rect? parentCullingFrame = null);
    protected virtual void AnimateCore(TimeSpan previousTime, TimeSpan currentTime);
    protected virtual Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);
    protected virtual void ArrangeCore(Rect rect, IMeasureContext context);
    protected virtual void RenderCore(IContext context);
    protected virtual void SetDefaultRenderState(IContext context);
    protected internal void RenderChild(IContext context, View child);
    protected internal void RenderChild(IContext context, View child, Rect cullingFrame);
}
public partial class View
{
    protected virtual void OnAttach(ref AttachEventRef e);
    protected virtual void OnDetach(ref DetachEventRef e);
    protected virtual void OnActivate();
    protected virtual void OnDeactivate();
}
public partial class View
{
    [Flags]
    public enum ViewFlags
    {
        Animated = 1 << 0,
        DescendantAnimated = 1 << 1,
        MeasureChanged = 1 << 2,
        ArrangeChanged = 1 << 3,
        DescendantArrangeChanged = 1 << 4,
        RenderChanged = 1 << 5,
        DescendantRenderChanged = 1 << 6,
        HitTestChanged = 1 << 7,
        DescendantHitTestChanged = 1 << 8,
        Active = 1 << 9,
        Attached = 1 << 10,
    }

    public ViewFlags Flags { get; }

    public bool RequiresRender(Xui.Core.Canvas.IContext context);
    protected bool HasRenderUpdates { get; }

    protected void Invalidate();
    protected bool SetViewProperty<T>(ref T field, T value);
    protected bool SetViewRenderProperty<T>(ref T field, T value);
    public void RequestAnimationFrame();
    protected virtual void OnChildRequestedAnimationFrame(View child);
    public void InvalidateMeasure();
    protected void InvalidateArrange();
    public void InvalidateRender();
    protected void InvalidateHitTest();
    public void ValidateMeasure();
    public void ValidateArrange();
    public void ValidateRender();
    public void ValidateHitTest();
    protected virtual void OnChildMeasureChanged(View child);
    protected virtual void OnChildArrangeChanged(View child);
    protected virtual void OnChildRenderChanged(View child);
    protected virtual void OnChildHitTestChanged(View child);
    public void CapturePointer(int pointerId, Xui.Core.UI.Input.IPointerGesture? gesture = null);
    public void ReleasePointer(int pointerId);
    public Xui.Core.UI.Input.IPointerGesture? GetCapturedGesture(int pointerId);
}
public partial class View
{
    public virtual Rect CullingFrame { get; }

    public virtual Point TransformPoint(Point point);
    public virtual Point InverseTransformPoint(Point point);
    public virtual Rect TransformRect(Rect rect);
    public virtual Rect InverseTransformRect(Rect rect);
    public Point LocalToGlobal(Point point);
    public Point GlobalToLocal(Point point);
}
public partial class View
{
    public string? Id { get; set; }

    public ClassNameCollection ClassName;
    public View? Parent { get; }
    public Rect Frame { get; protected set; }
    public Frame Margin { get; set; }
    public HorizontalAlignment HorizontalAlignment { get; set; }
    public VerticalAlignment VerticalAlignment { get; set; }
    public Direction Direction { get; set; }
    public WritingMode WritingMode { get; set; }
    public Flow Flow { get; set; }
    public nfloat MinimumWidth { get; set; }
    public nfloat MinimumHeight { get; set; }
    public nfloat MaximumWidth { get; set; }
    public nfloat MaximumHeight { get; set; }

    public virtual bool HitTest(Point point);
}

void View.AddProtectedChild(View child)

protected void AddProtectedChild(View child);

Attaches a child view to this parent, setting Parent and performing basic validation. Intended for internal use by container views and single-child hosts.

void View.Animate(TimeSpan previousTime, TimeSpan currentTime)

public void Animate(TimeSpan previousTime, TimeSpan currentTime);

Advances animation state for this view and all descendants.

void View.AnimateCore(TimeSpan previousTime, TimeSpan currentTime)

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

Override to animate this view and its children.

void View.AnimateShell(in LayoutFrameContext frame)

protected void AnimateShell(in LayoutFrameContext frame);

Performs bookkeeping and animation for this view.

Rect View.Arrange(Rect rect, IMeasureContext context, Size? desiredSize = null)

public Rect Arrange(Rect rect, IMeasureContext context, Size? desiredSize = null);

Arranges the view within rect, finalising its position and size.

void View.ArrangeCore(Rect rect, IMeasureContext context)

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

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

void View.ArrangeShell(in LayoutFrameContext frame, in ArrangeConstraints constraints, ref LayoutMeasurements measurements)

protected void ArrangeShell(in LayoutFrameContext frame, in ArrangeConstraints constraints, ref LayoutMeasurements measurements);

Arranges this view using the supplied immutable constraints.

void View.Blur()

public void Blur();

Releases keyboard focus from this view.

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

public void CapturePointer(int pointerId, Xui.Core.UI.Input.IPointerGesture? gesture = null);

Captures the pointer with the specified identifier so that it continues to receive pointer events even if the pointer moves outside its bounds.

  • pointerId — The platform-assigned pointer identifier.

  • gesture — Optional marker describing what kind of gesture this view is tracking (e.g. Xui.Core.UI.Input.PointerGestures.Tap for a button, Xui.Core.UI.Input.PointerGestures.Drag for a slider). Ancestor containers (e.g. ScrollView) inspect this via EventRouter.GetCapturedGesture to decide whether they may steal capture.

ClassNameCollection View.ClassName

public ClassNameCollection ClassName;

The set of class names assigned to this view, used for lookup via Xui.Core.UI.ViewExtensions.FindViewsByClass(Xui.Core.UI.View,System.String,System.Collections.Generic.List{Xui.Core.UI.View}).

int View.Count

public virtual int Count { get; }

Returns the number of child views. Used by layout containers and traversal logic. Leaf views should return 0.

Rect View.CullingFrame

public virtual Rect CullingFrame { get; }

Gets this view's conservative bounds in its parent coordinate space for render culling.

A container may override this when its rendered geometry differs from its layout frame. Computing the union of descendant culling frames is deliberately deferred: it can be more expensive than rendering for small subtrees.

Direction View.Direction

public Direction Direction { get; set; }

Gets or sets the writing direction.

ViewFlags View.Flags

public ViewFlags Flags { get; }

Gets the current change flags for this view. These flags indicate which aspects (measure, arrange, render, hit test) have changed since the last time the parent acknowledged them via the corresponding Validate* method.

Flow View.Flow

public Flow Flow { get; set; }

Gets or sets the child flow behavior.

bool View.Focus()

public bool Focus();

Requests keyboard focus for this view.

bool View.Focusable

public virtual bool Focusable { get; }

Gets whether this view can receive keyboard focus via Tab navigation.

Rect View.Frame

public Rect Frame { get; protected set; }

The border edge of this view in global coordinates relative to the top-left of the window.

IPointerGesture? View.GetCapturedGesture(int pointerId)

public Xui.Core.UI.Input.IPointerGesture? GetCapturedGesture(int pointerId);

Returns the gesture marker for the view currently capturing pointerId, or null if the pointer is not captured or was captured without a gesture marker.

object? View.GetService(Type serviceType)

public virtual object? GetService(Type serviceType);

Resolves a service of the given type by walking up the parent chain. Returns null if no ancestor provides the service.

Point View.GlobalToLocal(Point point)

public Point GlobalToLocal(Point point);

Maps a point in root/window coordinate space into this view's local coordinate space.

bool View.HasRenderUpdates

protected bool HasRenderUpdates { get; }

Whether this view or its descendants have graphics updates for the current render. Unlike Flags, this remains available inside RenderCore after the render shell clears the incoming invalidation flags. Suitable for GroupOptions.HasUpdates; the context still decides whether content must be drawn, including on first use or SVG export.

bool View.HitTest(Point point)

public virtual bool HitTest(Point point);

Determines whether the given point (in this view's local coordinates) hits this view's visual bounds. Used for input dispatch and hit testing.

  • point — The point to test, relative to this view's coordinate space.

Returns: true if the point is inside the view's frame; otherwise false.

HorizontalAlignment View.HorizontalAlignment

public HorizontalAlignment HorizontalAlignment { get; set; }

Gets or sets the horizontal alignment within the layout anchor region.

string? View.Id

public string? Id { get; set; }

An optional unique identifier for this view, used for lookup via Xui.Core.UI.ViewExtensions.FindViewById(Xui.Core.UI.View,System.String).

void View.Invalidate()

protected void Invalidate();

Invalidates every phase affected by a change to the view's layout contract. Used by the base layout properties so cached measurements cannot survive a change to constraints, alignment, or spacing.

void View.InvalidateArrange()

protected void InvalidateArrange();

Marks this view as having changed in a way that may cause it to arrange its children differently, even with the same rectangle and context. Causes Xui.Core.UI.View.OnChildArrangeChanged(Xui.Core.UI.View) to be invoked on the parent.

void View.InvalidateHitTest()

protected void InvalidateHitTest();

Marks this view as having changed in a way that may cause hit testing to yield different results, even for the same input coordinates. Causes Xui.Core.UI.View.OnChildHitTestChanged(Xui.Core.UI.View) to be invoked on the parent.

void View.InvalidateMeasure()

public void InvalidateMeasure();

Marks this view as having changed in a way that may affect its measured size. Causes Xui.Core.UI.View.OnChildMeasureChanged(Xui.Core.UI.View) to be invoked on the parent.

void View.InvalidateRender()

public void InvalidateRender();

Marks this view as having changed visually in a way that requires re-rendering. Causes Xui.Core.UI.View.OnChildRenderChanged(Xui.Core.UI.View) to be invoked on the parent.

Point View.InverseTransformPoint(Point point)

public virtual Point InverseTransformPoint(Point point);

Maps a point from this view's local coordinate space into its parent coordinate space.

This must be the inverse of Xui.Core.UI.View.TransformPoint(Xui.Core.Math2D.Point) for points that can be hit tested. It is separate so a view can support coordinate mappings that are not yet represented by the canvas transform API.

Rect View.InverseTransformRect(Rect rect)

public virtual Rect InverseTransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's coordinate space into its parent coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

bool View.IsFocused

public bool IsFocused { get; }

Gets whether this view currently has keyboard focus.

View View.this[int index]

public virtual View this[int index] { get; }

Indexer to access child views by index. Layout containers should implement this to expose their children.

object? View.this[Extra key]

public object? this[Extra key] { get; set; }

Fallback indexer for extras whose value type is not covered by a typed overload (e.g. enums). Values are boxed. Prefer the typed overloads for System.IntPtr, System.Runtime.InteropServices.NFloat, System.String, and System.Boolean where possible.

bool View.this[Extra<bool> key]

public bool this[Extra<bool> key] { get; set; }

Gets or sets a System.Boolean extra on this view.

nint View.this[Extra<nint> key]

public nint this[Extra<nint> key] { get; set; }

Gets or sets an System.IntPtr extra on this view.

NFloat View.this[Extra<NFloat> key]

public nfloat this[Extra<nfloat> key] { get; set; }

Gets or sets an System.Runtime.InteropServices.NFloat extra on this view.

string? View.this[Extra<string?> key]

public string? this[Extra<string?> key] { get; set; }

Gets or sets a System.String extra on this view.

Point View.LocalToGlobal(Point point)

public Point LocalToGlobal(Point point);

Maps a point in this view's local coordinate space into root/window coordinate space.

Frame View.Margin

public Frame Margin { get; set; }

Gets or sets the external spacing around the view.

NFloat View.MaximumHeight

public nfloat MaximumHeight { get; set; }

Gets or sets the maximum border-edge height.

NFloat View.MaximumWidth

public nfloat MaximumWidth { get; set; }

Gets or sets the maximum border-edge width.

Size View.Measure(Size availableSize, IMeasureContext context)

public Size Measure(Size availableSize, IMeasureContext context);

Measures the view and returns the desired margin-box size.

Size View.MeasureCore(Size availableBorderEdgeSize, IMeasureContext context)

protected virtual Size MeasureCore(Size availableBorderEdgeSize, IMeasureContext context);

Override to compute the desired border-edge size.

void View.MeasureShell(in LayoutFrameContext frame, in MeasureConstraints constraints, ref LayoutMeasurements measurements)

protected void MeasureShell(in LayoutFrameContext frame, in MeasureConstraints constraints, ref LayoutMeasurements measurements);

Measures this view using the supplied immutable constraints.

NFloat View.MinimumHeight

public nfloat MinimumHeight { get; set; }

Gets or sets the minimum border-edge height.

NFloat View.MinimumWidth

public nfloat MinimumWidth { get; set; }

Gets or sets the minimum border-edge width.

void View.OnActivate()

protected virtual void OnActivate();

Called when this view becomes active — it will receive events, render, and animate. Override this to start animations, subscribe to data sources, or acquire resources.

void View.OnAttach(ref AttachEventRef e)

protected virtual void OnAttach(ref AttachEventRef e);

Called when this view is added to the visual tree and platform contexts become available. Override to acquire resources that depend on text measurement or bitmap factories.

void View.OnBlur()

protected internal virtual void OnBlur();

Called when this view loses keyboard focus.

void View.OnChar(ref KeyEventRef e)

public virtual void OnChar(ref KeyEventRef e);

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

void View.OnChildArrangeChanged(View child)

protected virtual void OnChildArrangeChanged(View child);

Called when a direct or indirect child view has changed in a way that may affect its arrangement of children. The default implementation forwards the notification up the visual tree to the parent.

  • child — The child view whose arrange state has changed.

void View.OnChildHitTestChanged(View child)

protected virtual void OnChildHitTestChanged(View child);

Called when a direct or indirect child view has changed in a way that may cause hit testing results to change. The default implementation forwards the notification up the visual tree to the parent.

  • child — The child view whose hit testing state has changed.

void View.OnChildMeasureChanged(View child)

protected virtual void OnChildMeasureChanged(View child);

Called when a direct or indirect child view has changed in a way that may affect its measured size. The default implementation forwards the notification up the visual tree to the parent.

  • child — The child view whose measure state has changed.

void View.OnChildRenderChanged(View child)

protected virtual void OnChildRenderChanged(View child);

Called when a direct or indirect child view has changed visually and requires re-rendering. The default implementation forwards the notification up the visual tree.

  • child — The child view whose render state has changed.

void View.OnChildRequestedAnimationFrame(View child)

protected virtual void OnChildRequestedAnimationFrame(View child);

Called when a direct or indirect child has requested another animation frame for the next UI tick. The default implementation marks Xui.Core.UI.View.ViewFlags.DescendantAnimated and forwards the notification up the visual tree.

  • child — The child view that requested the animation frame.

void View.OnDeactivate()

protected virtual void OnDeactivate();

Called when this view becomes dormant — it should stop animations, timers, and event subscriptions. The view may remain in the tree (e.g., in a virtualizing panel's recycle pool).

void View.OnDetach(ref DetachEventRef e)

protected virtual void OnDetach(ref DetachEventRef e);

Called when this view is removed from the visual tree. Override to release any resources acquired in Xui.Core.UI.View.OnAttach(Xui.Core.UI.AttachEventRef@).

void View.OnFocus()

protected internal virtual void OnFocus();

Called when this view receives keyboard focus.

void View.OnKeyDown(ref KeyEventRef e)

public virtual void OnKeyDown(ref KeyEventRef e);

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

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

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

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

void View.OnScrollWheel(ref ScrollWheelEventRef e)

public virtual void OnScrollWheel(ref ScrollWheelEventRef e);

Called when a scroll wheel or trackpad scroll event is dispatched to this view. Override to handle scroll input. Set Xui.Core.Abstract.Events.ScrollWheelEventRef.Handled to stop propagation.

void View.OnZoom(ref ZoomEventRef e)

public virtual void OnZoom(ref ZoomEventRef e);

Handles a platform magnification gesture. Set Handled to stop bubbling.

View? View.Parent

public View? Parent { get; }

The parent view in the visual hierarchy. This is set automatically when the view is added to a container.

void View.ReleasePointer(int pointerId)

public void ReleasePointer(int pointerId);

Releases a previously captured pointer so that pointer events are routed according to normal hit testing rules.

  • pointerId — The platform-assigned pointer identifier.

void View.RemoveProtectedChild(View child)

protected void RemoveProtectedChild(View child);

Detaches a child view from this parent, clearing Parent. Intended for internal use by container views and single-child hosts.

void View.Render(IContext context)

public void Render(IContext context);

Renders the view. Must be called after layout is complete.

void View.RenderChild(IContext context, View child)

protected internal void RenderChild(IContext context, View child);

Renders a child while preserving this view's active culling rectangle.

void View.RenderChild(IContext context, View child, Rect cullingFrame)

protected internal void RenderChild(IContext context, View child, Rect cullingFrame);

Renders a child using an explicit culling rectangle in this view's coordinate space.

void View.RenderCore(IContext context)

protected virtual void RenderCore(IContext context);

Override to render this view and its children.

Rect? View.RenderCullingFrame

protected Rect? RenderCullingFrame { get; }

The active render culling rectangle in this view's coordinate space, if any.

void View.RenderShell(in LayoutFrameContext frame, Rect? parentCullingFrame = null)

protected void RenderShell(in LayoutFrameContext frame, Rect? parentCullingFrame = null);

Performs bookkeeping and renders this view.

void View.RequestAnimationFrame()

public void RequestAnimationFrame();

Requests another animation frame for this view on the next UI tick. Sets Xui.Core.UI.View.ViewFlags.Animated and notifies ancestors (via Xui.Core.UI.View.OnChildRequestedAnimationFrame(Xui.Core.UI.View)) so they carry Xui.Core.UI.View.ViewFlags.DescendantAnimated.

bool View.RequiresKeyboard

public virtual bool RequiresKeyboard { get; }

Whether focusing this view requests the platform's software keyboard.

bool View.RequiresRender(IContext context)

public bool RequiresRender(Xui.Core.Canvas.IContext context);

Whether graphics changed, or this view last rendered into a different context.

Use when declaring a retained child surface before calling the child's Render method.

void View.SetDefaultRenderState(IContext context)

protected virtual void SetDefaultRenderState(IContext context);

Applies the drawing defaults used at the start of every view render. The active transform and clip are intentionally inherited from the parent.

void View.SetProtectedChild<T>(ref T? field, T? value)

protected void SetProtectedChild<T>(ref T? field, T? value)
    where T : View;

Sets a single protected child field, automatically detaching the old child (if any) and attaching the new child (if any). Use this for single-child containers.

bool View.SetViewProperty<T>(ref T field, T value)

protected bool SetViewProperty<T>(ref T field, T value);

Assigns a layout-affecting property when its value changes, then invalidates the view's measure, arrange, and render state.

Returns: true when field changed.

bool View.SetViewRenderProperty<T>(ref T field, T value)

protected bool SetViewRenderProperty<T>(ref T field, T value);

Assigns a render-only property when its value changes.

Returns: true when field changed.

Point View.TransformPoint(Point point)

public virtual Point TransformPoint(Point point);

Maps a point from this view's parent coordinate space into this view's local coordinate space.

Layout still supplies frames using the existing coordinate model. The default identity mapping deliberately preserves that behaviour until a container opts into a local coordinate transform. Containers such as Xui.Core.UI.ScrollView can override this to map input into their content space.

Rect View.TransformRect(Rect rect)

public virtual Rect TransformRect(Rect rect);

Conservatively maps an axis-aligned rectangle from this view's parent coordinate space into this view's coordinate space.

For non-translation transforms, an override must return the smallest parent-axis-aligned rectangle that encloses every transformed corner.

void View.Update(in LayoutFrameContext frame, in LayoutUpdate update, ref LayoutMeasurements measurements)

public virtual void Update(in LayoutFrameContext frame, in LayoutUpdate update, ref LayoutMeasurements measurements);

Drives the requested passes using shared frame state and per-view constraints.

void View.ValidateArrange()

public void ValidateArrange();

Clears the Xui.Core.UI.View.ViewFlags.ArrangeChanged flag on this view, indicating that a parent or container has acknowledged the child’s arrange change.

void View.ValidateHitTest()

public void ValidateHitTest();

Clears the Xui.Core.UI.View.ViewFlags.HitTestChanged flag on this view, indicating that hit-test caches (if any) have been updated or the parent has otherwise accounted for the changed hit-test behavior.

void View.ValidateMeasure()

public void ValidateMeasure();

Clears the Xui.Core.UI.View.ViewFlags.MeasureChanged flag on this view, indicating that a parent or container has acknowledged the child’s measure change and handled it (e.g., decided to keep the same column width in a grid regardless of the child’s new desired size). Use this when the parent has considered the change and no re-measure is required for this child.

void View.ValidateRender()

public void ValidateRender();

Clears the Xui.Core.UI.View.ViewFlags.RenderChanged flag on this view, indicating that the parent (or the rendering pipeline) has acknowledged the visual change and re-rendering for this view has been completed.

VerticalAlignment View.VerticalAlignment

public VerticalAlignment VerticalAlignment { get; set; }

Gets or sets the vertical alignment within the layout anchor region.

WritingMode View.WritingMode

public WritingMode WritingMode { get; set; }

Gets or sets the writing mode.

class View.Extra

Non-generic base for Xui.Core.UI.View.Extra1`. Used as a dictionary key when storage is implemented.

public abstract class Extra
{
}

class View.Extra<T>

A typed key for attaching extra layout or styling data to any Xui.Core.UI.View. Declare one static instance per logical property (e.g. Grid.Row, FlexBox.Grow) and use it with the view indexer: view[Grid.Row] = 2.

  • T — The type of the value stored under this key.
public sealed class Extra<T> : Extra
{
    public T DefaultValue { get; }

    public Extra(T defaultValue = default !);
    public T Get(View view);
}

Extra<T>.Extra(T defaultValue = default(T))

public Extra(T defaultValue = default !);
  • defaultValue — Returned by the indexer getter until a value is explicitly set.

T Extra<T>.DefaultValue

public T DefaultValue { get; }

The value returned when no data has been stored for this key on a given view.

T Extra<T>.Get(View view)

public T Get(View view);

Returns the value stored for this key on view, or Xui.Core.UI.View.Extra1.DefaultValue` if nothing has been set.

enum View.ViewFlags

Flags used internally by a Xui.Core.UI.View to track invalidation state across measure, arrangement, rendering, and hit testing phases. These flags allow the framework to selectively recompute only dirty subtrees during recursive passes.

[Flags]
public enum ViewFlags
{
    Animated = 1 << 0,
    DescendantAnimated = 1 << 1,
    MeasureChanged = 1 << 2,
    ArrangeChanged = 1 << 3,
    DescendantArrangeChanged = 1 << 4,
    RenderChanged = 1 << 5,
    DescendantRenderChanged = 1 << 6,
    HitTestChanged = 1 << 7,
    DescendantHitTestChanged = 1 << 8,
    Active = 1 << 9,
    Attached = 1 << 10,
}

ViewFlags.Active

Active = 1 << 9

This view is active — it is part of a live visual tree and will receive events, render, and animate. Set by Xui.Core.UI.View.ActivateSubtree(Xui.Core.UI.View) and cleared by Xui.Core.UI.View.DeactivateSubtree(Xui.Core.UI.View).

ViewFlags.Animated

Animated = 1 << 0

This view is animated. It has properties that are calculated based on the current UI time. It requires an animation notification on the next frame.

ViewFlags.ArrangeChanged

ArrangeChanged = 1 << 3

The Xui.Core.UI.View has changed in a way that may cause it to arrange its children differently, even if the available rectangle and measure context are the same.

ViewFlags.Attached

Attached = 1 << 10

This view is attached — it has been added to a visual tree that is itself attached to the platform (e.g. a window). Set by Xui.Core.UI.View.AttachSubtree(Xui.Core.UI.View,Xui.Core.UI.AttachEventRef@) and cleared by Xui.Core.UI.View.DetachSubtree(Xui.Core.UI.View,Xui.Core.UI.DetachEventRef@).

ViewFlags.DescendantAnimated

DescendantAnimated = 1 << 1

This view has animated children. While this view directly does not depend on the next frame time, it must propagate an animation notification to its animated children.

ViewFlags.DescendantArrangeChanged

DescendantArrangeChanged = 1 << 4

One or more descendants of this Xui.Core.UI.View have had their Xui.Core.UI.View.ViewFlags.ArrangeChanged flag set since the last validation. This flag does not indicate that this view itself needs re-arranging, but rather that some descendant may need to be re-arranged with its existing rectangle (e.g., a visual state change that affects only internal layout).

ViewFlags.DescendantHitTestChanged

DescendantHitTestChanged = 1 << 8

One or more descendants of this Xui.Core.UI.View have their hit testing changed. They will probably return a new result for the same Xui.Core.Math2D.Point.

ViewFlags.DescendantRenderChanged

DescendantRenderChanged = 1 << 6

One or more descendants of this Xui.Core.UI.View have had their Xui.Core.UI.View.ViewFlags.RenderChanged flag set since the last validation. This is a hint that rendering work exists below, even if this view itself does not need re-rendering.

ViewFlags.HitTestChanged

HitTestChanged = 1 << 7

This view's Xui.Core.UI.View.HitTest(Xui.Core.Math2D.Point) changed. It will probably return a new results for the same Xui.Core.Math2D.Point.

ViewFlags.MeasureChanged

MeasureChanged = 1 << 2

The Xui.Core.UI.View has changed since its last measure. It will likely return a different desired size if measured again with the same constraints.

ViewFlags.RenderChanged

RenderChanged = 1 << 5

The Xui.Core.UI.View has changed visually since its last render pass, and Xui.Core.UI.View.RenderCore(Xui.Core.Canvas.IContext) produce different output even if rendered within the same frame and context.

class ViewCollection

A base class for container views that hold and manage a list of child views. Provides methods for adding, removing, rendering, and hit testing children.

public class ViewCollection : View
{
    protected readonly List<View> children;
    public override int Count { get; }

    public override View this[int index] { get; }

    public ReadOnlySpan<View> Content { init; }

    public virtual void Add(View child);
    public virtual void Remove(View child);
    public virtual void Clear();
}

void ViewCollection.Add(View child)

public virtual void Add(View child);

Adds a view to this container.

Throws Thrown if the view already has a parent.: Thrown if the view already has a parent.

void ViewCollection.Clear()

public virtual void Clear();

Removes all child views from this container.

ReadOnlySpan<View> ViewCollection.Content

public ReadOnlySpan<View> Content { init; }

Adds the provided views to this container during object initialization. This property is intended for use with C# object initializers and will not clear existing children.

int ViewCollection.Count

public override int Count { get; }

Gets the number of child views in this collection.

View ViewCollection.this[int index]

public override View this[int index] { get; }

Gets the child view at the specified index.

void ViewCollection.Remove(View child)

public virtual void Remove(View child);

Removes a view from this container.

List<View> ViewCollection.children

protected readonly List<View> children;

The internal list of child views contained within this view.

class ViewExtensions

Provides extension methods for navigating the Xui view tree.

public static class ViewExtensions
{
    public static ParentsEnumerable Parents(this View view);
    public static bool TryFindParent<T>(this View view, [NotNullWhen(true)] out T? result)
        where T : View;
    public static View? FindViewById(this View root, string id);
    public static void FindViewsByClass(this View root, string className, List<View> results);
    public readonly ref struct ParentsEnumerable
    {
        public ParentsEnumerable(View? start);
        public Enumerator GetEnumerator();
        public ref struct Enumerator
        {
            public Enumerator(View? start);
            public View Current { get; }

            public bool MoveNext();
        }
    }
}

View? ViewExtensions.FindViewById(View root, string id)

public static View? FindViewById(this View root, string id);

Performs a depth-first search of the view subtree (including root itself) and returns the first view whose Xui.Core.UI.View.Id matches id.

Returns: The matching view, or null if not found.

void ViewExtensions.FindViewsByClass(View root, string className, List<View> results)

public static void FindViewsByClass(this View root, string className, List<View> results);

Performs a depth-first search of the view subtree (including root itself) and collects all views whose Xui.Core.UI.View.ClassName contains className.

ParentsEnumerable ViewExtensions.Parents(View view)

public static ParentsEnumerable Parents(this View view);

Returns an allocation-free enumerable that walks up the parent chain of a view.

  • view — The view whose parent chain should be traversed.

Returns: An enumerable of the view's parents, from immediate to root.

bool ViewExtensions.TryFindParent<T>(View view, out T? result)

public static bool TryFindParent<T>(this View view, [NotNullWhen(true)] out T? result)
    where T : View;

Attempts to find the first parent of a specific type in the view tree. Zero allocations. Returns true if a matching parent was found.

  • T — The type of view to search for.

  • view — The view whose parent chain will be searched.

  • result — The found parent of type T, or null if not found.

Returns: True if a matching parent was found; otherwise, false.

readonly ref struct ViewExtensions.ParentsEnumerable

Allocation-free enumerable for walking up the parent chain of a view.

public readonly ref struct ParentsEnumerable
{
    public ParentsEnumerable(View? start);
    public Enumerator GetEnumerator();
    public ref struct Enumerator
    {
        public Enumerator(View? start);
        public View Current { get; }

        public bool MoveNext();
    }
}

ParentsEnumerable.ParentsEnumerable(View? start)

public ParentsEnumerable(View? start);

Creates a new Xui.Core.UI.ViewExtensions.ParentsEnumerable starting from the given view.

  • start — The starting view.

Enumerator ParentsEnumerable.GetEnumerator()

public Enumerator GetEnumerator();

Returns an enumerator that iterates over the view's parents.

ref struct ViewExtensions.ParentsEnumerable.Enumerator

Enumerator for Xui.Core.UI.ViewExtensions.ParentsEnumerable, walking up the view hierarchy.

public ref struct Enumerator
{
    public Enumerator(View? start);
    public View Current { get; }

    public bool MoveNext();
}

Enumerator.Enumerator(View? start)

public Enumerator(View? start);

Initializes a new instance of the Xui.Core.UI.ViewExtensions.ParentsEnumerable.Enumerator struct.

  • start — The starting view for traversal.

View Enumerator.Current

public View Current { get; }

Gets the current parent view in the traversal.

bool Enumerator.MoveNext()

public bool MoveNext();

Moves to the next parent view.

Returns: True if there is a next parent; otherwise, false.

enum WritingMode

Specifies the orientation and flow direction of text and block layout. Affects which axis is considered "block" and "inline".

public enum WritingMode : byte
{
    Inherit,
    HorizontalTB,
    VerticalRL,
    VerticalLR,
    SidewaysRL,
    SidewaysLR
}

WritingMode.HorizontalTB

HorizontalTB

Horizontal writing mode. Text flows left-to-right, lines stack top-to-bottom.

WritingMode.Inherit

Inherit

Inherit direction from the parent view.

WritingMode.SidewaysLR

SidewaysLR

Sideways vertical mode. Lines stack left-to-right, with horizontal glyph orientation.

WritingMode.SidewaysRL

SidewaysRL

Sideways vertical mode. Lines stack right-to-left, but glyphs are rotated to remain horizontal.

WritingMode.VerticalLR

VerticalLR

Vertical writing mode. Lines stack left-to-right, text flows top-to-bottom.

WritingMode.VerticalRL

VerticalRL

Vertical writing mode. Lines stack right-to-left, text flows top-to-bottom.