From 8b2bcb29a03577e09d493f295d33765da3032a07 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 25 Oct 2020 08:56:48 +0100 Subject: [PATCH] Add `Small` `TextStyle` --- egui/src/paint/fonts.rs | 2 ++ egui/src/ui.rs | 5 +++++ egui/src/widgets/mod.rs | 26 +++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/egui/src/paint/fonts.rs b/egui/src/paint/fonts.rs index ae1e0769..6971b4a3 100644 --- a/egui/src/paint/fonts.rs +++ b/egui/src/paint/fonts.rs @@ -16,6 +16,7 @@ use super::{ #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum TextStyle { + Small, Body, Button, Heading, @@ -46,6 +47,7 @@ impl Default for FontDefinitions { impl FontDefinitions { pub fn with_pixels_per_point(pixels_per_point: f32) -> Self { let mut fonts = BTreeMap::new(); + fonts.insert(TextStyle::Small, (FontFamily::VariableWidth, 10.0)); fonts.insert(TextStyle::Body, (FontFamily::VariableWidth, 14.0)); fonts.insert(TextStyle::Button, (FontFamily::VariableWidth, 16.0)); fonts.insert(TextStyle::Heading, (FontFamily::VariableWidth, 24.0)); diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 6282aa6b..d54b2036 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -531,6 +531,11 @@ impl Ui { self.add(label.into().monospace()) } + /// Shortcut for `add(Label::new(text).small())` + pub fn small(&mut self, label: impl Into