use super::{DebugWidget, Widget};
use crate::{
graphics::{Shape, Size},
theme::TextTheme,
ToAny,
};
#[derive(Debug, Clone, PartialEq)]
pub struct Label {
pub text: String,
pub theme: TextTheme,
}
crate::dynamic_widget!(Label);
impl Widget for Label {
fn shape(&self, _size: Option<Size>) -> Shape {
panic!("cannot return shape for label");
}
}
impl Default for Label {
fn default() -> Self {
Self {
text: String::new(),
theme: TextTheme::default(),
}
}
}
impl Label {
pub fn new(text: &str, theme: TextTheme) -> Self {
Self {
text: text.to_string(),
theme,
}
}
pub fn simple(text: &str) -> Self {
Self {
text: text.to_string(),
..Self::default()
}
}
}