Simplify component implementation in iced_lazy

This commit is contained in:
Héctor Ramón Jiménez 2021-12-13 17:46:39 +07:00
parent a92307890f
commit 48b2264bc6
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 141 additions and 221 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
}
}
}