use super::{Color, TextUi};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SocketUI {
pub name: TextUi,
pub side: NodeSide,
pub is_connected: bool,
pub color: Color,
pub shape: SocketShape,
}
impl SocketUI {
#[inline]
#[must_use]
pub fn new(side: NodeSide, is_connected: bool) -> Self {
Self {
name: TextUi::default(),
side,
is_connected,
color: Color::WHITE,
shape: SocketShape::default(),
}
}
#[inline]
#[must_use]
pub fn with_name(mut self, name: impl Into<TextUi>) -> Self {
self.name = name.into();
self
}
#[inline]
#[must_use]
pub fn with_color(mut self, color: impl Into<Color>) -> Self {
self.color = color.into();
self
}
#[inline]
#[must_use]
pub fn with_shape(mut self, shape: SocketShape) -> Self {
self.shape = shape;
self
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SocketShape {
#[default]
Circle,
Square,
Triangle,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum NodeSide {
Left,
Right,
}