From 48b2264bc6026e4b4b00791fef5ce34d464abc17 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 13 Dec 2021 17:46:39 +0700 Subject: Simplify `component` implementation in `iced_lazy` --- native/src/layout/node.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'native') 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 + } + } } -- cgit