summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/src/layout/node.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs
index e9e6058e..e0c7dcb2 100644
--- a/native/src/layout/node.rs
+++ b/native/src/layout/node.rs
@@ -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
+ }
+ }
}