@@ -12,6 +12,8 @@ fn main() -> eframe::Result<()> {
1212 ..Default :: default ( )
1313 } ;
1414
15+ let tree = egui_dock:: Tree :: new ( vec ! [ 1 , 2 , 3 ] ) ;
16+
1517 eframe:: run_native (
1618 "re_ui example app" ,
1719 native_options,
@@ -20,6 +22,8 @@ fn main() -> eframe::Result<()> {
2022 Box :: new ( ExampleApp {
2123 re_ui,
2224
25+ tree,
26+
2327 left_panel : true ,
2428 right_panel : true ,
2529 bottom_panel : true ,
@@ -37,6 +41,8 @@ fn main() -> eframe::Result<()> {
3741pub struct ExampleApp {
3842 re_ui : re_ui:: ReUi ,
3943
44+ tree : egui_dock:: Tree < Tab > ,
45+
4046 left_panel : bool ,
4147 right_panel : bool ,
4248 bottom_panel : bool ,
@@ -60,31 +66,34 @@ impl eframe::App for ExampleApp {
6066 self . top_bar ( egui_ctx, frame) ;
6167
6268 egui:: SidePanel :: left ( "left_panel" ) . show_animated ( egui_ctx, self . left_panel , |ui| {
63- ui. label ( "Left panel" ) ;
69+ ui. strong ( "Left panel" ) ;
6470 ui. horizontal ( |ui| {
6571 ui. label ( "Toggle switch:" ) ;
6672 ui. add ( re_ui:: toggle_switch ( & mut self . dummy_bool ) ) ;
6773 } ) ;
74+ ui. label ( format ! ( "Latest command: {}" , self . latest_cmd) ) ;
6875 } ) ;
6976 egui:: SidePanel :: right ( "right_panel" ) . show_animated ( egui_ctx, self . right_panel , |ui| {
70- ui. label ( "Right panel" ) ;
77+ ui. strong ( "Right panel" ) ;
7178 selection_buttons ( ui) ;
7279 } ) ;
7380 egui:: TopBottomPanel :: bottom ( "bottom_panel" ) . show_animated (
7481 egui_ctx,
7582 self . bottom_panel ,
7683 |ui| {
77- ui. label ( "Bottom panel" ) ;
84+ ui. strong ( "Bottom panel" ) ;
7885 } ,
7986 ) ;
8087
81- egui:: CentralPanel :: default ( ) . show ( egui_ctx, |ui| {
82- egui:: warn_if_debug_build ( ui) ;
83- ui. label ( "Hover me for a tooltip" )
84- . on_hover_text ( "This is a tooltip" ) ;
85-
86- ui. label ( format ! ( "Latest command: {}" , self . latest_cmd) ) ;
87- } ) ;
88+ let central_panel_frame = egui:: Frame {
89+ fill : egui_ctx. style ( ) . visuals . panel_fill ,
90+ ..Default :: default ( )
91+ } ;
92+ egui:: CentralPanel :: default ( )
93+ . frame ( central_panel_frame)
94+ . show ( egui_ctx, |ui| {
95+ tabs_ui ( ui, & mut self . tree ) ;
96+ } ) ;
8897
8998 if let Some ( cmd) = self . cmd_palette . show ( egui_ctx) {
9099 self . pending_commands . push ( cmd) ;
@@ -205,3 +214,28 @@ fn selection_buttons(ui: &mut egui::Ui) {
205214 } ) ;
206215 } ) ;
207216}
217+
218+ fn tabs_ui ( ui : & mut egui:: Ui , tree : & mut egui_dock:: Tree < Tab > ) {
219+ let mut my_tab_viewer = MyTabViewer { } ;
220+ egui_dock:: DockArea :: new ( tree)
221+ . style ( re_ui:: egui_dock_style ( ui. style ( ) ) )
222+ . show_inside ( ui, & mut my_tab_viewer) ;
223+ }
224+
225+ pub type Tab = i32 ;
226+
227+ struct MyTabViewer { }
228+
229+ impl egui_dock:: TabViewer for MyTabViewer {
230+ type Tab = Tab ;
231+
232+ fn ui ( & mut self , ui : & mut egui:: Ui , _tab : & mut Self :: Tab ) {
233+ egui:: warn_if_debug_build ( ui) ;
234+ ui. label ( "Hover me for a tooltip" )
235+ . on_hover_text ( "This is a tooltip" ) ;
236+ }
237+
238+ fn title ( & mut self , tab : & mut Self :: Tab ) -> egui:: WidgetText {
239+ format ! ( "This is tab {tab}" ) . into ( )
240+ }
241+ }
0 commit comments