Enum egui_dock::Node

source ·
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

Fields

§rect: Rect

The full rectangle - tab bar plus tab body

§viewport: Rect

The tab body rectangle

§tabs: Vec<Tab>

All the tabs in this node.

§active: TabIndex

The opened tab.

Contains the actual tabs

§

Vertical

Fields

§rect: Rect

The rectangle in which all children of this node are drawn.

§fraction: f32

The fraction taken by the top child of this node.

Parent node in the vertical orientation

§

Horizontal

Fields

§rect: Rect

The rectangle in which all children of this node are drawn.

§fraction: f32

The fraction taken by the left child of this node.

Parent node in the horizontal orientation

Implementations§

source§

impl<Tab> Node<Tab>

source

pub fn leaf(tab: Tab) -> Self

Constructs a leaf node with a given tab.

source

pub const fn leaf_with(tabs: Vec<Tab>) -> Self

Constructs a leaf node with a given list of tabs.

source

pub fn set_rect(&mut self, new_rect: Rect)

Sets the area occupied by the node.

source

pub const fn is_empty(&self) -> bool

Returns true if the node is a Empty, false otherwise.

source

pub const fn is_leaf(&self) -> bool

Returns true if the node is a Leaf, false otherwise.

source

pub const fn is_horizontal(&self) -> bool

Returns true if the node is a Horizontal, false otherwise.

source

pub const fn is_vertical(&self) -> bool

Returns true if the node is a Vertical, false otherwise.

source

pub const fn is_parent(&self) -> bool

Returns true if the node is either Horizontal or Vertical, false otherwise.

source

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.

source

pub fn append_tab(&mut self, tab: Tab)

Adds a tab to the node.

Panics

Panics if the new capacity of tabs exceeds isize::MAX bytes.

source

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

source

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.

source

pub fn tabs_count(&self) -> usize

Gets the number of tabs in the node.

Trait Implementations§

source§

impl<Tab: Clone> Clone for Node<Tab>

source§

fn clone(&self) -> Node<Tab>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<Tab: Debug> Debug for Node<Tab>

source§

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

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> SerializableAny for Twhere T: 'static + Any + Clone + Send + Sync,