ui.label now take impl ToString
as argument, not impl Into<Label>
This commit is contained in:
parent
ebd2c859ac
commit
9f1a5dcb33
4 changed files with 18 additions and 21 deletions
|
@ -30,6 +30,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
|
|||
* `ScrollArea` will auto-shrink to content size unless told otherwise using `ScollArea::auto_shrink`.
|
||||
* By default, `Slider`'s `clamp_to_range` is set to true.
|
||||
* Rename `TextEdit::enabled` to `TextEdit::interactive`.
|
||||
* `ui.label` (and friends) now take `impl ToString` as argument instead of `impl Into<Label>`.
|
||||
|
||||
### Fixed 🐛
|
||||
* Fix wrongly sized multiline `TextEdit` in justified layouts.
|
||||
|
|
|
@ -406,7 +406,7 @@ pub use {
|
|||
/// Helper function that adds a label when compiling with debug assertions enabled.
|
||||
pub fn warn_if_debug_build(ui: &mut crate::Ui) {
|
||||
if cfg!(debug_assertions) {
|
||||
ui.label(
|
||||
ui.add(
|
||||
crate::Label::new("‼ Debug build ‼")
|
||||
.small()
|
||||
.text_color(crate::Color32::RED),
|
||||
|
|
|
@ -949,10 +949,10 @@ fn slider_vec2<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn ui_color(ui: &mut Ui, srgba: &mut Color32, text: impl Into<Label>) -> Response {
|
||||
fn ui_color(ui: &mut Ui, srgba: &mut Color32, label: impl Into<Label>) -> Response {
|
||||
ui.horizontal(|ui| {
|
||||
ui.color_edit_button_srgba(srgba);
|
||||
ui.label(text);
|
||||
ui.add(label.into());
|
||||
})
|
||||
.response
|
||||
}
|
||||
|
|
|
@ -1003,54 +1003,50 @@ impl Ui {
|
|||
///
|
||||
/// See also [`Label`].
|
||||
#[inline(always)]
|
||||
pub fn label(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().ui(self)
|
||||
pub fn label(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).ui(self)
|
||||
}
|
||||
|
||||
/// Show colored text.
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).text_color(color))`
|
||||
pub fn colored_label(
|
||||
&mut self,
|
||||
color: impl Into<Color32>,
|
||||
label: impl Into<Label>,
|
||||
) -> Response {
|
||||
label.into().text_color(color).ui(self)
|
||||
pub fn colored_label(&mut self, color: impl Into<Color32>, text: impl ToString) -> Response {
|
||||
Label::new(text).text_color(color).ui(self)
|
||||
}
|
||||
|
||||
/// Show large text.
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).heading())`
|
||||
pub fn heading(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().heading().ui(self)
|
||||
pub fn heading(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).heading().ui(self)
|
||||
}
|
||||
|
||||
/// Show monospace (fixed width) text.
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).monospace())`
|
||||
pub fn monospace(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().monospace().ui(self)
|
||||
pub fn monospace(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).monospace().ui(self)
|
||||
}
|
||||
|
||||
/// Show text as monospace with a gray background.
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).code())`
|
||||
pub fn code(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().code().ui(self)
|
||||
pub fn code(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).code().ui(self)
|
||||
}
|
||||
|
||||
/// Show small text.
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).small())`
|
||||
pub fn small(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().small().ui(self)
|
||||
pub fn small(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).small().ui(self)
|
||||
}
|
||||
|
||||
/// Show text that stand out a bit (e.g. slightly brighter).
|
||||
///
|
||||
/// Shortcut for `add(Label::new(text).strong())`
|
||||
pub fn strong(&mut self, label: impl Into<Label>) -> Response {
|
||||
label.into().strong().ui(self)
|
||||
pub fn strong(&mut self, text: impl ToString) -> Response {
|
||||
Label::new(text).strong().ui(self)
|
||||
}
|
||||
|
||||
/// Shortcut for `add(Hyperlink::new(url))`
|
||||
|
|
Loading…
Reference in a new issue