pub struct NodeLayout<'a> {
pub size: (u16, u16),
/* private fields */
}Expand description
Render information for a single node.
size is the node’s total size including its 1-cell border, so the
inner content area is (size.0 - 2, size.1 - 2). This is the unit that
crate::NodeGraph lays out.
Optional port display names can be attached via
with_port_name; when present, a port’s name is
drawn one cell inside the node from its port symbol (inward of the border).
Port positions are unchanged — the name is a pure overlay. By default a
node has no port names, so rendering is byte-for-byte identical to a node
built without them (opt-in).
Fields§
§size: (u16, u16)Implementations§
Source§impl<'a> NodeLayout<'a>
impl<'a> NodeLayout<'a>
pub fn new(size: (u16, u16)) -> Self
Sourcepub fn from_content(content: &str) -> Self
pub fn from_content(content: &str) -> Self
Build a node whose size auto-fits the given multi-line content.
The inner content area is sized to the widest line (by display width)
and the number of lines; the returned size then adds 2 cells per axis
for the border, so the content fits exactly inside when rendered into
the rect returned by crate::NodeGraph::split.
Only the size is derived from content — the node does not store or
render it. Render your own widget into the content rect yourself.
Display width uses unicode-width, so wide (e.g. CJK) and zero-width
characters are measured correctly.
pub fn with_title(self, title: &'a str) -> Self
pub fn title(&self) -> &str
pub fn with_border_type(self, border: BorderType) -> Self
pub fn border_type(&self) -> BorderType
pub fn with_border_style(self, style: Style) -> Self
Sourcepub fn with_port_name(self, port: PortId, name: &'a str) -> Self
pub fn with_port_name(self, port: PortId, name: &'a str) -> Self
Attach a display name to a port (Step 9). When the graph renders a port symbol (on the node’s border), the name’s first characters are written starting one cell inside the node from that symbol, going horizontally and truncated to the available inner width on that row.
Port positions are not affected — the PortId still maps to the same
y/x offset along the node’s side (see crate::NodeGraph). This is a
pure visual overlay: a node with no port names renders byte-for-byte
identically to one without the feature (the field defaults to empty).
Names are best kept short (a few chars); long names get truncated to fit the node’s inner width. The name may collide visually with the node’s own content (which you render separately into the content rect), so prefer short, distinctive labels.
port is matched against a connection’s to_port (in port, drawn on the
left/top side) or from_port (out port, drawn on the right/bottom side)
depending on which connection references it.
Sourcepub fn port_name(&self, port: PortId) -> Option<&str>
pub fn port_name(&self, port: PortId) -> Option<&str>
The display name attached to port, if any (set via
with_port_name). None for ports with no name
(the default).
pub fn block(&self) -> Block<'_>
Trait Implementations§
Source§impl<'a> Clone for NodeLayout<'a>
impl<'a> Clone for NodeLayout<'a>
Auto Trait Implementations§
impl<'a> Freeze for NodeLayout<'a>
impl<'a> RefUnwindSafe for NodeLayout<'a>
impl<'a> Send for NodeLayout<'a>
impl<'a> Sync for NodeLayout<'a>
impl<'a> Unpin for NodeLayout<'a>
impl<'a> UnsafeUnpin for NodeLayout<'a>
impl<'a> UnwindSafe for NodeLayout<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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