43 lines
863 B
Rust
43 lines
863 B
Rust
#[global_allocator]
|
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
|
|
pub mod anim;
|
|
pub mod draw;
|
|
pub mod panel;
|
|
pub mod widgets;
|
|
|
|
use canary_script::*;
|
|
use glam::Vec2;
|
|
use widgets::Widget;
|
|
|
|
export_abi!(DummyPanel);
|
|
|
|
pub struct DummyPanel {
|
|
panel: Panel,
|
|
menu: widgets::MainMenu,
|
|
}
|
|
|
|
impl BindPanel for DummyPanel {
|
|
fn bind(panel: Panel) -> Box<dyn PanelImpl> {
|
|
Box::new(Self {
|
|
panel,
|
|
menu: widgets::MainMenu::default(),
|
|
})
|
|
}
|
|
}
|
|
|
|
impl PanelImpl for DummyPanel {
|
|
fn update(&mut self, dt: f32) {
|
|
self.menu.update(dt);
|
|
}
|
|
|
|
fn draw(&mut self) {
|
|
let ctx = draw::DrawContext::new(self.panel);
|
|
self.menu.draw(&ctx);
|
|
}
|
|
|
|
fn on_cursor_event(&mut self, kind: CursorEventKind, at: canary_script::Vec2) {
|
|
self.menu.on_cursor_event(kind, at.into());
|
|
}
|
|
}
|