Class UIContext

Namespace
Forma
Assembly
Forma.dll

Owns a UI tree's input state, focus and rendering. Add it to a Game's update/draw loop, or use UIComponent for the usual game component integration.

public sealed class UIContext : IDisposable
Inheritance
UIContext
Implements
Inherited Members

Constructors

UIContext()

public UIContext()

Properties

ApplicationCulture

Application locale used by controls with ApplicationLocale.

public CultureInfo ApplicationCulture { get; set; }

Property Value

CultureInfo

Clipboard

Clipboard capability used by copy, cut, and paste commands in retained text controls.

public IClipboard Clipboard { get; set; }

Property Value

IClipboard

CurrentKeyboardState

Keyboard state for the input frame currently being dispatched, including modifier keys used by controls such as Tree.

public KeyboardState CurrentKeyboardState { get; }

Property Value

KeyboardState

CurrentTime

Game time for the input frame currently being dispatched, used by retained multi-click gestures.

public TimeSpan CurrentTime { get; }

Property Value

TimeSpan

DisplayFontResolver

Optionally resolves a denser font atlas for the supplied logical font and display scale.

public Func<SpriteFont, float, SpriteFont> DisplayFontResolver { get; set; }

Property Value

Func<SpriteFont, float, SpriteFont>

DisplayScale

Physical display pixels per logical UI coordinate. Input is mapped back to logical coordinates and drawing is scaled to physical pixels.

public float DisplayScale { get; set; }

Property Value

float

DragData

Payload supplied by the active retained drag source, or null when not dragging.

public object DragData { get; }

Property Value

object

DynamicGlyphDiagnostics

Read-only diagnostics for this context's device-scoped dynamic glyph cache.

public DynamicGlyphCacheDiagnostics DynamicGlyphDiagnostics { get; }

Property Value

DynamicGlyphCacheDiagnostics

FocusedControl

public Control FocusedControl { get; }

Property Value

Control

InputModality

public InputModality InputModality { get; set; }

Property Value

InputModality

IsDragging

Whether a retained drag-and-drop operation is currently active.

public bool IsDragging { get; }

Property Value

bool

IsTooltipVisible

public bool IsTooltipVisible { get; }

Property Value

bool

PointerPosition

Most recently dispatched pointer position, available to retained controls that coordinate transient surfaces.

public Point PointerPosition { get; }

Property Value

Point

Resources

public ResourceDictionary Resources { get; }

Property Value

ResourceDictionary

RootLayoutDirection

Fallback layout direction for root controls whose direction is inherited.

public LayoutDirection RootLayoutDirection { get; set; }

Property Value

LayoutDirection

Roots

public IReadOnlyList<Control> Roots { get; }

Property Value

IReadOnlyList<Control>

SvgRasterDiagnostics

Read-only diagnostics for this context's device-scoped SVG raster cache.

public SvgRasterCacheDiagnostics SvgRasterDiagnostics { get; }

Property Value

SvgRasterCacheDiagnostics

SystemCulture

System locale used by controls with SystemLocale.

public CultureInfo SystemCulture { get; set; }

Property Value

CultureInfo

TextLayoutEngine

public TextLayoutEngine TextLayoutEngine { get; }

Property Value

TextLayoutEngine

Theme

public Theme Theme { get; set; }

Property Value

Theme

ThemeIconDiagnostics

Current default icon-atlas resource and lookup counters.

public ThemeIconDiagnostics ThemeIconDiagnostics { get; }

Property Value

ThemeIconDiagnostics

ThemeIconRenderingPolicy

public ThemeIconRenderingPolicy ThemeIconRenderingPolicy { get; set; }

Property Value

ThemeIconRenderingPolicy

ThemeVariant

public ThemeVariant ThemeVariant { get; set; }

Property Value

ThemeVariant

TooltipDelay

Delay before hover help becomes visible. Defaults to Godot-like delayed presentation.

public TimeSpan TooltipDelay { get; set; }

Property Value

TimeSpan

TooltipFont

Font used when drawing tooltip text. Assign the same font used by the application UI.

public SpriteFont TooltipFont { get; set; }

Property Value

SpriteFont

TooltipOffset

public Vector2 TooltipOffset { get; set; }

Property Value

Vector2

TooltipOwner

public Control TooltipOwner { get; }

Property Value

Control

TooltipPadding

public Thickness TooltipPadding { get; set; }

Property Value

Thickness

TooltipText

public string TooltipText { get; }

Property Value

string

TooltipUIFont

public UIFont TooltipUIFont { get; set; }

Property Value

UIFont

TouchscreenAvailable

Whether retained touch-style interactions should be enabled for pointer input.

public bool TouchscreenAvailable { get; set; }

Property Value

bool

ViewportSize

public Vector2 ViewportSize { get; set; }

Property Value

Vector2

Methods

Add(Control)

public void Add(Control control)

Parameters

control Control

ClearDynamicGlyphCache()

Clears device-scoped dynamic glyph pages between draw calls. Cumulative counters remain available.

public void ClearDynamicGlyphCache()

ClearSvgRasterCache()

Clears device-scoped SVG documents, rasters, and pages between draw calls.

public void ClearSvgRasterCache()

Dispose()

public void Dispose()

Draw(GraphicsDevice)

public void Draw(GraphicsDevice graphicsDevice)

Parameters

graphicsDevice GraphicsDevice

GetDynamicGlyphAtlasPages()

Returns immutable grayscale snapshots of currently allocated glyph-atlas pages.

public IReadOnlyList<DynamicGlyphAtlasPageSnapshot> GetDynamicGlyphAtlasPages()

Returns

IReadOnlyList<DynamicGlyphAtlasPageSnapshot>

GetSvgRasterAtlasPages()

Returns immutable RGBA snapshots of currently allocated SVG-atlas pages.

public IReadOnlyList<SvgRasterAtlasPageSnapshot> GetSvgRasterAtlasPages()

Returns

IReadOnlyList<SvgRasterAtlasPageSnapshot>

HitTest(Point)

public Control HitTest(Point point)

Parameters

point Point

Returns

Control

Layout()

public void Layout()

PrewarmSvg(SvgImageSource, Vector2)

Queues an SVG raster variant for creation before the next UI draw.

public void PrewarmSvg(SvgImageSource source, Vector2 logicalSize)

Parameters

source SvgImageSource
logicalSize Vector2

RegisterFrameBoundaryCallback(Action<GameTime>)

public IDisposable RegisterFrameBoundaryCallback(Action<GameTime> callback)

Parameters

callback Action<GameTime>

Returns

IDisposable

Remove(Control)

public bool Remove(Control control)

Parameters

control Control

Returns

bool

SetFocus(Control)

public void SetFocus(Control control)

Parameters

control Control

TextComposition(string, int, int)

Forwards platform IME preedit text and its selected range to the focused control.

public void TextComposition(string text, int selectionStart = 0, int selectionLength = 0)

Parameters

text string
selectionStart int
selectionLength int

TextInput(char)

Forwards one platform text-input character to the focused retained control.

public void TextInput(char character)

Parameters

character char

Update(GameTime)

public void Update(GameTime gameTime)

Parameters

gameTime GameTime

Update(GameTime, MouseState, KeyboardState)

Updates the tree from supplied states; this overload makes UI input deterministic in tests.

public void Update(GameTime gameTime, MouseState mouse, KeyboardState keyboard)

Parameters

gameTime GameTime
mouse MouseState
keyboard KeyboardState

Events

AdaptiveEnvironmentChanged

public event EventHandler AdaptiveEnvironmentChanged

Event Type

EventHandler