1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

make label into a macro

This commit is contained in:
Emil Ernerfeldt
2019-01-21 01:48:32 -06:00
parent c2c94ddda5
commit ef4f0908f2
6 changed files with 75 additions and 74 deletions

View File

@@ -40,8 +40,11 @@ impl Label {
}
}
pub fn label<S: Into<String>>(text: S) -> Label {
Label::new(text)
/// Usage: label!("Foo: {}", bar)
#[macro_export]
macro_rules! label {
($fmt:expr) => (Label::new($fmt));
($fmt:expr, $($arg:tt)*) => (Label::new(format!($fmt, $($arg)*)));
}
impl Widget for Label {
@@ -264,7 +267,7 @@ impl<'a> Widget for Slider<'a> {
columns[1].available_space.y = response.rect.size().y;
columns[1].horizontal(Align::Center, |region| {
region.add(label(full_text));
region.add(Label::new(full_text));
});
response