API reference
Struct UiContext
Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets
What widgets measure and draw with: the root’s font and theme, the layout unit and the root’s clock.
public readonly struct UiContext : IEquatable<UiContext>Implements
Constructors
UiContext(IFont, UiTheme, float, float)
What widgets measure and draw with: the root’s font and theme, the layout unit and the root’s clock.
public UiContext(IFont Font, UiTheme Theme, float Unit, float Time)Parameters
Font IFont
The font of every widget’s text.
Theme UiTheme
The colours.
Unit float
The layout unit in UI units: 1 for the built-in 10-pixel pixel font, proportionally more for a larger font, so margins grow with the text. Widgets express their padding and spacing in it.
Time float
Seconds the root has been updated, for blinking carets and other animation.
Properties
Clip
The area drawing is restricted to (UI units), or null for none: set by containers that clip their children.
public RectF? Clip { get; init; }Property Value
Font
The font of every widget’s text.
public IFont Font { get; init; }Property Value
Opacity
How opaque drawing is, 0..1 (1 by default): the product of the Opacity of the widget drawn and every widget around it. Theme is already faded by it; colours of a widget’s own go through Fade.
public float Opacity { get; init; }Property Value
Theme
The colours.
public UiTheme Theme { get; init; }Property Value
Time
Seconds the root has been updated, for blinking carets and other animation.
public float Time { get; init; }Property Value
Unit
The layout unit in UI units: 1 for the built-in 10-pixel pixel font, proportionally more for a larger font, so margins grow with the text. Widgets express their padding and spacing in it.
public float Unit { get; init; }Property Value
Methods
ClipTo(IRenderer, RectF, out UiContext)
Restricts drawing to area within the current Clip, until the result is disposed,
which restores the current clip. Draw with inner, which carries the new clip, so a clip set
further down nests inside this one. Use it instead of SetClip, which cannot nest.
public UiClip ClipTo(IRenderer renderer, RectF area, out UiContext inner)Parameters
renderer IRenderer
area RectF
inner UiContext
Returns
Examples
using (context.ClipTo(renderer, Bounds, out var inner)) content.Draw(renderer, inner);Deconstruct(out IFont, out UiTheme, out float, out float)
public void Deconstruct(out IFont Font, out UiTheme Theme, out float Unit, out float Time)Parameters
Font IFont
Theme UiTheme
Unit float
Time float
Equals(object)
public override bool Equals(object obj)Parameters
obj object
Returns
Equals(UiContext)
public bool Equals(UiContext other)Parameters
other UiContext
Returns
Fade(Color)
color at this context’s Opacity.
public Color Fade(Color color)Parameters
color Color
Returns
Fade(PanelStyle)
style at this context’s Opacity.
public PanelStyle Fade(PanelStyle style)Parameters
style PanelStyle
Returns
Faded(float)
This context with drawing opacity times as opaque, the theme faded with it.
public UiContext Faded(float opacity)Parameters
opacity float
Returns
GetHashCode()
public override int GetHashCode()Returns
ToString()
public override string ToString()Returns
Operators
operator ==(UiContext, UiContext)
public static bool operator ==(UiContext left, UiContext right)Parameters
left UiContext
right UiContext
Returns
operator !=(UiContext, UiContext)
public static bool operator !=(UiContext left, UiContext right)Parameters
left UiContext
right UiContext