I really like this extension to egui! I've written several apps at my previous work using egui_dock
, but I am now switching to egui_tiles
for my current company's game engine. Adding docking/tiles to egui really takes the gui to the next level.
The thing that was not so nice about egui_dock
was the way in which you defined the initial layout of all the tabs and panes in code. If I really put my head to it, I was able to get the layout I wanted, but after coming back to the code way later it was always a pain.
Sadly, I felt the same now that I came back to my layout code for egui_tiles
. I feel like there should be a way to describe the layout I want in a more expressive and editable way rather than a bunch of calls to set_share
and needing to have good names for panes/tiles/tabs and manually inserting them into the correct Container. Maybe it's just me, but not knowing the internals of egui_tiles
there seem to be a lot of concepts to learn for the user.
I usually don't advocate for crazy macros, but I feel like there could be a use for one here just to make the initial creation of the Tree
really ergonomic. Perhaps this can even be done with plain functions - implementation detail.
Here is my current layout:
![image](https://private-user-images.githubusercontent.com/19771356/300249403-59ab8a57-464c-491e-acc9-ebf613d50c45.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4MjMzNTksIm5iZiI6MTcxOTgyMzA1OSwicGF0aCI6Ii8xOTc3MTM1Ni8zMDAyNDk0MDMtNTlhYjhhNTctNDY0Yy00OTFlLWFjYzktZWJmNjEzZDUwYzQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAxVDA4MzczOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQxOGQwMmQ5ODRjNGEwNzRmMWJjMDg3ZDgzN2VhYTY5NjE2MmNiNmNiZjg3NGJmM2Q1YjI3NmIxNjMzY2FhNWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1rRtqbMIfPl93CDSWPi_h4n5ir564XzAdHi5M6KiXMM)
And it would be lovely to be able to express it in a way like this:
// (all panes defined above)
let initial_layout = egui_tiles::layout_helper! {
horizontal(1.0, {
tabs(0.7, [scene_pane, profiler_pane, game_pane]),
vertical(0.3, {
tabs(0.5, [inspector_pane]),
tabs(0.3, [scene_settings_pane]),
tabs(0.2, [assets_pane]),
}),
})
};
let root = tiles.insert_new(initial_layout);
let tree = Tree::new("application_tree", root, tiles);
rather than
// (all panes defined above)
let mut inner_right = Linear {
children: vec![inspector, scene_settings, assets],
dir: LinearDir::Vertical,
..Default::default()
};
inner_right.shares.set_share(inspector, 0.5);
inner_right.shares.set_share(scene_settings, 0.3);
inner_right.shares.set_share(assets, 0.2);
let right = tiles.insert_new(Tile::Container(Container::Linear(inner_right)));
let left_tabs = tiles.insert_tab_tile(vec![scene_view, profiler, game]);
let mut inner_left = Linear {
children: vec![left_tabs],
dir: LinearDir::Vertical,
..Default::default()
};
inner_left.shares.set_share(left_tabs , 1.0);
let left = tiles.insert_new(Tile::Container(Container::Linear(inner_left)));
let mut inner = Linear {
children: vec![left, right],
dir: LinearDir::Horizontal,
..Default::default()
};
inner.shares.set_share(left, 0.7);
inner.shares.set_share(right, 0.3);
let root = tiles.insert_new(Tile::Container(Container::Linear(inner)));
let tree = Tree::new("application_tree", root, tiles);
Maybe I'm just using egui_tiles
poorly though and there are some hidden gems here that I've not discovered to make the layout cleaner/readable xP