Skip to content

Commit 89968e6

Browse files
authored
Bug fix: ui opacity and gray-out not affecting strokes (#4581)
Bug introduced in #4353
1 parent 16277eb commit 89968e6

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

crates/epaint/src/shape_transform.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,16 @@ pub fn adjust_colors(
1010
#![allow(clippy::match_same_arms)]
1111
match shape {
1212
Shape::Noop => {}
13+
1314
Shape::Vec(shapes) => {
1415
for shape in shapes {
1516
adjust_colors(shape, adjust_color);
1617
}
1718
}
18-
Shape::LineSegment { stroke, points: _ } => match &stroke.color {
19-
color::ColorMode::Solid(mut col) => adjust_color(&mut col),
20-
color::ColorMode::UV(callback) => {
21-
let callback = callback.clone();
22-
stroke.color = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
23-
let mut col = callback(rect, pos);
24-
adjust_color(&mut col);
25-
col
26-
})));
27-
}
28-
},
19+
20+
Shape::LineSegment { stroke, points: _ } => {
21+
adjust_color_mode(&mut stroke.color, adjust_color);
22+
}
2923

3024
Shape::Path(PathShape {
3125
points: _,
@@ -46,17 +40,7 @@ pub fn adjust_colors(
4640
stroke,
4741
}) => {
4842
adjust_color(fill);
49-
match &stroke.color {
50-
color::ColorMode::Solid(mut col) => adjust_color(&mut col),
51-
color::ColorMode::UV(callback) => {
52-
let callback = callback.clone();
53-
stroke.color = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
54-
let mut col = callback(rect, pos);
55-
adjust_color(&mut col);
56-
col
57-
})));
58-
}
59-
}
43+
adjust_color_mode(&mut stroke.color, adjust_color);
6044
}
6145

6246
Shape::Circle(CircleShape {
@@ -124,3 +108,20 @@ pub fn adjust_colors(
124108
}
125109
}
126110
}
111+
112+
fn adjust_color_mode(
113+
color_mode: &mut ColorMode,
114+
adjust_color: impl Fn(&mut Color32) + Send + Sync + Copy + 'static,
115+
) {
116+
match color_mode {
117+
color::ColorMode::Solid(color) => adjust_color(color),
118+
color::ColorMode::UV(callback) => {
119+
let callback = callback.clone();
120+
*color_mode = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
121+
let mut color = callback(rect, pos);
122+
adjust_color(&mut color);
123+
color
124+
})));
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)