Vixen
02b45cc4
csharp
public readonly struct StyleValue

A declaration's value, parsed far enough to be interpolated.

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

Remarks

The cascade works on interned strings, and is right to: deciding which declaration wins needs no opinion about what spring(1, 100, 10) means, and keeping it that way is what lets a stylesheet carry a property this engine has never heard of. Animation is the point at which that stops being enough — you cannot interpolate a string — so this is where the typing happens, once, on the values that are actually being animated.

A struct with an overlapping reading rather than a class hierarchy. There is one of these per animated property per element per frame, and a Number that costs a heap allocation to represent is a design that stops being usable at exactly the point a UI gets interesting.

Fields and properties (7)

  • public StyleValueKind Kind

    What kind of value it is.

  • public float Number

    The number, for Number and Length.

  • public StyleUnit Unit

    The unit, for Length.

  • public Color4 Color

    The colour, for Color. Linear, not sRGB-encoded.

  • public int Keyword

    The interned identifier, for Keyword.

  • public ReadOnlySpan<StyleValue> Items

    The parts, for List.

  • public static StyleValue Unknown

    The value nothing could be made of.

Methods (14)

  • public static StyleValue FromNumber(float value)

    A bare number.

  • public static StyleValue FromLength(float value, StyleUnit unit)

    A length.

  • public static StyleValue FromColor(Color4 colour)

    A colour.

  • public static StyleValue FromKeyword(int keyword)

    An identifier.

  • public static StyleValue FromList(StyleValue[] parts)

    A sequence of values.

  • public static bool CanInterpolate(StyleValue from, StyleValue to)

    Whether two values can be interpolated between.

  • public static StyleValue Lerp(StyleValue from, StyleValue to, float amount)

    Interpolates between two values.

  • public bool Equals(StyleValue 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 ==(StyleValue left, StyleValue right)

    Compares two values.

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

    Compares two values.

  • public string ToCss(NameTable names)

    Writes the value back as CSS text.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (12)

  • AnimationTestsVixen.Ui.Styling.Tests
  • AnimatorVixen.Ui.Styling
  • CompactionTestsVixen.Ui.Styling.Tests
  • DrawListBuilderVixen.Ui
  • LayoutStyleBuilderVixen.Ui
  • LengthContextVixen.Ui
  • MultipleAnimationTestsVixen.Ui.Styling.Tests
  • RunningTransitionVixen.Ui.Styling
  • StyleValueParserVixen.Ui.Styling
  • StyleValueTestsVixen.Ui.Styling.Tests
  • TransitionTestsVixen.Ui.Styling.Tests
  • UiDocumentVixen.Ui