pub struct AlignPlugin;Expand description
Align selected nodes to their shared bounding box (⌘⇧L/R/T/B/H/V or Ctrl⇧…).
Implementations§
Source§impl AlignPlugin
impl AlignPlugin
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/bench.rs (line 33)
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}More examples
examples/theme.rs (line 76)
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 49)
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}Trait Implementations§
Source§impl Plugin for AlignPlugin
impl Plugin for AlignPlugin
fn name(&self) -> &'static str
fn setup(&mut self, _ctx: &mut InitPluginContext<'_, '_>)
fn priority(&self) -> i32
fn on_event( &mut self, event: &FlowEvent, ctx: &mut PluginContext<'_>, ) -> EventResult
fn render(&mut self, _ctx: &mut RenderContext<'_>) -> Option<AnyElement>
fn render_layer(&self) -> RenderLayer
Auto Trait Implementations§
impl Freeze for AlignPlugin
impl RefUnwindSafe for AlignPlugin
impl Send for AlignPlugin
impl Sync for AlignPlugin
impl Unpin for AlignPlugin
impl UnsafeUnpin for AlignPlugin
impl UnwindSafe for AlignPlugin
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> DowncastSync for T
impl<T> DowncastSync for T
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