use crate::style::Color;
use crate::widget::theme::MUTED_TEXT;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum DiagramType {
#[default]
Flowchart,
Sequence,
Tree,
Er,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NodeShape {
#[default]
Rectangle,
Rounded,
Diamond,
Circle,
Parallelogram,
Database,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ArrowStyle {
#[default]
Solid,
Dashed,
Thick,
Line,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Direction {
#[default]
TopDown,
LeftRight,
BottomUp,
RightLeft,
}
#[derive(Clone, Debug)]
pub struct DiagramNode {
pub id: String,
pub label: String,
pub shape: NodeShape,
pub color: Option<Color>,
pub bg: Option<Color>,
}
impl DiagramNode {
pub fn new(id: impl Into<String>, label: impl Into<String>) -> Self {
Self {
id: id.into(),
label: label.into(),
shape: NodeShape::default(),
color: None,
bg: None,
}
}
pub fn shape(mut self, shape: NodeShape) -> Self {
self.shape = shape;
self
}
pub fn color(mut self, color: Color) -> Self {
self.color = Some(color);
self
}
pub fn bg(mut self, color: Color) -> Self {
self.bg = Some(color);
self
}
}
#[derive(Clone, Debug)]
pub struct DiagramEdge {
pub from: String,
pub to: String,
pub label: Option<String>,
pub style: ArrowStyle,
}
impl DiagramEdge {
pub fn new(from: impl Into<String>, to: impl Into<String>) -> Self {
Self {
from: from.into(),
to: to.into(),
label: None,
style: ArrowStyle::default(),
}
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn style(mut self, style: ArrowStyle) -> Self {
self.style = style;
self
}
}
#[derive(Clone, Debug)]
pub struct DiagramColors {
pub node_fg: Color,
pub node_bg: Color,
pub arrow: Color,
pub label: Color,
pub title: Color,
}
impl Default for DiagramColors {
fn default() -> Self {
Self {
node_fg: Color::WHITE,
node_bg: Color::rgb(40, 60, 80),
arrow: Color::rgb(100, 150, 200),
label: MUTED_TEXT,
title: Color::CYAN,
}
}
}