#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release struct Pane { nr: usize, } struct TreeBehavior {} impl egui_tiles::Behavior for TreeBehavior { fn tab_title_for_pane(&mut self, pane: &Pane) -> egui::WidgetText { format!("Pane {}", pane.nr).into() } fn pane_ui( &mut self, ui: &mut egui::Ui, _tile_id: egui_tiles::TileId, pane: &mut Pane, ) -> egui_tiles::UiResponse { // Give each pane a unique color: let color = egui::epaint::Hsva::new(0.103 * pane.nr as f32, 0.5, 0.5, 1.0); ui.painter().rect_filled(ui.max_rect(), 0.0, color); ui.label(format!("The contents of pane {}.", pane.nr)); // You can make your pane draggable like so: if ui .add(egui::Button::new("Drag me!").sense(egui::Sense::drag())) .drag_started() { egui_tiles::UiResponse::DragStarted } else { egui_tiles::UiResponse::None } } } fn main() -> Result<(), eframe::Error> { env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]), ..Default::default() }; let mut tree = create_tree(); eframe::run_simple_native("My egui App", options, move |ctx, _frame| { egui::CentralPanel::default().show(ctx, |ui| { let mut behavior = TreeBehavior {}; tree.ui(&mut behavior, ui); }); }) } fn create_tree() -> egui_tiles::Tree { let mut next_view_nr = 0; let mut gen_pane = || { let pane = Pane { nr: next_view_nr }; next_view_nr += 1; pane }; let mut tiles = egui_tiles::Tiles::default(); let mut tabs = vec![]; tabs.push({ let children = (0..7).map(|_| tiles.insert_pane(gen_pane())).collect(); tiles.insert_horizontal_tile(children) }); tabs.push({ let cells = (0..11).map(|_| tiles.insert_pane(gen_pane())).collect(); tiles.insert_grid_tile(cells) }); tabs.push(tiles.insert_pane(gen_pane())); let root = tiles.insert_tab_tile(tabs); egui_tiles::Tree::new("my_tree", root, tiles) }