Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Bottom panel nested inside a window keeps expanding the window #5173

Closed
crumblingstatue opened this issue Sep 27, 2024 · 6 comments · Fixed by #5196
Closed

Regression: Bottom panel nested inside a window keeps expanding the window #5173

crumblingstatue opened this issue Sep 27, 2024 · 6 comments · Fixed by #5196
Labels
bug Something is broken

Comments

@crumblingstatue
Copy link
Contributor

crumblingstatue commented Sep 27, 2024

If we put a TopBottomPanel::bottom inside a window, some widgets inside it, like TextEdit::singleline will cause the window to keep expanding vertically indefinitely.

Demo video

demo.mp4

Bisect

This is a regression caused by #4943.

The offending code is here:
https://github.com/emilk/egui/pull/4943/files#diff-1b1b7f67a664568e1201e4336ca926fa687c506ffaaf2f237a21a1fa4619fab7R824-R825

// Keep this rect snapped so that panel content can be pixel-perfect
let rect = ui.painter().round_rect_to_pixels(rect);

If we comment this line out, the window stops expanding.

Minimal reproducing code

        egui::Window::new("Bottom panel inside window").show(ctx, |ui| {
            egui::TopBottomPanel::bottom("bottom panel").show_inside(ui, |ui| {
                let mut s = String::new();
                ui.text_edit_singleline(&mut s);
            });
        });
@emilk
Copy link
Owner

emilk commented Sep 27, 2024

Thanks for reporting and bisecting!

This seems very related to:

Basically: we should round visual shapes to physical pixels, and widgets/Uis to logical points, and not confuse the two

@rustbasic
Copy link
Contributor

OS: Windows10
egui: master ( = 0.29.0 )
Renderer: glow, wgpu

If you run the example below under the above conditions, it will be normal.
Can you show the entire example that is problematic?

use eframe::egui::*;

fn main() -> eframe::Result {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
        // vsync: false,
        ..Default::default()
    };
    eframe::run_native(
        "My egui App",
        options,
        Box::new(|_cc| Ok(Box::<MyApp>::default())),
    )
}

#[derive(Default)]
struct MyApp {
    input: String,
    _text: String,
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        CentralPanel::default().show(ctx, |ui| {
            ScrollArea::vertical()
                .id_salt("editor")
                .max_height(200.0)
                .show(ui, |ui| {
                    ui.text_edit_multiline(&mut self.input);
                });
            ScrollArea::vertical().id_salt("list").show(ui, |ui| {
                for i in 0..100 {
                    ui.label(format!("test{}", i));
                }
            });
        });

        egui::Window::new("Bottom panel inside window").show(ctx, |ui| {
            egui::TopBottomPanel::bottom("bottom panel").show_inside(ui, |ui| {
                let mut s = String::new();
                ui.text_edit_singleline(&mut s);
            });
        });
    }
}

@emilk
Copy link
Owner

emilk commented Sep 27, 2024

I suspect this is dependent on pixels_per_point being non-integer

@crumblingstatue
Copy link
Contributor Author

crumblingstatue commented Sep 27, 2024

@rustbasic Not sure why you included a CentralPanel, since it's not relevant to the problem.
But this code, indeed, causes the window to expand for me. Linux, X11.
Haven't tested on windows. I guess it's possible it depends on OS.
image

Also, just in case it wasn't clear, when I say window, I refer to egui::Window, not the platform window.

@rustbasic
Copy link
Contributor

OS: Windows10
native_pixels_per_point : 2.0, 1.25

Yes, it seems to be fine under the above conditions.

@fluxxcode
Copy link

I can confirm that the same error occurs on Linux with Wayland.
But I couldn't actually reproduce it on Windows either.

@emilk emilk closed this as completed in ce744e6 Sep 30, 2024
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants