use crate::element::ElementProps;
use crate::parser::AttributeMap;
use bevy::app::App;
use bevy::prelude::{Entity, World};
use roxmltree::Node;
use std::fmt::Debug;
pub mod checkbox;
pub mod switch;
pub mod node;
pub mod button;
pub mod text;
pub mod image;
pub mod text_input;
pub mod slider;
pub mod progress_bar;
pub mod tooltip;
pub mod divider;
pub mod scroll_view;
pub mod dropdown;
pub trait Widget: Debug + Send + Sync + 'static {
fn name() -> &'static str
where
Self: Sized;
fn setup(&self, app: &mut App);
fn parse(&mut self, node: &Node, attrs: &AttributeMap) -> Result<(), String>;
fn spawn(&self, entity: Entity, world: &mut World) -> Entity;
fn apply_defaults(
&self,
attrs: &AttributeMap,
default: &mut ElementProps,
hover: &mut ElementProps,
click: &mut ElementProps,
);
fn dyn_clone(&self) -> Box<dyn Widget>;
}
impl Clone for Box<dyn Widget> {
#[inline(always)]
fn clone(&self) -> Self {
self.dyn_clone()
}
}