Skip to main content

ThemedBuilder

Struct ThemedBuilder 

Source
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>

Source

pub fn new(builder: &'a mut StyledTreeBuilder, theme: &'a Theme) -> Self

Create a themed builder wrapping an existing StyledTreeBuilder.

Source

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.

Source

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.

Source

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).

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.