Skip to content

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.

C#
public readonly struct UiContext : IEquatable<UiContext>

Implements

IEquatable<UiContext>

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.

C#
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.

C#
public RectF? Clip { get; init; }

Property Value

RectF?

Font

The font of every widget’s text.

C#
public IFont Font { get; init; }

Property Value

IFont

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.

C#
public float Opacity { get; init; }

Property Value

float

Theme

The colours.

C#
public UiTheme Theme { get; init; }

Property Value

UiTheme

Time

Seconds the root has been updated, for blinking carets and other animation.

C#
public float Time { get; init; }

Property Value

float

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.

C#
public float Unit { get; init; }

Property Value

float

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.

C#
public UiClip ClipTo(IRenderer renderer, RectF area, out UiContext inner)

Parameters

renderer IRenderer

area RectF

inner UiContext

Returns

UiClip

Examples

C#
using (context.ClipTo(renderer, Bounds, out var inner)) content.Draw(renderer, inner);

Deconstruct(out IFont, out UiTheme, out float, out float)

C#
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)

C#
public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(UiContext)

C#
public bool Equals(UiContext other)

Parameters

other UiContext

Returns

bool

Fade(Color)

color at this context’s Opacity.

C#
public Color Fade(Color color)

Parameters

color Color

Returns

Color

Fade(PanelStyle)

style at this context’s Opacity.

C#
public PanelStyle Fade(PanelStyle style)

Parameters

style PanelStyle

Returns

PanelStyle

Faded(float)

This context with drawing opacity times as opaque, the theme faded with it.

C#
public UiContext Faded(float opacity)

Parameters

opacity float

Returns

UiContext

GetHashCode()

C#
public override int GetHashCode()

Returns

int

ToString()

C#
public override string ToString()

Returns

string

Operators

operator ==(UiContext, UiContext)

C#
public static bool operator ==(UiContext left, UiContext right)

Parameters

left UiContext

right UiContext

Returns

bool

operator !=(UiContext, UiContext)

C#
public static bool operator !=(UiContext left, UiContext right)

Parameters

left UiContext

right UiContext

Returns

bool