public readonly record struct BoxStyleWhat 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 CornersIts corner radii.
public Color4 GradientEndThe colour at the far end of its gradient.
public Vector2 GradientAxisWhich 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 ShapeWhich family of gradient fills this box.
public GradientSpace SpaceWhich space the stops are interpolated in.
public Color4 GradientViaThe colour at the middle stop. Read only when HasVia.
public bool HasViaWhether there is a middle stop at all.
public GradientStops StopsWhere the three stops sit along the ramp.
public Vector2 PaintCentreWhere the ramp's own centre sits, in pixels from the centre of the tile it fills.
public Vector2 PaintExtentHow far the ramp reaches from PaintCentre, in pixels.
public Vector2 AreaCentreWhere the first tile's centre sits, in pixels from the box's centre.
public Vector2 AreaHalfHalf the tile, signed: background-size, with background-repeat in the sign.
public bool InsetWhether this box is an inset shadow, drawn inside the box rather than around it.
public Vector2 InsetOffsetAn inset shadow's offset, in pixels. Read only when Inset.
public float InsetSpreadHow far an inset shadow's rectangle shrinks from the box. Read only when Inset.
public bool HasGradientWhether this box is filled with more than one colour.
Methods (3)
public BoxStyle(CornerRadii Corners, Color4 GradientEnd, Vector2 GradientAxis)What a box needs beyond a colour and a size.
public static BoxStyle Rounded(CornerRadii corners)Corners and nothing else.
public static BoxStyle Vertical(Color4 end, CornerRadii corners = default(CornerRadii))A gradient down the box, which is what a panel or a button usually wants.
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