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

Fix : egui::Window size recognition issue & is_manually #4545

Closed
wants to merge 22 commits into from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented May 26, 2024

Fix : egui::Window size recognition issue

Fix : is_manually - Made functions like .default_size() and .resizeable() work properly that were not working.

The disadvantage is that resize::reset_largest_content_size() must be called when necessary.

It will be easier to check the problem using the example below.

struct TestApp;

impl eframe::App for TestApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::Window::new("test1 : scroll O, resizable O")
            .scroll(true)
            .resizable(true)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test2 : scroll X, resizable O")
            .scroll(false)
            .resizable(true)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test3 : scroll O, resizable X")
            .scroll(true)
            .resizable(false)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test4 : scroll X, resizable X")
            .scroll(false)
            .resizable(false)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test1-2 : scroll O, resizable O, (300.0, 20.0)")
            .scroll(true)
            .resizable(true)
            .default_size([300.0, 20.0])
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test2-2 : scroll X, resizable O, (300.0, 20.0)")
            .scroll(false)
            .resizable(true)
            .default_size([300.0, 20.0])
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test3-2 : scroll O, resizable X, (300.0, 20.0)")
            .scroll(true)
            .resizable(false)
            .default_size([300.0, 20.0])
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::Window::new("test4-2 : scroll X, resizable X, (300.0, 20.0)")
            .scroll(false)
            .resizable(false)
            .default_size([300.0, 20.0])
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |ui| {
                        ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                    },
                );
            });

        egui::CentralPanel::default().show(ctx, |ui| {
            ctx.options_mut(|options| {
                options.tessellation_options.debug_paint_clip_rects = true;
            });
            ctx.settings_ui(ui);
        });
    }
}

fn main() {
    let _result = eframe::run_native(
        "Test",
        Default::default(),
        Box::new(|_cc| Ok(Box::new(TestApp))),
    );
}

@rustbasic
Copy link
Contributor Author

If you apply #4602, we should check again to see if this #4545 is not needed.
I haven't checked it yet.
Even if we don't need to apply #4545, we should apply #4388.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window contents can sometimes be affected by mouse interaction outside the window
1 participant