pub enum Node<Tab> {
Empty,
Leaf {
rect: Rect,
viewport: Rect,
tabs: Vec<Tab>,
active: TabIndex,
},
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
Parent node in the vertical orientation
Horizontal
Parent node in the horizontal orientation
Implementations
sourceimpl<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.
pub fn tabs_count(&self) -> usize
Auto Trait Implementations
impl<Tab> RefUnwindSafe for Node<Tab>where
Tab: RefUnwindSafe,
impl<Tab> Send for Node<Tab>where
Tab: Send,
impl<Tab> Sync for Node<Tab>where
Tab: Sync,
impl<Tab> Unpin for Node<Tab>where
Tab: Unpin,
impl<Tab> UnwindSafe for Node<Tab>where
Tab: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more