handlers and ids

This commit is contained in:
2025-07-05 06:28:50 +02:00
parent 921bfa27c1
commit 661756eccd
8 changed files with 112 additions and 39 deletions
+31
View File
@@ -0,0 +1,31 @@
use std::sync::Arc;
use crate::widget::{Element, Widget};
#[derive(Default)]
pub struct Div {
pub children: Vec<Arc<Widget>>,
}
impl Element for Div {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
}
impl Div {
pub fn new() -> Self {
Div {
children: Vec::new(),
}
}
pub fn draw<E: Element + 'static>(&mut self, element: E) -> &Arc<Widget> {
self.children.push(Arc::new(Widget::new(Box::new(element))));
self.children.last().unwrap()
}
}