#[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; pub use glam::Vec2; pub mod abi; pub mod anim; pub mod draw; pub mod panel; pub mod widgets; use abi::UiPanel; use widgets::Widget; pub struct DummyPanel { panel: UiPanel, menu: widgets::MainMenu, } impl DummyPanel { fn bind(panel: UiPanel) -> Self { Self { panel, menu: widgets::MainMenu::default(), } } } impl abi::PanelImpl for DummyPanel { fn update(&mut self, dt: f32) { self.menu.update(dt); let ctx = draw::DrawContext::new(self.panel); self.menu.draw(&ctx); } fn on_cursor_event(&mut self, kind: CursorEventKind, at: Vec2) { self.menu.on_cursor_event(kind, at); } } #[repr(C)] #[derive(Copy, Clone, Debug)] pub struct Color { pub r: f32, pub g: f32, pub b: f32, pub a: f32, } impl Color { pub const WHITE: Self = Self::new(1., 1., 1., 1.); pub const BLACK: Self = Self::new(0., 0., 0., 1.); pub const TRANSPARENT: Self = Self::new(0., 0., 0., 0.); pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self { Self { r, g, b, a } } } impl From for Color { fn from(other: glam::Vec4) -> Self { let glam::Vec4 { x, y, z, w } = other; Self::new(x, y, z, w) } } impl From for glam::Vec4 { fn from(other: Color) -> Self { let Color { r, g, b, a } = other; Self::new(r, g, b, a) } } #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum CursorEventKind { Hover, Select, Drag, Deselect, }