bevy_pages 0.2.0

A lightweight and elegant framework to upgrade your Bevy UI experience.
Documentation
use crate::element::{ElementProps, ElementWidget};
use bevy::asset::AssetServer;
use bevy::prelude::{Entity, EntityCommands};
use roxmltree::Node;

/// Contains the checkbox widget and functionality.
pub mod checkbox;

/// Contains the node widget and functionality.
pub mod node;

/// Contains the button widget and functionality.
pub mod button;

/// Contains the text widget and functionality.
pub mod text;

/// Contains the image widget and functionality.
pub mod image;

/// Contains the text input widget and functionality.
pub mod text_input;

/// Contains the slider widget and functionality.
pub mod slider;

/// Contains the progress bar widget and functionality.
pub mod progress_bar;

/// Contains the tooltip widget and functionality.
pub mod tooltip;

/// Contains the divider widget and functionality.
pub mod divider;

/// Contains the scroll view widget and functionality.
pub mod scroll_view;

/// Contains the dropdown widget and functionality.
pub mod dropdown;

/// A trait to define a widget.
pub trait Widget {
    /// Spawns the widget. Called inside [Element::spawn](crate::element::Element::spawn).
    fn spawn(&self, commands: &mut EntityCommands, assets: &AssetServer) -> Entity;

    /// Parses the widget using the provided XML node.
    fn parse(
        node: &Node,
        prefix: Option<&str>,
        base: Option<&ElementWidget>,
    ) -> Result<Self, String>
    where
        Self: Sized;

    /// Apply default widget props.
    ///
    /// Defaults should only be applied, when the attribute modifying the property is not set.
    fn apply_defaults(
        node: &Node,
        default: &mut ElementProps,
        hover: &mut ElementProps,
        click: &mut ElementProps,
    );
}