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 #4388

Open
wants to merge 59 commits into
base: master
Choose a base branch
from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Apr 21, 2024

Fix : egui::Window size recognition issue

This is completed. Removed another commit.

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("test")
            .scroll(true)
            .resizable(true)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |_ui| {},
                );
            });

        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| Box::new(TestApp)),
    );
}

Comment on lines 462 to 465
if let Some(mut state) = resize::State::load(ctx, resize_id) {
state.desired_size = last_frame_outer_rect.size() - margins;
state.store(ctx, resize_id);
}
Copy link
Contributor Author

@rustbasic rustbasic Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix 1: egui::Window size recognition issue
The biggest problem (bug) solution is saving state.

@rustbasic rustbasic changed the title Fix: egui::Window size recognition issue Fix: egui::Window size recognition issue & To prevent egui::Window from growing or shrinking May 21, 2024
@s-nie
Copy link
Contributor

s-nie commented May 22, 2024

Thanks for taking a shot at this. I tried it and it does fix the issue.

However, the fix seems to have had some unintended side effects. For example, when increasing the size of a window, its contents will always be scaled to the maximum size that the window had at any point. On the master branch, they would take up less space again as the window is made smaller.

@rustbasic rustbasic changed the title Fix: egui::Window size recognition issue & To prevent egui::Window from growing or shrinking Fix: egui::Window size recognition issue May 23, 2024
@rustbasic
Copy link
Contributor Author

This is completed. Removed another commit.

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
2 participants