ui: Add buffer_font method to labels (#24479)
Now you don't need to wrap the `Label` in a `div` anymore Release Notes: - N/A Co-authored-by: Danilo <danilo@zed.dev>
This commit is contained in:
@@ -75,6 +75,11 @@ impl LabelCommon for HighlightedLabel {
|
|||||||
self.base = self.base.single_line();
|
self.base = self.base.single_line();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn buffer_font(mut self, cx: &App) -> Self {
|
||||||
|
self.base = self.base.buffer_font(cx);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn highlight_ranges(
|
pub fn highlight_ranges(
|
||||||
|
|||||||
@@ -172,6 +172,11 @@ impl LabelCommon for Label {
|
|||||||
self.base = self.base.single_line();
|
self.base = self.base.single_line();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn buffer_font(mut self, cx: &App) -> Self {
|
||||||
|
self.base = self.base.buffer_font(cx);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Label {
|
impl RenderOnce for Label {
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ pub trait LabelCommon {
|
|||||||
|
|
||||||
/// Sets the label to render as a single line.
|
/// Sets the label to render as a single line.
|
||||||
fn single_line(self) -> Self;
|
fn single_line(self) -> Self;
|
||||||
|
|
||||||
|
/// Sets the font to the buffer's
|
||||||
|
fn buffer_font(self, cx: &App) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(IntoElement)]
|
#[derive(IntoElement)]
|
||||||
@@ -159,6 +162,13 @@ impl LabelCommon for LabelLike {
|
|||||||
self.single_line = true;
|
self.single_line = true;
|
||||||
self
|
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 {
|
impl ParentElement for LabelLike {
|
||||||
|
|||||||
@@ -86,3 +86,9 @@ impl Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Hsla> for Color {
|
||||||
|
fn from(color: Hsla) -> Self {
|
||||||
|
Color::Custom(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user