Clarify behavior of window resizing

closes https://github.com/emilk/egui/issues/206
This commit is contained in:
Emil Ernerfeldt 2021-03-07 20:15:42 +01:00
parent d6233de9dc
commit c212d4512e

View file

@ -298,31 +298,16 @@ impl super::Demo for WindowResizeTest {
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) { fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
use egui::*; use egui::*;
Window::new("resizable") Window::new("auto-sized")
.open(open) .open(open)
.scroll(false) .auto_sized()
.resizable(true)
.show(ctx, |ui| { .show(ctx, |ui| {
assert!(ui.enabled()); // TODO: remove ui.label("This window will auto-size based on its contents.");
ui.label("scroll: NO"); ui.heading("Resize this area:");
ui.label("resizable: YES"); Resize::default().show(ui, |ui| {
ui.label(crate::LOREM_IPSUM); ui.code(crate::LOREM_IPSUM);
}); });
ui.heading("Resize the above area!");
Window::new("↔ resizable + embedded scroll")
.open(open)
.scroll(false)
.resizable(true)
.default_height(300.0)
.show(ctx, |ui| {
ui.label("scroll: NO");
ui.label("resizable: YES");
ui.heading("We have a sub-region with scroll bar:");
ScrollArea::auto_sized().show(ui, |ui| {
ui.label(crate::LOREM_IPSUM_LONG);
ui.label(crate::LOREM_IPSUM_LONG);
});
// ui.heading("Some additional text here, that should also be visible"); // this works, but messes with the resizing a bit
}); });
Window::new("↔ resizable + scroll") Window::new("↔ resizable + scroll")
@ -331,21 +316,38 @@ impl super::Demo for WindowResizeTest {
.resizable(true) .resizable(true)
.default_height(300.0) .default_height(300.0)
.show(ctx, |ui| { .show(ctx, |ui| {
ui.label("scroll: YES"); ui.label(
ui.label("resizable: YES"); "This window is resizable and has a scroll area. You can shrink it to any size",
ui.label(crate::LOREM_IPSUM_LONG); );
ui.separator();
ui.code(crate::LOREM_IPSUM_LONG);
}); });
Window::new("auto_sized") Window::new("resizable + embedded scroll")
.open(open) .open(open)
.auto_sized() .scroll(false)
.resizable(true)
.default_height(300.0)
.show(ctx, |ui| { .show(ctx, |ui| {
ui.label("This window will auto-size based on its contents."); ui.label("This window is resizable but has no built-in scroll area.");
ui.heading("Resize this area:"); ui.label("However, we have a sub-region with a scroll bar:");
Resize::default().show(ui, |ui| { ui.separator();
ui.label(crate::LOREM_IPSUM); ScrollArea::auto_sized().show(ui, |ui| {
ui.code(crate::LOREM_IPSUM_LONG);
ui.code(crate::LOREM_IPSUM_LONG);
}); });
ui.heading("Resize the above area!"); // ui.heading("Some additional text here, that should also be visible"); // this works, but messes with the resizing a bit
});
Window::new("↔ resizable without scroll")
.open(open)
.scroll(false)
.resizable(true)
.show(ctx, |ui| {
ui.label("This window is resizable but has no scroll area. This means it can only be resized to a size where all the contents is visible.");
ui.label("egui will not clip the contents of a window, nor add whitespace to it.");
ui.separator();
ui.code(crate::LOREM_IPSUM);
}); });
} }
} }