use serde::{Serialize, Deserialize};
use wgpu::{Device, Queue, RenderPass};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum TextAlign {
Left,
Center,
Right,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Label {
pub x: f32,
pub y: f32,
pub width: Option<f32>,
pub height: Option<f32>,
pub text: String,
pub color: [f32; 4],
pub font_size: f32,
pub align: TextAlign,
}
impl Label {
pub fn new(x: f32, y: f32, text: &str) -> Self {
Self {
x,
y,
width: None,
height: None,
text: text.to_string(),
color: [1.0, 1.0, 1.0, 1.0], font_size: 16.0, align: TextAlign::Left,
}
}
pub fn set_color(&mut self, color: [f32; 4]) -> &mut Self {
self.color = color;
self
}
pub fn set_font_size(&mut self, font_size: f32) -> &mut Self {
self.font_size = font_size;
self
}
pub fn set_align(&mut self, align: TextAlign) -> &mut Self {
self.align = align;
self
}
pub fn set_size(&mut self, width: f32, height: f32) -> &mut Self {
self.width = Some(width);
self.height = Some(height);
self
}
pub fn set_text(&mut self, text: &str) -> &mut Self {
self.text = text.to_string();
self
}
pub fn render(&self, device: &Device, queue: &Queue, render_pass: &mut RenderPass) {
}
}