ui: Ensure Label with single_line set does not wrap (#21444)

Release Notes:

- N/A

---

Split from #21438, this change for make sure the `single_line` mode
Label will not be wrap.

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Jason Lee 2024-12-04 02:03:53 +08:00 committed by GitHub
parent 41a973b13f
commit afb253b406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 14 deletions

View file

@ -56,20 +56,6 @@ impl Label {
single_line: false,
}
}
/// Make the label display in a single line mode
///
/// # Examples
///
/// ```
/// use ui::prelude::*;
///
/// let my_label = Label::new("Hello, World!").single_line();
/// ```
pub fn single_line(mut self) -> Self {
self.single_line = true;
self
}
}
// Style methods.
@ -177,6 +163,12 @@ impl LabelCommon for Label {
self.base = self.base.underline(underline);
self
}
fn single_line(mut self) -> Self {
self.single_line = true;
self.base = self.base.single_line();
self
}
}
impl RenderOnce for Label {