41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
#[global_allocator]
|
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
|
|
use canary_script::{BindPanel, CursorEventKind, Color, TextLayout, Font, Message, Panel, PanelImpl, Vec2};
|
|
|
|
canary_script::export_abi!(MusicPlayerPanel);
|
|
|
|
const DISPLAY_FONT: &str = "Liberation Sans";
|
|
|
|
pub struct MusicPlayerPanel {
|
|
panel: Panel,
|
|
display_font: Font,
|
|
}
|
|
|
|
impl BindPanel for MusicPlayerPanel {
|
|
fn bind(panel: Panel, message: Message) -> Box<dyn PanelImpl> {
|
|
let display_font = Font::new(DISPLAY_FONT);
|
|
let panel = Self {
|
|
panel,
|
|
display_font,
|
|
};
|
|
Box::new(panel)
|
|
}
|
|
}
|
|
|
|
impl PanelImpl for MusicPlayerPanel {
|
|
fn update(&mut self, dt: f32) {}
|
|
|
|
fn draw(&mut self) {
|
|
let layout = TextLayout::new(&self.display_font, "Hello world!");
|
|
let offset = Vec2 { x: 0.0, y: 0.0 };
|
|
let scale = 0.1;
|
|
let color = Color::WHITE;
|
|
self.panel.draw_text_layout(&layout, offset, scale, color);
|
|
}
|
|
|
|
fn on_cursor_event(&mut self, kind: CursorEventKind, at: Vec2) {}
|
|
|
|
fn on_message(&mut self, message: Message) {}
|
|
}
|