public class UiElementOne node of the user interface.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Elements are classes, and that is a deliberate departure from the rest of the engine. An ECS component is a struct because there are a million of them in a hot loop; a UI node has identity, virtual behaviour and event handlers, and there are ten thousand of them. The struct-of-arrays discipline lives where the loops actually are — the layout store and, later, the draw list — and this type is a handle into them.
It holds no geometry and no style of its own. The cascade owns the computed style, the layout tree owns the result, and everything read from here is a lookup into one of the two. That is what keeps a hundred identical list rows from being a hundred copies of anything.
Fields and properties (39)
public bool HasInlineStyleWhether anything has been written on this element directly.
public UiDocument DocumentThe document this belongs to.
public bool IsRemovedWhether it has been taken out of its document.
public string TagIts element name, which selectors match on.
protected internal virtual string TagNameThe element name this type answers to when a caller does not choose one.
protected internal virtual UiElement ContentHostWhere content written inside this element's tag actually goes.
public UiElement? ParentIts parent, or null for the root.
public UiSurface? SurfaceRootThe surface this element is the root of, if it is one.
public IReadOnlyList<UiElement> ChildrenIts children, in document order.
public float LineHeightIts line-height in pixels, or NaN for the font's own.
public float LetterSpacingIts letter-spacing in pixels.
public int ZIndexWhere it sits among its siblings when they overlap.
public ComputedStyle StyleWhat the cascade decided. Interned, so two alike elements share one object.
public float FontSizeIts resolved font size in pixels, which every em on it measures against.
public float LeftIts left edge, relative to its parent, after the last layout pass.
public float TopIts top edge, relative to its parent.
public float WidthIts width.
public float HeightIts height.
public ElementState StateIts interaction state — hover, focus, active — which selectors match on.
public char AccessKeypublic bool Focusablepublic int TabIndexpublic bool IsFocusScopepublic bool IsFocusedWhether the focus is on it.
public string? Textpublic float OffsetXpublic float OffsetYpublic float AbsoluteLeftIts left edge in document space, after the last layout pass.
public float AbsoluteTopIts top edge in document space.
public Rectangle BoundsWhere it is in document space, after the last layout pass.
public bool IsHitTestVisibleWhether a pointer can land on it. pointer-events: none makes it false.
public int IndexInParentWhere this element sits among its siblings, or -1 if it has no parent.
public static readonly UiPropertyKey AccessKeyPropertyIdentity for AccessKey.
public static readonly UiPropertyKey FocusablePropertyIdentity for Focusable.
public static readonly UiPropertyKey TabIndexPropertyIdentity for TabIndex.
public static readonly UiPropertyKey IsFocusScopePropertyIdentity for IsFocusScope.
public static readonly UiPropertyKey TextPropertyIdentity for Text.
public static readonly UiPropertyKey OffsetXPropertyIdentity for OffsetX.
public static readonly UiPropertyKey OffsetYPropertyIdentity for OffsetY.
Events (1)
public Action<UiElement, UiPropertyKey>? PropertyChangedRaised after any generated UI property changes.
Methods (29)
public void SetStyle(string property, string? value)Writes a declaration onto this element, over anything a stylesheet said.
public string? GetStyle(string property)Reads back a declaration written with SetStyle.
public void ClearStyle()Takes every inline declaration off this element.
public UiElement()Creates a detached element.
public UiElement Add(string tag, string? id = null, params ReadOnlySpan<string> classNames)Adds a child element.
public T Add<T>(string? tag = null, string? id = null, params ReadOnlySpan<string> classNames) where T : UiElement, new()Adds a child of a particular element type.
public bool AddClass(string className)Adds a class, and invalidates what that could have changed.
public bool RemoveClass(string className)Removes a class.
public bool HasClass(string className)Whether it carries a class.
public string? Attribute(string name)An attribute's value, if it has one.
public void SetAttribute(string name, string value)Sets an attribute.
public TextLayout? Block()Its text, shaped and wrapped to the width it is being laid out in.
public TextLayout? Block(float width)Its text wrapped to a given width.
protected internal virtual void OnCreated()Builds whatever this element is made of, once, as it joins a document.
protected internal virtual void OnRemoved()Called once, as the element leaves the document.
protected internal virtual void OnPropertyChanged(UiPropertyKey key)Raised after any generated UI property changes.
protected void RaisePropertyChanged(UiPropertyKey key)Tells the override and the subscribers that a property changed.
protected internal virtual void OnDraw(DrawContext context)Draws whatever this element is, beyond what a stylesheet can describe.
public void AddHandler<T>(Action<UiElement, T> handler, RoutingStrategy strategy = Bubble, bool handledEventsToo = false) where T : UiEventListens for an event on its way through this element.
public bool RemoveHandler<T>(Action<UiElement, T> handler) where T : UiEventStops listening.
public void Raise<T>(T args) where T : UiEventSends an event to this element and along its route.
public void Remove()Takes this element and everything under it out of its document.
public void ClearAccessKey()Unsets AccessKey, so it takes its default or its ancestor's value again.
public void ClearFocusable()Unsets Focusable, so it takes its default or its ancestor's value again.
public void ClearTabIndex()Unsets TabIndex, so it takes its default or its ancestor's value again.
public void ClearIsFocusScope()Unsets IsFocusScope, so it takes its default or its ancestor's value again.
public void ClearText()Unsets Text, so it takes its default or its ancestor's value again.
public void ClearOffsetX()Unsets OffsetX, so it takes its default or its ancestor's value again.
public void ClearOffsetY()Unsets OffsetY, so it takes its default or its ancestor's value again.
Used by (404, showing 40)
- ShellHelloUi
- UiHostHelloUi
- DocumentBenchmarksVixen.Benchmarks.Ui
- AccessKeyTestsVixen.Ui.Tests
- AccordionVixen.Ui.Controls
- AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
- AlertVixen.Ui.Controls
- AvatarVixen.Ui.Controls
- BareVixen.Ui.Tests
- BatchTestsVixen.Ui.Tests
- BoundVixen.Ui.Tests
- BranchingVixen.Ui.Tests
- BreadcrumbVixen.Ui.Controls
- BreadcrumbItemVixen.Ui.Controls
- BuildContextVixen.Ui
- ButtonBaseVixen.Ui.Controls
- ButtonTestsVixen.Ui.Controls.Tests
- CardVixen.Ui.Tests
- CardVixen.Ui.Controls
- CheckBoxVixen.Ui.Controls
- ClickableVixen.Ui.Tests
- CodeEditorVixen.Ui.Controls.Advanced
- CodeEditorTestsVixen.Ui.Controls.Advanced.Tests
- CodeGutterRowVixen.Ui.Controls.Advanced
- CodeLineVixen.Ui.Controls.Advanced
- CodeOverlayVixen.Ui.Controls.Advanced
- CodeSpanVixen.Ui.Controls.Advanced
- ColorFieldVixen.Ui.Controls.Advanced
- ColorInputVixen.Ui.Controls.Advanced
- ColorInputTestsVixen.Ui.Controls.Advanced.Tests
- ColorPickerVixen.Ui.Controls.Advanced
- ColorPickerTestsVixen.Ui.Controls.Advanced.Tests
- ColorStripVixen.Ui.Controls.Advanced
- ColorSwatchVixen.Ui.Controls.Advanced
- ComboBoxVixen.Ui.Controls
- ComponentVixen.Ui
- CompositionTestsVixen.Ui.Tests
- ContextMenuVixen.Ui.Controls
- ControlVixen.Ui.Controls
- ControlFixtureVixen.Ui.Controls.Tests