Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/egui_graphs/src/elements/edge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::marker::PhantomData;

use egui::Color32;
use petgraph::{
stable_graph::{DefaultIx, EdgeIndex, IndexType},
Directed, EdgeType,
Expand All @@ -15,6 +16,17 @@ pub struct EdgeProps<E: Clone> {
pub order: usize,
pub selected: bool,
pub label: String,

color: Option<Color32>,
}

impl<E> EdgeProps<E>
where
E: Clone,
{
pub fn color(&self) -> Option<Color32> {
self.color
}
}

/// Stores properties of an edge that can be changed. Used to apply changes to the graph.
Expand Down Expand Up @@ -51,6 +63,7 @@ impl<
order: usize::default(),
selected: bool::default(),
label: String::default(),
color: None,
};

let display = D::from(props.clone());
Expand Down Expand Up @@ -115,4 +128,16 @@ impl<
pub fn label(&self) -> String {
self.props.label.clone()
}

pub fn color(&self) -> Option<Color32> {
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;
}
}
4 changes: 4 additions & 0 deletions crates/egui_graphs/src/elements/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down