Struct egui_tiles::Tree

source ·
pub struct Tree<Pane> {
    pub root: Option<TileId>,
    pub tiles: Tiles<Pane>,
}
Expand description

The top level type. Contains all persistent state, including layouts and sizes.

You’ll usually construct this once and then store it, calling Tree::ui each frame.

See the crate-level documentation for a complete example.

How to constriuct a Tree

use egui_tiles::{Tiles, TileId, Tree};

struct Pane { } // put some state here

let mut tiles = Tiles::default();
let tabs: Vec<TileId> = vec![tiles.insert_pane(Pane { }), tiles.insert_pane(Pane { })];
let root: TileId = tiles.insert_tab_tile(tabs);

let tree = Tree::new(root, tiles);

Fields§

§root: Option<TileId>

None = empty tree

§tiles: Tiles<Pane>

All the tiles in the tree.

Implementations§

source§

impl<Pane> Tree<Pane>

source

pub fn empty() -> Self

source

pub fn new(root: TileId, tiles: Tiles<Pane>) -> Self

The most flexible constructor, allowing you to set up the tiles however you want.

source

pub fn new_tabs(panes: Vec<Pane>) -> Self

Create a top-level crate::Tabs container with the given panes.

source

pub fn new_horizontal(panes: Vec<Pane>) -> Self

Create a top-level horizontal crate::Linear container with the given panes.

source

pub fn new_vertical(panes: Vec<Pane>) -> Self

Create a top-level vertical crate::Linear container with the given panes.

source

pub fn new_grid(panes: Vec<Pane>) -> Self

Create a top-level crate::Grid container with the given panes.

source

pub fn new_container(kind: ContainerKind, panes: Vec<Pane>) -> Self

Create a top-level container with the given panes.

source

pub fn is_empty(&self) -> bool

Check if Self::root is None.

source

pub fn root(&self) -> Option<TileId>

source

pub fn is_root(&self, tile: TileId) -> bool

source

pub fn is_visible(&self, tile_id: TileId) -> bool

Tiles are visible by default.

Invisible tiles still retain their place in the tile hierarchy.

source

pub fn set_visible(&mut self, tile_id: TileId, visible: bool)

Tiles are visible by default.

Invisible tiles still retain their place in the tile hierarchy.

source

pub fn ui(&mut self, behavior: &mut dyn Behavior<Pane>, ui: &mut Ui)

Show the tree in the given Ui.

The tree will use upp all the available space - nothing more, nothing less.

source

pub fn make_active(&mut self, should_activate: impl Fn(&Tile<Pane>) -> bool)

Recursively “activate” the ancestors of the tiles that matches the given predicate.

This means making the matching tiles and its ancestors the active tab in any tab layout.

source

pub fn dragged_id(&self, ctx: &Context) -> Option<TileId>

Find the currently dragged tile, if any.

Trait Implementations§

source§

impl<Pane: Clone> Clone for Tree<Pane>

source§

fn clone(&self) -> Tree<Pane>

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<Pane: Debug> Debug for Tree<Pane>

source§

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

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

impl<Pane> Default for Tree<Pane>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, Pane> Deserialize<'de> for Tree<Pane>where Pane: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Pane: PartialEq> PartialEq<Tree<Pane>> for Tree<Pane>

source§

fn eq(&self, other: &Tree<Pane>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Pane> Serialize for Tree<Pane>where Pane: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Pane> StructuralPartialEq for Tree<Pane>

Auto Trait Implementations§

§

impl<Pane> RefUnwindSafe for Tree<Pane>where Pane: RefUnwindSafe,

§

impl<Pane> Send for Tree<Pane>where Pane: Send,

§

impl<Pane> Sync for Tree<Pane>where Pane: Sync,

§

impl<Pane> Unpin for Tree<Pane>where Pane: Unpin,

§

impl<Pane> UnwindSafe for Tree<Pane>where Pane: 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 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.
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.
source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

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