30 lines
719 B
Rust
30 lines
719 B
Rust
use arkham::{
|
|
ui::{Cell, Color, Component, Rect, UI},
|
|
Result,
|
|
};
|
|
|
|
pub struct OuterComponent;
|
|
|
|
impl Component for OuterComponent {
|
|
fn view(&mut self, ctx: &mut arkham::ui::Context) -> Result<()> {
|
|
ctx.view
|
|
.fill_all(*Cell::default().content(' ').bg(Color::Red));
|
|
ctx.add_component(Rect::new(20, 20, 40, 40), &mut InnerComponent)?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub struct InnerComponent;
|
|
|
|
impl Component for InnerComponent {
|
|
fn view(&mut self, ctx: &mut arkham::ui::Context) -> Result<()> {
|
|
ctx.view
|
|
.fill_all(*Cell::default().content(' ').bg(Color::Green));
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
UI::new(OuterComponent).run().expect("Couldnt run UI loop");
|
|
}
|