Vixen
02b45cc4
csharp
public readonly struct StyleLength

A length as it was written: a number and what kind of number it is.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Eight bytes, and there are around fifty of them per node, which is most of what a style costs. Keeping the unit here rather than in a parallel array is deliberate: every read of a length reads both halves, and splitting them would double the cache lines a layout pass touches for no gain.

Fields and properties (7)

  • public static readonly StyleLength Undefined

    Nothing was set.

  • public static readonly StyleLength Auto

    The algorithm decides.

  • public static readonly StyleLength Zero

    Zero points.

  • public readonly float Value

    The number. Meaningless unless Unit says otherwise.

  • public readonly LayoutUnit Unit

    What kind of length this is.

  • public bool IsDefined

    Whether anything was set.

  • public bool IsResolvable

    Whether this is a length that resolves to a number against a containing size.

Methods (11)

  • public StyleLength(float value, LayoutUnit unit)

    Creates a length.

  • public static StyleLength Points(float value)

    An absolute length.

  • public static StyleLength Percent(float value)

    A fraction of the containing block.

  • public static StyleLength Keyword(LayoutUnit unit)

    A keyword length with no number of its own.

  • public float Resolve(float referenceLength)

    Resolves against a containing size, or NaN if it does not resolve.

  • public bool Equals(StyleLength other)

    Indicates whether the current object is equal to another object of the same type.

  • public override bool Equals(object? obj)

    Indicates whether this instance and a specified object are equal.

  • public override int GetHashCode()

    Returns the hash code for this instance.

  • public static bool operator ==(StyleLength left, StyleLength right)

    Compares two lengths.

  • public static bool operator !=(StyleLength left, StyleLength right)

    Compares two lengths.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (40)

  • LayoutBenchmarksVixen.Benchmarks.Ui
  • AbsolutePositionTestsVixen.Ui.Layout.Tests
  • AlignContentTestsVixen.Ui.Layout.Tests
  • AlignItemsTestsVixen.Ui.Layout.Tests
  • AlignSelfTestsVixen.Ui.Layout.Tests
  • AndroidNewsFeedTestsVixen.Ui.Layout.Tests
  • AspectRatioTestsVixen.Ui.Layout.Tests
  • AutoTestsVixen.Ui.Layout.Tests
  • AutomaticMinimumSizeTestsVixen.Ui.Layout.Tests
  • BorderTestsVixen.Ui.Layout.Tests
  • BoxSizingTestsVixen.Ui.Layout.Tests
  • DimensionLengthsVixen.Ui.Layout
  • DimensionTestsVixen.Ui.Layout.Tests
  • DisplayTestsVixen.Ui.Layout.Tests
  • EdgeLengthsVixen.Ui.Layout
  • FlexBasisFitContentTestsVixen.Ui.Layout.Tests
  • FlexDirectionTestsVixen.Ui.Layout.Tests
  • FlexTestsVixen.Ui.Layout.Tests
  • FlexWrapTestsVixen.Ui.Layout.Tests
  • GapTestsVixen.Ui.Layout.Tests
  • GutterLengthsVixen.Ui.Layout
  • IntrinsicSizeTestsVixen.Ui.Layout.Tests
  • JustifyContentTestsVixen.Ui.Layout.Tests
  • LayoutPassTestsVixen.Ui.Layout.Tests
  • LayoutStyleVixen.Ui.Layout
  • LayoutStyleBridgeTestsVixen.Ui.Tests
  • LayoutStyleBuilderVixen.Ui
  • LayoutTreeVixen.Ui.Layout
  • LayoutTreeTestsVixen.Ui.Layout.Tests
  • LengthContextVixen.Ui
  • MarginTestsVixen.Ui.Layout.Tests
  • MinMaxDimensionTestsVixen.Ui.Layout.Tests
  • PaddingTestsVixen.Ui.Layout.Tests
  • PanelSpecVixen.Ui.Layout.Tests
  • PercentageTestsVixen.Ui.Layout.Tests
  • PixelRoundingTestsVixen.Ui.Layout.Tests
  • RoundingTestsVixen.Ui.Layout.Tests
  • SizeOverflowTestsVixen.Ui.Layout.Tests
  • StaticPositionTestsVixen.Ui.Layout.Tests
  • StyleResolutionVixen.Ui.Layout