From 6de93cb0ec3b550591fae0bec6a6ffea004aef21 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 10 Dec 2020 10:15:25 +0100 Subject: [PATCH] Remove the label! macro --- CHANGELOG.md | 4 ++++ egui/src/demos/demo_window.rs | 2 +- egui/src/demos/fractal_clock.rs | 6 ++---- egui/src/demos/widgets.rs | 2 +- egui/src/widgets/mod.rs | 9 --------- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f5cb030..2251e3b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Changed default font to [Ubuntu-Light](https://fonts.google.com/specimen/Ubuntu). +### Removed 🔥 + +* Removed the `label!` macro + ## 0.4.0 - 2020-11-28 ### Added ⭐ diff --git a/egui/src/demos/demo_window.rs b/egui/src/demos/demo_window.rs index 4bbb01de..76e10a45 100644 --- a/egui/src/demos/demo_window.rs +++ b/egui/src/demos/demo_window.rs @@ -55,7 +55,7 @@ impl DemoWindow { ui.add(Slider::usize(&mut self.num_columns, 1..=10).text("Columns")); ui.columns(self.num_columns, |cols| { for (i, col) in cols.iter_mut().enumerate() { - col.add(label!("Column {} out of {}", i + 1, self.num_columns)); + col.label(format!("Column {} out of {}", i + 1, self.num_columns)); if i + 1 == self.num_columns && col.button("Delete this").clicked { self.num_columns -= 1; } diff --git a/egui/src/demos/fractal_clock.rs b/egui/src/demos/fractal_clock.rs index bf9c1588..16cff679 100644 --- a/egui/src/demos/fractal_clock.rs +++ b/egui/src/demos/fractal_clock.rs @@ -69,7 +69,7 @@ impl FractalClock { fn options_ui(&mut self, ui: &mut Ui, seconds_since_midnight: Option) { if seconds_since_midnight.is_some() { - ui.add(label!( + ui.label(format!( "Local time: {:02}:{:02}:{:02}.{:03}", (self.time % (24.0 * 60.0 * 60.0) / 3600.0).floor(), (self.time % (60.0 * 60.0) / 60.0).floor(), @@ -77,9 +77,7 @@ impl FractalClock { (self.time % 1.0 * 100.0).floor() )); } else { - ui.add(label!( - "The fractal_clock clock is not showing the correct time" - )); + ui.label("The fractal_clock clock is not showing the correct time"); }; ui.checkbox(&mut self.paused, "Paused"); diff --git a/egui/src/demos/widgets.rs b/egui/src/demos/widgets.rs index 6e8c0b64..16577e5e 100644 --- a/egui/src/demos/widgets.rs +++ b/egui/src/demos/widgets.rs @@ -91,7 +91,7 @@ impl Widgets { { self.count += 1; } - ui.add(label!("The button has been clicked {} times", self.count)); + ui.label(format!("The button has been clicked {} times", self.count)); }); ui.separator(); diff --git a/egui/src/widgets/mod.rs b/egui/src/widgets/mod.rs index 96350b0e..a8772bdb 100644 --- a/egui/src/widgets/mod.rs +++ b/egui/src/widgets/mod.rs @@ -123,15 +123,6 @@ impl Label { } } -/// Shortcut for creating a `Label` widget. -/// -/// Usage: `label!("Foo: {}", bar)` equivalent to `Label::new(format!("Foo: {}", bar))`. -#[macro_export] -macro_rules! label { - ($fmt:expr) => ($crate::widgets::Label::new($fmt)); - ($fmt:expr, $($arg:tt)*) => ($crate::widgets::Label::new(format!($fmt, $($arg)*))); -} - impl Widget for Label { fn ui(self, ui: &mut Ui) -> Response { let galley = self.layout(ui);