This commit is contained in:
2025-06-24 17:21:12 +02:00
parent f72959bcee
commit 6c0dde8e85
5 changed files with 65 additions and 88 deletions
+7 -26
View File
@@ -1,31 +1,12 @@
use osui::{
output::{OutputExtension, RenderAble},
run, Args, BaseElement,
text::{text, DisplayComponent},
Element,
};
pub struct MyElem(*mut Vec<Box<dyn osui::ElementComponent>>);
impl BaseElement for MyElem {
fn init(&mut self) {
unsafe {
(*self.0).push(RenderAble::new(|| String::from("value")));
}
}
fn get_components<'a>(&'a mut self) -> &'a mut Vec<Box<dyn osui::ElementComponent>> {
unsafe { &mut *self.0 }
}
}
impl MyElem {
pub fn new(mut v: Vec<Box<dyn osui::ElementComponent>>) -> Box<MyElem> {
Box::new(MyElem(&mut v))
}
}
fn main() {
let args = Args {
tick_rate: 40,
base_elements: vec![],
};
run(args, vec![Box::new(OutputExtension)]);
let mut e = text("Hello, World!");
if let Some(comp) = e.get_component::<DisplayComponent>() {
println!("Ok: {:?}", comp);
}
}