Use new children approach for Toolbar

This commit is contained in:
Marshall Bowers 2023-10-12 15:47:26 -04:00
parent 30979caf25
commit 24bab48043
3 changed files with 68 additions and 77 deletions

View file

@ -21,35 +21,23 @@ impl<S: 'static + Send + Sync + Clone> EditorPane<S> {
}
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
struct LeftItemsPayload {
path: PathBuf,
symbols: Vec<Symbol>,
}
v_stack()
.w_full()
.h_full()
.flex_1()
.child(TabBar::new(self.editor.tabs.clone()))
.child(Toolbar::new(
|_, payload| {
let payload = payload.downcast_ref::<LeftItemsPayload>().unwrap();
vec![Breadcrumb::new(payload.path.clone(), payload.symbols.clone()).into_any()]
},
Box::new(LeftItemsPayload {
path: self.editor.path.clone(),
symbols: self.editor.symbols.clone(),
}),
|_, _| {
vec![
.child(
Toolbar::new()
.left_item(Breadcrumb::new(
self.editor.path.clone(),
self.editor.symbols.clone(),
))
.right_items(vec![
IconButton::new(Icon::InlayHint).into_any(),
IconButton::new(Icon::MagnifyingGlass).into_any(),
IconButton::new(Icon::MagicWand).into_any(),
]
},
Box::new(()),
))
]),
)
.child(self.editor.buffer.clone())
}
}