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>
impl<Pane> Tree<Pane>
pub fn empty() -> Self
sourcepub fn new(root: TileId, tiles: Tiles<Pane>) -> Self
pub fn new(root: TileId, tiles: Tiles<Pane>) -> Self
The most flexible constructor, allowing you to set up the tiles however you want.
sourcepub fn new_tabs(panes: Vec<Pane>) -> Self
pub fn new_tabs(panes: Vec<Pane>) -> Self
Create a top-level crate::Tabs
container with the given panes.
sourcepub fn new_horizontal(panes: Vec<Pane>) -> Self
pub fn new_horizontal(panes: Vec<Pane>) -> Self
Create a top-level horizontal crate::Linear
container with the given panes.
sourcepub fn new_vertical(panes: Vec<Pane>) -> Self
pub fn new_vertical(panes: Vec<Pane>) -> Self
Create a top-level vertical crate::Linear
container with the given panes.
sourcepub fn new_grid(panes: Vec<Pane>) -> Self
pub fn new_grid(panes: Vec<Pane>) -> Self
Create a top-level crate::Grid
container with the given panes.
sourcepub fn new_container(kind: ContainerKind, panes: Vec<Pane>) -> Self
pub fn new_container(kind: ContainerKind, panes: Vec<Pane>) -> Self
Create a top-level container with the given panes.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if Self::root
is None
.
pub fn root(&self) -> Option<TileId>
pub fn is_root(&self, tile: TileId) -> bool
sourcepub fn is_visible(&self, tile_id: TileId) -> bool
pub fn is_visible(&self, tile_id: TileId) -> bool
Tiles are visible by default.
Invisible tiles still retain their place in the tile hierarchy.
sourcepub fn set_visible(&mut self, tile_id: TileId, visible: bool)
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.
sourcepub fn ui(&mut self, behavior: &mut dyn Behavior<Pane>, ui: &mut Ui)
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.
sourcepub fn make_active(&mut self, should_activate: impl Fn(&Tile<Pane>) -> bool)
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.
sourcepub fn dragged_id(&self, ctx: &Context) -> Option<TileId>
pub fn dragged_id(&self, ctx: &Context) -> Option<TileId>
Find the currently dragged tile, if any.