Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ui: Add `buffer_font` method to labels (#24479)
Agus Zubiaga56cfc60875f6
diff --git a/crates/ui/src/components/label/highlighted_label.rs b/crates/ui/src/components/label/highlighted_label.rsindex d528f47218a..14ea7a5cf16 100644--- a/crates/ui/src/components/label/highlighted_label.rs+++ b/crates/ui/src/components/label/highlighted_label.rs@@ -75,6 +75,11 @@ impl LabelCommon for HighlightedLabel {self.base = self.base.single_line();self}++ fn buffer_font(mut self, cx: &App) -> Self {+ self.base = self.base.buffer_font(cx);+ self+ }}pub fn highlight_ranges(diff --git a/crates/ui/src/components/label/label.rs b/crates/ui/src/components/label/label.rsindex 5f170b9a152..ff2687d0478 100644--- a/crates/ui/src/components/label/label.rs+++ b/crates/ui/src/components/label/label.rs@@ -172,6 +172,11 @@ impl LabelCommon for Label {self.base = self.base.single_line();self}++ fn buffer_font(mut self, cx: &App) -> Self {+ self.base = self.base.buffer_font(cx);+ self+ }}impl RenderOnce for Label {diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rsindex c9674f10a01..fad24d8699c 100644--- a/crates/ui/src/components/label/label_like.rs+++ b/crates/ui/src/components/label/label_like.rs@@ -55,6 +55,9 @@ pub trait LabelCommon {/// Sets the label to render as a single line.fn single_line(self) -> Self;++ /// Sets the font to the buffer's+ fn buffer_font(self, cx: &App) -> Self;}#[derive(IntoElement)]@@ -159,6 +162,13 @@ impl LabelCommon for LabelLike {self.single_line = true;self}++ fn buffer_font(mut self, cx: &App) -> Self {+ self.base = self+ .base+ .font(theme::ThemeSettings::get_global(cx).buffer_font.clone());+ self+ }}impl ParentElement for LabelLike {diff --git a/crates/ui/src/styles/color.rs b/crates/ui/src/styles/color.rsindex a8cf1d51e50..0d234ad50d9 100644--- a/crates/ui/src/styles/color.rs+++ b/crates/ui/src/styles/color.rs@@ -86,3 +86,9 @@ impl Color {}}}++impl From<Hsla> for Color {+ fn from(color: Hsla) -> Self {+ Color::Custom(color)+ }+}