use std::{fmt::Debug, rc::Rc};
use dces::prelude::{Component, Entity};
use crate::{event::EventHandler, properties::AttachedProperty, theming::Selector};
pub use self::build_context::*;
pub use self::context::*;
pub use self::registry::*;
pub use self::state::*;
pub use self::states_context::*;
pub use self::template::*;
pub use self::widget_container::*;
mod build_context;
mod context;
mod registry;
mod state;
mod states_context;
mod template;
mod widget_container;
pub fn toggle_flag(flag: &str, widget: &mut WidgetContainer) {
if !widget.has::<bool>(flag) {
return;
}
let value = *widget.get::<bool>(flag);
if let Some(selector) = widget.try_get_mut::<Selector>("selector") {
if value {
selector.set_state(flag);
} else {
selector.clear_state();
}
}
}
pub enum ParentType {
None,
Single,
Multi,
}
pub trait Widget: Template {
fn new() -> Self;
#[inline(always)]
#[deprecated = "Use new instead"]
fn create() -> Self {
Self::new()
}
fn attach<P: Component + Debug>(self, _: AttachedProperty<P>) -> Self {
self
}
fn build(self, ctx: &mut BuildContext) -> Entity;
fn insert_handler(self, handler: impl Into<Rc<dyn EventHandler>>) -> Self;
fn child(self, child: Entity) -> Self;
}