Skip to main content

NodeLayout

Struct NodeLayout 

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

Source

pub fn new(size: (u16, u16)) -> Self

Source

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.

Source

pub fn with_title(self, title: &'a str) -> Self

Source

pub fn title(&self) -> &str

Source

pub fn with_border_type(self, border: BorderType) -> Self

Source

pub fn border_type(&self) -> BorderType

Source

pub fn with_border_style(self, style: Style) -> Self

Source

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.

Source

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).

Source

pub fn block(&self) -> Block<'_>

Trait Implementations§

Source§

impl<'a> Clone for NodeLayout<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for NodeLayout<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.