From d5ff97f42ed1e682a66ea8d51e5f9ed1be547b9c Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 2 Aug 2020 16:56:14 +0200 Subject: =?UTF-8?q?Move=20binary=20into=20separate=20crate=20and=20tidy=20?= =?UTF-8?q?dependencies=20=F0=9F=8E=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/actions.rs | 5 ++++- src/layout/mod.rs | 12 +++++++----- src/layout/model.rs | 3 +-- src/layout/stack.rs | 3 +-- 4 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/layout') diff --git a/src/layout/actions.rs b/src/layout/actions.rs index 89c10285..7a32a46a 100644 --- a/src/layout/actions.rs +++ b/src/layout/actions.rs @@ -1,9 +1,11 @@ //! Drawing and configuration actions composing layouts. use std::fmt::{self, Debug, Formatter}; + +#[cfg(feature = "serialize")] use serde::ser::{Serialize, Serializer, SerializeTuple}; -use fontdock::FaceId; +use fontdock::FaceId; use crate::geom::Size; use super::Layout; use self::LayoutAction::*; @@ -22,6 +24,7 @@ pub enum LayoutAction { DebugBox(Size), } +#[cfg(feature = "serialize")] impl Serialize for LayoutAction { fn serialize(&self, serializer: S) -> Result where S: Serializer { match self { diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 510f504a..64a2825b 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -1,10 +1,11 @@ //! Layouting types and engines. use std::fmt::{self, Display, Formatter}; -use smallvec::SmallVec; + +#[cfg(feature = "serialize")] use serde::Serialize; -use fontdock::FaceId; +use fontdock::FaceId; use crate::geom::{Size, Margins}; use self::prelude::*; @@ -31,12 +32,13 @@ pub mod prelude { pub type MultiLayout = Vec; /// A finished box with content at fixed positions. -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serialize", derive(Serialize))] pub struct Layout { /// The size of the box. pub dimensions: Size, /// How to align this layout in a parent container. - #[serde(skip)] + #[cfg_attr(feature = "serialize", serde(skip))] pub align: LayoutAlign, /// The actions composing this layout. pub actions: Vec, @@ -59,7 +61,7 @@ impl Layout { /// A vector of layout spaces, that is stack allocated as long as it only /// contains at most 2 spaces. -pub type LayoutSpaces = SmallVec<[LayoutSpace; 2]>; +pub type LayoutSpaces = Vec; /// The space into which content is laid out. #[derive(Debug, Copy, Clone, PartialEq)] diff --git a/src/layout/model.rs b/src/layout/model.rs index 08a9ec0e..bde451e6 100644 --- a/src/layout/model.rs +++ b/src/layout/model.rs @@ -4,7 +4,6 @@ use std::future::Future; use std::pin::Pin; -use smallvec::smallvec; use crate::{Pass, Feedback}; use crate::SharedFontLoader; @@ -271,7 +270,7 @@ impl<'a> ModelLayouter<'a> { // new page style and update it within the layouter. let margins = style.margins(); self.ctx.base = style.dimensions.unpadded(margins); - self.layouter.set_spaces(smallvec![ + self.layouter.set_spaces(vec![ LayoutSpace { dimensions: style.dimensions, padding: margins, diff --git a/src/layout/stack.rs b/src/layout/stack.rs index e684a6ab..48c7b40a 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -21,7 +21,6 @@ //! The position of the first aligned box thus depends on the length of the //! sentence in the second box. -use smallvec::smallvec; use crate::geom::Value4; use super::*; @@ -248,7 +247,7 @@ impl StackLayouter { pub fn remaining(&self) -> LayoutSpaces { let dimensions = self.usable(); - let mut spaces = smallvec![LayoutSpace { + let mut spaces = vec![LayoutSpace { dimensions, padding: Margins::ZERO, expansion: LayoutExpansion::new(false, false), -- cgit v1.2.3