pub struct FlowCanvas { /* private fields */ }Implementations§
Source§impl FlowCanvas
impl FlowCanvas
pub fn new( id: impl Into<SharedString>, graph: Graph, cx: &mut Context<'_, FlowCanvas>, ) -> FlowCanvas
Sourcepub fn renderer(
self,
kind: impl Into<Arc<str>>,
renderer: impl NodeRenderer,
) -> FlowCanvas
pub fn renderer( self, kind: impl Into<Arc<str>>, renderer: impl NodeRenderer, ) -> FlowCanvas
为某种 Node::kind 注册渲染器。
Sourcepub fn validator(
self,
validator: impl ConnectionValidator + 'static,
) -> FlowCanvas
pub fn validator( self, validator: impl ConnectionValidator + 'static, ) -> FlowCanvas
连线校验器,默认 DefaultValidator(允许成环);工作流可用 DefaultValidator::dag()。
Sourcepub fn new_edge_shape(self, shape: EdgeShape) -> FlowCanvas
pub fn new_edge_shape(self, shape: EdgeShape) -> FlowCanvas
新建连线的形状。
Sourcepub fn snap_to_grid(self, grid: Option<f32>) -> FlowCanvas
pub fn snap_to_grid(self, grid: Option<f32>) -> FlowCanvas
拖拽时吸附到网格(世界 px)。
Sourcepub fn align_guides(self, enabled: bool) -> FlowCanvas
pub fn align_guides(self, enabled: bool) -> FlowCanvas
首次布局后自动适配视图。 拖动节点时与其他节点的边线 / 中线对齐并画参考线(默认开启)。
Sourcepub fn minimap(self, show: bool) -> FlowCanvas
pub fn minimap(self, show: bool) -> FlowCanvas
右下角小地图(点击或拖动可移动视口)。
Sourcepub fn controls(self, show: bool) -> FlowCanvas
pub fn controls(self, show: bool) -> FlowCanvas
左下角控件栏:放大、缩小、适配视图、锁定编辑。
右键回调:给出目标与窗口坐标,调用方据此弹出菜单。
pub fn fit_on_mount(self) -> FlowCanvas
pub fn initial_viewport(self, viewport: Viewport) -> FlowCanvas
pub fn on_viewport_change( self, handler: impl Fn(&Viewport, &mut Window, &mut App) + 'static, ) -> FlowCanvas
Sourcepub fn on_connect_error(
self,
handler: impl Fn(&ConnectError, &mut Window, &mut App) + 'static,
) -> FlowCanvas
pub fn on_connect_error( self, handler: impl Fn(&ConnectError, &mut Window, &mut App) + 'static, ) -> FlowCanvas
连线被拒时回调(F5 接 toast)。
pub fn graph(&self) -> &Graph
Sourcepub fn update_graph<R>(
&mut self,
cx: &mut Context<'_, FlowCanvas>,
f: impl FnOnce(&mut Graph) -> R,
) -> R
pub fn update_graph<R>( &mut self, cx: &mut Context<'_, FlowCanvas>, f: impl FnOnce(&mut Graph) -> R, ) -> R
直接修改图(运行状态等,不进撤销历史);结束后自动重绘。
Sourcepub fn commit(
&mut self,
op: GraphOp,
label: &'static str,
cx: &mut Context<'_, FlowCanvas>,
) -> Result<(), GraphError>
pub fn commit( &mut self, op: GraphOp, label: &'static str, cx: &mut Context<'_, FlowCanvas>, ) -> Result<(), GraphError>
应用一个可撤销的操作。
pub fn history(&self) -> &History
pub fn undo(&mut self, cx: &mut Context<'_, FlowCanvas>)
pub fn redo(&mut self, cx: &mut Context<'_, FlowCanvas>)
pub fn selection(&self) -> &HashSet<NodeId>
pub fn edge_selection(&self) -> &HashSet<EdgeId>
pub fn select_edges( &mut self, ids: impl IntoIterator<Item = EdgeId>, cx: &mut Context<'_, FlowCanvas>, )
pub fn select( &mut self, ids: impl IntoIterator<Item = NodeId>, cx: &mut Context<'_, FlowCanvas>, )
Sourcepub fn connect_drag(&self) -> Option<&ConnectDrag>
pub fn connect_drag(&self) -> Option<&ConnectDrag>
正在进行的连线草稿(测试与外部提示用)。
pub fn last_connect_error(&self) -> Option<&ConnectError>
Sourcepub fn interactive(&self) -> bool
pub fn interactive(&self) -> bool
是否允许编辑(拖动、连线、删除、粘贴、选择)。锁定时仍可平移缩放。
pub fn set_interactive( &mut self, interactive: bool, cx: &mut Context<'_, FlowCanvas>, )
pub fn viewport(&self) -> Viewport
Sourcepub fn aria_label(self, label: impl Into<SharedString>) -> FlowCanvas
pub fn aria_label(self, label: impl Into<SharedString>) -> FlowCanvas
画布在可访问性树中的名称(默认 “Flow canvas”)。
Sourcepub fn rendered_offscreen(&self) -> usize
pub fn rendered_offscreen(&self) -> usize
上一帧以合成可访问节点暴露的视口外节点数(F9)。
Sourcepub fn active_node(&self) -> Option<NodeId>
pub fn active_node(&self) -> Option<NodeId>
键盘导航的当前节点:恰好选中一个节点时即它。
Sourcepub fn rendered_lod(&self) -> (usize, usize, usize)
pub fn rendered_lod(&self) -> (usize, usize, usize)
上一帧按细节层级统计的节点数:(完整, 外壳, 点)。
pub fn rendered_counts(&self) -> (usize, usize)
pub fn set_viewport( &mut self, viewport: Viewport, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )
Sourcepub fn animate_viewport(
&mut self,
target: Viewport,
window: &mut Window,
cx: &mut Context<'_, FlowCanvas>,
)
pub fn animate_viewport( &mut self, target: Viewport, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )
平滑过渡到 target(spring.smooth);reduced motion 下立即跳转。
Sourcepub fn target_viewport(&self) -> Viewport
pub fn target_viewport(&self) -> Viewport
视口动画的终点;没有动画时即当前视口。
Sourcepub fn motion(&self) -> &FlowMotion
pub fn motion(&self) -> &FlowMotion
只读访问动效状态(测试与调试)。
Sourcepub fn fit_view(
&mut self,
window: &mut Window,
cx: &mut Context<'_, FlowCanvas>,
)
pub fn fit_view( &mut self, window: &mut Window, cx: &mut Context<'_, FlowCanvas>, )
适配全部节点;画布尚未布局时推迟到首帧。
Trait Implementations§
Source§impl Focusable for FlowCanvas
impl Focusable for FlowCanvas
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Returns the focus handle associated with this view.
Source§impl Render for FlowCanvas
impl Render for FlowCanvas
Source§fn render(
&mut self,
window: &mut Window,
cx: &mut Context<'_, FlowCanvas>,
) -> impl IntoElement
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 FlowCanvaswhere
&'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 FlowCanvaswhere
&'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 FlowCanvaswhere
&'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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.impl<T> ErasedDestructor for Twhere
T: 'static,
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