pub struct ThemedBuilder<'a> { /* private fields */ }Expand description
Convenience wrapper around StyledTreeBuilder that auto-applies theme styles.
ⓘ
let theme = Theme::default();
let mut builder = StyledTreeBuilder::new(IrVersion::new(1, 0));
let mut tb = ThemedBuilder::new(&mut builder, &theme);
let root = tb.add_node(ContentVariant::Container, SemanticRole::Document, None);
tb.add_child(root, ContentVariant::Text(TextContent::new("Hello")), SemanticRole::Paragraph, None);Implementations§
Source§impl<'a> ThemedBuilder<'a>
impl<'a> ThemedBuilder<'a>
Sourcepub fn new(builder: &'a mut StyledTreeBuilder, theme: &'a Theme) -> Self
pub fn new(builder: &'a mut StyledTreeBuilder, theme: &'a Theme) -> Self
Create a themed builder wrapping an existing StyledTreeBuilder.
Sourcepub fn add_node(
&mut self,
content: ContentVariant,
role: SemanticRole,
element_id: Option<String>,
) -> NodeId
pub fn add_node( &mut self, content: ContentVariant, role: SemanticRole, element_id: Option<String>, ) -> NodeId
Add a root node with the theme style for the given role.
Sourcepub fn add_child(
&mut self,
parent: NodeId,
content: ContentVariant,
role: SemanticRole,
element_id: Option<String>,
) -> NodeId
pub fn add_child( &mut self, parent: NodeId, content: ContentVariant, role: SemanticRole, element_id: Option<String>, ) -> NodeId
Add a child node with the theme style for the given role.
Sourcepub fn add_child_with_style(
&mut self,
parent: NodeId,
content: ContentVariant,
style: ResolvedStyle,
role: Option<SemanticRole>,
element_id: Option<String>,
) -> NodeId
pub fn add_child_with_style( &mut self, parent: NodeId, content: ContentVariant, style: ResolvedStyle, role: Option<SemanticRole>, element_id: Option<String>, ) -> NodeId
Add a child with a custom style override (ignoring the theme for this node).
Sourcepub fn inner(&mut self) -> &mut StyledTreeBuilder
pub fn inner(&mut self) -> &mut StyledTreeBuilder
Access the underlying builder for operations the themed wrapper doesn’t cover.
Auto Trait Implementations§
impl<'a> Freeze for ThemedBuilder<'a>
impl<'a> RefUnwindSafe for ThemedBuilder<'a>
impl<'a> Send for ThemedBuilder<'a>
impl<'a> Sync for ThemedBuilder<'a>
impl<'a> Unpin for ThemedBuilder<'a>
impl<'a> UnsafeUnpin for ThemedBuilder<'a>
impl<'a> !UnwindSafe for ThemedBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more