diff --git a/emigui/src/containers/resize.rs b/emigui/src/containers/resize.rs
index 0e2b6bb0..9ec3eb5d 100644
--- a/emigui/src/containers/resize.rs
+++ b/emigui/src/containers/resize.rs
@@ -74,8 +74,10 @@ impl Resize {
self
}
+ /// Not resizable, just takes the size of its contents.
pub fn auto_sized(self) -> Self {
- self.resizable(false)
+ self.default_size(Vec2::splat(f32::INFINITY))
+ .resizable(false)
.auto_shrink_width(true)
.auto_expand_width(true)
.auto_shrink_height(true)
diff --git a/emigui/src/containers/window.rs b/emigui/src/containers/window.rs
index 1faab18f..d55ec333 100644
--- a/emigui/src/containers/window.rs
+++ b/emigui/src/containers/window.rs
@@ -10,7 +10,7 @@ pub struct Window {
pub area: Area,
pub frame: Option,
pub resize: Resize,
- pub scroll: ScrollArea,
+ pub scroll: Option,
}
impl Window {
@@ -31,9 +31,11 @@ impl Window {
.auto_expand_width(true)
.auto_shrink_height(false)
.auto_expand_height(false),
- scroll: ScrollArea::default()
+ scroll: Some(
+ ScrollArea::default()
.always_show_scroll(false)
- .max_height(f32::INFINITY), // As large as we can be
+ .max_height(f32::INFINITY),
+ ), // As large as we can be
}
}
@@ -82,9 +84,16 @@ impl Window {
self.resize = self.resize.resizable(resizable);
self
}
+
+ /// Not resizable, just takes the size of its contents.
+ pub fn auto_sized(mut self) -> Self {
+ self.resize = self.resize.auto_sized();
+ self.scroll = None;
+ self
+ }
}
-impl Window {
+impl<'open> Window<'open> {
pub fn show(self, ctx: &Arc, add_contents: impl FnOnce(&mut Ui)) -> InteractInfo {
let Window {
title_label,
@@ -101,7 +110,12 @@ impl Window {
resize.show(ui, |ui| {
ui.add(title_label);
ui.add(Separator::new().line_width(1.0)); // TODO: nicer way to split window title from contents
+
+ if let Some(scroll) = scroll {
scroll.show(ui, add_contents)
+ } else {
+ add_contents(ui)
+ }
})
})
})