Guide API
Skip to main content

Node

Struct Node 

Source
pub struct Node {
    pub text: String,
    pub child_list: Option<Box<Node>>,
    pub next: Option<Box<Node>>,
    pub expanded: bool,
}
Expand description

One outline tree node.

A node owns its first child (child_list) and its next sibling (next), both as Option<Box<Node>>; the recursive Box drop frees the whole subtree automatically when the node is dropped or replaced. text is the displayed label; expanded controls whether children are shown in the outline viewer.

Build a tree with Node::new and the builder methods, then pass the root to Outline::new:

use tvision_rs::widgets::outline::Node;
let root = Box::new(
    Node::new("Animals")
        .with_children(Box::new(
            Node::new("Cats")
                .with_next(Box::new(Node::new("Dogs")))
        ))
);

§Turbo Vision heritage

Ports TNode (toutline.cpp); the recursive node destructor becomes the automatic Box<Node> drop.

Fields§

§text: String

The text displayed in the outline row for this node.

Displayed verbatim; assign a new value and call ov_update to refresh the column widths.

§child_list: Option<Box<Node>>

The first child of this node, or None if the node is a leaf.

Siblings of the first child chain through their Node::next fields. Set this (or use Node::with_children) before inserting the node into an Outline; then call ov_update to publish the new extents.

§next: Option<Box<Node>>

The next sibling of this node, or None if this is the last sibling.

Use Node::with_next in the builder chain, or assign directly when building a sibling list manually.

§expanded: bool

Whether this node’s children are currently shown (true) or hidden (false).

New nodes default to true (expanded). Set to false via Node::with_expanded to start collapsed, or let the user collapse the node interactively via the - key or a click on the graph column.

Implementations§

Source§

impl Node

Source

pub fn new(text: impl Into<String>) -> Self

Create a leaf node with the given display text.

The new node has no children or next sibling and starts expanded. Chain with_children, with_next, and with_expanded to build a full subtree before boxing and passing to Outline::new.

Source

pub fn with_next(self, next: Box<Node>) -> Self

Attach a next sibling to this node and return self.

The next sibling (and its own next chain) is freed automatically when this node is dropped. To build a sibling list for use as children, chain with_next calls starting from the last sibling:

use tvision_rs::widgets::outline::Node;
// "Cats" → "Dogs" sibling pair.
let siblings = Box::new(Node::new("Cats").with_next(Box::new(Node::new("Dogs"))));
Source

pub fn with_children(self, children: Box<Node>) -> Self

Attach a first child to this node and return self.

Additional children are siblings of children, chained via with_next. The entire subtree is freed automatically when this node is dropped.

Source

pub fn with_expanded(self, expanded: bool) -> Self

Set whether this node starts expanded or collapsed and return self.

Pass false to start collapsed; the user can then expand it with the + key or a click on the graph column. When false, Node::child_list is owned but not shown until expanded.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

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 Debug for Node

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Node

Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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> CustomValue for T
where T: Any + Debug,

Source§

fn as_any_rc(self: Rc<T>) -> Rc<dyn Any>

Upcast Rc<Self> to Rc<dyn Any> so FieldValue::as_custom / FieldValue::value_as can downcast.
§

impl<T> Downcast for T
where T: 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.
§

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

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

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> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.