Compare commits

...

2 commits

Author SHA1 Message Date
Emil Ernerfeldt
a38123f46e Make weak_text_color an Option 2022-10-01 14:21:35 +02:00
Emil Ernerfeldt
fa51e01076 Add ability to pick color of weak text with Visual::weak_text_color 2022-10-01 08:22:20 +02:00
2 changed files with 13 additions and 1 deletions

View file

@ -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: 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)). * ⚠️ 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 🐛 ### Fixed 🐛
* Improved text rendering ([#2071](https://github.com/emilk/egui/pull/2071)). * Improved text rendering ([#2071](https://github.com/emilk/egui/pull/2071)).

View file

@ -450,6 +450,11 @@ pub struct Visuals {
/// Background color behind code-styled monospaced labels. /// Background color behind code-styled monospaced labels.
pub code_bg_color: Color32, pub code_bg_color: Color32,
/// Color used for weak text.
///
/// If `None`, a color is automatially chosen based on [`Self::text_color`] and [`Self::window_fill`].
pub weak_text_color: Option<Color32>,
/// A good color for warning text (e.g. orange). /// A good color for warning text (e.g. orange).
pub warn_fg_color: Color32, pub warn_fg_color: Color32,
@ -489,7 +494,9 @@ impl Visuals {
} }
pub fn weak_text_color(&self) -> Color32 { pub fn weak_text_color(&self) -> Color32 {
self.weak_text_color.unwrap_or_else(|| {
crate::color::tint_color_towards(self.text_color(), self.window_fill()) crate::color::tint_color_towards(self.text_color(), self.window_fill())
})
} }
#[inline(always)] #[inline(always)]
@ -675,6 +682,7 @@ impl Visuals {
faint_bg_color: Color32::from_gray(35), faint_bg_color: Color32::from_gray(35),
extreme_bg_color: Color32::from_gray(10), // e.g. TextEdit background extreme_bg_color: Color32::from_gray(10), // e.g. TextEdit background
code_bg_color: Color32::from_gray(64), code_bg_color: Color32::from_gray(64),
weak_text_color: None,
warn_fg_color: Color32::from_rgb(255, 143, 0), // orange warn_fg_color: Color32::from_rgb(255, 143, 0), // orange
error_fg_color: Color32::from_rgb(255, 0, 0), // red error_fg_color: Color32::from_rgb(255, 0, 0), // red
window_rounding: Rounding::same(6.0), window_rounding: Rounding::same(6.0),
@ -1181,6 +1189,7 @@ impl Visuals {
faint_bg_color, faint_bg_color,
extreme_bg_color, extreme_bg_color,
code_bg_color, code_bg_color,
weak_text_color: _, // TODO(emilk)
warn_fg_color, warn_fg_color,
error_fg_color, error_fg_color,
window_rounding, window_rounding,