Skip to main content

FlowCanvas

Struct FlowCanvas 

Source
pub struct FlowCanvas { /* private fields */ }

Implementations§

Source§

impl FlowCanvas

Source

pub fn new( id: impl Into<SharedString>, graph: Graph, cx: &mut Context<'_, FlowCanvas>, ) -> FlowCanvas

Source

pub fn renderer( self, kind: impl Into<Arc<str>>, renderer: impl NodeRenderer, ) -> FlowCanvas

为某种 Node::kind 注册渲染器。

Source

pub fn validator( self, validator: impl ConnectionValidator + 'static, ) -> FlowCanvas

连线校验器,默认 DefaultValidator(允许成环);工作流可用 DefaultValidator::dag()。

Source

pub fn new_edge_shape(self, shape: EdgeShape) -> FlowCanvas

新建连线的形状。

Source

pub fn snap_to_grid(self, grid: Option<f32>) -> FlowCanvas

拖拽时吸附到网格(世界 px)。

Source

pub fn align_guides(self, enabled: bool) -> FlowCanvas

首次布局后自动适配视图。 拖动节点时与其他节点的边线 / 中线对齐并画参考线(默认开启)。

Source

pub fn minimap(self, show: bool) -> FlowCanvas

右下角小地图(点击或拖动可移动视口)。

Source

pub fn controls(self, show: bool) -> FlowCanvas

左下角控件栏:放大、缩小、适配视图、锁定编辑。

Source

pub fn on_context_menu( self, handler: impl Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App) + 'static, ) -> FlowCanvas

右键回调:给出目标与窗口坐标,调用方据此弹出菜单。

Source

pub fn fit_on_mount(self) -> FlowCanvas

Source

pub fn initial_viewport(self, viewport: Viewport) -> FlowCanvas

Source

pub fn on_viewport_change( self, handler: impl Fn(&Viewport, &mut Window, &mut App) + 'static, ) -> FlowCanvas

Source

pub fn on_connect_error( self, handler: impl Fn(&ConnectError, &mut Window, &mut App) + 'static, ) -> FlowCanvas

连线被拒时回调(F5 接 toast)。

Source

pub fn graph(&self) -> &Graph

Source

pub fn update_graph<R>( &mut self, cx: &mut Context<'_, FlowCanvas>, f: impl FnOnce(&mut Graph) -> R, ) -> R

直接修改图(运行状态等,不进撤销历史);结束后自动重绘。

Source

pub fn commit( &mut self, op: GraphOp, label: &'static str, cx: &mut Context<'_, FlowCanvas>, ) -> Result<(), GraphError>

应用一个可撤销的操作。

Source

pub fn history(&self) -> &History

Source

pub fn undo(&mut self, cx: &mut Context<'_, FlowCanvas>)

Source

pub fn redo(&mut self, cx: &mut Context<'_, FlowCanvas>)

Source

pub fn selection(&self) -> &HashSet<NodeId>

Source

pub fn edge_selection(&self) -> &HashSet<EdgeId>

Source

pub fn select_edges( &mut self, ids: impl IntoIterator<Item = EdgeId>, cx: &mut Context<'_, FlowCanvas>, )

Source

pub fn select( &mut self, ids: impl IntoIterator<Item = NodeId>, cx: &mut Context<'_, FlowCanvas>, )

Source

pub fn connect_drag(&self) -> Option<&ConnectDrag>

正在进行的连线草稿(测试与外部提示用)。

Source

pub fn last_connect_error(&self) -> Option<&ConnectError>

Source

pub fn interactive(&self) -> bool

是否允许编辑(拖动、连线、删除、粘贴、选择)。锁定时仍可平移缩放。

Source

pub fn set_interactive( &mut self, interactive: bool, cx: &mut Context<'_, FlowCanvas>, )

Source

pub fn guides(&self) -> &[Guide]

当前绘制中的对齐参考线(世界坐标)。

Source

pub fn viewport(&self) -> Viewport

Source

pub fn aria_label(self, label: impl Into<SharedString>) -> FlowCanvas

画布在可访问性树中的名称(默认 “Flow canvas”)。

Source

pub fn rendered_offscreen(&self) -> usize

上一帧以合成可访问节点暴露的视口外节点数(F9)。

Source

pub fn active_node(&self) -> Option<NodeId>

键盘导航的当前节点:恰好选中一个节点时即它。

Source

pub fn rendered_lod(&self) -> (usize, usize, usize)

上一帧按细节层级统计的节点数:(完整, 外壳, 点)。

Source

pub fn rendered_counts(&self) -> (usize, usize)

Source

pub fn set_viewport( &mut self, viewport: Viewport, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )

Source

pub fn animate_viewport( &mut self, target: Viewport, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )

平滑过渡到 target(spring.smooth);reduced motion 下立即跳转。

Source

pub fn target_viewport(&self) -> Viewport

视口动画的终点;没有动画时即当前视口。

Source

pub fn motion(&self) -> &FlowMotion

只读访问动效状态(测试与调试)。

Source

pub fn fit_view( &mut self, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )

适配全部节点;画布尚未布局时推迟到首帧。

Source

pub fn zoom_by( &mut self, factor: f32, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )

以画布中心缩放。

Trait Implementations§

Source§

impl Focusable for FlowCanvas

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for FlowCanvas

Source§

fn render( &mut self, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, ) -> impl IntoElement

Render this view into an element tree.

Auto Trait Implementations§

§

impl !RefUnwindSafe for FlowCanvas

§

impl !Send for FlowCanvas

§

impl !Sync for FlowCanvas

§

impl !UnwindSafe for FlowCanvas

§

impl Forget for FlowCanvas

§

impl Freeze for FlowCanvas
where &'static str: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, *const u8 is !null: Freeze, PhantomData<(NodeId, Node)>: Freeze, PhantomData<(PortId, Port)>: Freeze, PhantomData<(EdgeId, Edge)>: Freeze, PhantomData<NodeId>: Freeze, PhantomData<(PortId, Vec<EdgeId>)>: Freeze, PhantomData<(NodeId, Vec<NodeId>)>: Freeze, PhantomData<Entry>: Freeze, PhantomData<(Arc<str>, Rc<dyn NodeRenderer>)>: Freeze, *const RcInner<dyn NodeRenderer> is !null: Freeze, PhantomData<RcInner<dyn NodeRenderer>>: Freeze, *const RcInner<dyn ConnectionValidator> is !null: Freeze, PhantomData<RcInner<dyn ConnectionValidator>>: Freeze, NonZero<u32>: Freeze, *const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Freeze, PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: Freeze, *const RcInner<Cell<Option<Bounds<Pixels>>>> is !null: Freeze, PhantomData<RcInner<Cell<Option<Bounds<Pixels>>>>>: Freeze, PhantomData<((i32, i32), Vec<NodeId>)>: Freeze, PhantomData<(NodeId, Rect)>: Freeze, PhantomData<(NodeId, usize)>: Freeze, PhantomData<((i32, i32), Vec<EdgeId>)>: Freeze, PhantomData<(EdgeId, Rect)>: Freeze, PhantomData<(EdgeId, Rc<EdgeGeometry>)>: Freeze, PhantomData<(EdgeId, (Vec2, Side, Vec2, Side, EdgeShape))>: Freeze, PhantomData<(EdgeId, (PortId, PortId, EdgeShape, NodeId, NodeId))>: Freeze, PhantomData<(NodeId, Vec2)>: Freeze, PhantomData<(NodeId, ())>: Freeze, PhantomData<u8>: Freeze, PhantomData<(EdgeId, ())>: Freeze, PhantomData<(Node, Vec<Port>)>: Freeze, PhantomData<Edge>: Freeze, *const RcInner<dyn Fn(&Viewport, &mut Window, &mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&Viewport, &mut Window, &mut App)>>: Freeze, *const RcInner<dyn Fn(&ConnectError, &mut Window, &mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&ConnectError, &mut Window, &mut App)>>: Freeze, *const RcInner<dyn Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App)>>: Freeze, PhantomData<Guide>: Freeze, PhantomData<(NodeId, Spring2)>: Freeze, PhantomData<(NodeId, Tween)>: Freeze, PhantomData<Ghost>: Freeze, PhantomData<(EdgeId, Tween)>: Freeze,

§

impl Move for FlowCanvas

§

impl Unpin for FlowCanvas
where &'static str: Unpin, Arc<str>: Unpin, *const u8 is !null: Unpin, Box<PortType>: Unpin, Rc<dyn NodeRenderer>: Unpin, Rc<dyn ConnectionValidator>: Unpin, NonZero<u32>: Unpin, Arc<RwLock<RawRwLock, FocusMap>>: Unpin, Rc<Cell<Option<Bounds<Pixels>>>>: Unpin, Rc<EdgeGeometry>: Unpin, Rc<dyn Fn(&Viewport, &mut Window, &mut App)>: Unpin, Rc<dyn Fn(&ConnectError, &mut Window, &mut App)>: Unpin, Rc<dyn Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App)>: Unpin,

§

impl UnsafeUnpin for FlowCanvas
where &'static str: UnsafeUnpin, *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<(NodeId, Node)>: UnsafeUnpin, PhantomData<(PortId, Port)>: UnsafeUnpin, PhantomData<(EdgeId, Edge)>: UnsafeUnpin, PhantomData<NodeId>: UnsafeUnpin, PhantomData<(PortId, Vec<EdgeId>)>: UnsafeUnpin, PhantomData<(NodeId, Vec<NodeId>)>: UnsafeUnpin, PhantomData<Entry>: UnsafeUnpin, PhantomData<(Arc<str>, Rc<dyn NodeRenderer>)>: UnsafeUnpin, *const RcInner<dyn NodeRenderer> is !null: UnsafeUnpin, PhantomData<RcInner<dyn NodeRenderer>>: UnsafeUnpin, *const RcInner<dyn ConnectionValidator> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ConnectionValidator>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: UnsafeUnpin, PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: UnsafeUnpin, *const RcInner<Cell<Option<Bounds<Pixels>>>> is !null: UnsafeUnpin, PhantomData<RcInner<Cell<Option<Bounds<Pixels>>>>>: UnsafeUnpin, PhantomData<((i32, i32), Vec<NodeId>)>: UnsafeUnpin, PhantomData<(NodeId, Rect)>: UnsafeUnpin, PhantomData<(NodeId, usize)>: UnsafeUnpin, PhantomData<((i32, i32), Vec<EdgeId>)>: UnsafeUnpin, PhantomData<(EdgeId, Rect)>: UnsafeUnpin, PhantomData<(EdgeId, Rc<EdgeGeometry>)>: UnsafeUnpin, PhantomData<(EdgeId, (Vec2, Side, Vec2, Side, EdgeShape))>: UnsafeUnpin, PhantomData<(EdgeId, (PortId, PortId, EdgeShape, NodeId, NodeId))>: UnsafeUnpin, PhantomData<(NodeId, Vec2)>: UnsafeUnpin, PhantomData<(NodeId, ())>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<(EdgeId, ())>: UnsafeUnpin, PhantomData<(Node, Vec<Port>)>: UnsafeUnpin, PhantomData<Edge>: UnsafeUnpin, *const RcInner<dyn Fn(&Viewport, &mut Window, &mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&Viewport, &mut Window, &mut App)>>: UnsafeUnpin, *const RcInner<dyn Fn(&ConnectError, &mut Window, &mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&ConnectError, &mut Window, &mut App)>>: UnsafeUnpin, *const RcInner<dyn Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&ContextTarget, Point<Pixels>, &mut Window, &mut App)>>: UnsafeUnpin, PhantomData<Guide>: UnsafeUnpin, PhantomData<(NodeId, Spring2)>: UnsafeUnpin, PhantomData<(NodeId, Tween)>: UnsafeUnpin, PhantomData<Ghost>: UnsafeUnpin, PhantomData<(EdgeId, Tween)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more