Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,17 @@ pub struct Visuals {
/// it is disabled, non-interactive, hovered etc.
pub override_text_color: Option<Color32>,

/// How strong "weak" text is.
///
/// Ignored if [`Self::weak_text_color`] is set.
pub weak_text_alpha: f32,

/// Color of "weak" text.
///
/// If `None`, the color is [`Self::text_color`]
/// multiplied by [`Self::weak_text_alpha`].
pub weak_text_color: Option<Color32>,

/// Visual styles of widgets
pub widgets: Widgets,

Expand Down Expand Up @@ -1043,7 +1054,8 @@ impl Visuals {
}

pub fn weak_text_color(&self) -> Color32 {
self.gray_out(self.text_color())
self.weak_text_color
.unwrap_or_else(|| self.text_color().gamma_multiply(self.weak_text_alpha))
}

#[inline(always)]
Expand Down Expand Up @@ -1363,6 +1375,8 @@ impl Visuals {
Self {
dark_mode: true,
override_text_color: None,
weak_text_alpha: 0.6,
weak_text_color: None,
widgets: Widgets::default(),
selection: Selection::default(),
hyperlink_color: Color32::from_rgb(90, 170, 255),
Expand Down Expand Up @@ -2055,6 +2069,8 @@ impl Visuals {
let Self {
dark_mode,
override_text_color: _,
weak_text_alpha,
weak_text_color: _,
Comment thread
emilk marked this conversation as resolved.
Outdated
widgets,
selection,
hyperlink_color,
Expand Down Expand Up @@ -2118,6 +2134,7 @@ impl Visuals {

ui.collapsing("Text color", |ui| {
ui_text_color(ui, &mut widgets.noninteractive.fg_stroke.color, "Label");

ui_text_color(
ui,
&mut widgets.inactive.fg_stroke.color,
Expand All @@ -2141,6 +2158,8 @@ impl Visuals {
});
},
);

ui.add(Slider::new(weak_text_alpha, 0.0..=1.0).text("Weak text alpha"));
});

ui.collapsing("Text cursor", |ui| {
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_demo_app/tests/snapshots/easymarkeditor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Input Test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Panels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Scene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/widget_gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is much more readable now!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading