Rename Drawable::boxed to into_element and make containers generic
Multi-element are now generic over any drawable child, which can be converted into an element. Co-Authored-By: Nathan Sobo <nathan@zed.dev> Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
4d433663bd
commit
03619dfa55
80 changed files with 1132 additions and 1434 deletions
|
@ -96,9 +96,9 @@ impl View for ProjectDiagnosticsEditor {
|
|||
.aligned()
|
||||
.contained()
|
||||
.with_style(theme.container)
|
||||
.boxed()
|
||||
.into_element()
|
||||
} else {
|
||||
ChildView::new(&self.editor, cx).boxed()
|
||||
ChildView::new(&self.editor, cx).into_element()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,8 +694,7 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
|
|||
icon.constrained()
|
||||
.with_width(icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.boxed(),
|
||||
.contained(),
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
|
@ -706,22 +705,20 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
|
|||
.contained()
|
||||
.with_style(style.message.container)
|
||||
.with_margin_left(cx.gutter_padding)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.with_children(diagnostic.code.clone().map(|code| {
|
||||
Label::new(code, style.code.text.clone().with_font_size(font_size))
|
||||
.contained()
|
||||
.with_style(style.code.container)
|
||||
.aligned()
|
||||
.boxed()
|
||||
}))
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.with_padding_left(cx.gutter_padding)
|
||||
.with_padding_right(cx.gutter_padding)
|
||||
.expanded()
|
||||
.named("diagnostic header")
|
||||
.into_named_element("diagnostic header")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -731,21 +728,22 @@ pub(crate) fn render_summary<T: View>(
|
|||
theme: &theme::ProjectDiagnostics,
|
||||
) -> Element<T> {
|
||||
if summary.error_count == 0 && summary.warning_count == 0 {
|
||||
Label::new("No problems", text_style.clone()).boxed()
|
||||
Label::new("No problems", text_style.clone()).into_element()
|
||||
} else {
|
||||
let icon_width = theme.tab_icon_width;
|
||||
let icon_spacing = theme.tab_icon_spacing;
|
||||
let summary_spacing = theme.tab_summary_spacing;
|
||||
Flex::row()
|
||||
.with_children([
|
||||
.with_child(
|
||||
Svg::new("icons/circle_x_mark_12.svg")
|
||||
.with_color(text_style.color)
|
||||
.constrained()
|
||||
.with_width(icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(icon_spacing)
|
||||
.named("no-icon"),
|
||||
.with_margin_right(icon_spacing),
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
summary.error_count.to_string(),
|
||||
LabelStyle {
|
||||
|
@ -753,8 +751,9 @@ pub(crate) fn render_summary<T: View>(
|
|||
highlight_text: None,
|
||||
},
|
||||
)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.with_child(
|
||||
Svg::new("icons/triangle_exclamation_12.svg")
|
||||
.with_color(text_style.color)
|
||||
.constrained()
|
||||
|
@ -762,8 +761,9 @@ pub(crate) fn render_summary<T: View>(
|
|||
.aligned()
|
||||
.contained()
|
||||
.with_margin_left(summary_spacing)
|
||||
.with_margin_right(icon_spacing)
|
||||
.named("warn-icon"),
|
||||
.with_margin_right(icon_spacing),
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
summary.warning_count.to_string(),
|
||||
LabelStyle {
|
||||
|
@ -771,10 +771,9 @@ pub(crate) fn render_summary<T: View>(
|
|||
highlight_text: None,
|
||||
},
|
||||
)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
])
|
||||
.boxed()
|
||||
.aligned(),
|
||||
)
|
||||
.into_element()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,23 +103,23 @@ impl View for DiagnosticIndicator {
|
|||
|
||||
let mut summary_row = Flex::row();
|
||||
if self.summary.error_count > 0 {
|
||||
summary_row.add_children([
|
||||
summary_row.add_child(
|
||||
Svg::new("icons/circle_x_mark_16.svg")
|
||||
.with_color(style.icon_color_error)
|
||||
.constrained()
|
||||
.with_width(style.icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(style.icon_spacing)
|
||||
.named("error-icon"),
|
||||
.with_margin_right(style.icon_spacing),
|
||||
);
|
||||
summary_row.add_child(
|
||||
Label::new(self.summary.error_count.to_string(), style.text.clone())
|
||||
.aligned()
|
||||
.boxed(),
|
||||
]);
|
||||
.aligned(),
|
||||
);
|
||||
}
|
||||
|
||||
if self.summary.warning_count > 0 {
|
||||
summary_row.add_children([
|
||||
summary_row.add_child(
|
||||
Svg::new("icons/triangle_exclamation_16.svg")
|
||||
.with_color(style.icon_color_warning)
|
||||
.constrained()
|
||||
|
@ -131,12 +131,12 @@ impl View for DiagnosticIndicator {
|
|||
style.summary_spacing
|
||||
} else {
|
||||
0.
|
||||
})
|
||||
.named("warning-icon"),
|
||||
}),
|
||||
);
|
||||
summary_row.add_child(
|
||||
Label::new(self.summary.warning_count.to_string(), style.text.clone())
|
||||
.aligned()
|
||||
.boxed(),
|
||||
]);
|
||||
.aligned(),
|
||||
);
|
||||
}
|
||||
|
||||
if self.summary.error_count == 0 && self.summary.warning_count == 0 {
|
||||
|
@ -146,7 +146,7 @@ impl View for DiagnosticIndicator {
|
|||
.constrained()
|
||||
.with_width(style.icon_width)
|
||||
.aligned()
|
||||
.named("ok-icon"),
|
||||
.into_named_element("ok-icon"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,6 @@ impl View for DiagnosticIndicator {
|
|||
} else {
|
||||
style.container_ok
|
||||
})
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, |_, _, cx| {
|
||||
|
@ -175,7 +174,7 @@ impl View for DiagnosticIndicator {
|
|||
cx,
|
||||
)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.into_element(),
|
||||
);
|
||||
|
||||
let style = &cx.global::<Settings>().theme.workspace.status_bar;
|
||||
|
@ -186,8 +185,7 @@ impl View for DiagnosticIndicator {
|
|||
Label::new("Checking…", style.diagnostic_message.default.text.clone())
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_left(item_spacing)
|
||||
.boxed(),
|
||||
.with_margin_left(item_spacing),
|
||||
);
|
||||
} else if let Some(diagnostic) = &self.current_diagnostic {
|
||||
let message_style = style.diagnostic_message.clone();
|
||||
|
@ -200,17 +198,15 @@ impl View for DiagnosticIndicator {
|
|||
.aligned()
|
||||
.contained()
|
||||
.with_margin_left(item_spacing)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, |_, _, cx| {
|
||||
cx.dispatch_action(GoToDiagnostic)
|
||||
})
|
||||
.boxed(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
element.named("diagnostic indicator")
|
||||
element.into_named_element("diagnostic indicator")
|
||||
}
|
||||
|
||||
fn debug_json(&self, _: &gpui::AppContext) -> serde_json::Value {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue