Vixen
02b45cc4
csharp
public enum StyleUnit

The units a length can carry.

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

Remarks

Relative units are carried here, and never resolved here. A value of two em means exactly that and nothing more; turning it into pixels needs a context — the element's own font size, the root's, the surface's — that does not exist at parse time, and that step belongs to Vixen.Ui. Nothing in this assembly is allowed to half-resolve one, because a consumer would then have to ask which half.

⚠ This type used to leave em and friends out entirely, on the argument that they belonged downstream. That was right about resolution and wrong about representation, and transitions are what settled it: the animator interpolates StyleValue, so a unit this type cannot express is a unit that cannot animate. Leaving them out meant width: 2em parsed as Unknown, and a transition on it silently did nothing — no diagnostic, no exception, just a property that snaps while its neighbours ease.

The known limit, which is older than this change: interpolation requires both endpoints to share a unit, so 2em → 40px does not animate. CSS resolves both to pixels at computed-value time and Vixen animates specified values, which was already true of % against px.

Fields and properties (11)

  • None

    No unit — a bare number used where a length is expected, which CSS allows only for zero.

  • Pixels

    Device-independent pixels.

  • Percent

    A percentage of something the property decides.

  • Seconds

    Seconds. Durations and delays.

  • Degrees

    Degrees. Angles.

  • Em

    The element's own font size — except on font-size, where it is the parent's.

  • Rem

    The root element's font size, however deep the element is.

  • ViewportWidth

    A hundredth of the viewport's width.

  • ViewportHeight

    A hundredth of the viewport's height.

  • ViewportMin

    A hundredth of the viewport's smaller side.

  • ViewportMax

    A hundredth of the viewport's larger side.

Used by (6)

  • DrawListBuilderVixen.Ui
  • LengthContextVixen.Ui
  • StyleValueVixen.Ui.Styling
  • StyleValueParserVixen.Ui.Styling
  • StyleValueTestsVixen.Ui.Styling.Tests
  • UiDocumentVixen.Ui