use iced_core::{Color, Font};
use crate::core::Offset;
use crate::style::default_colors;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Align {
Start,
End,
Center,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Placement {
BothSides {
inside: bool,
offset: Offset,
},
LeftOrTop {
inside: bool,
offset: Offset,
},
RightOrBottom {
inside: bool,
offset: Offset,
},
Center {
align: Align,
offset: Offset,
},
}
impl std::default::Default for Placement {
fn default() -> Self {
Placement::LeftOrTop {
inside: false,
offset: Default::default(),
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct Appearance {
pub color: Color,
pub text_size: u16,
pub font: Font,
pub bounds_width: u16,
pub bounds_height: u16,
}
impl std::cmp::PartialEq for Appearance {
fn eq(&self, rhs: &Appearance) -> bool {
self.color == rhs.color
&& self.text_size == rhs.text_size
&& self.bounds_width == rhs.bounds_width
&& self.bounds_height == rhs.bounds_width
&& match self.font {
Font::Default => matches!(rhs.font, Font::Default),
Font::External { name, .. } => {
let self_name = name;
match rhs.font {
Font::Default => false,
Font::External { name, .. } => self_name == name,
}
}
}
}
}
impl Default for Appearance {
fn default() -> Self {
Self {
color: default_colors::TEXT_MARK,
text_size: 12,
font: Default::default(),
bounds_width: 30,
bounds_height: 14,
}
}
}