From fa51e0107603321ab8af2709bc113c8150f805e9 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 1 Oct 2022 08:22:20 +0200 Subject: [PATCH] Add ability to pick color of weak text with Visual::weak_text_color --- CHANGELOG.md | 3 +++ crates/egui/src/style.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738b0029..243b56cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG * ⚠️ BREAKING: Fix text being too small ([#2069](https://github.com/emilk/egui/pull/2069)). * ⚠️ BREAKING: egui now expects integrations to do all color blending in gamma space ([#2071](https://github.com/emilk/egui/pull/2071)). +### Added ⭐ +* Added `egui::Visuals::weak_text_color`. + ### Fixed 🐛 * Improved text rendering ([#2071](https://github.com/emilk/egui/pull/2071)). diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index b83c0acbd..7ebae0214 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -450,6 +450,9 @@ pub struct Visuals { /// Background color behind code-styled monospaced labels. pub code_bg_color: Color32, + /// Color used for weak text. + pub weak_text_color: Color32, + /// A good color for warning text (e.g. orange). pub warn_fg_color: Color32, @@ -488,8 +491,9 @@ impl Visuals { .unwrap_or_else(|| self.widgets.noninteractive.text_color()) } + #[inline] pub fn weak_text_color(&self) -> Color32 { - crate::color::tint_color_towards(self.text_color(), self.window_fill()) + self.weak_text_color } #[inline(always)] @@ -675,6 +679,7 @@ impl Visuals { faint_bg_color: Color32::from_gray(35), extreme_bg_color: Color32::from_gray(10), // e.g. TextEdit background code_bg_color: Color32::from_gray(64), + weak_text_color: Color32::from_gray(83), warn_fg_color: Color32::from_rgb(255, 143, 0), // orange error_fg_color: Color32::from_rgb(255, 0, 0), // red window_rounding: Rounding::same(6.0), @@ -699,6 +704,7 @@ impl Visuals { faint_bg_color: Color32::from_gray(242), extreme_bg_color: Color32::from_gray(255), // e.g. TextEdit background code_bg_color: Color32::from_gray(230), + weak_text_color: Color32::from_gray(164), warn_fg_color: Color32::from_rgb(255, 0, 0), // red also, beecause orange doesn't look great because of https://github.com/emilk/egui/issues/1455 error_fg_color: Color32::from_rgb(255, 0, 0), // red window_shadow: Shadow::big_light(), @@ -1181,6 +1187,7 @@ impl Visuals { faint_bg_color, extreme_bg_color, code_bg_color, + weak_text_color, warn_fg_color, error_fg_color, window_rounding, @@ -1224,6 +1231,7 @@ impl Visuals { &mut widgets.noninteractive.fg_stroke.color, "Text color", ); + ui_color(ui, weak_text_color, RichText::new("Weak text")); ui_color(ui, warn_fg_color, RichText::new("Warnings")); ui_color(ui, error_fg_color, RichText::new("Errors")); });