Bug fix: ui opacity and gray-out not affecting strokes (#4581)

Bug introduced in https://github.com/emilk/egui/pull/4353
This commit is contained in:
Emil Ernerfeldt 2024-05-29 22:37:55 +02:00 committed by GitHub
parent 16277ebb86
commit 89968e6f96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 22 deletions

View File

@ -10,22 +10,16 @@ pub fn adjust_colors(
#![allow(clippy::match_same_arms)]
match shape {
Shape::Noop => {}
Shape::Vec(shapes) => {
for shape in shapes {
adjust_colors(shape, adjust_color);
}
}
Shape::LineSegment { stroke, points: _ } => match &stroke.color {
color::ColorMode::Solid(mut col) => adjust_color(&mut col),
color::ColorMode::UV(callback) => {
let callback = callback.clone();
stroke.color = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
let mut col = callback(rect, pos);
adjust_color(&mut col);
col
})));
}
},
Shape::LineSegment { stroke, points: _ } => {
adjust_color_mode(&mut stroke.color, adjust_color);
}
Shape::Path(PathShape {
points: _,
@ -46,17 +40,7 @@ pub fn adjust_colors(
stroke,
}) => {
adjust_color(fill);
match &stroke.color {
color::ColorMode::Solid(mut col) => adjust_color(&mut col),
color::ColorMode::UV(callback) => {
let callback = callback.clone();
stroke.color = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
let mut col = callback(rect, pos);
adjust_color(&mut col);
col
})));
}
}
adjust_color_mode(&mut stroke.color, adjust_color);
}
Shape::Circle(CircleShape {
@ -124,3 +108,20 @@ pub fn adjust_colors(
}
}
}
fn adjust_color_mode(
color_mode: &mut ColorMode,
adjust_color: impl Fn(&mut Color32) + Send + Sync + Copy + 'static,
) {
match color_mode {
color::ColorMode::Solid(color) => adjust_color(color),
color::ColorMode::UV(callback) => {
let callback = callback.clone();
*color_mode = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
let mut color = callback(rect, pos);
adjust_color(&mut color);
color
})));
}
}
}