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: StringThe 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: boolWhether 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
impl Node
Sourcepub fn new(text: impl Into<String>) -> Self
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.
Sourcepub fn with_next(self, next: Box<Node>) -> Self
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"))));Sourcepub fn with_children(self, children: Box<Node>) -> Self
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.
Sourcepub fn with_expanded(self, expanded: bool) -> Self
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§
impl Eq for Node
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> 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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.