Skip to content

Commit c6bd306

Browse files
Avoid infinite extension of ColorTest inside a Window (#5698)
Current implementation of ColorTest infinitely expand horizontally at each redraw if included in a Window. The effect can be see replacing the Panel in the ColorTestApp::update with a Window: ``` egui::CentralPanel::default().show(ctx, |ui| { egui::Window::new("Colors").vscroll(true).show(ctx, |ui| { if frame.is_web() { ui.label( "NOTE: Some old browsers stuck on WebGL1 without sRGB support will not pass the color test.", ); ui.separator(); } egui::ScrollArea::both().auto_shrink(false).show(ui, |ui| { self.color_test.ui(ui); }); self.color_test.ui(ui); }); ``` The cause is the is the _pixel_test_strokes_ function that, at each redraw, tries to expand the target rectangle of 2.0 points in each direction.
1 parent 36e007b commit c6bd306

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/egui_demo_lib/src/rendering_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ fn pixel_test_strokes(ui: &mut Ui) {
469469
let thickness_points = thickness_pixels / pixels_per_point;
470470
let num_squares = (pixels_per_point * 10.0).round().max(10.0) as u32;
471471
let size_pixels = vec2(ui.min_size().x, num_squares as f32 + thickness_pixels * 2.0);
472-
let size_points = size_pixels / pixels_per_point + Vec2::splat(2.0);
472+
let size_points = size_pixels / pixels_per_point;
473473
let (response, painter) = ui.allocate_painter(size_points, Sense::hover());
474474

475475
let mut cursor_pixel = Pos2::new(

0 commit comments

Comments
 (0)