use macroquad::prelude::*;
use super::TextBoxBase;
#[derive(Clone)]
pub struct TextBox {
pub text: String,
pub uuid: &'static str,
pub queue_free: bool,
pub rect: Rect,
pub base: TextBoxBase
}
impl TextBox {
pub fn new(
text: &str,
placeholder: &str,
size: (f32, f32),
font: Option<Font>,
uuid: Option<&'static str>,
) -> Self {
let rect = Rect::new(0.,0.,size.0, size.1);
Self {
text: text.to_string(),
uuid: uuid.unwrap_or(""),
rect,
queue_free: false,
base: TextBoxBase::new(rect, placeholder, font)
}
}
pub fn set_uuid(&mut self, uuid: &'static str) -> &mut Self {
self.uuid = uuid;
self
}
pub fn update(&mut self, selected: bool) {
self.base.rect = self.rect;
self.base.update(selected);
self.text = self.base.text.clone();
}
pub fn render(&mut self) {
self.base.rect = self.rect;
self.base.render();
}
}