diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index cb0d81c3..4969a59a 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -64,7 +64,7 @@ impl Area { } } - /// moveable by draggin the area? + /// moveable by dragging the area? pub fn movable(mut self, movable: bool) -> Self { self.movable = movable; self.interactable |= movable; @@ -75,7 +75,7 @@ impl Area { self.movable } - /// If false, clicks goes stright throught to what is behind us. + /// If false, clicks goes straight through to what is behind us. /// Good for tooltips etc. pub fn interactable(mut self, interactable: bool) -> Self { self.interactable = interactable; diff --git a/egui/src/containers/resize.rs b/egui/src/containers/resize.rs index 5a11ecc7..0975c049 100644 --- a/egui/src/containers/resize.rs +++ b/egui/src/containers/resize.rs @@ -25,6 +25,7 @@ pub struct Resize { resizable: bool, pub(crate) min_size: Vec2, + pub(crate) max_size: Vec2, default_size: Vec2, @@ -37,6 +38,7 @@ impl Default for Resize { id: None, resizable: true, min_size: Vec2::splat(16.0), + max_size: Vec2::splat(f32::INFINITY), default_size: vec2(320.0, 128.0), // TODO: preferred size of `Resize` area. with_stroke: true, } @@ -84,6 +86,12 @@ impl Resize { self } + /// Won't expand to larger than this + pub fn max_size(mut self, max_size: impl Into) -> Self { + self.max_size = max_size.into(); + self + } + /// Can you resize it with the mouse? /// Note that a window can still auto-resize pub fn resizable(mut self, resizable: bool) -> Self { @@ -96,6 +104,7 @@ impl Resize { } /// Not manually resizable, just takes the size of its contents. + /// Text will not wrap, but will instead make your window width expand. pub fn auto_sized(self) -> Self { self.min_size(Vec2::zero()) .default_size(Vec2::splat(f32::INFINITY)) @@ -106,6 +115,7 @@ impl Resize { let size = size.into(); self.default_size = size; self.min_size = size; + self.max_size = size; self.resizable = false; self } @@ -140,6 +150,7 @@ impl Resize { }); state.desired_size = state.desired_size.max(self.min_size); + state.desired_size = state.desired_size.min(self.max_size); let position = ui.available().min; @@ -164,6 +175,7 @@ impl Resize { state.desired_size = requested_size; } state.desired_size = state.desired_size.max(self.min_size); + state.desired_size = state.desired_size.min(self.max_size); // ------------------------------ diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 42f5c7df..1b83b727 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -117,6 +117,11 @@ impl<'open> Window<'open> { self } + /// Sets the window pos and size and prevents it from being moved and resized by dragging its edges. + pub fn fixed_rect(self, rect: Rect) -> Self { + self.fixed_pos(rect.min).fixed_size(rect.size()) + } + /// Can the user resize the window by dragging its edges? /// Note that even if you set this to `false` the window may still auto-resize. pub fn resizable(mut self, resizable: bool) -> Self { @@ -132,6 +137,7 @@ impl<'open> Window<'open> { /// Not resizable, just takes the size of its contents. /// Also disabled scrolling. + /// Text will not wrap, but will instead make your window width expand. pub fn auto_sized(mut self) -> Self { self.resize = self.resize.auto_sized(); self.scroll = None; diff --git a/egui/src/demos/demo_window.rs b/egui/src/demos/demo_window.rs index d2bac86b..c0e7003f 100644 --- a/egui/src/demos/demo_window.rs +++ b/egui/src/demos/demo_window.rs @@ -49,7 +49,7 @@ impl DemoWindow { }); CollapsingHeader::new("Colors") - .default_open(true) + .default_open(false) .show(ui, |ui| { self.colors.ui(ui); });