use day_spec::{Font, FontWeight, Insets};
use crate::IntoInsets;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Space {
XS,
S,
M,
L,
XL,
}
impl Space {
pub const fn points(self) -> f64 {
match self {
Space::XS => 4.0,
Space::S => 8.0,
Space::M => 12.0,
Space::L => 16.0,
Space::XL => 24.0,
}
}
}
impl From<Space> for f64 {
fn from(s: Space) -> f64 {
s.points()
}
}
impl IntoInsets for Space {
fn into_insets(self) -> Insets {
Insets::all(self.points())
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct TextPreset {
pub(crate) font: Font,
pub(crate) font_scale: f64,
pub(crate) weight: Option<FontWeight>,
pub(crate) italic: bool,
pub(crate) tabular: bool,
pub(crate) monospace: bool,
pub(crate) secondary: bool,
pub(crate) single_line: bool,
pub(crate) color: Option<day_spec::Color>,
}
impl TextPreset {
pub const fn new(font: Font) -> TextPreset {
TextPreset {
font,
font_scale: 1.0,
weight: None,
italic: false,
tabular: false,
monospace: false,
secondary: false,
single_line: false,
color: None,
}
}
pub const fn font_scale(mut self, scale: f64) -> TextPreset {
self.font_scale = scale;
self
}
pub const fn weight(mut self, weight: FontWeight) -> TextPreset {
self.weight = Some(weight);
self
}
pub const fn bold(self) -> TextPreset {
self.weight(FontWeight::Bold)
}
pub const fn italic(mut self) -> TextPreset {
self.italic = true;
self
}
pub const fn tabular(mut self) -> TextPreset {
self.tabular = true;
self
}
pub const fn monospace(mut self) -> TextPreset {
self.monospace = true;
self
}
pub const fn secondary(mut self) -> TextPreset {
self.secondary = true;
self
}
pub const fn single_line(mut self) -> TextPreset {
self.single_line = true;
self
}
pub const fn color(mut self, color: day_spec::Color) -> TextPreset {
self.color = Some(color);
self
}
}