public readonly struct DrawContextWhat an element is given to draw itself with.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The escape hatch out of the declarative side. A stylesheet describes boxes, and most of an interface is boxes; a chart, a sparkline, a knob and a hand-drawn icon are not, and there is no font-family for those. OnDraw is where a control draws whatever it is, and this is the surface it draws on.
Everything is in document space, the same as the rest of the draw list. Bounds is where the element ended up, so a control that wants to draw inside itself starts from there rather than from an origin it has to be handed.
A struct passed by value, not a class handed out per element per frame. It is three references' worth of state and it exists for the length of one virtual call.
⚠ There is no text method here, and that does not mean a drawn layer cannot write a word — #1112, which read the absence as a wall and is why this paragraph exists. Every piece is public and reachable from here: Fonts resolves a face, Shaping shapes one run through the same LRU the layout pass uses — so a canvas of forty labels costs forty lookups and not forty shapings — TextRun.Place gives the glyphs on a baseline, and List takes them through AddGlyphs, AddFont and a DrawCommandKind.Text command. That is five calls, and it is what DrawListBuilder does per run without the layout pass a layer is avoiding.
Vixen.Ui.Tests.DrawnLayerTextTests is that recipe, executed, rather than a paragraph that can rot. ⚠ What a layer does not get from it is a paragraph: no line breaking, no bidi reordering, no fallback across scripts and no cascade — those are an element's, and a layer wanting them wants an element. There is no shorthand on this type because no production layer has needed one twice; the day a second does, it wraps those five calls.
Fields and properties (4)
Methods (8)
public void Fill(PathBuilder path, Color4 color, PathFillRule rule = NonZero)Fills a path.
public void FillField(PathBuilder path, Vector2 origin, Color4 color, PathFillRule rule = NonZero)Fills a small path as a cached distance field, rather than tessellating it.
public void Stroke(PathBuilder path, Color4 color, float thickness, LineJoin join = Miter, LineCap cap = Butt, float miterLimit = 0, Vector2 origin = default(Vector2))Strokes a path.
public void FillRectangle(Rectangle rectangle, Color4 color, float radius = 0)Fills a rectangle, with optional rounded corners.
public void DrawImage(Rectangle rectangle, ulong image, Color4 tint = default(Color4), Rectangle source = default(Rectangle), UiImageView view = default(UiImageView))Draws a texture over a rectangle.
public void DrawNineSlice(Rectangle rectangle, ulong image, NineSlice border, NineSlice sourceBorder, Color4 tint = default(Color4), Rectangle source = default(Rectangle), bool hollowCentre = false)Draws a texture over a rectangle with its borders held at their own size.
public void FillRectangle(Rectangle rectangle, Color4 color, BoxStyle style)Fills a rectangle with per-corner radii, a gradient, or both.
public void StrokeRectangle(Rectangle rectangle, Color4 color, float thickness, BoxStyle style = default(BoxStyle))Draws a border inside a rectangle's edges, with per-corner radii.
Used by (41, showing 40)
- BoxVixen.Ui.Tests
- CodeEditorVixen.Ui.Controls.Advanced
- CodeOverlayVixen.Ui.Controls.Advanced
- ColorFieldVixen.Ui.Controls.Advanced
- ColorStripVixen.Ui.Controls.Advanced
- ColorSwatchVixen.Ui.Controls.Advanced
- CurveEditorVixen.Ui.Controls.Advanced
- DrawContextBoxTestsVixen.Ui.Tests
- DrawListBuilderVixen.Ui
- DrawnLayerTextTestsVixen.Ui.Tests
- GradientBarVixen.Ui.Controls.Advanced
- GradientRailVixen.Ui.Controls.Advanced
- IconVixen.Ui.Controls
- ImageVixen.Ui.Controls
- ImageViewVixen.Ui.Controls.Advanced
- LayerVixen.Ui.Tests
- NodeCanvasVixen.Ui.Controls.Advanced
- NodeMinimapVixen.Ui.Controls.Advanced
- NodeOverlayLayerVixen.Ui.Controls.Advanced
- NodeWireLayerVixen.Ui.Controls.Advanced
- PathTestsVixen.Ui.Tests
- ProgressBarVixen.Ui.Controls
- RangeBaseVixen.Ui.Controls
- RangeSliderVixen.Ui.Controls
- ScrollBarVixen.Ui.Controls
- SliderVixen.Ui.Controls
- SpinnerVixen.Ui.Controls
- TextFieldVixen.Ui.Controls
- TimelineLanesVixen.Ui.Controls.Advanced
- TimelineRulerVixen.Ui.Controls.Advanced
- TreeRowVixen.Ui.Controls.Advanced
- TriangleVixen.Ui.Tests
- UiElementVixen.Ui
- ViewportVixen.Ui.Controls.Advanced
- ViewportGizmoVixen.Ui.Controls.Advanced
- FontAtlasViewVixen.Editor.AssetEditors
- MarqueeOverlayVixen.Editor.SceneView
- NodeGraphViewVixen.Editor.NodeGraph
- NodePreviewLayerVixen.Editor.NodeGraph
- StateMapViewVixen.Editor.AssetEditors