From 261ef9e33a8548d4b7aa53e69e71866648982ae8 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 16 Nov 2019 10:37:30 +0100 Subject: =?UTF-8?q?Generalize=20tree=20layouter=20=F0=9F=8C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/flex.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/layout/flex.rs') diff --git a/src/layout/flex.rs b/src/layout/flex.rs index a364b608..c136ad0d 100644 --- a/src/layout/flex.rs +++ b/src/layout/flex.rs @@ -75,16 +75,18 @@ impl FlexLayouter { } } - /// This layouter's context. - pub fn ctx(&self) -> FlexContext { - self.ctx - } - /// Add a sublayout. pub fn add(&mut self, layout: Layout) { self.units.push(FlexUnit::Boxed(layout)); } + /// Add multiple sublayouts from a multi-layout. + pub fn add_multiple(&mut self, layouts: MultiLayout) { + for layout in layouts { + self.add(layout); + } + } + /// Add a space box which can be replaced by a run break. pub fn add_space(&mut self, space: Size) { self.units.push(FlexUnit::Space(space)); @@ -181,6 +183,11 @@ impl FlexLayouter { Ok(()) } + /// This layouter's context. + pub fn ctx(&self) -> FlexContext { + self.ctx + } + /// Whether this layouter contains any items. pub fn is_empty(&self) -> bool { self.units.is_empty() -- cgit v1.2.3