From 40af1771575890a286f9f890aa9f8cf2d09f81ff Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Sun, 9 Aug 2020 14:31:46 +0200 Subject: [PATCH] Add fixed_pos to Window (#16) * Add fixed_pos to Window This allows changing the position of a window by opening the window with a different value. * Add docstrings for `fixed_pos` --- egui/src/containers/area.rs | 1 + egui/src/containers/window.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index 8d37103f..90802d1b 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -90,6 +90,7 @@ impl Area { self } + /// Positions the window and prevents it from being moved pub fn fixed_pos(mut self, fixed_pos: impl Into) -> Self { let fixed_pos = fixed_pos.into(); self.default_pos = Some(fixed_pos); diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index b76035f1..e50c2553 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -91,6 +91,12 @@ impl<'open> Window<'open> { self.default_pos(rect.min).default_size(rect.size()) } + /// Positions the window and prevents it from being moved + pub fn fixed_pos(mut self, pos: impl Into) -> Self { + self.area = self.area.fixed_pos(pos); + self + } + pub fn fixed_size(mut self, size: impl Into) -> Self { self.resize = self.resize.fixed_size(size); self