public readonly record struct LengthContextWhat a relative length is relative to.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is the context Vixen.Ui.Styling deliberately does not have. The cascade decides which declaration wins without knowing what any of it measures, and that separation is what lets a stylesheet be resolved once and applied to two surfaces of different sizes.
Everything here is in device-independent pixels. DPI scaling is applied at the far end, when the draw list becomes geometry, so a stylesheet is not re-resolved because a window moved to another monitor.
Fields and properties (5)
public float FontSizeThe element's own computed font size, in pixels. What em means — except on font-size itself, where em means the parent's and this must therefore be the parent's too.
public float RootFontSizeThe root element's computed font size. What rem means.
public float ViewportWidthThe surface's width in pixels. A hundredth of it is 1vw.
public float ViewportHeightThe surface's height. A hundredth of it is 1vh.
public const float InitialFontSizeCSS's initial font size, which is what a document with no font-size gets.
Methods (5)
public LengthContext(float FontSize, float RootFontSize, float ViewportWidth, float ViewportHeight)What a relative length is relative to.
public static LengthContext ForViewport(float width, float height, float rootFontSize = 16)A context for a surface, before any element's own font size is known.
public LengthContext WithFontSize(float fontSize)The same context with a different font size.
public float PixelsPer(StyleUnit unit)How many pixels one of a unit is worth.
public StyleLength ToLength(StyleValue value)Turns a parsed value into a length layout can use.
Used by (12)
- BridgeFixtureVixen.Ui.Tests
- ContextMenuVixen.Ui.Controls
- DrawListBuilderVixen.Ui
- LayoutStyleBridgeTestsVixen.Ui.Tests
- LayoutStyleBuilderVixen.Ui
- OverlayVixen.Ui.Controls
- UiDocumentVixen.Ui
- UiElementVixen.Ui
- UiSurfaceVixen.Ui
- UiTestVixen.Ui.Testing
- AddComponentMenuTestsVixen.Editor.App.Tests
- CommandPaletteVixen.Editor.Ui