summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-02 16:56:14 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-02 16:56:14 +0200
commitd5ff97f42ed1e682a66ea8d51e5f9ed1be547b9c (patch)
tree2fdc3a368c4320051e3f62a460f3912fe5f44c7c /src/layout
parent533374db14087ac54fdc86afa5f009487ac1b850 (diff)
Move binary into separate crate and tidy dependencies 🎭
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/actions.rs5
-rw-r--r--src/layout/mod.rs12
-rw-r--r--src/layout/model.rs3
-rw-r--r--src/layout/stack.rs3
4 files changed, 13 insertions, 10 deletions
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 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<Layout>;
/// 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<LayoutAction>,
@@ -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<LayoutSpace>;
/// 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),