pub struct FlowCanvas {
pub graph: Graph,
pub history: Box<dyn HistoryProvider>,
pub event_queue: Vec<FlowEvent>,
pub port_offset_cache: PortLayoutCache,
pub theme: FlowTheme,
/* private fields */
}Fields§
§graph: Graph§history: Box<dyn HistoryProvider>§event_queue: Vec<FlowEvent>§port_offset_cache: PortLayoutCache§theme: FlowThemeVisual tokens for canvas chrome; plugins adjust via InitPluginContext::theme.
Implementations§
Source§impl FlowCanvas
impl FlowCanvas
pub fn new(graph: Graph, cx: &mut Context<'_, Self>) -> Self
Sourcepub fn builder<'a, 'b>(
graph: Graph,
ctx: &'a mut Context<'b, Self>,
window: &'a Window,
) -> FlowCanvasBuilder<'a, 'b>
pub fn builder<'a, 'b>( graph: Graph, ctx: &'a mut Context<'b, Self>, window: &'a Window, ) -> FlowCanvasBuilder<'a, 'b>
Examples found in repository?
examples/extension.rs (line 35)
8fn main() {
9 Application::new().run(|cx| {
10 let mut graph = Graph::new();
11
12 graph
13 .create_node("number")
14 .position(100.0, 100.0)
15 .size(300.0, 150.0)
16 .output()
17 .data(json!({ "label": "Number Node" }))
18 .build(&mut graph);
19
20 graph
21 .create_node("")
22 .position(300.0, 400.0)
23 .input()
24 .build(&mut graph);
25
26 graph
27 .create_node("undefined")
28 .position(500.0, 500.0)
29 .input()
30 .output()
31 .build(&mut graph);
32
33 cx.open_window(WindowOptions::default(), |window, cx| {
34 cx.new(|ctx| {
35 FlowCanvas::builder(graph, ctx, window)
36 .plugins_core()
37 .plugin(SnapGuidesPlugin::new())
38 .plugin(ZoomControlsPlugin::new())
39 .plugin(FocusSelectionPlugin::new())
40 .plugin(FitAllGraphPlugin::new())
41 .plugin(ClipboardPlugin::new())
42 .plugin(ContextMenuPlugin::new())
43 .node_renderer("number", NumberNode {})
44 .build()
45 })
46 })
47 .unwrap();
48 });
49}More examples
examples/bench.rs (line 27)
5fn main() {
6 Application::new().run(|cx| {
7 let mut graph = Graph::new();
8
9 for j in 0..100 {
10 for i in 0..100 {
11 graph
12 .create_node("")
13 .position(200.0 * i as f32, 200.0 * j as f32)
14 .input()
15 .output()
16 .data(json!({ "label": format!("Node {}", i * 100 + j) }))
17 .build(&mut graph);
18 }
19 }
20
21 let node_ids = graph.nodes().iter().map(|(id, _)| *id).collect::<Vec<_>>();
22
23 generate_chain_edges(&mut graph, node_ids);
24
25 cx.open_window(WindowOptions::default(), |window, cx| {
26 cx.new(|ctx| {
27 FlowCanvas::builder(graph, ctx, window)
28 .plugins_core()
29 .plugin(MinimapPlugin::new())
30 .plugin(ClipboardPlugin::new())
31 .plugin(ContextMenuPlugin::new())
32 .plugin(SelectAllViewportPlugin::new())
33 .plugin(AlignPlugin::new())
34 .plugin(FocusSelectionPlugin::new())
35 .plugin(FitAllGraphPlugin::new())
36 .plugin(SnapGuidesPlugin::new())
37 .plugin(ZoomControlsPlugin::new())
38 .build()
39 })
40 })
41 .unwrap();
42 });
43}examples/theme.rs (line 61)
47fn main() {
48 Application::new().run(|cx| {
49 let mut graph = Graph::new();
50
51 graph
52 .create_node("")
53 .position(100.0, 100.0)
54 .output()
55 .output()
56 .data(json!({ "label": "Themed" }))
57 .build(&mut graph);
58
59 cx.open_window(WindowOptions::default(), |window, cx| {
60 cx.new(|ctx| {
61 FlowCanvas::builder(graph, ctx, window)
62 .plugin(DarkGridThemePlugin)
63 .plugin(MinimapPlugin::new())
64 .plugin(SelectionPlugin::new())
65 .plugin(NodeInteractionPlugin::new())
66 .plugin(SnapGuidesPlugin::new())
67 .plugin(ViewportPlugin::new())
68 .plugin(ZoomControlsPlugin::new())
69 .plugin(BackgroundPlugin::new())
70 .plugin(NodePlugin::new())
71 .plugin(PortInteractionPlugin::new())
72 .plugin(EdgePlugin::new())
73 .plugin(ClipboardPlugin::new())
74 .plugin(ContextMenuPlugin::new())
75 .plugin(SelectAllViewportPlugin::new())
76 .plugin(AlignPlugin::new())
77 .plugin(FocusSelectionPlugin::new())
78 .plugin(FitAllGraphPlugin::new())
79 .plugin(DeletePlugin::new())
80 .plugin(HistoryPlugin::new())
81 .build()
82 })
83 })
84 .unwrap();
85 });
86}examples/basic.rs (line 41)
5fn main() {
6 Application::new().run(|cx| {
7 let mut graph = Graph::new();
8
9 graph
10 .create_node("")
11 .position(100.0, 100.0)
12 .output()
13 .output()
14 .output_with(PortPosition::Bottom, Size::new(px(20.0), px(20.0)))
15 .output_at(PortPosition::Bottom)
16 .data(json!({ "label": "Node 1" }))
17 .build(&mut graph);
18
19 graph
20 .create_node("")
21 .position(300.0, 400.0)
22 .input()
23 .input_at(PortPosition::Top)
24 .input_at(PortPosition::Top)
25 .output()
26 .output_at(PortPosition::Bottom)
27 .output_at(PortPosition::Bottom)
28 .data(json!({ "label": "Node 2" }))
29 .build(&mut graph);
30
31 graph
32 .create_node("")
33 .position(500.0, 500.0)
34 .input()
35 .output()
36 .data(json!({ "label": "Node 3" }))
37 .build(&mut graph);
38
39 cx.open_window(WindowOptions::default(), |window, cx| {
40 cx.new(|ctx| {
41 FlowCanvas::builder(graph, ctx, window)
42 .plugins_core()
43 .plugin(MinimapPlugin::new())
44 .plugin(SnapGuidesPlugin::new())
45 .plugin(ZoomControlsPlugin::new())
46 .plugin(ClipboardPlugin::new())
47 .plugin(ContextMenuPlugin::new())
48 .plugin(SelectAllViewportPlugin::new())
49 .plugin(AlignPlugin::new())
50 .plugin(FocusSelectionPlugin::new())
51 .plugin(FitAllGraphPlugin::new())
52 .build()
53 })
54 })
55 .unwrap();
56 });
57}pub fn handle_event(&mut self, event: FlowEvent, cx: &mut Context<'_, Self>)
Trait Implementations§
Source§impl Render for FlowCanvas
impl Render for FlowCanvas
Auto Trait Implementations§
impl Freeze for FlowCanvas
impl !RefUnwindSafe for FlowCanvas
impl !Send for FlowCanvas
impl !Sync for FlowCanvas
impl Unpin for FlowCanvas
impl UnsafeUnpin for FlowCanvas
impl !UnwindSafe for FlowCanvas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more