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
Clipboard
Clipboard capability used by copy, cut, and paste commands in retained text controls.
public IClipboard Clipboard { get; set; }
Property Value
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
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
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
DragData
Payload supplied by the active retained drag source, or null when not dragging.
public object DragData { get; }
Property Value
DynamicGlyphDiagnostics
Read-only diagnostics for this context's device-scoped dynamic glyph cache.
public DynamicGlyphCacheDiagnostics DynamicGlyphDiagnostics { get; }
Property Value
FocusedControl
public Control FocusedControl { get; }
Property Value
InputModality
public InputModality InputModality { get; set; }
Property Value
IsDragging
Whether a retained drag-and-drop operation is currently active.
public bool IsDragging { get; }
Property Value
IsTooltipVisible
public bool IsTooltipVisible { get; }
Property Value
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
RootLayoutDirection
Fallback layout direction for root controls whose direction is inherited.
public LayoutDirection RootLayoutDirection { get; set; }
Property Value
Roots
public IReadOnlyList<Control> Roots { get; }
Property Value
SvgRasterDiagnostics
Read-only diagnostics for this context's device-scoped SVG raster cache.
public SvgRasterCacheDiagnostics SvgRasterDiagnostics { get; }
Property Value
SystemCulture
System locale used by controls with SystemLocale.
public CultureInfo SystemCulture { get; set; }
Property Value
TextLayoutEngine
public TextLayoutEngine TextLayoutEngine { get; }
Property Value
Theme
public Theme Theme { get; set; }
Property Value
ThemeIconDiagnostics
Current default icon-atlas resource and lookup counters.
public ThemeIconDiagnostics ThemeIconDiagnostics { get; }
Property Value
ThemeIconRenderingPolicy
public ThemeIconRenderingPolicy ThemeIconRenderingPolicy { get; set; }
Property Value
ThemeVariant
public ThemeVariant ThemeVariant { get; set; }
Property Value
TooltipDelay
Delay before hover help becomes visible. Defaults to Godot-like delayed presentation.
public TimeSpan TooltipDelay { get; set; }
Property Value
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
TooltipPadding
public Thickness TooltipPadding { get; set; }
Property Value
TooltipText
public string TooltipText { get; }
Property Value
TooltipUIFont
public UIFont TooltipUIFont { get; set; }
Property Value
TouchscreenAvailable
Whether retained touch-style interactions should be enabled for pointer input.
public bool TouchscreenAvailable { get; set; }
Property Value
ViewportSize
public Vector2 ViewportSize { get; set; }
Property Value
- Vector2
Methods
Add(Control)
public void Add(Control control)
Parameters
controlControl
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
graphicsDeviceGraphicsDevice
GetDynamicGlyphAtlasPages()
Returns immutable grayscale snapshots of currently allocated glyph-atlas pages.
public IReadOnlyList<DynamicGlyphAtlasPageSnapshot> GetDynamicGlyphAtlasPages()
Returns
GetSvgRasterAtlasPages()
Returns immutable RGBA snapshots of currently allocated SVG-atlas pages.
public IReadOnlyList<SvgRasterAtlasPageSnapshot> GetSvgRasterAtlasPages()
Returns
HitTest(Point)
public Control HitTest(Point point)
Parameters
pointPoint
Returns
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
sourceSvgImageSourcelogicalSizeVector2
RegisterFrameBoundaryCallback(Action<GameTime>)
public IDisposable RegisterFrameBoundaryCallback(Action<GameTime> callback)
Parameters
callbackAction<GameTime>
Returns
Remove(Control)
public bool Remove(Control control)
Parameters
controlControl
Returns
SetFocus(Control)
public void SetFocus(Control control)
Parameters
controlControl
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
TextInput(char)
Forwards one platform text-input character to the focused retained control.
public void TextInput(char character)
Parameters
characterchar
Update(GameTime)
public void Update(GameTime gameTime)
Parameters
gameTimeGameTime
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
gameTimeGameTimemouseMouseStatekeyboardKeyboardState
Events
AdaptiveEnvironmentChanged
public event EventHandler AdaptiveEnvironmentChanged