use embedded_graphics_core::pixelcolor::Rgb565;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum DisplayMode {
#[default]
Normal,
Stealth,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InkRole {
Background,
Primary,
Highlight,
Accent,
Muted,
}
#[derive(Clone, Copy, Debug)]
pub struct DisplayPalette {
pub mode: DisplayMode,
pub normal: RoleColors,
pub stealth: RoleColors,
}
#[derive(Clone, Copy, Debug)]
pub struct RoleColors {
pub background: Rgb565,
pub primary: Rgb565,
pub highlight: Rgb565,
pub accent: Rgb565,
pub muted: Rgb565,
}
impl RoleColors {
pub const fn new(
background: Rgb565,
primary: Rgb565,
highlight: Rgb565,
accent: Rgb565,
muted: Rgb565,
) -> Self {
Self {
background,
primary,
highlight,
accent,
muted,
}
}
pub const fn resolve(self, role: InkRole) -> Rgb565 {
match role {
InkRole::Background => self.background,
InkRole::Primary => self.primary,
InkRole::Highlight => self.highlight,
InkRole::Accent => self.accent,
InkRole::Muted => self.muted,
}
}
}
impl DisplayPalette {
pub const fn new(normal: RoleColors, stealth: RoleColors) -> Self {
Self {
mode: DisplayMode::Normal,
normal,
stealth,
}
}
pub const fn with_mode(self, mode: DisplayMode) -> Self {
Self { mode, ..self }
}
pub fn set_mode(&mut self, mode: DisplayMode) {
self.mode = mode;
}
pub fn resolve(&self, role: InkRole) -> Rgb565 {
match self.mode {
DisplayMode::Normal => self.normal.resolve(role),
DisplayMode::Stealth => self.stealth.resolve(role),
}
}
}