From 6fbbc30f5cb1f699c61e064ed54fe428d96be7d3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 6 Aug 2024 03:19:27 +0200 Subject: Implement `row::Wrapping` widget If you have a `Row`, simply call `Row::wrap` at the end to turn it into a `Row` that will wrap its contents. The original alignment of the `Row` is preserved per row wrapped. --- core/src/layout/node.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'core/src/layout') diff --git a/core/src/layout/node.rs b/core/src/layout/node.rs index 5743a9bd..0c0f90fb 100644 --- a/core/src/layout/node.rs +++ b/core/src/layout/node.rs @@ -103,12 +103,13 @@ impl Node { } /// Translates the [`Node`] by the given translation. - pub fn translate(self, translation: impl Into) -> Self { - let translation = translation.into(); + pub fn translate(mut self, translation: impl Into) -> Self { + self.translate_mut(translation); + self + } - Self { - bounds: self.bounds + translation, - ..self - } + /// Translates the [`Node`] by the given translation. + pub fn translate_mut(&mut self, translation: impl Into) { + self.bounds = self.bounds + translation.into(); } } -- cgit