use crate::tokens::DESIGN_TOKENS;
use egui::Color32;
#[derive(Clone, Debug)]
pub struct EraserConfig {
pub highlight_color: Color32,
pub highlight_stroke: f32,
}
impl Default for EraserConfig {
fn default() -> Self {
let bearish = DESIGN_TOKENS.semantic.extended.bearish;
Self {
highlight_color: Color32::from_rgba_unmultiplied(
bearish.r(),
bearish.g(),
bearish.b(),
180,
), highlight_stroke: 3.0,
}
}
}
#[derive(Clone, Debug, Default)]
pub struct EraserMode {
pub active: bool,
pub hover_drawing: Option<usize>,
pub config: EraserConfig,
}
impl EraserMode {
pub fn new() -> Self {
Self::default()
}
pub fn set_active(&mut self, active: bool) {
self.active = active;
if !active {
self.hover_drawing = None;
}
}
pub fn set_hover(&mut self, drawing_id: Option<usize>) {
if self.active {
self.hover_drawing = drawing_id;
}
}
pub fn should_highlight(&self, drawing_id: usize) -> bool {
self.active && self.hover_drawing == Some(drawing_id)
}
pub fn highlight_color(&self) -> Color32 {
self.config.highlight_color
}
pub fn highlight_stroke(&self) -> f32 {
self.config.highlight_stroke
}
pub fn clear(&mut self) {
self.hover_drawing = None;
}
}