-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Resizing window makes it move #3074
Comments
The effect is even weirder when dragging the right/bottom edge below/right outside the OS/Root Window. Egui-Window-Resizing.mp4Program/* Cargo.toml
[dependencies]
eframe = "0.26.2"
egui = "0.26.2"
*/
fn main() {
_ = eframe::run_native(
"Test",
eframe::NativeOptions::default(),
Box::new(move |_cc| {
Box::new(MyApp{})
}),
);
}
struct MyApp {}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::Window::new("Test").show(ctx, |ui| {
ui.label("Egui Window")
});
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("OS/WM Window")
});
}
} |
I dug into trying to fix this, and have found why it occurs, but am stumped on how to fix it. There are two separate problems at work, but they both stem from doing the resizing before layouting. For the movement when resizing the top/left sides on a min sized window, this happens because:
This doesn't happen normally when resizing the bottom/right sides, since they don't touch the top left corner, and the window gets put back to the minimum size after layouting, so it looks like nothing happened. When resizing the bottom/right side beyond the window, the weird movement happens because of the default window constraints. The constraint is applied to the new pre-layout Area rect, so the top left point is moved upwards to compensate. Then layouting happens, resizing the window back down since it doesn't use that space, making it look like a translation once again since it all happens in one frame. This can be verified by setting I'm not sure how to fix either of these, at least while keeping the constraint of 0 delay resizing. If the previous frame's Area size is used, then the window could never be resized smaller. If the min possible size is used, then that would cause a frame of delay, or prevent the window from being resized if the possible min does change. A possible solution is using the new(ish) TSTransform to shift the window back into the correct position if the size didn't change after a resize and layouting is complete, but that feels very hacky. I'm also not sure if a good solution is even possible, since this seems like one of those issues inherent to immediate mode guis, so a compromise might have to be made. :( |
When resizing a window it can move the window also.
This can be reproduced with egui here https://www.egui.rs/ :
244389019-c7388936-8666-4ee7-9e5d-fbd7ce42c625.mp4
The text was updated successfully, but these errors were encountered: