use iced::Color;
use super::ColorQuad;
use super::PinShape;
#[derive(Debug, Clone, PartialEq)]
pub struct PinStyle {
pub color: ColorQuad,
pub radius: f32,
pub shape: PinShape,
pub border_color: ColorQuad,
pub border_width: f32,
}
impl PinStyle {
pub fn data() -> Self {
Self {
color: ColorQuad::solid(Color::from_rgb(0.3, 0.6, 1.0)),
radius: 6.0,
shape: PinShape::Circle,
border_color: ColorQuad::solid(Color::from_rgb(0.5, 0.7, 1.0)),
border_width: 1.0,
}
}
pub fn execution() -> Self {
Self {
color: ColorQuad::solid(Color::WHITE),
radius: 7.0,
shape: PinShape::Triangle,
border_color: ColorQuad::solid(Color::TRANSPARENT),
border_width: 0.0,
}
}
pub fn control() -> Self {
Self {
color: ColorQuad::solid(Color::from_rgb(1.0, 0.85, 0.3)),
radius: 6.0,
shape: PinShape::Diamond,
border_color: ColorQuad::solid(Color::from_rgb(1.0, 0.95, 0.6)),
border_width: 1.0,
}
}
pub fn event() -> Self {
Self {
color: ColorQuad::solid(Color::from_rgb(0.3, 0.8, 0.4)),
radius: 5.0,
shape: PinShape::Square,
border_color: ColorQuad::solid(Color::from_rgb(0.5, 0.9, 0.6)),
border_width: 1.0,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn struct_update_overrides_over_default() {
use crate::style::{PinStatus, default_pin_style};
let base = default_pin_style(&iced::Theme::Dark, PinStatus::Idle);
let style = PinStyle {
radius: 10.0,
shape: PinShape::Square,
..base.clone()
};
assert_eq!(style.radius, 10.0); assert_eq!(style.shape, PinShape::Square); assert_eq!(style.color, base.color); }
}