diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-23 12:45:20 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-23 12:45:20 +0100 |
| commit | 4f9e5819bbab1f93ad4f4b789038c60487a76368 (patch) | |
| tree | 488a4e0422db4531d9882cf08f0b5cc21ae55a23 /src/layout | |
| parent | d3f6040cedacad1b6c323be721c9086f6c5d9a44 (diff) | |
2d alignments with plus operator
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 8f46c049..be4e994c 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -104,27 +104,27 @@ impl PackedNode { } /// Force a size for this node. - pub fn sized(self, w: Option<Linear>, h: Option<Linear>) -> Self { - if w.is_some() || h.is_some() { - SizedNode { child: self, sizing: Spec::new(w, h) }.pack() + pub fn sized(self, sizing: Spec<Option<Linear>>) -> Self { + if sizing.any(Option::is_some) { + SizedNode { child: self, sizing }.pack() } else { self } } /// Set alignments for this node. - pub fn aligned(self, x: Option<Align>, y: Option<Align>) -> Self { - if x.is_some() || y.is_some() { - AlignNode { child: self, aligns: Spec::new(x, y) }.pack() + pub fn aligned(self, aligns: Spec<Option<Align>>) -> Self { + if aligns.any(Option::is_some) { + AlignNode { child: self, aligns }.pack() } else { self } } /// Move this node's contents without affecting layout. - pub fn moved(self, dx: Option<Linear>, dy: Option<Linear>) -> Self { - if dx.is_some() || dy.is_some() { - MoveNode { child: self, offset: Spec::new(dx, dy) }.pack() + pub fn moved(self, offset: Spec<Option<Linear>>) -> Self { + if offset.any(Option::is_some) { + MoveNode { child: self, offset }.pack() } else { self } |
