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`
This commit is contained in:
Tomas Sedovic 2020-08-09 14:31:46 +02:00 committed by GitHub
parent d4cb2fa62e
commit 40af177157
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -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<Pos2>) -> Self {
let fixed_pos = fixed_pos.into();
self.default_pos = Some(fixed_pos);

View file

@ -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<Pos2>) -> Self {
self.area = self.area.fixed_pos(pos);
self
}
pub fn fixed_size(mut self, size: impl Into<Vec2>) -> Self {
self.resize = self.resize.fixed_size(size);
self