Merge pull request #1154 from nicksenger/overlay-components

Implement `overlay` for `Component`
This commit is contained in:
Héctor Ramón 2021-12-19 11:41:18 +07:00 committed by GitHub
commit d19858bce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 290 additions and 57 deletions

View file

@ -1,4 +1,4 @@
use crate::{Alignment, Point, Rectangle, Size};
use crate::{Alignment, Point, Rectangle, Size, Vector};
/// The bounds of an element and its children.
#[derive(Debug, Clone, Default)]
@ -80,4 +80,12 @@ impl Node {
self.bounds.x = position.x;
self.bounds.y = position.y;
}
/// Translates the [`Node`] by the given translation.
pub fn translate(self, translation: Vector) -> Self {
Self {
bounds: self.bounds + translation,
..self
}
}
}