pub enum Node<Tab> {
Empty,
Leaf {
rect: Rect,
viewport: Rect,
tabs: Vec<Tab>,
active: TabIndex,
scroll: f32,
},
Vertical {
rect: Rect,
fraction: f32,
},
Horizontal {
rect: Rect,
fraction: f32,
},
}
Expand description
Represents an abstract node of a Tree
.
Variants§
Empty
Empty node
Leaf
Contains the actual tabs
Vertical
Fields
rect: Rect
The rectangle in which all children of this node are drawn.
Parent node in the vertical orientation
Horizontal
Fields
rect: Rect
The rectangle in which all children of this node are drawn.
Parent node in the horizontal orientation
Implementations§
source§impl<Tab> Node<Tab>
impl<Tab> Node<Tab>
sourcepub const fn leaf_with(tabs: Vec<Tab>) -> Self
pub const fn leaf_with(tabs: Vec<Tab>) -> Self
Constructs a leaf node with a given list of tabs
.
sourcepub const fn is_horizontal(&self) -> bool
pub const fn is_horizontal(&self) -> bool
Returns true
if the node is a Horizontal
, false
otherwise.
sourcepub const fn is_vertical(&self) -> bool
pub const fn is_vertical(&self) -> bool
Returns true
if the node is a Vertical
, false
otherwise.
sourcepub const fn is_parent(&self) -> bool
pub const fn is_parent(&self) -> bool
Returns true
if the node is either Horizontal
or Vertical
, false
otherwise.
sourcepub fn split(&mut self, split: Split, fraction: f32) -> Self
pub fn split(&mut self, split: Split, fraction: f32) -> Self
Replaces the node with a Horizontal
or Vertical
one (depending on split
) and assigns it an empty rect.
sourcepub fn append_tab(&mut self, tab: Tab)
pub fn append_tab(&mut self, tab: Tab)
sourcepub fn insert_tab(&mut self, index: TabIndex, tab: Tab)
pub fn insert_tab(&mut self, index: TabIndex, tab: Tab)
Adds a tab
to the node.
Panics
Panics if the new capacity of tabs
exceeds isize::MAX bytes.
index > tabs_count()
sourcepub fn remove_tab(&mut self, tab_index: TabIndex) -> Option<Tab>
pub fn remove_tab(&mut self, tab_index: TabIndex) -> Option<Tab>
Removes a tab at given index
from the node.
Returns the removed tab if the node is a Leaf
, or None
otherwise.
Panics
Panics if index
is out of bounds.
sourcepub fn tabs_count(&self) -> usize
pub fn tabs_count(&self) -> usize
Gets the number of tabs in the node.