Merge pull request #1154 from nicksenger/overlay-components
Implement `overlay` for `Component`
This commit is contained in:
commit
d19858bce8
2 changed files with 290 additions and 57 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue