Log view name alongside error in ChildView

This commit is contained in:
Antonio Scandurra 2022-10-13 15:40:21 +02:00
parent edb61a9c8f
commit a5a60eb854
29 changed files with 105 additions and 63 deletions

View file

@ -255,7 +255,7 @@ impl Dock {
enum DockResizeHandle {}
let resizable = Container::new(ChildView::new(self.pane.clone()).boxed())
let resizable = Container::new(ChildView::new(self.pane.clone(), cx).boxed())
.with_style(panel_style)
.with_resize_handle::<DockResizeHandle, _>(
resize_side as usize,
@ -285,8 +285,8 @@ impl Dock {
enum ExpandedDockPane {}
Container::new(
MouseEventHandler::<ExpandedDockWash>::new(0, cx, |_state, cx| {
MouseEventHandler::<ExpandedDockPane>::new(0, cx, |_state, _cx| {
ChildView::new(self.pane.clone()).boxed()
MouseEventHandler::<ExpandedDockPane>::new(0, cx, |_state, cx| {
ChildView::new(&self.pane, cx).boxed()
})
.capture_all()
.contained()

View file

@ -1439,8 +1439,8 @@ impl View for Pane {
.flex(1., false)
.named("tab bar")
})
.with_child(ChildView::new(&self.toolbar).expanded().boxed())
.with_child(ChildView::new(active_item).flex(1., true).boxed())
.with_child(ChildView::new(&self.toolbar, cx).expanded().boxed())
.with_child(ChildView::new(active_item, cx).flex(1., true).boxed())
.boxed()
} else {
enum EmptyPane {}
@ -1480,7 +1480,7 @@ impl View for Pane {
})
.boxed(),
)
.with_child(ChildView::new(&self.tab_bar_context_menu).boxed())
.with_child(ChildView::new(&self.tab_bar_context_menu, cx).boxed())
.named("pane")
}

View file

@ -222,7 +222,12 @@ impl Member {
};
Stack::new()
.with_child(ChildView::new(pane).contained().with_border(border).boxed())
.with_child(
ChildView::new(pane, cx)
.contained()
.with_border(border)
.boxed(),
)
.with_children(prompt)
.boxed()
}

View file

@ -192,7 +192,7 @@ impl View for Sidebar {
if let Some(active_item) = self.active_item() {
enum ResizeHandleTag {}
let style = &cx.global::<Settings>().theme.workspace.sidebar;
ChildView::new(active_item.to_any())
ChildView::new(active_item.to_any(), cx)
.contained()
.with_style(style.container)
.with_resize_handle::<ResizeHandleTag, _>(

View file

@ -42,14 +42,14 @@ impl View for StatusBar {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
Flex::row()
.with_children(self.left_items.iter().map(|i| {
ChildView::new(i.as_ref())
ChildView::new(i.as_ref(), cx)
.aligned()
.contained()
.with_margin_right(theme.item_spacing)
.boxed()
}))
.with_children(self.right_items.iter().rev().map(|i| {
ChildView::new(i.as_ref())
ChildView::new(i.as_ref(), cx)
.aligned()
.contained()
.with_margin_left(theme.item_spacing)

View file

@ -67,7 +67,7 @@ impl View for Toolbar {
match *position {
ToolbarItemLocation::Hidden => {}
ToolbarItemLocation::PrimaryLeft { flex } => {
let left_item = ChildView::new(item.as_ref())
let left_item = ChildView::new(item.as_ref(), cx)
.aligned()
.contained()
.with_margin_right(spacing);
@ -78,7 +78,7 @@ impl View for Toolbar {
}
}
ToolbarItemLocation::PrimaryRight { flex } => {
let right_item = ChildView::new(item.as_ref())
let right_item = ChildView::new(item.as_ref(), cx)
.aligned()
.contained()
.with_margin_left(spacing)
@ -91,7 +91,7 @@ impl View for Toolbar {
}
ToolbarItemLocation::Secondary => {
secondary_item = Some(
ChildView::new(item.as_ref())
ChildView::new(item.as_ref(), cx)
.constrained()
.with_height(theme.height)
.boxed(),

View file

@ -2126,7 +2126,7 @@ impl Workspace {
enum TitleBar {}
ConstrainedBox::new(
MouseEventHandler::<TitleBar>::new(0, cx, |_, _| {
MouseEventHandler::<TitleBar>::new(0, cx, |_, cx| {
Container::new(
Stack::new()
.with_child(
@ -2138,7 +2138,7 @@ impl Workspace {
.with_children(
self.titlebar_item
.as_ref()
.map(|item| ChildView::new(item).aligned().right().boxed()),
.map(|item| ChildView::new(item, cx).aligned().right().boxed()),
)
.boxed(),
)
@ -2231,14 +2231,18 @@ impl Workspace {
}
}
fn render_notifications(&self, theme: &theme::Workspace) -> Option<ElementBox> {
fn render_notifications(
&self,
theme: &theme::Workspace,
cx: &AppContext,
) -> Option<ElementBox> {
if self.notifications.is_empty() {
None
} else {
Some(
Flex::column()
.with_children(self.notifications.iter().map(|(_, _, notification)| {
ChildView::new(notification.as_ref())
ChildView::new(notification.as_ref(), cx)
.contained()
.with_style(theme.notification)
.boxed()
@ -2570,7 +2574,7 @@ impl View for Workspace {
.with_children(
if self.left_sidebar.read(cx).active_item().is_some() {
Some(
ChildView::new(&self.left_sidebar)
ChildView::new(&self.left_sidebar, cx)
.flex(0.8, false)
.boxed(),
)
@ -2606,7 +2610,7 @@ impl View for Workspace {
.with_children(
if self.right_sidebar.read(cx).active_item().is_some() {
Some(
ChildView::new(&self.right_sidebar)
ChildView::new(&self.right_sidebar, cx)
.flex(0.8, false)
.boxed(),
)
@ -2624,15 +2628,17 @@ impl View for Workspace {
DockAnchor::Expanded,
cx,
))
.with_children(self.modal.as_ref().map(|m| {
ChildView::new(m)
.with_children(self.modal.as_ref().map(|modal| {
ChildView::new(modal, cx)
.contained()
.with_style(theme.workspace.modal)
.aligned()
.top()
.boxed()
}))
.with_children(self.render_notifications(&theme.workspace))
.with_children(
self.render_notifications(&theme.workspace, cx),
)
.boxed(),
)
.boxed(),
@ -2640,7 +2646,7 @@ impl View for Workspace {
.flex(1.0, true)
.boxed(),
)
.with_child(ChildView::new(&self.status_bar).boxed())
.with_child(ChildView::new(&self.status_bar, cx).boxed())
.contained()
.with_background_color(theme.workspace.background)
.boxed(),