emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.53k stars 1.61k forks source link

'Resize' container explodes if pixel_per_point != 1.0 #5346

Open SEBROVATER opened 3 weeks ago

SEBROVATER commented 3 weeks ago

Describe the bug The Resize container becomes infinitely wide when I set pixel_per_point to any value other than the default. Ignoring default_size setting.

To Reproduce

  1. Create a horizontal layout
    ui.horizontal_top(|ui| {   } );
  2. Put inside of it two Resize containers with some value for default_size (max_size for demonstration purposes):
    egui::Resize::default()
            .id_salt(idx)
            .default_size(Vec2::new(full_width / img_count as f32 - 2., full_height - 2.))
            .max_size(Vec2::new(full_width - 10., full_height - 10.))
            .show(ui, |ui| {
                ui.with_layout(Layout::top_down(Align::LEFT), |ui| {
                    ui.heading("test text");
                });
            });
  3. Add the line cc.egui_ctx.set_pixels_per_point(1.5); inside of the new method of your App

Screenshots When cc.egui_ctx.set_pixels_per_point(1.0);, image

When cc.egui_ctx.set_pixels_per_point(1.5);, image

Expected behavior The initial size of the containers should not change depending on the pixel_per_point setting.

Environment

Additional context Reproduced on the master branch version of egui and eframe. Behaves the same way if pixel_per_point is lower than 1.0.