Vixen
dd8b0a81
csharp
public readonly record struct BoxStyle

What a box needs beyond a colour and a size.

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

Remarks

⚠ A side buffer, not more fields on DrawCommand. Eight radius floats, two colours, an axis and a stop list would more than double the size of the struct the frame diff compares every frame — and every text run, every path and every plain rectangle would pay for them. The draw list already keeps variable and rare things beside the commands, for glyphs and for path segments, and this is the same argument with a different shape.

⚠ A zero axis was the sentinel for "no gradient", and Shape is what replaced it — because a radial gradient has no axis, so the sentinel could no longer tell "flat" from "round". The zero axis still implies flat, and a non-zero one still implies linear, which is what keeps every caller written against the three-parameter form drawing what it drew.

⚠ Three of the four new members normalise their zero on read, in one place each. A record struct's default has to be the sensible value — this type is reached through default(BoxStyle) on every box that has no side-buffer entry — and the sensible value for a stop list is not (0, 0, 0). The init accessors normalise in the other direction so that stating a default explicitly still compares equal to leaving it out; without that, two identical styles would differ and the frame diff would redraw.

Fields and properties (16)

  • public CornerRadii Corners

    Its corner radii.

  • public Color4 GradientEnd

    The colour at the far end of its gradient.

  • public Vector2 GradientAxis

    Which way the gradient runs, as a direction in the box's own space. A zero axis means the box is filled flat and is not read — unless Shape says otherwise, because a radial gradient has no direction at all.

  • public GradientShape Shape

    Which family of gradient fills this box.

  • public GradientSpace Space

    Which space the stops are interpolated in.

  • public Color4 GradientVia

    The colour at the middle stop. Read only when HasVia.

  • public bool HasVia

    Whether there is a middle stop at all.

  • public GradientStops Stops

    Where the three stops sit along the ramp.

  • public Vector2 PaintCentre

    Where the ramp's own centre sits, in pixels from the centre of the tile it fills.

  • public Vector2 PaintExtent

    How far the ramp reaches from PaintCentre, in pixels.

  • public Vector2 AreaCentre

    Where the first tile's centre sits, in pixels from the box's centre.

  • public Vector2 AreaHalf

    Half the tile, signed: background-size, with background-repeat in the sign.

  • public bool Inset

    Whether this box is an inset shadow, drawn inside the box rather than around it.

  • public Vector2 InsetOffset

    An inset shadow's offset, in pixels. Read only when Inset.

  • public float InsetSpread

    How far an inset shadow's rectangle shrinks from the box. Read only when Inset.

  • public bool HasGradient

    Whether this box is filled with more than one colour.

Methods (3)

Used by (23)

  • BorderLonghandTestsVixen.Ui.Tests
  • BorderStyleTestsVixen.Ui.Tests
  • ColorFieldVixen.Ui.Controls.Advanced
  • ColorStripVixen.Ui.Controls.Advanced
  • CurveEditorVixen.Ui.Controls.Advanced
  • DrawContextVixen.Ui
  • DrawContextBoxTestsVixen.Ui.Tests
  • DrawListVixen.Ui
  • DrawListBuilderVixen.Ui
  • DrawListTestsVixen.Ui.Tests
  • EditorShellBudgetTestsVixen.Ui.Controls.Advanced.Tests
  • GradientBarVixen.Ui.Controls.Advanced
  • GradientRailVixen.Ui.Controls.Advanced
  • GradientTestsVixen.Ui.Tests
  • RangeBaseVixen.Ui.Controls
  • RasterizerTestsVixen.Ui.Testing.Tests
  • UiBoxAgreementTestsVixen.Graphics.Golden.Tests
  • UiGamutTestsVixen.Ui.Tests
  • UiGeometryBuilderVixen.Ui
  • UiGeometryTestsVixen.Ui.Tests
  • UiImageTestsVixen.Graphics.Golden.Tests
  • UtilityConsumptionProbeVixen.Ui.Styling.Utilities.Tests
  • UtilityFamilySupportTestsVixen.Editor.Ui.Tests