diff options
author | 2021-12-19 11:41:18 +0700 | |
---|---|---|
committer | 2021-12-19 11:41:18 +0700 | |
commit | d19858bce8f4e425837d55c9bda44c258b2dd176 (patch) | |
tree | 72b7ca0dbe22aa5299992d63c5152d1f1bb19bc2 /native | |
parent | e24eaa7c665f6b73aa4e9bac4b723cd8d24b78e1 (diff) | |
parent | 44c0d75953984b0b31ac723bc040c016f572244d (diff) | |
download | iced-d19858bce8f4e425837d55c9bda44c258b2dd176.tar.gz iced-d19858bce8f4e425837d55c9bda44c258b2dd176.tar.bz2 iced-d19858bce8f4e425837d55c9bda44c258b2dd176.zip |
Merge pull request #1154 from nicksenger/overlay-components
Implement `overlay` for `Component`
Diffstat (limited to 'native')
-rw-r--r-- | native/src/layout/node.rs | 10 |
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 + } + } } |