euv-core 0.50.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Builder methods for `NodeInitPatch` consumed by `view!` procedural macro expansions.
impl NodeInitPatch {
    /// Creates an empty `NodeInitPatch` with all modifiers unset.
    ///
    /// # Returns
    ///
    /// - `Self` - Empty node initialization patch.
    #[must_use]
    #[inline(always)]
    pub fn empty() -> Self {
        Self::default()
    }

    /// Sets explicit keyboard focusability on the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `bool` - Whether keyboard focus is enabled.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_focusable(mut self, focusable: bool) -> Self {
        let _: &mut Self = self.set_focusable(Some(focusable));
        self
    }

    /// Attaches an `on_click` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Click event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_click(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_click(Some(handler));
        self
    }

    /// Attaches an `on_change` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Change event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_change(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_change(Some(handler));
        self
    }

    /// Attaches an `on_scroll` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Scroll event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_scroll(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_scroll(Some(handler));
        self
    }

    /// Attaches an `on_pointer_down` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Pointer-down event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_pointer_down(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_pointer_down(Some(handler));
        self
    }

    /// Attaches an `on_pointer_move` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Pointer-move event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_pointer_move(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_pointer_move(Some(handler));
        self
    }

    /// Attaches an `on_pointer_up` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Pointer-up event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_pointer_up(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_pointer_up(Some(handler));
        self
    }

    /// Attaches an `on_pointer_enter` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Pointer-enter event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_pointer_enter(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_pointer_enter(Some(handler));
        self
    }

    /// Attaches an `on_pointer_leave` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Pointer-leave event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_pointer_leave(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_pointer_leave(Some(handler));
        self
    }

    /// Attaches a unified `on_hover` handler invoked on both `PointerEnter` and `PointerLeave`.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Hover event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_hover(mut self, handler: UiEventHandler) -> Self {
        let leave_handler: UiEventHandler = Rc::clone(&handler);
        let _: &mut Self = self
            .set_on_pointer_enter(Some(handler))
            .set_on_pointer_leave(Some(leave_handler));
        self
    }

    /// Attaches an `on_key` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Key-down event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_key(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_key_down(Some(handler));
        self
    }

    /// Attaches an `on_focus` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Focus event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_focus(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_focus(Some(handler));
        self
    }

    /// Attaches an `on_blur` callback handler to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `UiEventHandler` - Blur event callback.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_on_blur(mut self, handler: UiEventHandler) -> Self {
        let _: &mut Self = self.set_on_blur(Some(handler));
        self
    }

    /// Attaches semantic `A11yProps` accessibility metadata to the target node.
    ///
    /// # Arguments
    ///
    /// - `Self` - Patch builder.
    /// - `A11yProps` - Accessibility role, label, hint, and state metadata.
    ///
    /// # Returns
    ///
    /// - `Self` - Updated patch builder.
    #[must_use]
    #[inline(always)]
    pub fn with_a11y(mut self, props: A11yProps) -> Self {
        let _: &mut Self = self.set_a11y(Some(props));
        self
    }
}