sao-ui-rs/src/lib.rs

58 lines
1018 B
Rust
Raw Normal View History

2022-07-07 18:39:21 +00:00
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
2022-07-08 18:48:31 +00:00
pub use glam::Vec2;
2022-07-07 18:39:21 +00:00
2022-07-08 18:48:31 +00:00
pub mod abi;
2022-07-08 19:48:32 +00:00
pub mod anim;
2022-07-08 18:48:31 +00:00
pub mod draw;
pub mod panel;
pub mod widgets;
2022-07-07 18:39:21 +00:00
2022-07-08 18:48:31 +00:00
use abi::UiPanel;
use widgets::Widget;
2022-07-07 18:39:21 +00:00
pub struct DummyPanel {
panel: UiPanel,
2022-07-09 22:56:19 +00:00
menu: widgets::MainMenu,
2022-07-07 18:39:21 +00:00
}
impl DummyPanel {
fn bind(panel: UiPanel) -> Self {
2022-07-09 22:56:19 +00:00
Self {
panel,
menu: widgets::MainMenu::default(),
2022-07-08 18:48:31 +00:00
}
2022-07-07 18:39:21 +00:00
}
}
2022-07-08 18:48:31 +00:00
impl abi::PanelImpl for DummyPanel {
fn update(&mut self, dt: f32) {
2022-07-09 22:56:19 +00:00
self.menu.update(dt);
2022-07-08 18:48:31 +00:00
let ctx = draw::DrawContext::new(self.panel);
2022-07-09 22:56:19 +00:00
self.menu.draw(&ctx);
2022-07-08 18:48:31 +00:00
}
2022-07-08 19:48:32 +00:00
fn on_cursor_event(&mut self, kind: CursorEventKind, at: Vec2) {
2022-07-09 22:56:19 +00:00
self.menu.on_cursor_event(kind, at);
2022-07-08 19:48:32 +00:00
}
2022-07-07 18:39:21 +00:00
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
2022-07-08 19:48:32 +00:00
2022-07-10 18:35:40 +00:00
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2022-07-08 19:48:32 +00:00
pub enum CursorEventKind {
Hover,
Select,
Drag,
Deselect,
}