use crate::{
font::Font,
maths::{Matrix, Quat, Vec3},
prelude::*,
system::{Text, TextStyle},
util::{Color32, named_colors},
};
#[derive(IStepper, Clone)]
pub struct Title {
id: StepperId,
sk_info: Option<Rc<RefCell<SkInfo>>>,
pub transform: Matrix,
pub text: String,
pub text_style: Option<TextStyle>,
}
unsafe impl Send for Title {}
impl Default for Title {
fn default() -> Self {
Self {
id: "Title".to_string(),
sk_info: None,
transform: Matrix::t_r((Vec3::NEG_Z * 0.5) + Vec3::Y, Quat::from_angles(0.0, 180.0, 0.0)),
text: "Title".to_owned(),
text_style: None,
}
}
}
impl Title {
pub fn new(text: &str, color: Option<Color32>, font_size: Option<f32>, font: Option<Font>) -> Self {
let mut title = Self { text: text.into(), ..Default::default() };
let font = font.unwrap_or_default();
let font_size = font_size.unwrap_or(0.5);
let color = color.unwrap_or(named_colors::WHITE);
title.text_style = Some(Text::make_style(font, font_size, color));
title
}
fn start(&mut self) -> bool {
true
}
fn check_event(&mut self, _id: &StepperId, _key: &str, _value: &str) {
}
fn draw(&mut self, token: &MainThreadToken) {
Text::add_at(token, &self.text, self.transform, self.text_style, None, None, None, None, None, None);
}
}