diff --git a/crates/egui_graphs/src/elements/edge.rs b/crates/egui_graphs/src/elements/edge.rs index 752b333..42a62b8 100644 --- a/crates/egui_graphs/src/elements/edge.rs +++ b/crates/egui_graphs/src/elements/edge.rs @@ -1,5 +1,6 @@ use std::marker::PhantomData; +use egui::Color32; use petgraph::{ stable_graph::{DefaultIx, EdgeIndex, IndexType}, Directed, EdgeType, @@ -15,6 +16,17 @@ pub struct EdgeProps { pub order: usize, pub selected: bool, pub label: String, + + color: Option, +} + +impl EdgeProps +where + E: Clone, +{ + pub fn color(&self) -> Option { + self.color + } } /// Stores properties of an edge that can be changed. Used to apply changes to the graph. @@ -51,6 +63,7 @@ impl< order: usize::default(), selected: bool::default(), label: String::default(), + color: None, }; let display = D::from(props.clone()); @@ -115,4 +128,16 @@ impl< pub fn label(&self) -> String { self.props.label.clone() } + + pub fn color(&self) -> Option { + self.props.color() + } + + pub fn set_color(&mut self, color: Color32) { + self.props.color = Some(color); + } + + pub fn unset_color(&mut self) { + self.props.color = None; + } } diff --git a/crates/egui_graphs/src/elements/node.rs b/crates/egui_graphs/src/elements/node.rs index a8dc6bd..6a62c7e 100644 --- a/crates/egui_graphs/src/elements/node.rs +++ b/crates/egui_graphs/src/elements/node.rs @@ -161,6 +161,10 @@ where self.props.color = Some(color); } + pub fn unset_color(&mut self) { + self.props.color = None; + } + pub fn location(&self) -> Pos2 { self.props.location() }