azul_core::dom

Struct Dom

Source
pub struct Dom {
    pub root: NodeData,
    pub children: Vec<Dom>,
    /* private fields */
}
Expand description

The document model, similar to HTML. This is a create-only structure, you don’t actually read anything back

Fields§

§root: NodeData§children: Vec<Dom>

Implementations§

Source§

impl Dom

Source

pub const fn new(node_type: NodeType) -> Self

Creates an empty DOM with a give NodeType. Note: This is a const fn and doesn’t allocate, it only allocates once you add at least one child node.

Source

pub fn with_capacity(node_type: NodeType, cap: usize) -> Self

Creates an empty DOM with space reserved for cap nodes

Source

pub const fn div() -> Self

Shorthand for Dom::new(NodeType::Div).

Source

pub const fn body() -> Self

Shorthand for Dom::new(NodeType::Body).

Source

pub fn label<S: Into<DomString>>(value: S) -> Self

Shorthand for Dom::new(NodeType::Label(value.into()))

Source

pub const fn text_id(text_id: TextId) -> Self

Shorthand for Dom::new(NodeType::Text(text_id))

Source

pub const fn image(image: ImageId) -> Self

Shorthand for Dom::new(NodeType::Image(image_id))

Source

pub fn gl_texture<I: Into<RefAny>>(callback: GlCallbackType, ptr: I) -> Self

Shorthand for Dom::new(NodeType::GlTexture((callback, ptr)))

Source

pub fn iframe<I: Into<RefAny>>(callback: IFrameCallbackType, ptr: I) -> Self

Shorthand for Dom::new(NodeType::IFrame((callback, ptr)))

Source

pub fn add_child(&mut self, child: Self)

Adds a child DOM to the current DOM

Source

pub fn with_id<S: Into<DomString>>(self, id: S) -> Self

Same as id, but easier to use for method chaining in a builder-style pattern

Source

pub fn with_class<S: Into<DomString>>(self, class: S) -> Self

Same as id, but easier to use for method chaining in a builder-style pattern

Source

pub fn with_callback<O: Into<EventFilter>>( self, on: O, callback: CallbackType, ptr: RefAny, ) -> Self

Same as event, but easier to use for method chaining in a builder-style pattern

Source

pub fn with_child(self, child: Self) -> Self

Source

pub fn with_css_override<S: Into<DomString>>( self, id: S, property: CssProperty, ) -> Self

Source

pub fn with_tab_index(self, tab_index: TabIndex) -> Self

Source

pub fn is_draggable(self, draggable: bool) -> Self

Source

pub fn add_id<S: Into<DomString>>(&mut self, id: S)

Source

pub fn add_class<S: Into<DomString>>(&mut self, class: S)

Source

pub fn add_callback<O: Into<EventFilter>>( &mut self, on: O, callback: CallbackType, ptr: RefAny, )

Source

pub fn add_css_override<S: Into<DomString>, P: Into<CssProperty>>( &mut self, override_id: S, property: P, )

Source

pub fn set_tab_index(&mut self, tab_index: TabIndex)

Source

pub fn set_draggable(&mut self, draggable: bool)

Source

pub fn get_html_string(&self) -> String

Returns a HTML-formatted version of the DOM for easier debugging, i.e.

Dom::div().with_id("hello")
    .with_child(Dom::div().with_id("test"))

will return:

<div id="hello">
     <div id="test" />
</div>

Trait Implementations§

Source§

impl Clone for Dom

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dom

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Dom> for CompactDom

Source§

fn from(dom: Dom) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Dom> for Dom

Source§

fn from_iter<I: IntoIterator<Item = Dom>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<NodeData> for Dom

Source§

fn from_iter<I: IntoIterator<Item = NodeData>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<NodeType> for Dom

Source§

fn from_iter<I: IntoIterator<Item = NodeType>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for Dom

Source§

fn eq(&self, rhs: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Dom

Auto Trait Implementations§

§

impl Freeze for Dom

§

impl !RefUnwindSafe for Dom

§

impl !Send for Dom

§

impl !Sync for Dom

§

impl Unpin for Dom

§

impl !UnwindSafe for Dom

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.