Skip to content

Commit

Permalink
Clone for graph + doc for csutom draw (#86)
Browse files Browse the repository at this point in the history
Solves #85
  • Loading branch information
blitzarx1 authored Oct 4, 2023
1 parent e600159 commit aee1e91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "egui_graphs"
version = "0.13.0"
version = "0.13.1"
authors = ["Dmitrii Samsonov <[email protected]>"]
license = "MIT"
homepage = "https://github.com/blitzarx1/egui_graphs"
Expand Down
8 changes: 7 additions & 1 deletion src/draw/drawer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ use super::layers::Layers;
/// Mapping for 2 nodes and all edges between them
type EdgeMap<'a, E> = HashMap<(NodeIndex, NodeIndex), Vec<Edge<E>>>;

/// Custom node draw function
/// Custom node draw function. Allows to fully customize what shaped would be drawn for node.
/// The function is called for every node in the graph. Parmaeters:
/// - `ctx` - egui context, is needed for computing node props and styles;
/// - `n` - node reference, contains all node data;
/// - `meta` - metadata, contains current zoom level and pan;
/// - `style` - style settings, contains all style settings;
/// - `l` - drawing layers, contains all shapes which will be drawn. When you create a shape, add it to the layers.
pub type FnCustomNodeDraw<N> = fn(&Context, n: &Node<N>, &Metadata, &SettingsStyle, &mut Layers);

pub struct Drawer<'a, N: Clone, E: Clone, Ty: EdgeType> {
Expand Down
1 change: 1 addition & 0 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use petgraph::{
use crate::{metadata::Metadata, transform, Edge, Node, SettingsStyle};

/// Graph type compatible with [`super::GraphView`].
#[derive(Debug, Clone)]
pub struct Graph<N: Clone, E: Clone, Ty: EdgeType> {
pub g: StableGraph<Node<N>, Edge<E>, Ty>,
}
Expand Down

0 comments on commit aee1e91

Please sign in to comment.