pub struct AnyElement {
pub id: GlobalElementId,
pub kind: ElementKind,
pub children: Vec<AnyElement>,
pub inherited_foreground: Option<Color>,
pub inherited_text_style: Option<TextStyleRefinement>,
pub semantics_decoration: Option<SemanticsDecoration>,
pub key_context: Option<Arc<str>>,
}Expand description
Declarative element tree node (ephemeral per frame), keyed by a stable GlobalElementId.
This is the authoring-layer representation described by ADR 0028 / ADR 0039.
Note: AnyElement is intentionally move-only. Reusing the same AnyElement value in multiple
places (e.g. via cloning) can create duplicate GlobalElementIds within a single frame, which
violates the element-tree contract and can lead to downstream traversal issues.
Fields§
§id: GlobalElementId§kind: ElementKind§children: Vec<AnyElement>§inherited_foreground: Option<Color>Layout-transparent inherited foreground installed on this subtree root.
This is the non-wrapper equivalent of ForegroundScope: descendants that opt into
currentColor-style paint inheritance can resolve this value during paint without adding a
new layout node.
inherited_text_style: Option<TextStyleRefinement>Layout-transparent inherited passive-text typography installed on this subtree root.
This is consumed by passive text leaves (Text, StyledText, SelectableText) via the
runtime’s inherited text-style cascade (ADR 0314) without introducing a layout wrapper.
semantics_decoration: Option<SemanticsDecoration>Layout-transparent semantics overrides applied when producing semantics snapshots.
key_context: Option<Arc<str>>Layout-transparent key context identifier used by shortcut/keymap when expressions.
Implementations§
Source§impl AnyElement
impl AnyElement
pub fn new( id: GlobalElementId, kind: ElementKind, children: Vec<AnyElement>, ) -> AnyElement
Sourcepub fn inherit_foreground(self, foreground: Color) -> AnyElement
pub fn inherit_foreground(self, foreground: Color) -> AnyElement
Attach a subtree-local inherited foreground without introducing a layout wrapper.
Descendants that support currentColor / IconTheme-style paint inheritance resolve this
value at paint time.
Sourcepub fn inherit_text_style(self, refinement: TextStyleRefinement) -> AnyElement
pub fn inherit_text_style(self, refinement: TextStyleRefinement) -> AnyElement
Attach a subtree-local inherited passive-text refinement without introducing a layout wrapper.
Descendants that render passive text (Text, StyledText, SelectableText) resolve this
refinement through the runtime’s inherited text-style cascade.
Sourcepub fn attach_semantics(self, decoration: SemanticsDecoration) -> AnyElement
pub fn attach_semantics(self, decoration: SemanticsDecoration) -> AnyElement
Attach layout-transparent semantics metadata to this element (ADR 0222).
Prefer this over wrapping a subtree in Semantics when you only need to stamp
test_id / label / role / value for diagnostics or UI automation, since Semantics
introduces a real layout node.
use fret_core::SemanticsRole;
use fret_ui::element::SemanticsDecoration;
// `some_element` is any `AnyElement` produced by your view constructors:
let el = some_element.attach_semantics(
SemanticsDecoration::default()
.role(SemanticsRole::Button)
.label("Save")
.test_id("toolbar.save"),
);Sourcepub fn a11y(self, decoration: SemanticsDecoration) -> AnyElement
pub fn a11y(self, decoration: SemanticsDecoration) -> AnyElement
Shorthand for attaching a SemanticsDecoration without introducing a layout node.
This is a convenience wrapper over AnyElement::attach_semantics.
Sourcepub fn a11y_role(self, role: SemanticsRole) -> AnyElement
pub fn a11y_role(self, role: SemanticsRole) -> AnyElement
Attach a semantics role override (ARIA role-like outcome).
Sourcepub fn a11y_label(self, label: impl Into<Arc<str>>) -> AnyElement
pub fn a11y_label(self, label: impl Into<Arc<str>>) -> AnyElement
Attach a semantics label override (ARIA aria-label-like outcome).
Sourcepub fn test_id(self, test_id: impl Into<Arc<str>>) -> AnyElement
pub fn test_id(self, test_id: impl Into<Arc<str>>) -> AnyElement
Attach a debug/test-only identifier for diagnostics and deterministic UI automation.
This is shorthand for attaching a SemanticsDecoration with test_id set.
let el = some_element.test_id("settings.theme.toggle");Sourcepub fn a11y_value(self, value: impl Into<Arc<str>>) -> AnyElement
pub fn a11y_value(self, value: impl Into<Arc<str>>) -> AnyElement
Attach a semantics value override (ARIA aria-valuetext-like outcome).
Sourcepub fn a11y_disabled(self, disabled: bool) -> AnyElement
pub fn a11y_disabled(self, disabled: bool) -> AnyElement
Attach a disabled override (ARIA aria-disabled-like outcome).
Sourcepub fn a11y_selected(self, selected: bool) -> AnyElement
pub fn a11y_selected(self, selected: bool) -> AnyElement
Attach a selected override (ARIA aria-selected-like outcome).
Sourcepub fn a11y_expanded(self, expanded: bool) -> AnyElement
pub fn a11y_expanded(self, expanded: bool) -> AnyElement
Attach an expanded override (ARIA aria-expanded-like outcome).
Sourcepub fn a11y_checked(self, checked: Option<bool>) -> AnyElement
pub fn a11y_checked(self, checked: Option<bool>) -> AnyElement
Attach a tri-state checked override (ARIA aria-checked-like outcome).
Sourcepub fn key_context(self, key_context: impl Into<Arc<str>>) -> AnyElement
pub fn key_context(self, key_context: impl Into<Arc<str>>) -> AnyElement
Attach a key context identifier to this element for shortcut routing.
This is a layout-transparent annotation used by when expressions via keyctx.*.