From 7660978ee5d842648e244e2972273264d94ca37b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 12 Jun 2022 17:45:52 +0200 Subject: Move `Arc` into `Frame` --- src/model/content.rs | 6 +++--- src/model/layout.rs | 24 ++++++++++++------------ src/model/locate.rs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/model') diff --git a/src/model/content.rs b/src/model/content.rs index 3e27c02f..d2af4595 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -22,7 +22,7 @@ use crate::util::EcoString; /// Layout content into a collection of pages. /// /// Relayouts until all pinned locations are converged. -pub fn layout(ctx: &mut Context, content: &Content) -> TypResult>> { +pub fn layout(ctx: &mut Context, content: &Content) -> TypResult> { let mut pass = 0; let mut frames; @@ -46,7 +46,7 @@ pub fn layout(ctx: &mut Context, content: &Content) -> TypResult> } /// Layout content into a collection of pages once. -fn layout_once(ctx: &mut Context, content: &Content) -> TypResult>> { +fn layout_once(ctx: &mut Context, content: &Content) -> TypResult> { let copy = ctx.config.styles.clone(); let styles = StyleChain::with_root(©); let scratch = Scratch::default(); @@ -263,7 +263,7 @@ impl Layout for Content { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>> { + ) -> TypResult> { let scratch = Scratch::default(); let mut builder = Builder::new(ctx, &scratch, false); builder.accept(self, styles)?; diff --git a/src/model/layout.rs b/src/model/layout.rs index c971197a..22797b48 100644 --- a/src/model/layout.rs +++ b/src/model/layout.rs @@ -28,7 +28,7 @@ pub trait Layout: 'static { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>>; + ) -> TypResult>; /// Convert to a packed node. fn pack(self) -> LayoutNode @@ -222,7 +222,7 @@ impl Layout for LayoutNode { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>> { + ) -> TypResult> { let prev = ctx.pins.dirty.replace(false); let (result, at, fresh, dirty) = crate::memo::memoized( @@ -238,7 +238,7 @@ impl Layout for LayoutNode { if let Some(role) = styles.role() { result = result.map(|mut frames| { for frame in frames.iter_mut() { - Arc::make_mut(frame).apply_role(role); + frame.apply_role(role); } frames }); @@ -319,10 +319,10 @@ impl Layout for EmptyNode { _: &mut Context, regions: &Regions, _: StyleChain, - ) -> TypResult>> { - Ok(vec![Arc::new(Frame::new( + ) -> TypResult> { + Ok(vec![Frame::new( regions.expand.select(regions.first, Size::zero()), - ))]) + )]) } } @@ -341,7 +341,7 @@ impl Layout for SizedNode { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>> { + ) -> TypResult> { // The "pod" is the region into which the child will be layouted. let pod = { // Resolve the sizing to a concrete size. @@ -367,7 +367,7 @@ impl Layout for SizedNode { // Ensure frame size matches regions size if expansion is on. let frame = &mut frames[0]; let target = regions.expand.select(regions.first, frame.size()); - Arc::make_mut(frame).resize(target, Align::LEFT_TOP); + frame.resize(target, Align::LEFT_TOP); Ok(frames) } @@ -388,11 +388,11 @@ impl Layout for FillNode { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>> { + ) -> TypResult> { let mut frames = self.child.layout(ctx, regions, styles)?; for frame in &mut frames { let shape = Geometry::Rect(frame.size()).filled(self.fill); - Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape)); + frame.prepend(Point::zero(), Element::Shape(shape)); } Ok(frames) } @@ -413,11 +413,11 @@ impl Layout for StrokeNode { ctx: &mut Context, regions: &Regions, styles: StyleChain, - ) -> TypResult>> { + ) -> TypResult> { let mut frames = self.child.layout(ctx, regions, styles)?; for frame in &mut frames { let shape = Geometry::Rect(frame.size()).stroked(self.stroke); - Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape)); + frame.prepend(Point::zero(), Element::Shape(shape)); } Ok(frames) } diff --git a/src/model/locate.rs b/src/model/locate.rs index bda12ae9..f6432d43 100644 --- a/src/model/locate.rs +++ b/src/model/locate.rs @@ -272,7 +272,7 @@ impl PinBoard { } /// Locate all pins in the frames. - pub fn locate(&mut self, frames: &[Arc]) { + pub fn locate(&mut self, frames: &[Frame]) { let mut flow = 0; for (i, frame) in frames.iter().enumerate() { locate_in_frame( -- cgit v1.2.3